Change menu_driver_load_background to menu_driver_load_image

This commit is contained in:
twinaphex 2015-06-04 10:39:48 +02:00
parent 959fd621a5
commit 1b67864a3b
6 changed files with 48 additions and 25 deletions

View File

@ -22,6 +22,7 @@
#include <limits.h>
#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,
};

View File

@ -21,6 +21,7 @@
#include <limits.h>
#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,
};

View File

@ -61,7 +61,7 @@ extern "C" {
typedef enum
{
MENU_FILE_NONE,
MENU_FILE_NONE = 0,
MENU_FILE_PLAIN,
MENU_FILE_DIRECTORY,
MENU_FILE_PATH,

View File

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

View File

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

View File

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