(RPNG) Rewrite rpng_nbio_load_image_process

This commit is contained in:
twinaphex 2015-03-14 03:18:15 +01:00
parent 533f647fe0
commit 9a0bd3c650
4 changed files with 26 additions and 22 deletions

View File

@ -191,26 +191,17 @@ bool rpng_nbio_load_image_argb_iterate(uint8_t *buf, struct rpng_t *rpng)
return true;
}
bool rpng_nbio_load_image_argb_process(struct rpng_t *rpng,
int rpng_nbio_load_image_argb_process(struct rpng_t *rpng,
uint32_t **data, unsigned *width, unsigned *height)
{
int retval = 0;
if (!rpng->process.initialized)
{
if (!rpng_load_image_argb_process_init(rpng, data, width,
height))
return false;
return PNG_PROCESS_ERROR;
}
do{
retval = png_reverse_filter_iterate(rpng, data);
}while(retval == PNG_PROCESS_NEXT);
if (retval == PNG_PROCESS_ERROR || retval == PNG_PROCESS_ERROR_END)
return false;
return true;
return png_reverse_filter_iterate(rpng, data);
}
void rpng_nbio_load_image_free(struct rpng_t *rpng)

View File

@ -23,6 +23,14 @@
#include <formats/rpng.h>
#include <formats/tga.h>
enum image_process_code
{
IMAGE_PROCESS_ERROR = -2,
IMAGE_PROCESS_ERROR_END = -1,
IMAGE_PROCESS_NEXT = 0,
IMAGE_PROCESS_END = 1,
};
struct texture_image
{
unsigned width;

View File

@ -113,7 +113,7 @@ void rpng_nbio_load_image_free(struct rpng_t *rpng);
bool rpng_nbio_load_image_argb_iterate(uint8_t *buf,
struct rpng_t *rpng);
bool rpng_nbio_load_image_argb_process(struct rpng_t *rpng,
int rpng_nbio_load_image_argb_process(struct rpng_t *rpng,
uint32_t **data, unsigned *width, unsigned *height);
bool rpng_nbio_load_image_argb_start(struct rpng_t *rpng);

View File

@ -166,10 +166,7 @@ static int rarch_main_iterate_http_poll(void)
#ifdef HAVE_MENU
static int cb_image_menu_wallpaper(void *data, size_t len)
{
uint32_t **pixels = NULL;
unsigned *width = NULL;
unsigned *height = NULL;
int retval;
nbio_handle_t *nbio = (nbio_handle_t*)data;
if (!nbio || !data)
@ -180,11 +177,13 @@ static int cb_image_menu_wallpaper(void *data, size_t len)
!nbio->image.handle->has_iend)
return -1;
pixels = &nbio->image.ti.pixels;
width = &nbio->image.ti.width;
height = &nbio->image.ti.height;
do{
retval = rpng_nbio_load_image_argb_process(nbio->image.handle,
&nbio->image.ti.pixels, &nbio->image.ti.width, &nbio->image.ti.height);
}while(retval == IMAGE_PROCESS_NEXT);
rpng_nbio_load_image_argb_process(nbio->image.handle, pixels, width, height);
if (retval == IMAGE_PROCESS_ERROR || retval == IMAGE_PROCESS_ERROR_END)
return -1;
if (driver.menu_ctx && driver.menu_ctx->load_background)
driver.menu_ctx->load_background(&nbio->image.ti);
@ -525,7 +524,13 @@ void do_data_nbio_state_checks(nbio_handle_t *nbio)
if (nbio->image.handle)
{
if (!nbio->image.is_blocking)
#if 0
if (nbio->image.is_blocking_on_processing)
{
}
else
#endif
if (!nbio->image.is_blocking)
{
if (rarch_main_iterate_image_transfer(nbio) == -1)
rarch_main_iterate_image_parse(nbio);