From 9d6bfabd02324845c4894a66074805d773ea15f0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 28 Sep 2020 03:30:22 +0200 Subject: [PATCH] Move reset_list_buffer to gfx_widgets and turn it into a static function --- gfx/gfx_display.c | 30 +----------------------------- gfx/gfx_display.h | 6 ------ gfx/gfx_widgets.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/gfx/gfx_display.c b/gfx/gfx_display.c index 95ba8d03d6..f4e8654a56 100644 --- a/gfx/gfx_display.c +++ b/gfx/gfx_display.c @@ -1648,6 +1648,7 @@ void gfx_display_draw_text( video_driver_set_osd_msg(text, ¶ms, (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) diff --git a/gfx/gfx_display.h b/gfx/gfx_display.h index a229675f14..be7b81e608 100644 --- a/gfx/gfx_display.h +++ b/gfx/gfx_display.h @@ -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); diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index 83f3d8cd6a..210292ba66 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -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,