(gfx/video_texture_image.c) Refactor - go through image_transfer

interface
This commit is contained in:
twinaphex 2016-05-17 16:11:37 +02:00
parent 99bcf5946c
commit b268869669

View File

@ -159,6 +159,7 @@ static bool video_texture_image_rpng_gx_convert_texture32(
#endif #endif
static bool video_texture_image_load_png( static bool video_texture_image_load_png(
enum image_type_enum type,
void *ptr, void *ptr,
struct texture_image *out_img, struct texture_image *out_img,
unsigned a_shift, unsigned r_shift, unsigned a_shift, unsigned r_shift,
@ -166,26 +167,25 @@ static bool video_texture_image_load_png(
{ {
int ret; int ret;
bool success = false; bool success = false;
rpng_t *rpng = rpng_alloc(); rpng_t *rpng = (rpng_t*)image_transfer_new(type);
if (!rpng) if (!rpng)
goto end; goto end;
if (!rpng_set_buf_ptr(rpng, (uint8_t*)ptr)) image_transfer_set_buffer_ptr(rpng, type, (uint8_t*)ptr);
if (!image_transfer_start(rpng, type))
goto end; goto end;
if (!rpng_start(rpng)) while (image_transfer_iterate((void*)rpng, type));
goto end;
while (rpng_iterate_image(rpng));
if (!rpng_is_valid(rpng)) if (!rpng_is_valid(rpng))
goto end; goto end;
do do
{ {
ret = rpng_process_image(rpng, ret = image_transfer_process((void*)rpng, type,
(void**)&out_img->pixels, 0, &out_img->width, (uint32_t**)&out_img->pixels, 0, &out_img->width,
&out_img->height); &out_img->height);
}while(ret == IMAGE_PROCESS_NEXT); }while(ret == IMAGE_PROCESS_NEXT);
@ -207,7 +207,7 @@ static bool video_texture_image_load_png(
end: end:
if (rpng) if (rpng)
rpng_free(rpng); image_transfer_free(rpng, type);
return success; return success;
} }
@ -277,7 +277,9 @@ bool video_texture_image_load(struct texture_image *out_img,
break; break;
case IMAGE_FORMAT_PNG: case IMAGE_FORMAT_PNG:
#ifdef HAVE_RPNG #ifdef HAVE_RPNG
if (video_texture_image_load_png(ptr, out_img, if (video_texture_image_load_png(
IMAGE_TYPE_PNG,
ptr,out_img,
a_shift, r_shift, g_shift, b_shift)) a_shift, r_shift, g_shift, b_shift))
goto success; goto success;
#endif #endif