mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 10:10:57 +00:00
Move p_anim state to rarch_state
This commit is contained in:
parent
31e50f1221
commit
c250b94dcf
@ -49,14 +49,6 @@ static update_time_cb update_time_callback = gfx_animation_update_time_default;
|
||||
|
||||
/* from https://github.com/kikito/tween.lua/blob/master/tween.lua */
|
||||
|
||||
static gfx_animation_t *anim_get_ptr(void)
|
||||
{
|
||||
/* TODO/FIXME - global that gets referenced outside,
|
||||
* needs to be refactored */
|
||||
static gfx_animation_t anim;
|
||||
return &anim;
|
||||
}
|
||||
|
||||
static float easing_linear(float t, float b, float c, float d)
|
||||
{
|
||||
return c * t / d + b;
|
||||
@ -1276,6 +1268,7 @@ static void gfx_animation_update_time(
|
||||
}
|
||||
|
||||
bool gfx_animation_update(
|
||||
gfx_animation_t *p_anim,
|
||||
retro_time_t current_time,
|
||||
bool timedate_enable,
|
||||
float ticker_speed,
|
||||
@ -1283,7 +1276,6 @@ bool gfx_animation_update(
|
||||
unsigned video_height)
|
||||
{
|
||||
unsigned i;
|
||||
gfx_animation_t *p_anim = anim_get_ptr();
|
||||
|
||||
gfx_animation_update_time(
|
||||
p_anim,
|
||||
@ -1391,6 +1383,32 @@ static void build_ticker_loop_string(
|
||||
}
|
||||
}
|
||||
|
||||
static void build_line_ticker_string(
|
||||
size_t num_display_lines, size_t line_offset,
|
||||
struct string_list *lines,
|
||||
char *dest_str, size_t dest_str_len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < num_display_lines; i++)
|
||||
{
|
||||
size_t offset = i + line_offset;
|
||||
size_t line_index = offset % (lines->size + 1);
|
||||
bool line_valid = true;
|
||||
|
||||
if (line_index >= lines->size)
|
||||
line_valid = false;
|
||||
|
||||
if (line_valid)
|
||||
strlcat(dest_str, lines->elems[line_index].data, dest_str_len);
|
||||
|
||||
if (i < num_display_lines - 1)
|
||||
strlcat(dest_str, "\n", dest_str_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool gfx_animation_ticker(gfx_animation_ctx_ticker_t *ticker)
|
||||
{
|
||||
gfx_animation_t *p_anim = anim_get_ptr();
|
||||
@ -1470,9 +1488,10 @@ bool gfx_animation_ticker(gfx_animation_ctx_ticker_t *ticker)
|
||||
}
|
||||
|
||||
/* 'Fixed width' font version of gfx_animation_ticker_smooth() */
|
||||
bool gfx_animation_ticker_smooth_fw(gfx_animation_ctx_ticker_smooth_t *ticker)
|
||||
static bool gfx_animation_ticker_smooth_fw(
|
||||
gfx_animation_t *p_anim,
|
||||
gfx_animation_ctx_ticker_smooth_t *ticker)
|
||||
{
|
||||
gfx_animation_t *p_anim = anim_get_ptr();
|
||||
size_t spacer_len = 0;
|
||||
unsigned glyph_width = ticker->glyph_width;
|
||||
unsigned src_str_width = 0;
|
||||
@ -1645,7 +1664,7 @@ bool gfx_animation_ticker_smooth(gfx_animation_ctx_ticker_smooth_t *ticker)
|
||||
/* If we are using a fixed width font (ticker->font == NULL),
|
||||
* switch to optimised code path */
|
||||
if (!ticker->font)
|
||||
return gfx_animation_ticker_smooth_fw(ticker);
|
||||
return gfx_animation_ticker_smooth_fw(p_anim, ticker);
|
||||
|
||||
/* Find the display width of each character in
|
||||
* the src string + total width */
|
||||
@ -1856,30 +1875,6 @@ end:
|
||||
return is_active;
|
||||
}
|
||||
|
||||
static void build_line_ticker_string(
|
||||
size_t num_display_lines, size_t line_offset,
|
||||
struct string_list *lines,
|
||||
char *dest_str, size_t dest_str_len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < num_display_lines; i++)
|
||||
{
|
||||
size_t offset = i + line_offset;
|
||||
size_t line_index = offset % (lines->size + 1);
|
||||
bool line_valid = true;
|
||||
|
||||
if (line_index >= lines->size)
|
||||
line_valid = false;
|
||||
|
||||
if (line_valid)
|
||||
strlcat(dest_str, lines->elems[line_index].data, dest_str_len);
|
||||
|
||||
if (i < num_display_lines - 1)
|
||||
strlcat(dest_str, "\n", dest_str_len);
|
||||
}
|
||||
}
|
||||
|
||||
bool gfx_animation_line_ticker(gfx_animation_ctx_line_ticker_t *line_ticker)
|
||||
{
|
||||
char *wrapped_str = NULL;
|
||||
@ -1930,18 +1925,14 @@ bool gfx_animation_line_ticker(gfx_animation_ctx_line_ticker_t *line_ticker)
|
||||
switch (line_ticker->type_enum)
|
||||
{
|
||||
case TICKER_TYPE_LOOP:
|
||||
{
|
||||
gfx_animation_line_ticker_loop(
|
||||
line_ticker->idx,
|
||||
line_ticker->line_len,
|
||||
lines->size,
|
||||
&line_offset);
|
||||
|
||||
break;
|
||||
}
|
||||
case TICKER_TYPE_BOUNCE:
|
||||
default:
|
||||
{
|
||||
gfx_animation_line_ticker_generic(
|
||||
line_ticker->idx,
|
||||
line_ticker->line_len,
|
||||
@ -1950,7 +1941,6 @@ bool gfx_animation_line_ticker(gfx_animation_ctx_line_ticker_t *line_ticker)
|
||||
&line_offset);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Build output string from required lines */
|
||||
@ -2069,16 +2059,16 @@ bool gfx_animation_line_ticker_smooth(gfx_animation_ctx_line_ticker_smooth_t *li
|
||||
if (line_ticker->fade_enabled)
|
||||
{
|
||||
if (line_ticker->top_fade_str_len > 0)
|
||||
line_ticker->top_fade_str[0] = '\0';
|
||||
line_ticker->top_fade_str[0] = '\0';
|
||||
|
||||
if (line_ticker->bottom_fade_str_len > 0)
|
||||
line_ticker->bottom_fade_str[0] = '\0';
|
||||
|
||||
*line_ticker->top_fade_y_offset = 0.0f;
|
||||
*line_ticker->top_fade_y_offset = 0.0f;
|
||||
*line_ticker->bottom_fade_y_offset = 0.0f;
|
||||
|
||||
*line_ticker->top_fade_alpha = 0.0f;
|
||||
*line_ticker->bottom_fade_alpha = 0.0f;
|
||||
*line_ticker->top_fade_alpha = 0.0f;
|
||||
*line_ticker->bottom_fade_alpha = 0.0f;
|
||||
}
|
||||
|
||||
success = true;
|
||||
@ -2175,12 +2165,6 @@ end:
|
||||
return is_active;
|
||||
}
|
||||
|
||||
bool gfx_animation_is_active(void)
|
||||
{
|
||||
gfx_animation_t *p_anim = anim_get_ptr();
|
||||
return p_anim->animation_is_active || p_anim->ticker_is_active;
|
||||
}
|
||||
|
||||
bool gfx_animation_kill_by_tag(uintptr_t *tag)
|
||||
{
|
||||
unsigned i;
|
||||
|
@ -29,6 +29,8 @@ RETRO_BEGIN_DECLS
|
||||
|
||||
#define TICKER_SPACER_DEFAULT " | "
|
||||
|
||||
#define ANIM_IS_ACTIVE(_p) ((_p)->animation_is_active || (_p)->ticker_is_active)
|
||||
|
||||
typedef void (*tween_cb) (void*);
|
||||
|
||||
typedef void (*update_time_cb) (float *ticker_pixel_increment,
|
||||
@ -231,6 +233,7 @@ void gfx_timer_start(gfx_timer_t *timer, gfx_timer_ctx_entry_t *timer_entry);
|
||||
void gfx_timer_kill(gfx_timer_t *timer);
|
||||
|
||||
bool gfx_animation_update(
|
||||
gfx_animation_t *p_anim,
|
||||
retro_time_t current_time,
|
||||
bool timedate_enable,
|
||||
float ticker_speed,
|
||||
@ -247,8 +250,6 @@ bool gfx_animation_line_ticker_smooth(gfx_animation_ctx_line_ticker_smooth_t *li
|
||||
|
||||
float gfx_animation_get_delta_time(void);
|
||||
|
||||
bool gfx_animation_is_active(void);
|
||||
|
||||
bool gfx_animation_kill_by_tag(uintptr_t *tag);
|
||||
|
||||
bool gfx_animation_push(gfx_animation_ctx_entry_t *entry);
|
||||
@ -269,6 +270,8 @@ void gfx_animation_set_update_time_cb(update_time_cb cb);
|
||||
|
||||
void gfx_animation_unset_update_time_cb(void);
|
||||
|
||||
gfx_animation_t *anim_get_ptr(void);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -1639,7 +1639,8 @@ void gfx_display_set_msg_force(bool state)
|
||||
bool gfx_display_get_update_pending(void)
|
||||
{
|
||||
gfx_display_t *p_disp = disp_get_ptr();
|
||||
if (gfx_animation_is_active() || p_disp->framebuf_dirty)
|
||||
gfx_animation_t *p_anim = anim_get_ptr();
|
||||
if (ANIM_IS_ACTIVE(p_anim) || p_disp->framebuf_dirty)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
#include "../input_driver.h"
|
||||
|
||||
#include "../../retroarch.h"
|
||||
#include "../../verbosity.h"
|
||||
|
||||
#include "dinput_joypad.h"
|
||||
|
@ -2415,6 +2415,7 @@ struct rarch_state
|
||||
#endif
|
||||
|
||||
struct retro_audio_callback audio_callback;
|
||||
gfx_animation_t anim;
|
||||
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
|
||||
rarch_timer_t shader_delay_timer;
|
||||
#endif
|
||||
@ -2939,6 +2940,12 @@ struct netplay_room* netplay_get_host_room(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;
|
||||
@ -38798,6 +38805,7 @@ 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,
|
||||
|
Loading…
Reference in New Issue
Block a user