Move reset_list_buffer to gfx_widgets and turn it into a static function

This commit is contained in:
twinaphex 2020-09-28 03:30:22 +02:00
parent 783bcb7a61
commit 9d6bfabd02
3 changed files with 31 additions and 36 deletions

View File

@ -1648,6 +1648,7 @@ void gfx_display_draw_text(
video_driver_set_osd_msg(text, &params, (void*)font);
}
/* NOTE: Reads image from file */
bool gfx_display_reset_textures_list(
const char *texture_path, const char *iconpath,
uintptr_t *item, enum texture_filter_type filter_type,
@ -1687,35 +1688,6 @@ bool gfx_display_reset_textures_list(
return true;
}
bool gfx_display_reset_textures_list_buffer(
uintptr_t *item, enum texture_filter_type filter_type,
void* buffer, unsigned buffer_len, enum image_type_enum image_type,
unsigned *width, unsigned *height)
{
struct texture_image ti;
ti.width = 0;
ti.height = 0;
ti.pixels = NULL;
ti.supports_rgba = video_driver_supports_rgba();
if (!image_texture_load_buffer(&ti, image_type, buffer, buffer_len))
return false;
if (width)
*width = ti.width;
if (height)
*height = ti.height;
/* if the poke interface doesn't support texture load then return false */
if (!video_driver_texture_load(&ti, filter_type, item))
return false;
image_texture_free(&ti);
return true;
}
/* Teardown; deinitializes and frees all
* fonts associated to the display driver */
void gfx_display_font_free(font_data_t *font)

View File

@ -324,12 +324,6 @@ bool gfx_display_reset_textures_list(
uintptr_t *item, enum texture_filter_type filter_type,
unsigned *width, unsigned *height);
bool gfx_display_reset_textures_list_buffer(
uintptr_t *item, enum texture_filter_type filter_type,
void* buffer, unsigned buffer_len,
enum image_type_enum image_type,
unsigned *width, unsigned *height);
/* Returns the OSK key at a given position */
int gfx_display_osk_ptr_at_pos(void *data, int x, int y,
unsigned width, unsigned height);

View File

@ -2047,6 +2047,35 @@ static void gfx_widgets_free(dispgfx_widget_t *p_dispwidget)
}
#ifdef HAVE_TRANSLATE
/* NOTE: Reads image from memory buffer */
static bool gfx_widgets_reset_textures_list_buffer(
uintptr_t *item, enum texture_filter_type filter_type,
void* buffer, unsigned buffer_len, enum image_type_enum image_type,
unsigned *width, unsigned *height)
{
struct texture_image ti;
ti.width = 0;
ti.height = 0;
ti.pixels = NULL;
ti.supports_rgba = video_driver_supports_rgba();
if (!image_texture_load_buffer(&ti, image_type, buffer, buffer_len))
return false;
if (width)
*width = ti.width;
if (height)
*height = ti.height;
/* if the poke interface doesn't support texture load then return false */
if (!video_driver_texture_load(&ti, filter_type, item))
return false;
image_texture_free(&ti);
return true;
}
bool gfx_widgets_ai_service_overlay_load(
dispgfx_widget_t *p_dispwidget,
char* buffer, unsigned buffer_len,
@ -2054,7 +2083,7 @@ bool gfx_widgets_ai_service_overlay_load(
{
if (p_dispwidget->ai_service_overlay_state == 0)
{
bool res = gfx_display_reset_textures_list_buffer(
bool res = gfx_widgets_reset_textures_list_buffer(
&p_dispwidget->ai_service_overlay_texture,
TEXTURE_FILTER_MIPMAP_LINEAR,
(void *) buffer, buffer_len, image_type,