mirror of
https://github.com/libretro/RetroArch
synced 2025-04-02 16:20:39 +00:00
Move stuff into typedef structs so that we can create mechanisms
for handling multiple file/image streams at once
This commit is contained in:
parent
15065d3b21
commit
4ff8a4a6e9
42
general.h
42
general.h
@ -398,6 +398,27 @@ typedef struct rarch_resolution
|
|||||||
|
|
||||||
typedef int (*transfer_cb_t )(void *data, size_t len);
|
typedef int (*transfer_cb_t )(void *data, size_t len);
|
||||||
|
|
||||||
|
typedef struct nbio_image_handle
|
||||||
|
{
|
||||||
|
bool is_blocking;
|
||||||
|
bool is_finished;
|
||||||
|
transfer_cb_t cb;
|
||||||
|
msg_queue_t *msg_queue;
|
||||||
|
struct rpng_t *handle;
|
||||||
|
unsigned pos_increment;
|
||||||
|
} nbio_image_handle_t;
|
||||||
|
|
||||||
|
typedef struct nbio_handle
|
||||||
|
{
|
||||||
|
nbio_image_handle_t image;
|
||||||
|
bool is_blocking;
|
||||||
|
bool is_finished;
|
||||||
|
transfer_cb_t cb;
|
||||||
|
struct nbio_t *handle;
|
||||||
|
unsigned pos_increment;
|
||||||
|
msg_queue_t *msg_queue;
|
||||||
|
} nbio_handle_t;
|
||||||
|
|
||||||
/* All run-time- / command line flag-related globals go here. */
|
/* All run-time- / command line flag-related globals go here. */
|
||||||
|
|
||||||
struct global
|
struct global
|
||||||
@ -592,26 +613,7 @@ struct global
|
|||||||
} http;
|
} http;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct
|
nbio_handle_t nbio;
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
bool is_blocking;
|
|
||||||
bool is_finished;
|
|
||||||
transfer_cb_t cb;
|
|
||||||
msg_queue_t *msg_queue;
|
|
||||||
struct rpng_t *handle;
|
|
||||||
unsigned pos_increment;
|
|
||||||
} image;
|
|
||||||
|
|
||||||
bool is_blocking;
|
|
||||||
bool is_finished;
|
|
||||||
transfer_cb_t cb;
|
|
||||||
struct nbio_t *handle;
|
|
||||||
unsigned pos_increment;
|
|
||||||
msg_queue_t *msg_queue;
|
|
||||||
} nbio;
|
|
||||||
|
|
||||||
|
|
||||||
bool exec;
|
bool exec;
|
||||||
|
|
||||||
|
@ -137,23 +137,27 @@ static int cb_image_menu_wallpaper(void *data, size_t len)
|
|||||||
uint32_t **pixels = &ti.pixels;
|
uint32_t **pixels = &ti.pixels;
|
||||||
unsigned *width = &ti.width;
|
unsigned *width = &ti.width;
|
||||||
unsigned *height = &ti.height;
|
unsigned *height = &ti.height;
|
||||||
|
nbio_handle_t *nbio = data;
|
||||||
|
|
||||||
if ( !g_extern.nbio.image.handle->has_ihdr ||
|
if (!nbio || !data)
|
||||||
!g_extern.nbio.image.handle->has_idat ||
|
|
||||||
!g_extern.nbio.image.handle->has_iend)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rpng_nbio_load_image_argb_process(g_extern.nbio.image.handle, pixels, width, height);
|
if ( !nbio->image.handle->has_ihdr ||
|
||||||
|
!nbio->image.handle->has_idat ||
|
||||||
|
!nbio->image.handle->has_iend)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
rpng_nbio_load_image_argb_process(nbio->image.handle, pixels, width, height);
|
||||||
|
|
||||||
if (driver.menu_ctx && driver.menu_ctx->load_background)
|
if (driver.menu_ctx && driver.menu_ctx->load_background)
|
||||||
driver.menu_ctx->load_background(&ti);
|
driver.menu_ctx->load_background(&ti);
|
||||||
|
|
||||||
texture_image_free(&ti);
|
texture_image_free(&ti);
|
||||||
|
|
||||||
g_extern.nbio.image.is_blocking = true;
|
nbio->image.is_blocking = true;
|
||||||
g_extern.nbio.image.is_finished = true;
|
nbio->image.is_finished = true;
|
||||||
g_extern.nbio.is_blocking = true;
|
nbio->is_blocking = true;
|
||||||
g_extern.nbio.is_finished = true;
|
nbio->is_finished = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -161,28 +165,40 @@ static int cb_image_menu_wallpaper(void *data, size_t len)
|
|||||||
static int cb_nbio_image_menu_wallpaper(void *data, size_t len)
|
static int cb_nbio_image_menu_wallpaper(void *data, size_t len)
|
||||||
{
|
{
|
||||||
void *ptr = NULL;
|
void *ptr = NULL;
|
||||||
|
nbio_handle_t *nbio = data;
|
||||||
|
|
||||||
g_extern.nbio.image.handle = (struct rpng_t*)calloc(1, sizeof(struct rpng_t));
|
if (!nbio || !data)
|
||||||
g_extern.nbio.image.cb = &cb_image_menu_wallpaper;
|
|
||||||
|
|
||||||
if (!g_extern.nbio.image.handle)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ptr = nbio_get_ptr(g_extern.nbio.handle, &len);
|
nbio->image.handle = (struct rpng_t*)calloc(1, sizeof(struct rpng_t));
|
||||||
|
nbio->image.cb = &cb_image_menu_wallpaper;
|
||||||
|
|
||||||
g_extern.nbio.image.handle->buff_data = (uint8_t*)ptr;
|
if (!nbio->image.handle)
|
||||||
g_extern.nbio.image.pos_increment = (len / 2) ? (len / 2) : 1;
|
return -1;
|
||||||
|
|
||||||
if (!rpng_nbio_load_image_argb_start(g_extern.nbio.image.handle))
|
ptr = nbio_get_ptr(nbio->handle, &len);
|
||||||
|
|
||||||
|
if (!ptr)
|
||||||
{
|
{
|
||||||
rpng_nbio_load_image_free(g_extern.nbio.image.handle);
|
free(nbio->image.handle);
|
||||||
|
nbio->image.handle = NULL;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_extern.nbio.image.is_blocking = false;
|
nbio->image.handle->buff_data = (uint8_t*)ptr;
|
||||||
g_extern.nbio.image.is_finished = false;
|
nbio->image.pos_increment = (len / 2) ? (len / 2) : 1;
|
||||||
g_extern.nbio.is_blocking = false;
|
|
||||||
g_extern.nbio.is_finished = true;
|
if (!rpng_nbio_load_image_argb_start(nbio->image.handle))
|
||||||
|
{
|
||||||
|
rpng_nbio_load_image_free(nbio->image.handle);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
nbio->image.is_blocking = false;
|
||||||
|
nbio->image.is_finished = false;
|
||||||
|
nbio->is_blocking = false;
|
||||||
|
nbio->is_finished = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -248,9 +264,8 @@ static int rarch_main_iterate_image_parse_free(void)
|
|||||||
static int rarch_main_iterate_image_parse(void)
|
static int rarch_main_iterate_image_parse(void)
|
||||||
{
|
{
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
if (g_extern.nbio.image.handle && g_extern.nbio.image.cb)
|
if (g_extern.nbio.image.handle && g_extern.nbio.image.cb)
|
||||||
g_extern.nbio.image.cb(g_extern.nbio.image.handle, len);
|
g_extern.nbio.image.cb(&g_extern.nbio, len);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -262,11 +277,15 @@ static int rarch_main_iterate_image_parse(void)
|
|||||||
|
|
||||||
static int cb_nbio_default(void *data, size_t len)
|
static int cb_nbio_default(void *data, size_t len)
|
||||||
{
|
{
|
||||||
(void)data;
|
nbio_handle_t *nbio = (nbio_handle_t*)data;
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
return -1;
|
||||||
|
|
||||||
(void)len;
|
(void)len;
|
||||||
|
|
||||||
g_extern.nbio.is_blocking = false;
|
nbio->is_blocking = false;
|
||||||
g_extern.nbio.is_finished = true;
|
nbio->is_finished = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -365,11 +384,9 @@ static int rarch_main_iterate_nbio_parse_free(void)
|
|||||||
|
|
||||||
static int rarch_main_iterate_nbio_parse(void)
|
static int rarch_main_iterate_nbio_parse(void)
|
||||||
{
|
{
|
||||||
size_t len = 0;
|
int len = 0;
|
||||||
char *data = (char*)nbio_get_ptr(g_extern.nbio.handle, &len);
|
if (g_extern.nbio.cb)
|
||||||
|
g_extern.nbio.cb(&g_extern.nbio, len);
|
||||||
if (data && g_extern.nbio.cb)
|
|
||||||
g_extern.nbio.cb(data, len);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user