From fe529ff591cc3a71919cdd32e3a3116602dfa023 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Fri, 12 May 2023 01:00:08 +0200 Subject: [PATCH] Refactor away menu_driver_list_cache --- menu/cbs/menu_cbs_left.c | 9 +++------ menu/cbs/menu_cbs_ok.c | 8 ++++---- menu/cbs/menu_cbs_right.c | 10 +++------- menu/menu_displaylist.c | 21 ++++++++------------- menu/menu_driver.c | 11 ----------- menu/menu_driver.h | 2 -- runloop.c | 8 +++----- 7 files changed, 21 insertions(+), 48 deletions(-) diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index e301aed9da..be2c684327 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -254,16 +254,13 @@ static int action_left_scroll(unsigned type, const char *label, static int action_left_goto_tab(void) { - menu_ctx_list_t list_info; struct menu_state *menu_st = menu_state_get_ptr(); menu_list_t *menu_list = menu_st->entries.list; file_list_t *selection_buf = menu_list ? MENU_LIST_GET_SELECTION(menu_list, 0) : NULL; - list_info.type = MENU_LIST_HORIZONTAL; - list_info.action = MENU_ACTION_LEFT; - - menu_driver_list_cache(&list_info); - + if (menu_st->driver_ctx && menu_st->driver_ctx->list_cache) + menu_st->driver_ctx->list_cache(menu_st->userdata, + MENU_LIST_HORIZONTAL, MENU_ACTION_LEFT); return menu_driver_deferred_push_content_list(selection_buf); } diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 32c38240a4..9d70fe1de1 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -6988,7 +6988,7 @@ static int action_ok_start_core(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { content_ctx_info_t content_info; - menu_ctx_list_t list_info; + struct menu_state *menu_st = menu_state_get_ptr(); content_info.argc = 0; content_info.argv = NULL; @@ -6998,9 +6998,9 @@ static int action_ok_start_core(const char *path, /* We are going to push a new menu; ensure * that the current one is cached for animation * purposes */ - list_info.type = MENU_LIST_PLAIN; - list_info.action = 0; - menu_driver_list_cache(&list_info); + if (menu_st->driver_ctx && menu_st->driver_ctx->list_cache) + menu_st->driver_ctx->list_cache(menu_st->userdata, + MENU_LIST_PLAIN, MENU_ACTION_NOOP); path_clear(RARCH_PATH_BASENAME); if (!task_push_start_current_core(&content_info)) diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 63a61e6e01..fdde7f690f 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -283,16 +283,12 @@ static int audio_mixer_stream_volume_right(unsigned type, const char *label, static int action_right_goto_tab(void) { - menu_ctx_list_t list_info; struct menu_state *menu_st = menu_state_get_ptr(); menu_list_t *menu_list = menu_st->entries.list; file_list_t *selection_buf = menu_list ? MENU_LIST_GET_SELECTION(menu_list, 0) : NULL; - - list_info.type = MENU_LIST_HORIZONTAL; - list_info.action = MENU_ACTION_RIGHT; - - menu_driver_list_cache(&list_info); - + if (menu_st->driver_ctx && menu_st->driver_ctx->list_cache) + menu_st->driver_ctx->list_cache(menu_st->userdata, + MENU_LIST_HORIZONTAL, MENU_ACTION_RIGHT); return menu_driver_deferred_push_content_list(selection_buf); } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 358c1f80c2..d068017cb2 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -14092,21 +14092,16 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, info->flags |= MD_FLAG_NEED_NAVIGATION_CLEAR; /* fall-through */ case DISPLAYLIST_PENDING_CLEAR: - { - menu_ctx_list_t list_info; + if (menu_st->driver_ctx && menu_st->driver_ctx->list_cache) + menu_st->driver_ctx->list_cache(menu_st->userdata, + MENU_LIST_PLAIN, MENU_ACTION_NOOP); - list_info.type = MENU_LIST_PLAIN; - list_info.action = 0; + if (menu_entries_append(info->list, info->path, + info->label, MSG_UNKNOWN, info->type, info->directory_ptr, 0, + NULL)) + count++; - menu_driver_list_cache(&list_info); - - if (menu_entries_append(info->list, info->path, - info->label, MSG_UNKNOWN, info->type, info->directory_ptr, 0, - NULL)) - count++; - - info->flags |= MD_FLAG_NEED_ENTRIES_REFRESH; - } + info->flags |= MD_FLAG_NEED_ENTRIES_REFRESH; break; case DISPLAYLIST_USER_BINDS_LIST: menu_entries_clear(info->list); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index ce196ef830..3371617206 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -4399,17 +4399,6 @@ void menu_driver_frame(bool menu_is_alive, video_frame_info_t *video_info) menu_st->driver_ctx->frame(menu_st->userdata, video_info); } -bool menu_driver_list_cache(menu_ctx_list_t *list) -{ - struct menu_state *menu_st = &menu_driver_state; - if (!list || !menu_st->driver_ctx || !menu_st->driver_ctx->list_cache) - return false; - - menu_st->driver_ctx->list_cache(menu_st->userdata, - list->type, list->action); - return true; -} - /* Teardown function for the menu driver. */ void menu_driver_destroy( struct menu_state *menu_st) diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 492229927a..ee0596633f 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -617,8 +617,6 @@ void menu_driver_frame(bool menu_is_alive, video_frame_info_t *video_info); int menu_driver_deferred_push_content_list(file_list_t *list); -bool menu_driver_list_cache(menu_ctx_list_t *list); - bool menu_driver_init(bool video_is_threaded); size_t menu_driver_list_get_selection(void); diff --git a/runloop.c b/runloop.c index 476ae8ea65..49124726c1 100644 --- a/runloop.c +++ b/runloop.c @@ -5720,14 +5720,12 @@ static enum runloop_state_enum runloop_check_state( * and exit the function to go to the next frame. */ if (menu_st->flags & MENU_ST_FLAG_PENDING_QUICK_MENU) { - menu_ctx_list_t list_info; - /* We are going to push a new menu; ensure * that the current one is cached for animation * purposes */ - list_info.type = MENU_LIST_PLAIN; - list_info.action = 0; - menu_driver_list_cache(&list_info); + if (menu_st->driver_ctx && menu_st->driver_ctx->list_cache) + menu_st->driver_ctx->list_cache(menu_st->userdata, + MENU_LIST_PLAIN, MENU_ACTION_NOOP); p_disp->flags |= GFX_DISP_FLAG_MSG_FORCE;