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,
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;

View File

@ -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();
}

View File

@ -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);

View File

@ -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,

View File

@ -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:

View File

@ -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));

View File

@ -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);