From fabdede6673e8715024c349dcd36999dff21a49f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 20 Sep 2021 20:17:53 +0200 Subject: [PATCH] Move anim_get_ptr to gfx_animation.c --- gfx/gfx_animation.c | 40 +++++++++++++++++++++++++++++++--------- gfx/gfx_animation.h | 3 +-- retroarch.c | 18 +++++------------- retroarch_data.h | 1 - 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/gfx/gfx_animation.c b/gfx/gfx_animation.c index 638d2c897f..45821bf384 100644 --- a/gfx/gfx_animation.c +++ b/gfx/gfx_animation.c @@ -55,8 +55,29 @@ * from one line to the next */ #define TICKER_LINE_SMOOTH_SCROLL_TICKS(line_len) ((size_t)(TICKER_LINE_DURATION_MS(line_len) / TICKER_PIXEL_PERIOD)) -/* from https://github.com/kikito/tween.lua/blob/master/tween.lua */ +static gfx_animation_t anim_st = { + 0, /* ticker_idx */ + 0, /* ticker_slow_idx */ + 0, /* ticker_pixel_idx */ + 0, /* ticker_pixel_line_idx */ + 0, /* cur_time */ + 0, /* old_time */ + NULL, /* updatetime_cb */ + NULL, /* list */ + NULL, /* pending */ + 0.0f, /* delta_time */ + false, /* pending_deletes */ + false, /* in_update */ + false, /* animation_is_active */ + false /* ticker_is_active */ +}; +gfx_animation_t *anim_get_ptr(void) +{ + return &anim_st; +} + +/* from https://github.com/kikito/tween.lua/blob/master/tween.lua */ static float easing_linear(float t, float b, float c, float d) { return c * t / d + b; @@ -993,7 +1014,7 @@ void gfx_animation_push_delayed( bool gfx_animation_push(gfx_animation_ctx_entry_t *entry) { struct tween t; - gfx_animation_t *p_anim = anim_get_ptr(); + gfx_animation_t *p_anim = &anim_st; t.duration = entry->duration; t.running_since = 0; @@ -1132,7 +1153,6 @@ bool gfx_animation_push(gfx_animation_ctx_entry_t *entry) } bool gfx_animation_update( - gfx_animation_t *p_anim, retro_time_t current_time, bool timedate_enable, float _ticker_speed, @@ -1140,6 +1160,7 @@ bool gfx_animation_update( unsigned video_height) { unsigned i; + gfx_animation_t *p_anim = &anim_st; const bool ticker_is_active = p_anim->ticker_is_active; static retro_time_t last_clock_update = 0; @@ -1369,7 +1390,7 @@ static void build_line_ticker_string( bool gfx_animation_ticker(gfx_animation_ctx_ticker_t *ticker) { - gfx_animation_t *p_anim = anim_get_ptr(); + gfx_animation_t *p_anim = &anim_st; size_t str_len = utf8len(ticker->str); if (!ticker->spacer) @@ -1606,7 +1627,7 @@ bool gfx_animation_ticker_smooth(gfx_animation_ctx_ticker_smooth_t *ticker) const char *str_ptr = NULL; bool success = false; bool is_active = false; - gfx_animation_t *p_anim = anim_get_ptr(); + gfx_animation_t *p_anim = &anim_st; /* Sanity check */ if (string_is_empty(ticker->src_str) || @@ -1837,7 +1858,7 @@ bool gfx_animation_line_ticker(gfx_animation_ctx_line_ticker_t *line_ticker) size_t line_offset = 0; bool success = false; bool is_active = false; - gfx_animation_t *p_anim = anim_get_ptr(); + gfx_animation_t *p_anim = &anim_st; /* Sanity check */ if (!line_ticker) @@ -1940,7 +1961,7 @@ bool gfx_animation_line_ticker_smooth(gfx_animation_ctx_line_ticker_smooth_t *li bool fade_active = false; bool success = false; bool is_active = false; - gfx_animation_t *p_anim = anim_get_ptr(); + gfx_animation_t *p_anim = &anim_st; const char *wideglyph_str = msg_hash_get_wideglyph_str(); int wideglyph_width = 100; void (*word_wrap_func)(char *dst, size_t dst_size, const char *src, @@ -2136,7 +2157,7 @@ end: bool gfx_animation_kill_by_tag(uintptr_t *tag) { unsigned i; - gfx_animation_t *p_anim = anim_get_ptr(); + gfx_animation_t *p_anim = &anim_st; if (!tag || *tag == (uintptr_t)-1) return false; @@ -2188,8 +2209,9 @@ bool gfx_animation_kill_by_tag(uintptr_t *tag) return true; } -void gfx_animation_deinit(gfx_animation_t *p_anim) +void gfx_animation_deinit(void) { + gfx_animation_t *p_anim = &anim_st; if (!p_anim) return; RBUF_FREE(p_anim->list); diff --git a/gfx/gfx_animation.h b/gfx/gfx_animation.h index 1234dcd940..4fd3573c85 100644 --- a/gfx/gfx_animation.h +++ b/gfx/gfx_animation.h @@ -238,7 +238,6 @@ void gfx_animation_timer_start(gfx_timer_t *timer, gfx_timer_ctx_entry_t *timer_entry); bool gfx_animation_update( - gfx_animation_t *p_anim, retro_time_t current_time, bool timedate_enable, float ticker_speed, @@ -259,7 +258,7 @@ bool gfx_animation_push(gfx_animation_ctx_entry_t *entry); void gfx_animation_push_delayed(unsigned delay, gfx_animation_ctx_entry_t *entry); -void gfx_animation_deinit(gfx_animation_t *p_anim); +void gfx_animation_deinit(void); gfx_animation_t *anim_get_ptr(void); diff --git a/retroarch.c b/retroarch.c index eb1ab4740f..37c7ee5b96 100644 --- a/retroarch.c +++ b/retroarch.c @@ -305,12 +305,6 @@ bool state_manager_frame_is_reversed(void) } #endif -gfx_animation_t *anim_get_ptr(void) -{ - struct rarch_state *p_rarch = &rarch_st; - return &p_rarch->anim; -} - content_state_t *content_state_get_ptr(void) { struct rarch_state *p_rarch = &rarch_st; @@ -3497,7 +3491,6 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) if ( p_rarch->menu_driver_ctx && p_rarch->menu_driver_ctx->free) p_rarch->menu_driver_ctx->free(p_rarch->menu_userdata); - p_rarch->anim.updatetime_cb = NULL; if (p_rarch->menu_userdata) free(p_rarch->menu_userdata); @@ -3513,7 +3506,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) memset(&system->info, 0, sizeof(struct retro_system_info)); } - gfx_animation_deinit(&p_rarch->anim); + gfx_animation_deinit(); gfx_display_free(); menu_entries_settings_deinit(menu_st); @@ -18524,7 +18517,7 @@ static unsigned menu_event( if (set_scroll) menu_st->scroll.acceleration = (unsigned)(new_scroll_accel); - delay_count += p_rarch->anim.delta_time; + delay_count += anim_get_ptr()->delta_time; if (display_kb) { @@ -24620,7 +24613,7 @@ static void video_driver_frame(const void *data, unsigned width, RUNLOOP_MSG_QUEUE_LOCK(runloop_state); /* Check whether duration timer has elapsed */ - runloop_core_status_msg.duration -= p_rarch->anim.delta_time; + runloop_core_status_msg.duration -= anim_get_ptr()->delta_time; if (runloop_core_status_msg.duration < 0.0f) { @@ -26046,7 +26039,7 @@ static void drivers_init(struct rarch_state *p_rarch, p_rarch->widgets_active = gfx_widgets_init( &p_rarch->dispwidget_st, &p_rarch->dispgfx, - &p_rarch->anim, + anim_get_ptr(), settings, (uintptr_t)&p_rarch->widgets_active, video_is_threaded, @@ -30482,7 +30475,6 @@ static enum runloop_state runloop_check_state( #if defined(HAVE_MENU) || defined(HAVE_GFX_WIDGETS) gfx_animation_update( - &p_rarch->anim, current_time, settings->bools.menu_timedate_enable, settings->floats.menu_ticker_speed, @@ -30613,7 +30605,7 @@ static enum runloop_state runloop_check_state( else if (!menu_driver_iterate(p_rarch, menu_st, &p_rarch->dispgfx, - &p_rarch->anim, + anim_get_ptr(), settings, action, current_time)) { diff --git a/retroarch_data.h b/retroarch_data.h index eedd490b61..9699e77684 100644 --- a/retroarch_data.h +++ b/retroarch_data.h @@ -1183,7 +1183,6 @@ struct rarch_state uint64_t video_driver_frame_time_count; uint64_t video_driver_frame_count; struct retro_camera_callback camera_cb; /* uint64_t alignment */ - gfx_animation_t anim; /* uint64_t alignment */ gfx_thumbnail_state_t gfx_thumb_state; /* uint64_t alignment */ #if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) input_remote_state_t remote_st_ptr; /* uint64_t alignment */