From 1b67864a3bb1fe2d49caca679f85681609977499 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 4 Jun 2015 10:39:48 +0200 Subject: [PATCH] Change menu_driver_load_background to menu_driver_load_image --- menu/drivers/glui.c | 24 +++++++++++++++++------- menu/drivers/xmb.c | 26 ++++++++++++++++---------- menu/menu.h | 2 +- menu/menu_driver.c | 6 +++--- menu/menu_driver.h | 11 +++++++++-- tasks/task_file_transfer.c | 4 ++-- 6 files changed, 48 insertions(+), 25 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index d03c7137ab..fa6bf623e9 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -22,6 +22,7 @@ #include #include "../menu.h" +#include "../menu_driver.h" #include "../menu_entry.h" #include "../menu_display.h" #include "../../runloop_data.h" @@ -556,7 +557,7 @@ static void glui_context_destroy(void) glui_context_bg_destroy(glui); } -static bool glui_load_wallpaper(void *data) +static bool glui_load_image(void *data, menu_image_type_t type) { glui_handle_t *glui = NULL; menu_handle_t *menu = menu_driver_get_ptr(); @@ -565,12 +566,21 @@ static bool glui_load_wallpaper(void *data) return false; glui = (glui_handle_t*)menu->userdata; - - glui_context_bg_destroy(glui); - glui->textures.bg.id = video_texture_load(data, - TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); - glui_allocate_white_texture(glui); + switch (type) + { + case MENU_IMAGE_NONE: + break; + case MENU_IMAGE_WALLPAPER: + glui_context_bg_destroy(glui); + + glui->textures.bg.id = video_texture_load(data, + TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); + glui_allocate_white_texture(glui); + break; + case MENU_IMAGE_BOXART: + break; + } return true; } @@ -687,7 +697,7 @@ menu_ctx_driver_t menu_ctx_glui = { NULL, NULL, NULL, - glui_load_wallpaper, + glui_load_image, "glui", NULL, }; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index a3453173bf..9097a09983 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -21,6 +21,7 @@ #include #include "../menu.h" +#include "../menu_driver.h" #include "../menu_entry.h" #include "../menu_animation.h" #include "../menu_display.h" @@ -1467,7 +1468,7 @@ static void xmb_context_bg_destroy(xmb_handle_t *xmb) glDeleteTextures(1, &xmb->textures.bg.id); } -static bool xmb_load_wallpaper(void *data) +static bool xmb_load_image(void *data, menu_image_type_t type) { xmb_handle_t *xmb = NULL; menu_handle_t *menu = menu_driver_get_ptr(); @@ -1477,16 +1478,21 @@ static bool xmb_load_wallpaper(void *data) xmb = (xmb_handle_t*)menu->userdata; - if (!xmb) - return false; - if (!data) + if (!xmb || !data) return false; - xmb_context_bg_destroy(xmb); - - xmb->textures.bg.id = video_texture_load(data, - TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); - + switch (type) + { + case MENU_IMAGE_NONE: + break; + case MENU_IMAGE_WALLPAPER: + xmb_context_bg_destroy(xmb); + xmb->textures.bg.id = video_texture_load(data, + TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); + break; + case MENU_IMAGE_BOXART: + break; + } return true; } @@ -1949,7 +1955,7 @@ menu_ctx_driver_t menu_ctx_xmb = { NULL, xmb_list_cache, NULL, - xmb_load_wallpaper, + xmb_load_image, "xmb", NULL, }; diff --git a/menu/menu.h b/menu/menu.h index 5edbd5cada..e8f9a5a031 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -61,7 +61,7 @@ extern "C" { typedef enum { - MENU_FILE_NONE, + MENU_FILE_NONE = 0, MENU_FILE_PLAIN, MENU_FILE_DIRECTORY, MENU_FILE_PATH, diff --git a/menu/menu_driver.c b/menu/menu_driver.c index b9a252d336..2dd6e1bd25 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -365,12 +365,12 @@ void menu_driver_populate_entries(const char *path, const char *label, driver->populate_entries(path, label, k); } -bool menu_driver_load_background(void *data) +bool menu_driver_load_image(void *data, menu_image_type_t type) { const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr(); - if (driver->load_background) - return driver->load_background(data); + if (driver->load_image) + return driver->load_image(data, type); return false; } diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 47a1fe9304..b970523047 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -43,6 +43,13 @@ extern "C" { #define MAX_USERS 16 #endif +typedef enum +{ + MENU_IMAGE_NONE = 0, + MENU_IMAGE_WALLPAPER, + MENU_IMAGE_BOXART, +} menu_image_type_t; + struct menu_bind_state_port { bool buttons[MENU_MAX_BUTTONS]; @@ -249,7 +256,7 @@ typedef struct menu_ctx_driver void (*list_clear)(file_list_t *list); void (*list_cache)(bool, unsigned); void (*list_set_selection)(file_list_t *list); - bool (*load_background)(void *data); + bool (*load_image)(void *data, menu_image_type_t type); const char *ident; bool (*perform_action)(void* data, unsigned action); } menu_ctx_driver_t; @@ -323,7 +330,7 @@ void menu_driver_render_messagebox(const char *msg); void menu_driver_populate_entries(const char *path, const char *label, unsigned k); -bool menu_driver_load_background(void *data); +bool menu_driver_load_image(void *data, menu_image_type_t type); void menu_driver_navigation_descend_alphabet(size_t *); diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index cd4c6b66a0..f624ef4804 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -59,7 +59,7 @@ static int cb_image_menu_wallpaper_upload(void *data, size_t len) if (cb_image_menu_upload_generic(nbio) != 0) return -1; - menu_driver_load_background(&nbio->image.ti); + menu_driver_load_image(&nbio->image.ti, MENU_IMAGE_WALLPAPER); texture_image_free(&nbio->image.ti); @@ -73,7 +73,7 @@ static int cb_image_menu_boxart_upload(void *data, size_t len) if (cb_image_menu_upload_generic(nbio) != 0) return -1; - menu_driver_load_background(&nbio->image.ti); + menu_driver_load_image(&nbio->image.ti, MENU_IMAGE_BOXART); texture_image_free(&nbio->image.ti);