Revert "Remove supports_rgba varaible from image_texture.c"

This reverts commit bd0c97fdc4.
This commit is contained in:
twinaphex 2016-12-29 22:53:10 +01:00
parent bd0c97fdc4
commit 6a166faa0c
8 changed files with 69 additions and 86 deletions

View File

@ -1503,6 +1503,7 @@ void video_driver_set_rgba(void)
{ {
video_driver_lock(); video_driver_lock();
video_driver_use_rgba = true; video_driver_use_rgba = true;
image_texture_set_rgba();
video_driver_unlock(); video_driver_unlock();
} }
@ -1510,6 +1511,7 @@ void video_driver_unset_rgba(void)
{ {
video_driver_lock(); video_driver_lock();
video_driver_use_rgba = false; video_driver_use_rgba = false;
image_texture_unset_rgba();
video_driver_unlock(); video_driver_unlock();
} }

View File

@ -38,8 +38,19 @@ enum video_image_format
IMAGE_FORMAT_BMP IMAGE_FORMAT_BMP
}; };
static bool image_texture_supports_rgba = false;
void image_texture_set_rgba(void)
{
image_texture_supports_rgba = true;
}
void image_texture_unset_rgba(void)
{
image_texture_supports_rgba = false;
}
bool image_texture_set_color_shifts( bool image_texture_set_color_shifts(
struct texture_image *out_img,
unsigned *r_shift, unsigned *g_shift, unsigned *b_shift, unsigned *r_shift, unsigned *g_shift, unsigned *b_shift,
unsigned *a_shift) unsigned *a_shift)
{ {
@ -48,7 +59,7 @@ bool image_texture_set_color_shifts(
*g_shift = 8; *g_shift = 8;
*b_shift = 0; *b_shift = 0;
if (out_img->supports_rgba) if (image_texture_supports_rgba)
{ {
*r_shift = 0; *r_shift = 0;
*b_shift = 16; *b_shift = 16;
@ -272,8 +283,7 @@ bool image_texture_load(struct texture_image *out_img,
void *ptr = NULL; void *ptr = NULL;
enum video_image_format fmt = image_texture_get_type(path); enum video_image_format fmt = image_texture_get_type(path);
image_texture_set_color_shifts(out_img, image_texture_set_color_shifts(&r_shift, &g_shift, &b_shift,
&r_shift, &g_shift, &b_shift,
&a_shift); &a_shift);
if (fmt != IMAGE_FORMAT_NONE) if (fmt != IMAGE_FORMAT_NONE)

View File

@ -44,7 +44,6 @@ struct texture_image
unsigned width; unsigned width;
unsigned height; unsigned height;
uint32_t *pixels; uint32_t *pixels;
bool supports_rgba;
}; };
enum image_type_enum enum image_type_enum
@ -56,9 +55,7 @@ enum image_type_enum
IMAGE_TYPE_TGA IMAGE_TYPE_TGA
}; };
bool image_texture_set_color_shifts( bool image_texture_set_color_shifts(unsigned *r_shift, unsigned *g_shift,
struct texture_image *out_img,
unsigned *r_shift, unsigned *g_shift,
unsigned *b_shift, unsigned *a_shift); unsigned *b_shift, unsigned *a_shift);
bool image_texture_color_convert(unsigned r_shift, bool image_texture_color_convert(unsigned r_shift,
@ -67,6 +64,8 @@ bool image_texture_color_convert(unsigned r_shift,
bool image_texture_load(struct texture_image *img, const char *path); bool image_texture_load(struct texture_image *img, const char *path);
void image_texture_free(struct texture_image *img); void image_texture_free(struct texture_image *img);
void image_texture_set_rgba(void);
void image_texture_unset_rgba(void);
/* Image transfer */ /* Image transfer */

View File

@ -1058,9 +1058,7 @@ static int generic_action_ok(const char *path,
strlcpy(settings->path.menu_wallpaper, strlcpy(settings->path.menu_wallpaper,
action_path, sizeof(settings->path.menu_wallpaper)); action_path, sizeof(settings->path.menu_wallpaper));
task_push_image_load( task_push_image_load(action_path,
video_driver_supports_rgba(),
action_path,
MENU_ENUM_LABEL_CB_MENU_WALLPAPER, MENU_ENUM_LABEL_CB_MENU_WALLPAPER,
menu_display_handle_wallpaper_upload, NULL); menu_display_handle_wallpaper_upload, NULL);
} }

View File

@ -1565,8 +1565,7 @@ static void mui_context_reset(void *data)
menu_display_allocate_white_texture(); menu_display_allocate_white_texture();
mui_context_reset_textures(mui); mui_context_reset_textures(mui);
task_push_image_load(video_driver_supports_rgba(), task_push_image_load(settings->path.menu_wallpaper,
settings->path.menu_wallpaper,
MENU_ENUM_LABEL_CB_MENU_WALLPAPER, MENU_ENUM_LABEL_CB_MENU_WALLPAPER,
menu_display_handle_wallpaper_upload, NULL); menu_display_handle_wallpaper_upload, NULL);
} }

View File

@ -997,9 +997,7 @@ static void xmb_update_thumbnail_image(void *data)
return; return;
if (path_file_exists(xmb->thumbnail_file_path)) if (path_file_exists(xmb->thumbnail_file_path))
task_push_image_load( task_push_image_load(xmb->thumbnail_file_path,
video_driver_supports_rgba(),
xmb->thumbnail_file_path,
MENU_ENUM_LABEL_CB_MENU_THUMBNAIL, MENU_ENUM_LABEL_CB_MENU_THUMBNAIL,
menu_display_handle_thumbnail_upload, NULL); menu_display_handle_thumbnail_upload, NULL);
else if (xmb->depth == 1) else if (xmb->depth == 1)
@ -1013,9 +1011,7 @@ static void xmb_update_savestate_thumbnail_image(void *data)
return; return;
if (path_file_exists(xmb->savestate_thumbnail_file_path)) if (path_file_exists(xmb->savestate_thumbnail_file_path))
task_push_image_load( task_push_image_load(xmb->savestate_thumbnail_file_path,
video_driver_supports_rgba(),
xmb->savestate_thumbnail_file_path,
MENU_ENUM_LABEL_CB_MENU_SAVESTATE_THUMBNAIL, MENU_ENUM_LABEL_CB_MENU_SAVESTATE_THUMBNAIL,
menu_display_handle_savestate_thumbnail_upload, NULL); menu_display_handle_savestate_thumbnail_upload, NULL);
else else
@ -1359,9 +1355,7 @@ static void xmb_list_switch_new(xmb_handle_t *xmb,
{ {
if(path_file_exists(path)) if(path_file_exists(path))
{ {
task_push_image_load( task_push_image_load(path,
video_driver_supports_rgba(),
path,
MENU_ENUM_LABEL_CB_MENU_WALLPAPER, MENU_ENUM_LABEL_CB_MENU_WALLPAPER,
menu_display_handle_wallpaper_upload, NULL); menu_display_handle_wallpaper_upload, NULL);
strlcpy(xmb->background_file_path, strlcpy(xmb->background_file_path,
@ -3467,9 +3461,7 @@ static void xmb_context_reset_background(const char *iconpath)
if (path_file_exists(path)) if (path_file_exists(path))
task_push_image_load( task_push_image_load(path,
video_driver_supports_rgba(),
path,
MENU_ENUM_LABEL_CB_MENU_WALLPAPER, MENU_ENUM_LABEL_CB_MENU_WALLPAPER,
menu_display_handle_wallpaper_upload, NULL); menu_display_handle_wallpaper_upload, NULL);
} }

View File

@ -55,12 +55,6 @@ struct nbio_image_handle
enum image_status_enum status; enum image_status_enum status;
}; };
struct nbio_wrapper_handle
{
nbio_handle_t *nbio;
bool supports_rgba;
};
static int cb_image_menu_upload_generic(void *data, size_t len) static int cb_image_menu_upload_generic(void *data, size_t len)
{ {
unsigned r_shift, g_shift, b_shift, a_shift; unsigned r_shift, g_shift, b_shift, a_shift;
@ -74,9 +68,7 @@ static int cb_image_menu_upload_generic(void *data, size_t len)
image->processing_final_state == IMAGE_PROCESS_ERROR_END) image->processing_final_state == IMAGE_PROCESS_ERROR_END)
return -1; return -1;
image_texture_set_color_shifts( image_texture_set_color_shifts(&r_shift, &g_shift, &b_shift,
&image->ti,
&r_shift, &g_shift, &b_shift,
&a_shift); &a_shift);
image_texture_color_convert(r_shift, g_shift, b_shift, image_texture_color_convert(r_shift, g_shift, b_shift,
@ -257,25 +249,25 @@ error:
static int cb_nbio_image_menu_thumbnail(void *data, size_t len) static int cb_nbio_image_menu_thumbnail(void *data, size_t len)
{ {
struct nbio_image_handle *image = NULL; struct nbio_image_handle *image = NULL;
void *handle = NULL; void *handle = NULL;
struct nbio_wrapper_handle *nbio = (struct nbio_wrapper_handle*)data; nbio_handle_t *nbio = (nbio_handle_t*)data;
if (!nbio) if (!nbio)
goto error; goto error;
handle = image_transfer_new(nbio->nbio->image_type); handle = image_transfer_new(nbio->image_type);
if (!handle) if (!handle)
goto error; goto error;
image = (struct nbio_image_handle*)nbio->nbio->data; image = (struct nbio_image_handle*)nbio->data;
image->handle = handle; image->handle = handle;
image->size = len; image->size = len;
image->cb = &cb_image_menu_thumbnail; image->cb = &cb_image_menu_thumbnail;
return cb_nbio_generic(nbio->nbio, &len); return cb_nbio_generic(nbio, &len);
error: error:
return -1; return -1;
@ -283,29 +275,29 @@ error:
bool task_image_load_handler(retro_task_t *task) bool task_image_load_handler(retro_task_t *task)
{ {
struct nbio_wrapper_handle *nbio = (struct nbio_wrapper_handle *)task->state; nbio_handle_t *nbio = (nbio_handle_t*)task->state;
struct nbio_image_handle *image = (struct nbio_image_handle*)nbio->nbio->data; struct nbio_image_handle *image = (struct nbio_image_handle*)nbio->data;
if (image) if (image)
{ {
switch (image->status) switch (image->status)
{ {
case IMAGE_STATUS_PROCESS_TRANSFER: case IMAGE_STATUS_PROCESS_TRANSFER:
if (task_image_iterate_process_transfer(nbio->nbio) == -1) if (task_image_iterate_process_transfer(nbio) == -1)
image->status = IMAGE_STATUS_PROCESS_TRANSFER_PARSE; image->status = IMAGE_STATUS_PROCESS_TRANSFER_PARSE;
break; break;
case IMAGE_STATUS_TRANSFER_PARSE: case IMAGE_STATUS_TRANSFER_PARSE:
task_image_iterate_transfer_parse(nbio->nbio); task_image_iterate_transfer_parse(nbio);
if (image->is_blocking_on_processing) if (image->is_blocking_on_processing)
image->status = IMAGE_STATUS_PROCESS_TRANSFER; image->status = IMAGE_STATUS_PROCESS_TRANSFER;
break; break;
case IMAGE_STATUS_TRANSFER: case IMAGE_STATUS_TRANSFER:
if (!image->is_blocking) if (!image->is_blocking)
if (task_image_iterate_transfer(nbio->nbio) == -1) if (task_image_iterate_transfer(nbio) == -1)
image->status = IMAGE_STATUS_TRANSFER_PARSE; image->status = IMAGE_STATUS_TRANSFER_PARSE;
break; break;
case IMAGE_STATUS_PROCESS_TRANSFER_PARSE: case IMAGE_STATUS_PROCESS_TRANSFER_PARSE:
task_image_iterate_transfer_parse(nbio->nbio); task_image_iterate_transfer_parse(nbio);
if (!image->is_finished) if (!image->is_finished)
break; break;
case IMAGE_STATUS_TRANSFER_PARSE_FREE: case IMAGE_STATUS_TRANSFER_PARSE_FREE:
@ -315,7 +307,7 @@ bool task_image_load_handler(retro_task_t *task)
} }
} }
if ( (nbio->nbio && nbio->nbio->is_finished ) if ( (nbio && nbio->is_finished )
&& (image && image->is_finished ) && (image && image->is_finished )
&& (task && !task_get_cancelled(task))) && (task && !task_get_cancelled(task)))
{ {
@ -332,76 +324,70 @@ bool task_image_load_handler(retro_task_t *task)
return true; return true;
} }
bool task_push_image_load(bool supports_rgba, bool task_push_image_load(const char *fullpath,
const char *fullpath,
enum msg_hash_enums enum_idx, retro_task_callback_t cb, void *user_data) enum msg_hash_enums enum_idx, retro_task_callback_t cb, void *user_data)
{ {
retro_task_t *task = NULL; nbio_handle_t *nbio = NULL;
retro_task_t *t = NULL;
struct nbio_t *handle = NULL; struct nbio_t *handle = NULL;
struct nbio_image_handle *image = NULL; struct nbio_image_handle *image = NULL;
struct nbio_wrapper_handle *nbio = NULL;
if (enum_idx == MSG_UNKNOWN) if (enum_idx == MSG_UNKNOWN)
goto error_msg; goto error_msg;
task = (retro_task_t*)calloc(1, sizeof(*task)); t = (retro_task_t*)calloc(1, sizeof(*t));
if (!task) if (!t)
goto error_msg; goto error_msg;
nbio = (struct nbio_wrapper_handle*)calloc(1, sizeof(*nbio)); nbio = (nbio_handle_t*)calloc(1, sizeof(*nbio));
if (!nbio) if (!nbio)
goto error; goto error;
nbio->nbio = (nbio_handle_t*)calloc(1, sizeof(*nbio->nbio)); handle = nbio_open(fullpath, NBIO_READ);
if (!nbio->nbio)
goto error;
handle = nbio_open(fullpath, NBIO_READ);
if (!handle) if (!handle)
goto error; goto error;
nbio->supports_rgba = supports_rgba; nbio->handle = handle;
nbio->nbio->handle = handle;
image = (struct nbio_image_handle*)calloc(1, sizeof(*image)); image = (struct nbio_image_handle*)calloc(1, sizeof(*image));
if (!image) if (!image)
goto error; goto error;
image->status = IMAGE_STATUS_TRANSFER; image->status = IMAGE_STATUS_TRANSFER;
nbio->nbio->data = (struct nbio_image_handle*)image; nbio->data = (struct nbio_image_handle*)image;
nbio->nbio->is_finished = false; nbio->is_finished = false;
nbio->nbio->cb = &cb_nbio_image_menu_thumbnail; nbio->cb = &cb_nbio_image_menu_thumbnail;
nbio->nbio->status = NBIO_STATUS_TRANSFER; nbio->status = NBIO_STATUS_TRANSFER;
if (strstr(fullpath, file_path_str(FILE_PATH_PNG_EXTENSION))) if (strstr(fullpath, file_path_str(FILE_PATH_PNG_EXTENSION)))
nbio->nbio->image_type = IMAGE_TYPE_PNG; nbio->image_type = IMAGE_TYPE_PNG;
else if (strstr(fullpath, file_path_str(FILE_PATH_JPEG_EXTENSION)) else if (strstr(fullpath, file_path_str(FILE_PATH_JPEG_EXTENSION))
|| strstr(fullpath, file_path_str(FILE_PATH_JPG_EXTENSION))) || strstr(fullpath, file_path_str(FILE_PATH_JPG_EXTENSION)))
nbio->nbio->image_type = IMAGE_TYPE_JPEG; nbio->image_type = IMAGE_TYPE_JPEG;
else if (strstr(fullpath, file_path_str(FILE_PATH_BMP_EXTENSION))) else if (strstr(fullpath, file_path_str(FILE_PATH_BMP_EXTENSION)))
nbio->nbio->image_type = IMAGE_TYPE_BMP; nbio->image_type = IMAGE_TYPE_BMP;
else if (strstr(fullpath, file_path_str(FILE_PATH_TGA_EXTENSION))) else if (strstr(fullpath, file_path_str(FILE_PATH_TGA_EXTENSION)))
nbio->nbio->image_type = IMAGE_TYPE_TGA; nbio->image_type = IMAGE_TYPE_TGA;
nbio_begin_read(handle); nbio_begin_read(handle);
task->state = nbio; t->state = nbio;
task->handler = task_file_load_handler; t->handler = task_file_load_handler;
task->cleanup = task_image_load_free; t->cleanup = task_image_load_free;
task->callback = cb; t->callback = cb;
task->user_data = user_data; t->user_data = user_data;
task_queue_ctl(TASK_QUEUE_CTL_PUSH, task); task_queue_ctl(TASK_QUEUE_CTL_PUSH, t);
return true; return true;
error: error:
nbio_free(handle); nbio_free(handle);
task_image_load_free(task); task_image_load_free(t);
free(task); free(t);
if (nbio->nbio) if (nbio)
free(nbio->nbio); free(nbio);
error_msg: error_msg:
RARCH_ERR("[image load] Failed to open '%s': %s.\n", RARCH_ERR("[image load] Failed to open '%s': %s.\n",

View File

@ -100,12 +100,9 @@ bool task_push_netplay_lan_scan(void);
#endif #endif
bool task_push_image_load( bool task_push_image_load(const char *fullpath,
bool supports_rgba,
const char *fullpath,
enum msg_hash_enums enum_idx, enum msg_hash_enums enum_idx,
retro_task_callback_t cb, retro_task_callback_t cb, void *userdata);
void *userdata);
#ifdef HAVE_LIBRETRODB #ifdef HAVE_LIBRETRODB
bool task_push_dbscan(const char *fullpath, bool task_push_dbscan(const char *fullpath,