Get rid of set_rgba/unset_rgba inside image_texture.c

This commit is contained in:
twinaphex 2016-12-29 23:22:40 +01:00
parent 05a899a411
commit 9657bbd998
7 changed files with 23 additions and 25 deletions

View File

@ -239,6 +239,10 @@ static bool imageviewer_load(const char *path, int image_index)
&comp, &comp,
4); 4);
#else #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)) if (!image_texture_load(&image_texture, path))
return false; return false;
image_buffer = (uint32_t*)image_texture.pixels; image_buffer = (uint32_t*)image_texture.pixels;

View File

@ -1503,7 +1503,6 @@ 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();
} }
@ -1511,7 +1510,6 @@ 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,28 +38,18 @@ 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(
unsigned *r_shift, unsigned *g_shift, unsigned *b_shift, unsigned *r_shift, unsigned *g_shift, unsigned *b_shift,
unsigned *a_shift) unsigned *a_shift,
struct texture_image *out_img
)
{ {
*a_shift = 24; *a_shift = 24;
*r_shift = 16; *r_shift = 16;
*g_shift = 8; *g_shift = 8;
*b_shift = 0; *b_shift = 0;
if (image_texture_supports_rgba) if (out_img->supports_rgba)
{ {
*r_shift = 0; *r_shift = 0;
*b_shift = 16; *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); enum video_image_format fmt = image_texture_get_type(path);
image_texture_set_color_shifts(&r_shift, &g_shift, &b_shift, image_texture_set_color_shifts(&r_shift, &g_shift, &b_shift,
&a_shift); &a_shift, out_img);
if (fmt != IMAGE_FORMAT_NONE) if (fmt != IMAGE_FORMAT_NONE)
{ {
@ -308,6 +298,7 @@ bool image_texture_load(struct texture_image *out_img,
} }
error: error:
out_img->supports_rgba = false;
out_img->pixels = NULL; out_img->pixels = NULL;
out_img->width = 0; out_img->width = 0;
out_img->height = 0; out_img->height = 0;

View File

@ -44,6 +44,7 @@ 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,7 +57,8 @@ enum image_type_enum
}; };
bool image_texture_set_color_shifts(unsigned *r_shift, unsigned *g_shift, 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, bool image_texture_color_convert(unsigned r_shift,
unsigned g_shift, unsigned b_shift, unsigned a_shift, unsigned g_shift, unsigned b_shift, unsigned a_shift,

View File

@ -132,10 +132,12 @@ static void nk_menu_context_reset_textures(nk_menu_handle_t *nk,
struct texture_image ti; struct texture_image ti;
char path[PATH_MAX_LENGTH]; char path[PATH_MAX_LENGTH];
path[0] = '\0';
ti.width = 0; ti.width = 0;
ti.height = 0; ti.height = 0;
ti.pixels = NULL; ti.pixels = NULL;
path[0] = '\0'; ti.supports_rgba = video_driver_supports_rgba();
switch(i) switch(i)
{ {

View File

@ -923,6 +923,7 @@ void menu_display_reset_textures_list(const char *texture_path, const char *icon
ti.width = 0; ti.width = 0;
ti.height = 0; ti.height = 0;
ti.pixels = NULL; ti.pixels = NULL;
ti.supports_rgba = video_driver_supports_rgba();
if (!string_is_empty(texture_path)) if (!string_is_empty(texture_path))
fill_pathname_join(path, iconpath, texture_path, sizeof(path)); fill_pathname_join(path, iconpath, texture_path, sizeof(path));

View File

@ -70,7 +70,7 @@ static int cb_image_menu_upload_generic(void *data, size_t len)
return -1; return -1;
image_texture_set_color_shifts(&r_shift, &g_shift, &b_shift, 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, image_texture_color_convert(r_shift, g_shift, b_shift,
a_shift, &image->ti); a_shift, &image->ti);