* Reduce the amount of cpu_features_get_time_usec calls

* Put code behind menu ifdefs
This commit is contained in:
twinaphex 2020-02-29 07:41:05 +01:00
parent fe51b44d98
commit add0cedc48
11 changed files with 86 additions and 38 deletions

View File

@ -428,14 +428,22 @@ default_sublabel_macro(action_bind_sublabel_stdin_cmd_enable, MENU_
default_sublabel_macro(action_bind_sublabel_mouse_enable, MENU_ENUM_SUBLABEL_MOUSE_ENABLE)
default_sublabel_macro(action_bind_sublabel_pointer_enable, MENU_ENUM_SUBLABEL_POINTER_ENABLE)
default_sublabel_macro(action_bind_sublabel_thumbnails, MENU_ENUM_SUBLABEL_THUMBNAILS)
default_sublabel_macro(action_bind_sublabel_thumbnails_rgui, MENU_ENUM_SUBLABEL_THUMBNAILS_RGUI)
#ifdef HAVE_MATERIALUI
default_sublabel_macro(action_bind_sublabel_thumbnails_materialui, MENU_ENUM_SUBLABEL_THUMBNAILS_MATERIALUI)
default_sublabel_macro(action_bind_sublabel_left_thumbnails_materialui, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS_MATERIALUI)
#endif
default_sublabel_macro(action_bind_sublabel_left_thumbnails, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS)
#ifdef HAVE_RGUI
default_sublabel_macro(action_bind_sublabel_left_thumbnails_rgui, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS_RGUI)
default_sublabel_macro(action_bind_sublabel_thumbnails_rgui, MENU_ENUM_SUBLABEL_THUMBNAILS_RGUI)
#endif
#ifdef HAVE_OZONE
default_sublabel_macro(action_bind_sublabel_left_thumbnails_ozone, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS_OZONE)
default_sublabel_macro(action_bind_sublabel_ozone_menu_color_theme, MENU_ENUM_SUBLABEL_OZONE_MENU_COLOR_THEME)
default_sublabel_macro(action_bind_sublabel_ozone_collapse_sidebar, MENU_ENUM_SUBLABEL_OZONE_COLLAPSE_SIDEBAR)
default_sublabel_macro(action_bind_sublabel_ozone_truncate_playlist_name, MENU_ENUM_SUBLABEL_OZONE_TRUNCATE_PLAYLIST_NAME)
default_sublabel_macro(action_bind_sublabel_ozone_scroll_content_metadata, MENU_ENUM_SUBLABEL_OZONE_SCROLL_CONTENT_METADATA)
#endif
default_sublabel_macro(action_bind_sublabel_menu_thumbnail_upscale_threshold, MENU_ENUM_SUBLABEL_MENU_THUMBNAIL_UPSCALE_THRESHOLD)
default_sublabel_macro(action_bind_sublabel_timedate_enable, MENU_ENUM_SUBLABEL_TIMEDATE_ENABLE)
default_sublabel_macro(action_bind_sublabel_timedate_style, MENU_ENUM_SUBLABEL_TIMEDATE_STYLE)
@ -517,21 +525,22 @@ default_sublabel_macro(action_bind_sublabel_disk_image_append,
default_sublabel_macro(action_bind_sublabel_disk_index, MENU_ENUM_SUBLABEL_DISK_INDEX)
default_sublabel_macro(action_bind_sublabel_disk_options, MENU_ENUM_SUBLABEL_DISK_OPTIONS)
default_sublabel_macro(action_bind_sublabel_menu_throttle_framerate, MENU_ENUM_SUBLABEL_MENU_ENUM_THROTTLE_FRAMERATE)
#ifdef HAVE_XMB
default_sublabel_macro(action_bind_sublabel_xmb_layout, MENU_ENUM_SUBLABEL_XMB_LAYOUT)
default_sublabel_macro(action_bind_sublabel_xmb_icon_theme, MENU_ENUM_SUBLABEL_XMB_THEME)
default_sublabel_macro(action_bind_sublabel_xmb_shadows_enable, MENU_ENUM_SUBLABEL_XMB_SHADOWS_ENABLE)
default_sublabel_macro(action_bind_sublabel_xmb_vertical_thumbnails, MENU_ENUM_SUBLABEL_XMB_VERTICAL_THUMBNAILS)
default_sublabel_macro(action_bind_sublabel_menu_xmb_thumbnail_scale_factor, MENU_ENUM_SUBLABEL_MENU_XMB_THUMBNAIL_SCALE_FACTOR)
default_sublabel_macro(action_bind_sublabel_menu_xmb_animation_horizontal_higlight, MENU_ENUM_SUBLABEL_MENU_XMB_ANIMATION_HORIZONTAL_HIGHLIGHT)
default_sublabel_macro(action_bind_sublabel_menu_xmb_animation_move_up_down, MENU_ENUM_SUBLABEL_MENU_XMB_ANIMATION_MOVE_UP_DOWN)
default_sublabel_macro(action_bind_sublabel_menu_xmb_animation_opening_main_menu, MENU_ENUM_SUBLABEL_MENU_XMB_ANIMATION_OPENING_MAIN_MENU)
#endif
default_sublabel_macro(action_bind_sublabel_menu_color_theme, MENU_ENUM_SUBLABEL_MATERIALUI_MENU_COLOR_THEME)
#ifdef HAVE_MATERIALUI
default_sublabel_macro(action_bind_sublabel_materialui_menu_transition_animation, MENU_ENUM_SUBLABEL_MATERIALUI_MENU_TRANSITION_ANIMATION)
default_sublabel_macro(action_bind_sublabel_materialui_menu_thumbnail_view_portrait, MENU_ENUM_SUBLABEL_MATERIALUI_MENU_THUMBNAIL_VIEW_PORTRAIT)
default_sublabel_macro(action_bind_sublabel_materialui_menu_thumbnail_view_landscape, MENU_ENUM_SUBLABEL_MATERIALUI_MENU_THUMBNAIL_VIEW_LANDSCAPE)
#endif
default_sublabel_macro(action_bind_sublabel_ozone_menu_color_theme, MENU_ENUM_SUBLABEL_OZONE_MENU_COLOR_THEME)
default_sublabel_macro(action_bind_sublabel_ozone_collapse_sidebar, MENU_ENUM_SUBLABEL_OZONE_COLLAPSE_SIDEBAR)
default_sublabel_macro(action_bind_sublabel_ozone_truncate_playlist_name, MENU_ENUM_SUBLABEL_OZONE_TRUNCATE_PLAYLIST_NAME)
default_sublabel_macro(action_bind_sublabel_ozone_scroll_content_metadata, MENU_ENUM_SUBLABEL_OZONE_SCROLL_CONTENT_METADATA)
default_sublabel_macro(action_bind_sublabel_menu_use_preferred_system_color_theme, MENU_ENUM_SUBLABEL_MENU_USE_PREFERRED_SYSTEM_COLOR_THEME)
default_sublabel_macro(action_bind_sublabel_menu_scale_factor, MENU_ENUM_SUBLABEL_MENU_SCALE_FACTOR)
default_sublabel_macro(action_bind_sublabel_menu_widget_scale_auto, MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_AUTO)
@ -539,9 +548,6 @@ default_sublabel_macro(action_bind_sublabel_menu_widget_scale_factor,
default_sublabel_macro(action_bind_sublabel_menu_wallpaper_opacity, MENU_ENUM_SUBLABEL_MENU_WALLPAPER_OPACITY)
default_sublabel_macro(action_bind_sublabel_menu_framebuffer_opacity, MENU_ENUM_SUBLABEL_MENU_FRAMEBUFFER_OPACITY)
default_sublabel_macro(action_bind_sublabel_menu_horizontal_animation, MENU_ENUM_SUBLABEL_MENU_HORIZONTAL_ANIMATION)
default_sublabel_macro(action_bind_sublabel_menu_xmb_animation_horizontal_higlight, MENU_ENUM_SUBLABEL_MENU_XMB_ANIMATION_HORIZONTAL_HIGHLIGHT)
default_sublabel_macro(action_bind_sublabel_menu_xmb_animation_move_up_down, MENU_ENUM_SUBLABEL_MENU_XMB_ANIMATION_MOVE_UP_DOWN)
default_sublabel_macro(action_bind_sublabel_menu_xmb_animation_opening_main_menu, MENU_ENUM_SUBLABEL_MENU_XMB_ANIMATION_OPENING_MAIN_MENU)
default_sublabel_macro(action_bind_sublabel_menu_ribbon_enable, MENU_ENUM_SUBLABEL_XMB_RIBBON_ENABLE)
default_sublabel_macro(action_bind_sublabel_menu_font, MENU_ENUM_SUBLABEL_XMB_FONT)
default_sublabel_macro(action_bind_sublabel_settings_show_drivers, MENU_ENUM_SUBLABEL_SETTINGS_SHOW_DRIVERS)
@ -1058,8 +1064,12 @@ static int action_bind_sublabel_playlist_entry(
playlist_t *playlist = NULL;
const struct playlist_entry *entry = NULL;
if (!settings->bools.playlist_show_sublabels || string_is_equal(settings->arrays.menu_driver, "ozone"))
if (!settings->bools.playlist_show_sublabels)
return 0;
#ifdef HAVE_OZONE
if (string_is_equal(settings->arrays.menu_driver, "ozone"))
return 0;
#endif
/* Get current playlist */
playlist = playlist_get_cached();
@ -1756,13 +1766,19 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_horizontal_animation);
break;
case MENU_ENUM_LABEL_MENU_XMB_ANIMATION_HORIZONTAL_HIGHLIGHT:
#ifdef HAVE_XMB
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_xmb_animation_horizontal_higlight);
#endif
break;
case MENU_ENUM_LABEL_MENU_XMB_ANIMATION_MOVE_UP_DOWN:
#ifdef HAVE_XMB
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_xmb_animation_move_up_down);
#endif
break;
case MENU_ENUM_LABEL_MENU_XMB_ANIMATION_OPENING_MAIN_MENU:
#ifdef HAVE_XMB
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_xmb_animation_opening_main_menu);
#endif
break;
case MENU_ENUM_LABEL_MENU_SCALE_FACTOR:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_scale_factor);
@ -1780,16 +1796,24 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_use_preferred_system_color_theme);
break;
case MENU_ENUM_LABEL_OZONE_MENU_COLOR_THEME:
#ifdef HAVE_OZONE
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_ozone_menu_color_theme);
#endif
break;
case MENU_ENUM_LABEL_OZONE_COLLAPSE_SIDEBAR:
#ifdef HAVE_OZONE
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_ozone_collapse_sidebar);
#endif
break;
case MENU_ENUM_LABEL_OZONE_TRUNCATE_PLAYLIST_NAME:
#ifdef HAVE_OZONE
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_ozone_truncate_playlist_name);
#endif
break;
case MENU_ENUM_LABEL_OZONE_SCROLL_CONTENT_METADATA:
#ifdef HAVE_OZONE
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_ozone_scroll_content_metadata);
#endif
break;
case MENU_ENUM_LABEL_MATERIALUI_MENU_COLOR_THEME:
case MENU_ENUM_LABEL_XMB_MENU_COLOR_THEME:
@ -1811,19 +1835,29 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
#endif
break;
case MENU_ENUM_LABEL_XMB_SHADOWS_ENABLE:
#ifdef HAVE_XMB
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_xmb_shadows_enable);
#endif
break;
case MENU_ENUM_LABEL_XMB_VERTICAL_THUMBNAILS:
#ifdef HAVE_XMB
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_xmb_vertical_thumbnails);
#endif
break;
case MENU_ENUM_LABEL_MENU_XMB_THUMBNAIL_SCALE_FACTOR:
#ifdef HAVE_XMB
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_xmb_thumbnail_scale_factor);
#endif
break;
case MENU_ENUM_LABEL_XMB_LAYOUT:
#ifdef HAVE_XMB
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_xmb_layout);
#endif
break;
case MENU_ENUM_LABEL_XMB_THEME:
#ifdef HAVE_XMB
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_xmb_icon_theme);
#endif
break;
case MENU_ENUM_LABEL_MENU_THROTTLE_FRAMERATE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_throttle_framerate);

