Merge pull request #1275 from lakkatv/xmb

(XMB) Move all caching stuff to the display driver
This commit is contained in:
Twinaphex 2014-11-27 19:06:23 +01:00
commit 07e2f24039
9 changed files with 57 additions and 43 deletions

View File

@ -624,6 +624,7 @@ menu_ctx_driver_t menu_ctx_glui = {
NULL,
NULL,
NULL,
NULL,
glui_init_core_info,
glui_update_core_info,
&menu_ctx_backend_common,

View File

@ -1338,6 +1338,7 @@ menu_ctx_driver_t menu_ctx_lakka = {
NULL,
NULL,
NULL,
NULL,
lakka_init_core_info,
lakka_update_core_info,
&menu_ctx_backend_lakka,

View File

@ -30,6 +30,7 @@ typedef struct menu_ctx_driver
void (*list_insert)(void *, const char *, const char *, size_t);
void (*list_delete)(void *, size_t, size_t);
void (*list_clear)(void *);
void (*list_cache)(bool, unsigned);
void (*list_set_selection)(void *);
void (*init_core_info)(void *);
void (*update_core_info)(void *);

View File

@ -594,6 +594,7 @@ menu_ctx_driver_t menu_ctx_rgui = {
NULL,
NULL,
NULL,
NULL,
rgui_update_core_info,
&menu_ctx_backend_common,
"rgui",

View File

@ -79,6 +79,10 @@ struct xmb_texture_item
typedef struct xmb_handle
{
file_list_t *menu_stack_old;
file_list_t *selection_buf_old;
size_t cat_selection_ptr_old;
size_t selection_ptr_old;
int active_category;
int active_category_old;
int num_categories;
@ -707,7 +711,7 @@ static void xmb_populate_entries(void *data, const char *path,
if (driver.menu->cat_selection_ptr != xmb->active_category_old)
{
dir = driver.menu->cat_selection_ptr > driver.menu->cat_selection_ptr_old ? 1 : -1;
dir = driver.menu->cat_selection_ptr > xmb->cat_selection_ptr_old ? 1 : -1;
xmb->active_category += dir;
@ -725,8 +729,8 @@ static void xmb_populate_entries(void *data, const char *path,
}
add_tween(XMB_DELAY, xmb->hspacing*-(float)driver.menu->cat_selection_ptr, &xmb->categories_x, &inOutQuad, NULL);
dir = driver.menu->cat_selection_ptr > driver.menu->cat_selection_ptr_old ? 1 : -1;
xmb_list_switch_old(driver.menu->menu_list->selection_buf_old, dir, driver.menu->selection_ptr_old);
dir = driver.menu->cat_selection_ptr > xmb->cat_selection_ptr_old ? 1 : -1;
xmb_list_switch_old(xmb->selection_buf_old, dir, xmb->selection_ptr_old);
xmb_list_switch_new(driver.menu->menu_list->selection_buf, dir, driver.menu->selection_ptr);
xmb->active_category_old = driver.menu->cat_selection_ptr;
return;
@ -752,7 +756,7 @@ static void xmb_populate_entries(void *data, const char *path,
add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL);
}
xmb_list_open_old(driver.menu->menu_list->selection_buf_old, dir, driver.menu->selection_ptr_old);
xmb_list_open_old(xmb->selection_buf_old, dir, xmb->selection_ptr_old);
xmb_list_open_new(driver.menu->menu_list->selection_buf, dir, driver.menu->selection_ptr);
if (xmb->depth == 1 || xmb->depth == 2)
@ -954,11 +958,11 @@ static void xmb_frame(void)
depth = file_list_get_size(driver.menu->menu_list->menu_stack);
xmb_draw_items(
driver.menu->menu_list->selection_buf_old,
driver.menu->menu_list->menu_stack_old,
driver.menu->selection_ptr_old,
xmb->selection_buf_old,
xmb->menu_stack_old,
xmb->selection_ptr_old,
depth > 1 ? driver.menu->cat_selection_ptr :
driver.menu->cat_selection_ptr_old);
xmb->cat_selection_ptr_old);
xmb_draw_items(
driver.menu->menu_list->selection_buf,
driver.menu->menu_list->menu_stack,
@ -1061,6 +1065,9 @@ static void *xmb_init(void)
xmb = (xmb_handle_t*)menu->userdata;
xmb->menu_stack_old = (file_list_t*)calloc(1, sizeof(file_list_t));
xmb->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t));
xmb->active_category = 0;
xmb->active_category_old = 0;
xmb->x = 0;
@ -1390,6 +1397,36 @@ static void xmb_list_clear(void *data)
(void)data;
}
static void xmb_list_cache(bool horizontal, unsigned action)
{
xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata;
if (!xmb)
return;
file_list_copy(driver.menu->menu_list->selection_buf, xmb->selection_buf_old);
file_list_copy(driver.menu->menu_list->menu_stack, xmb->menu_stack_old);
xmb->selection_ptr_old = driver.menu->selection_ptr;
if(!horizontal)
return;
xmb->cat_selection_ptr_old = driver.menu->cat_selection_ptr;
driver.menu->cat_selection_ptr += action == MENU_ACTION_LEFT ? -1 : 1;
size_t stack_size = driver.menu->menu_list->menu_stack->size;
if (driver.menu->cat_selection_ptr == 0)
{
strlcpy(driver.menu->menu_list->menu_stack->list[stack_size-1].label, "Main Menu", PATH_MAX);
driver.menu->menu_list->menu_stack->list[stack_size-1].type = MENU_SETTINGS;
}
else
{
strlcpy(driver.menu->menu_list->menu_stack->list[stack_size-1].label, "Horizontal Menu", PATH_MAX);
driver.menu->menu_list->menu_stack->list[stack_size-1].type = MENU_SETTING_HORIZONTAL_MENU;
}
}
static void xmb_list_set_selection(void *data)
{
(void)data;
@ -1424,7 +1461,6 @@ static void xmb_context_destroy(void *data)
}
}
menu_ctx_driver_t menu_ctx_xmb = {
NULL,
xmb_get_message,
@ -1448,6 +1484,7 @@ menu_ctx_driver_t menu_ctx_xmb = {
xmb_list_insert,
xmb_list_delete,
xmb_list_clear,
xmb_list_cache,
xmb_list_set_selection,
xmb_init_core_info,
xmb_update_core_info,

View File

@ -79,9 +79,7 @@ typedef struct
menu_list_t *menu_list;
size_t cat_selection_ptr;
size_t cat_selection_ptr_old;
size_t selection_ptr;
size_t selection_ptr_old;
bool need_refresh;
bool msg_force;
bool push_start_screen;

View File

@ -981,24 +981,8 @@ static int action_toggle_mainmenu(unsigned type, const char *label,
switch (push_list)
{
case 1:
file_list_copy(driver.menu->menu_list->selection_buf, driver.menu->menu_list->selection_buf_old);
file_list_copy(driver.menu->menu_list->menu_stack, driver.menu->menu_list->menu_stack_old);
driver.menu->selection_ptr_old = driver.menu->selection_ptr;
driver.menu->cat_selection_ptr_old = driver.menu->cat_selection_ptr;
driver.menu->cat_selection_ptr += action == MENU_ACTION_LEFT ? -1 : 1;
driver.menu->selection_ptr = 0;
size_t stack_size = driver.menu->menu_list->menu_stack->size;
if (driver.menu->cat_selection_ptr == 0)
{
strlcpy(driver.menu->menu_list->menu_stack->list[stack_size-1].label, "Main Menu", PATH_MAX);
driver.menu->menu_list->menu_stack->list[stack_size-1].type = MENU_SETTINGS;
}
else
{
strlcpy(driver.menu->menu_list->menu_stack->list[stack_size-1].label, "Horizontal Menu", PATH_MAX);
driver.menu->menu_list->menu_stack->list[stack_size-1].type = MENU_SETTING_HORIZONTAL_MENU;
}
if (driver.menu_ctx->list_cache)
driver.menu_ctx->list_cache(true, action);
if (cbs && cbs->action_content_list_switch)
return cbs->action_content_list_switch(

View File

@ -56,8 +56,6 @@ void *menu_list_new(void)
list->menu_stack = (file_list_t*)calloc(1, sizeof(file_list_t));
list->selection_buf = (file_list_t*)calloc(1, sizeof(file_list_t));
list->menu_stack_old = (file_list_t*)calloc(1, sizeof(file_list_t));
list->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t));
if (!list->menu_stack || !list->selection_buf)
{
@ -163,11 +161,9 @@ void menu_list_pop_stack(menu_list_t *list)
if (file_list_get_size(list->menu_stack) > 1)
{
#ifdef HAVE_XMB
file_list_copy(driver.menu->menu_list->selection_buf, driver.menu->menu_list->selection_buf_old);
file_list_copy(driver.menu->menu_list->menu_stack, driver.menu->menu_list->menu_stack_old);
driver.menu->selection_ptr_old = driver.menu->selection_ptr;
#endif
if (driver.menu_ctx->list_cache)
driver.menu_ctx->list_cache(false, 0);
menu_list_pop(list->menu_stack, &driver.menu->selection_ptr);
driver.menu->need_refresh = true;
}
@ -278,11 +274,8 @@ void menu_list_push_stack_refresh(menu_list_t *list,
if (!list)
return;
#ifdef HAVE_XMB
file_list_copy(driver.menu->menu_list->selection_buf, driver.menu->menu_list->selection_buf_old);
file_list_copy(driver.menu->menu_list->menu_stack, driver.menu->menu_list->menu_stack_old);
driver.menu->selection_ptr_old = driver.menu->selection_ptr;
#endif
if (driver.menu_ctx->list_cache)
driver.menu_ctx->list_cache(false, 0);
menu_list_push_stack(list, path, label, type, directory_ptr);
menu_navigation_clear(driver.menu, true);

View File

@ -26,9 +26,7 @@ extern "C" {
typedef struct menu_list
{
file_list_t *menu_stack;
file_list_t *menu_stack_old;
file_list_t *selection_buf;
file_list_t *selection_buf_old;
} menu_list_t;
void menu_list_free(menu_list_t *menu_list);