diff --git a/cores/libretro-imageviewer/image_core.c b/cores/libretro-imageviewer/image_core.c index 1e92fbd332..13e303dc9f 100644 --- a/cores/libretro-imageviewer/image_core.c +++ b/cores/libretro-imageviewer/image_core.c @@ -239,6 +239,10 @@ static bool imageviewer_load(const char *path, int image_index) &comp, 4); #else +#ifdef RARCH_INTERNAL + extern bool video_driver_supports_rgba(); + image_texture.supports_rgba = video_driver_supports_rgba(); +#endif if (!image_texture_load(&image_texture, path)) return false; image_buffer = (uint32_t*)image_texture.pixels; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index bc17f61234..d93decb44d 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1503,7 +1503,6 @@ void video_driver_set_rgba(void) { video_driver_lock(); video_driver_use_rgba = true; - image_texture_set_rgba(); video_driver_unlock(); } @@ -1511,7 +1510,6 @@ void video_driver_unset_rgba(void) { video_driver_lock(); video_driver_use_rgba = false; - image_texture_unset_rgba(); video_driver_unlock(); } diff --git a/libretro-common/formats/image_texture.c b/libretro-common/formats/image_texture.c index 72de97ed12..46f6143698 100644 --- a/libretro-common/formats/image_texture.c +++ b/libretro-common/formats/image_texture.c @@ -38,28 +38,18 @@ enum video_image_format 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( unsigned *r_shift, unsigned *g_shift, unsigned *b_shift, - unsigned *a_shift) + unsigned *a_shift, + struct texture_image *out_img + ) { *a_shift = 24; *r_shift = 16; *g_shift = 8; *b_shift = 0; - if (image_texture_supports_rgba) + if (out_img->supports_rgba) { *r_shift = 0; *b_shift = 16; @@ -284,7 +274,7 @@ bool image_texture_load(struct texture_image *out_img, enum video_image_format fmt = image_texture_get_type(path); image_texture_set_color_shifts(&r_shift, &g_shift, &b_shift, - &a_shift); + &a_shift, out_img); if (fmt != IMAGE_FORMAT_NONE) { @@ -308,9 +298,10 @@ bool image_texture_load(struct texture_image *out_img, } error: - out_img->pixels = NULL; - out_img->width = 0; - out_img->height = 0; + out_img->supports_rgba = false; + out_img->pixels = NULL; + out_img->width = 0; + out_img->height = 0; if (handle) nbio_free(handle); diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index 882c17d1c6..c462d12587 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -44,6 +44,7 @@ struct texture_image unsigned width; unsigned height; uint32_t *pixels; + bool supports_rgba; }; enum image_type_enum @@ -56,7 +57,8 @@ enum image_type_enum }; bool image_texture_set_color_shifts(unsigned *r_shift, unsigned *g_shift, - unsigned *b_shift, unsigned *a_shift); + unsigned *b_shift, unsigned *a_shift, + struct texture_image *out_img); bool image_texture_color_convert(unsigned r_shift, unsigned g_shift, unsigned b_shift, unsigned a_shift, diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index 1bce20c32d..d15bf03ff5 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -132,11 +132,13 @@ static void nk_menu_context_reset_textures(nk_menu_handle_t *nk, struct texture_image ti; char path[PATH_MAX_LENGTH]; - ti.width = 0; - ti.height = 0; - ti.pixels = NULL; path[0] = '\0'; + ti.width = 0; + ti.height = 0; + ti.pixels = NULL; + ti.supports_rgba = video_driver_supports_rgba(); + switch(i) { case NK_TEXTURE_POINTER: diff --git a/menu/menu_display.c b/menu/menu_display.c index 4d2d2ceddb..b52e2aa94b 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -923,6 +923,7 @@ void menu_display_reset_textures_list(const char *texture_path, const char *icon ti.width = 0; ti.height = 0; ti.pixels = NULL; + ti.supports_rgba = video_driver_supports_rgba(); if (!string_is_empty(texture_path)) fill_pathname_join(path, iconpath, texture_path, sizeof(path)); diff --git a/tasks/task_image.c b/tasks/task_image.c index fef0002a73..c59ae1f6ff 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -70,7 +70,7 @@ static int cb_image_menu_upload_generic(void *data, size_t len) return -1; image_texture_set_color_shifts(&r_shift, &g_shift, &b_shift, - &a_shift); + &a_shift, &image->ti); image_texture_color_convert(r_shift, g_shift, b_shift, a_shift, &image->ti);