View File

@ -3999,12 +3999,14 @@ static void rgui_update_menu_viewport(rgui_t *rgui)
size_t fb_pitch;
struct video_viewport vp;
unsigned fb_width, fb_height;
#if !defined(GEKKO)
bool do_integer_scaling = false;
settings_t *settings = config_get_ptr();
unsigned aspect_ratio_lock = settings ? settings->uints.menu_rgui_aspect_ratio_lock : 0;
if (!settings)
return;
#endif
gfx_display_get_fb_size(&fb_width, &fb_height, &fb_pitch);
video_driver_get_viewport_info(&vp);

View File

@ -5331,8 +5331,8 @@ unsigned menu_displaylist_build_list(
{
settings_t *settings = config_get_ptr();
bool show_hidden_files = settings->bools.show_hidden_files;
const char *path_content_database = settings->paths.path_content_database;
#ifdef HAVE_LIBRETRODB
const char *path_content_database = settings->paths.path_content_database;
struct string_list *system_name_list =
manual_content_scan_get_menu_system_name_list(
path_content_database,

View File

@ -27,6 +27,7 @@
#include <lists/string_list.h>
#include <streams/file_stream.h>
#include <string/stdstring.h>
#include <features/features_cpu.h>
#include <encodings/utf.h>
#ifdef HAVE_CONFIG_H
@ -116,15 +117,17 @@ static enum action_iterate_type action_iterate_type(const char *label)
static int generic_menu_iterate(void *data,
void *userdata, enum menu_action action)
{
static enum action_iterate_type last_iterate_type = ITERATE_TYPE_DEFAULT;
#ifdef HAVE_ACCESSIBILITY
static enum action_iterate_type
last_iterate_type = ITERATE_TYPE_DEFAULT;
#endif
enum action_iterate_type iterate_type;
unsigned file_type = 0;
int ret = 0;
const char *label = NULL;
menu_handle_t *menu = (menu_handle_t*)data;
(void)last_iterate_type;
/* TODO/FIXME - menus should take current time from retroarch.c */
retro_time_t current_time = cpu_features_get_time_usec();
if (!menu)
return 0;
@ -147,7 +150,8 @@ static int generic_menu_iterate(void *data,
{
case ITERATE_TYPE_HELP:
ret = menu_dialog_iterate(
menu->menu_state_msg, sizeof(menu->menu_state_msg), label);
menu->menu_state_msg, sizeof(menu->menu_state_msg), label,
current_time);
#ifdef HAVE_ACCESSIBILITY
if (iterate_type != last_iterate_type && is_accessibility_enabled())
@ -175,7 +179,7 @@ static int generic_menu_iterate(void *data,
bind.s = menu->menu_state_msg;
bind.len = sizeof(menu->menu_state_msg);
if (menu_input_key_bind_iterate(&bind))
if (menu_input_key_bind_iterate(&bind, current_time))
{
size_t selection = menu_navigation_get_selection();
menu_entries_pop_stack(&selection, 0, 0);
@ -333,9 +337,10 @@ static int generic_menu_iterate(void *data,
#ifdef HAVE_ACCESSIBILITY
if ((last_iterate_type == ITERATE_TYPE_HELP || last_iterate_type == ITERATE_TYPE_INFO) && last_iterate_type != iterate_type && is_accessibility_enabled())
accessibility_speak_priority("Closed dialog.", 10);
#endif
last_iterate_type = iterate_type;
#endif
BIT64_SET(menu->state, MENU_STATE_BLIT);
if (BIT64_GET(menu->state, MENU_STATE_POP_STACK))

View File

@ -40,7 +40,8 @@ static unsigned menu_dialog_current_id = 0;
static enum menu_dialog_type menu_dialog_current_type = MENU_DIALOG_NONE;
static enum msg_hash_enums menu_dialog_current_msg = MSG_UNKNOWN;
int menu_dialog_iterate(char *s, size_t len, const char *label)
int menu_dialog_iterate(char *s, size_t len, const char *label,
retro_time_t current_time)
{
#ifdef HAVE_CHEEVOS
rcheevos_ctx_desc_t desc_info;
@ -56,7 +57,7 @@ int menu_dialog_iterate(char *s, size_t len, const char *label)
if (!rarch_timer_is_running(&timer))
rarch_timer_begin(&timer, 3);
rarch_timer_tick(&timer);
rarch_timer_tick(&timer, current_time);
menu_hash_get_help_enum(
MENU_ENUM_LABEL_WELCOME_TO_RETROARCH,

View File

@ -54,7 +54,8 @@ void menu_dialog_push_pending(
bool push, enum menu_dialog_type type);
int menu_dialog_iterate(
char *s, size_t len, const char *label);
char *s, size_t len, const char *label,
retro_time_t current_time);
void menu_dialog_unset_pending_push(void);

View File

@ -566,7 +566,8 @@ bool menu_input_key_bind_set_min_max(menu_input_ctx_bind_limits_t *lim)
return true;
}
bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind)
bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind,
retro_time_t current_time)
{
bool timed_out = false;
settings_t * settings = config_get_ptr();
@ -582,8 +583,8 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind)
msg_hash_to_str( MENU_ENUM_LABEL_VALUE_SECONDS ) );
/*tick main timers*/
rarch_timer_tick( &menu_input_binds.timer_timeout );
rarch_timer_tick( &menu_input_binds.timer_hold );
rarch_timer_tick(&menu_input_binds.timer_timeout, current_time);
rarch_timer_tick(&menu_input_binds.timer_hold, current_time);
if (rarch_timer_has_expired(&menu_input_binds.timer_timeout))
{
@ -634,7 +635,7 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind)
rarch_timer_begin_new_time( &binds.timer_timeout, settings->uints.input_bind_timeout );
/*run hold timer*/
rarch_timer_tick( &binds.timer_hold );
rarch_timer_tick( &binds.timer_hold, current_time);
snprintf( bind->s, bind->len,
"[%s]\npress keyboard, mouse or joypad\nand hold ...",

View File

@ -52,7 +52,8 @@ bool menu_input_key_bind_set_mode(
bool menu_input_key_bind_set_min_max(menu_input_ctx_bind_limits_t *lim);
bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind);
bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind,
retro_time_t current_time);
RETRO_END_DECLS

View File

@ -121,11 +121,11 @@ void retro_perf_log(void)
log_counters(perf_counters_libretro, perf_ptr_libretro);
}
void rarch_timer_tick(rarch_timer_t *timer)
void rarch_timer_tick(rarch_timer_t *timer, retro_time_t current_time)
{
if (!timer)
return;
timer->current = cpu_features_get_time_usec();
timer->current = current_time;
timer->timeout_us = (timer->timeout_end - timer->current);
}
@ -163,8 +163,8 @@ void rarch_timer_begin_new_time(rarch_timer_t *timer, uint64_t sec)
{
if (!timer)
return;
timer->timeout_us = sec * 1000000;
timer->current = cpu_features_get_time_usec();
timer->timeout_us = sec * 1000000;
timer->current = cpu_features_get_time_usec();
timer->timeout_end = timer->current + timer->timeout_us;
}
@ -172,8 +172,8 @@ void rarch_timer_begin_new_time_us(rarch_timer_t *timer, uint64_t usec)
{
if (!timer)
return;
timer->timeout_us = usec;
timer->current = cpu_features_get_time_usec();
timer->timeout_us = usec;
timer->current = cpu_features_get_time_usec();
timer->timeout_end = timer->current + timer->timeout_us;
}

View File

@ -89,7 +89,7 @@ void rarch_perf_register(struct retro_perf_counter *perf);
**/
#define performance_counter_stop_plus(is_perfcnt_enable, perf) performance_counter_stop_internal(is_perfcnt_enable, perf)
void rarch_timer_tick(rarch_timer_t *timer);
void rarch_timer_tick(rarch_timer_t *timer, retro_time_t current_time);
bool rarch_timer_is_running(rarch_timer_t *timer);

View File

@ -3552,6 +3552,7 @@ static const void *hid_data = NULL;
static enum rarch_core_type last_core_type;
static retro_ctx_load_content_info_t *load_content_info;
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
static char *strcpy_alloc(const char *src)
{
char *result = NULL;
@ -3573,7 +3574,6 @@ static char *strcpy_alloc_force(const char *src)
return result;
}
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
/* Forward declarations */
static bool secondary_core_create(void);
static int16_t input_state_get_last(unsigned port,
@ -26949,7 +26949,9 @@ void runloop_get_status(bool *is_paused, bool *is_idle,
#ifdef HAVE_MENU
static bool input_driver_toggle_button_combo(
unsigned mode, input_bits_t* p_input)
unsigned mode,
retro_time_t current_time,
input_bits_t* p_input)
{
switch (mode)
{
@ -27018,7 +27020,7 @@ static bool input_driver_toggle_button_combo(
if (!rarch_timer_is_running(&timer))
rarch_timer_begin(&timer, HOLD_START_DELAY_SEC);
rarch_timer_tick(&timer);
rarch_timer_tick(&timer, current_time);
if (!timer.timer_end && rarch_timer_has_expired(&timer))
{
@ -27267,7 +27269,8 @@ static enum runloop_state runloop_check_state(retro_time_t current_time)
if (
((menu_toggle_gamepad_combo != INPUT_TOGGLE_NONE) &&
input_driver_toggle_button_combo(
menu_toggle_gamepad_combo, &last_input)))
menu_toggle_gamepad_combo, current_time,
&last_input)))
BIT256_SET(current_bits, RARCH_MENU_TOGGLE);
#endif
@ -27965,7 +27968,7 @@ static enum runloop_state runloop_check_state(retro_time_t current_time)
*/
if (need_to_apply)
{
rarch_timer_tick(&timer);
rarch_timer_tick(&timer, current_time);
if (!timer.timer_end && rarch_timer_has_expired(&timer))
{
@ -27983,7 +27986,7 @@ static enum runloop_state runloop_check_state(retro_time_t current_time)
settings->uints.video_shader_delay * 1000);
else
{
rarch_timer_tick(&shader_delay_timer);
rarch_timer_tick(&shader_delay_timer, current_time);
if (rarch_timer_has_expired(&shader_delay_timer))
{