From 58d7c0fd3b1c4db17bb838f4273ceacf210527ad Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 Jun 2015 01:50:57 +0200 Subject: [PATCH] Move some more variables to menu_animation_t --- menu/cbs/menu_cbs_get_value.c | 8 ++++---- menu/drivers/glui.c | 2 +- menu/drivers/rgui.c | 2 +- menu/drivers/xmb.c | 2 +- menu/menu.c | 19 +++---------------- menu/menu.h | 4 ---- menu/menu_animation.c | 23 +++++++++++++++++++++++ menu/menu_animation.h | 11 +++++++++++ menu/menu_display.c | 12 ++++-------- menu/menu_driver.h | 5 ----- menu/menu_setting.c | 6 +++--- 11 files changed, 51 insertions(+), 43 deletions(-) diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 8c604a3565..0fda66a7f0 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -424,7 +424,7 @@ static void menu_action_setting_disp_set_label_perf_counters( const char *path, char *s2, size_t len2) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_animation_t *anim = menu_animation_get_ptr(); const struct retro_perf_counter **counters = (const struct retro_perf_counter **)perf_counters_rarch; unsigned offset = type - MENU_SETTINGS_PERF_COUNTERS_BEGIN; @@ -436,7 +436,7 @@ static void menu_action_setting_disp_set_label_perf_counters( menu_action_setting_disp_set_label_perf_counters_common( counters, offset, s, len); - menu->label.is_updated = true; + anim->label.is_updated = true; } static void menu_action_setting_disp_set_label_libretro_perf_counters( @@ -448,7 +448,7 @@ static void menu_action_setting_disp_set_label_libretro_perf_counters( const char *path, char *s2, size_t len2) { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_animation_t *anim = menu_animation_get_ptr(); const struct retro_perf_counter **counters = (const struct retro_perf_counter **)perf_counters_libretro; unsigned offset = type - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN; @@ -460,7 +460,7 @@ static void menu_action_setting_disp_set_label_libretro_perf_counters( menu_action_setting_disp_set_label_perf_counters_common( counters, offset, s, len); - menu->label.is_updated = true; + anim->label.is_updated = true; } static void menu_action_setting_disp_set_label_menu_more( diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 4cc4088cb1..3ffd057d95 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -398,7 +398,7 @@ static void glui_frame(void) width, glui->line_height, 1, 1, 1, 0.1); anim->is_active = true; - menu->label.is_updated = false; + anim->label.is_updated = false; glui_render_quad(gl, 0, 0, width, disp->header_height, 0.2, 0.2, 0.2, 1); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index a4df500d52..ae7e5c5e1d 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -373,7 +373,7 @@ static void rgui_render(void) /* ensures the framebuffer will be rendered on the screen */ menu_display_fb_set_dirty(); anim->is_active = false; - menu->label.is_updated = false; + anim->label.is_updated = false; if (settings->menu.pointer.enable) { diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 0f4cdcb329..2fa02dd269 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1270,7 +1270,7 @@ static void xmb_render(void) } anim->is_active = false; - menu->label.is_updated = false; + anim->label.is_updated = false; } static void xmb_frame_horizontal_list(xmb_handle_t *xmb, menu_handle_t *menu, gl_t *gl) diff --git a/menu/menu.c b/menu/menu.c index aa0a0b0582..4c79703d42 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -24,8 +24,8 @@ #include "../dynamic.h" #include "../general.h" #include "../frontend/frontend.h" -#include "../../retroarch.h" -#include "../../performance.h" +#include "../retroarch.h" +#include "../performance.h" static void menu_environment_get(int *argc, char *argv[], void *args, void *params_data) @@ -294,7 +294,6 @@ void menu_free(menu_handle_t *menu) int menu_iterate(retro_input_t input, retro_input_t old_input, retro_input_t trigger_input) { - static retro_time_t last_clock_update = 0; int32_t ret = 0; unsigned action = 0; runloop_t *runloop = rarch_main_get_ptr(); @@ -303,20 +302,8 @@ int menu_iterate(retro_input_t input, settings_t *settings = config_get_ptr(); menu_input->joypad.state = menu_input_frame(input, trigger_input); - menu->animation->cur_time = rarch_get_time_usec(); - menu->animation->delta_time = menu->animation->cur_time - menu->animation->old_time; - if (menu->animation->delta_time >= IDEAL_DT * 4) - menu->animation->delta_time = IDEAL_DT * 4; - if (menu->animation->delta_time <= IDEAL_DT / 4) - menu->animation->delta_time = IDEAL_DT / 4; - menu->animation->old_time = menu->animation->cur_time; - - if (menu->animation->cur_time - last_clock_update > 1000000 && settings->menu.timedate_enable) - { - menu->label.is_updated = true; - last_clock_update = menu->animation->cur_time; - } + menu_animation_update_time(menu->animation); action = menu_input->joypad.state; diff --git a/menu/menu.h b/menu/menu.h index c4ab1ca214..6a893ad38b 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -52,10 +52,6 @@ #define MENU_SETTINGS_CORE_OPTION_NONE 0xffff #define MENU_SETTINGS_CORE_OPTION_START 0x10000 -#ifndef IDEAL_DT -#define IDEAL_DT (1.0 / 60.0 * 1000000.0) -#endif - #define MENU_KEYBOARD_BIND_TIMEOUT_SECONDS 5 #ifdef __cplusplus diff --git a/menu/menu_animation.c b/menu/menu_animation.c index c0037c5f6a..89d596414f 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -20,7 +20,9 @@ #include #include "menu_animation.h" +#include "../configuration.h" #include "../runloop.h" +#include "../performance.h" menu_animation_t *menu_animation_get_ptr(void) { @@ -531,3 +533,24 @@ void menu_animation_ticker_line(char *s, size_t len, uint64_t idx, anim->is_active = true; } + +void menu_animation_update_time(menu_animation_t *anim) +{ + static retro_time_t last_clock_update = 0; + settings_t *settings = config_get_ptr(); + + anim->cur_time = rarch_get_time_usec(); + anim->delta_time = anim->cur_time - anim->old_time; + + if (anim->delta_time >= IDEAL_DT * 4) + anim->delta_time = IDEAL_DT * 4; + if (anim->delta_time <= IDEAL_DT / 4) + anim->delta_time = IDEAL_DT / 4; + anim->old_time = anim->cur_time; + + if (anim->cur_time - last_clock_update > 1000000 && settings->menu.timedate_enable) + { + anim->label.is_updated = true; + last_clock_update = anim->cur_time; + } +} diff --git a/menu/menu_animation.h b/menu/menu_animation.h index c728761a2c..94f465e2b2 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -22,6 +22,10 @@ #include #include "../libretro.h" +#ifndef IDEAL_DT +#define IDEAL_DT (1.0 / 60.0 * 1000000.0) +#endif + #ifdef __cplusplus extern "C" { #endif @@ -53,6 +57,11 @@ typedef struct menu_animation float delta_time; retro_time_t cur_time; retro_time_t old_time; + + struct + { + bool is_updated; + } label; } menu_animation_t; enum menu_animation_easing_type @@ -135,6 +144,8 @@ void menu_animation_ticker_line(char *buf, size_t len, uint64_t tick, menu_animation_t *menu_animation_get_ptr(void); +void menu_animation_update_time(menu_animation_t *anim); + #ifdef __cplusplus } #endif diff --git a/menu/menu_display.c b/menu/menu_display.c index 80498d0dee..1c056b6068 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -94,17 +94,13 @@ void menu_display_fb(void) bool menu_display_update_pending(void) { - menu_handle_t *menu = menu_driver_get_ptr(); menu_animation_t *anim = menu_animation_get_ptr(); menu_framebuf_t *frame_buf = menu_display_fb_get_ptr(); - if (menu) - { - if (anim->is_active || menu->label.is_updated) - return true; - if (frame_buf && frame_buf->dirty) - return true; - } + if ((anim && anim->is_active) || (anim && anim->label.is_updated)) + return true; + if (frame_buf && frame_buf->dirty) + return true; return false; } diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 775ee0c6c6..15591dcc21 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -92,11 +92,6 @@ typedef struct menu_input_t input; - struct - { - bool is_updated; - } label; - struct { bool active; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 6b53e02c56..e0da687575 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1371,10 +1371,10 @@ static void setting_get_string_representation_st_float_video_refresh_rate_auto(v snprintf(s, len, "%.3f Hz (%.1f%% dev, %u samples)", video_refresh_rate, 100.0 * deviation, sample_points); { - menu_handle_t *menu = menu_driver_get_ptr(); + menu_animation_t *anim = menu_animation_get_ptr(); - if (menu) - menu->label.is_updated = true; + if (anim) + anim->label.is_updated = true; } } else