From 6daf6e227092d204885fa9d21ba4d2a4e216f5c2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 04:33:11 +0200 Subject: [PATCH] Cleanups --- tasks/task_image.c | 69 +++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 220848e3f9..5c7144fc9a 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -133,6 +133,44 @@ void *image_transfer_new(enum image_type_enum type) return NULL; } +bool image_transfer_start(void *data, enum image_type_enum type) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + if (!rpng_nbio_load_image_argb_start((rpng_t*)data)) + return false; +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } + + return true; +} + +void image_transfer_set_buffer_ptr( + void *data, + enum image_type_enum type, + void *ptr) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + rpng_set_buf_ptr((rpng_t*)data, (uint8_t*)ptr); +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } +} + static int image_transfer_process( void *data, enum image_type_enum type, @@ -259,7 +297,6 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) return -1; } - static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) { unsigned i; @@ -283,7 +320,6 @@ error: return -1; } - static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) { nbio_image_handle_t *image = nbio ? &nbio->image : NULL; @@ -307,35 +343,13 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) if (!ptr) goto error; - switch (nbio->image_type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - rpng_set_buf_ptr((rpng_t*)nbio->image.handle, (uint8_t*)ptr); -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } + image_transfer_set_buffer_ptr(nbio->image.handle, nbio->image_type, ptr); nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; - switch (nbio->image_type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - if (!rpng_nbio_load_image_argb_start((rpng_t*)nbio->image.handle)) - goto error; -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } + if (!image_transfer_start(nbio->image.handle, nbio->image_type)) + goto error; nbio->image.is_blocking = false; nbio->image.is_finished = false; @@ -348,7 +362,6 @@ error: return -1; } - static int cb_nbio_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data;