diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 5827303afe..f35b925922 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -151,22 +151,7 @@ static void mui_context_reset_textures(mui_handle_t *mui) APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_ICONS); for (i = 0; i < MUI_TEXTURE_LAST; i++) - { - struct texture_image ti = {0}; - char path[PATH_MAX_LENGTH] = {0}; - const char *texture_path = mui_texture_path(i); - - if (texture_path != NULL) - fill_pathname_join(path, iconpath, texture_path, sizeof(path)); - - if (string_is_empty(path) || !path_file_exists(path)) - continue; - - image_texture_load(&ti, path); - video_driver_texture_load(&ti, - TEXTURE_FILTER_MIPMAP_LINEAR, &mui->textures.list[i]); - image_texture_free(&ti); - } + menu_display_reset_textures_list(mui_texture_path(i), iconpath, &mui->textures.list[i]); } static void mui_draw_icon( diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 52c1e720cc..3fa00f9353 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2716,26 +2716,7 @@ static void xmb_context_reset_textures( unsigned i; for (i = 0; i < XMB_TEXTURE_LAST; i++) - { - struct texture_image ti = {0}; - char path[PATH_MAX_LENGTH] = {0}; - const char *texture_path = xmb_texture_path(i); - - if (texture_path != NULL) - fill_pathname_join(path, iconpath, texture_path, sizeof(path)); - - if (string_is_empty(path) || !path_file_exists(path)) - continue; - - image_texture_load(&ti, path); - - video_driver_texture_unload(&xmb->textures.list[i]); - video_driver_texture_load(&ti, - TEXTURE_FILTER_MIPMAP_LINEAR, - &xmb->textures.list[i]); - - image_texture_free(&ti); - } + menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i]); menu_display_allocate_white_texture(); diff --git a/menu/menu_display.c b/menu/menu_display.c index 33b6a030d7..d72444a7b7 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "../config.def.h" @@ -26,6 +27,7 @@ #include "../configuration.h" #include "../runloop.h" #include "../core.h" +#include "../gfx/video_driver.h" #include "../gfx/video_thread_wrapper.h" #include "../verbosity.h" @@ -805,3 +807,21 @@ void menu_display_set_alpha(float *color, float alpha_value) return; color[3] = color[7] = color[11] = color[15] = alpha_value; } + +void menu_display_reset_textures_list(const char *texture_path, const char *iconpath, + uintptr_t *item) +{ + struct texture_image ti = {0}; + char path[PATH_MAX_LENGTH] = {0}; + + if (texture_path != NULL) + fill_pathname_join(path, iconpath, texture_path, sizeof(path)); + + if (string_is_empty(path) || !path_file_exists(path)) + return; + + image_texture_load(&ti, path); + video_driver_texture_load(&ti, + TEXTURE_FILTER_MIPMAP_LINEAR, item); + image_texture_free(&ti); +} diff --git a/menu/menu_display.h b/menu/menu_display.h index 482f666c8f..df0162965e 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -251,6 +251,9 @@ void menu_display_set_alpha(float *color, float alpha_value); bool menu_display_font(enum application_special_type type); +void menu_display_reset_textures_list(const char *texture_path, const char *iconpath, + uintptr_t *item); + extern uintptr_t menu_display_white_texture; extern menu_display_ctx_driver_t menu_display_ctx_gl;