Make update_time_callback a part of the animation struct

This commit is contained in:
twinaphex 2020-10-15 08:35:37 +02:00
parent a7f4e534ed
commit 5f8c270d4c
6 changed files with 30 additions and 36 deletions

View File

@ -40,10 +40,6 @@
* */
#define TICKER_PIXEL_PERIOD (16.666666666666668f)
/* By default, this should be a NOOP */
/* TODO/FIXME - static global variable */
static update_time_cb update_time_callback = NULL;
/* from https://github.com/kikito/tween.lua/blob/master/tween.lua */
static float easing_linear(float t, float b, float c, float d)
@ -1144,16 +1140,6 @@ bool gfx_animation_push(gfx_animation_ctx_entry_t *entry)
return true;
}
void gfx_animation_set_update_time_cb(update_time_cb cb)
{
update_time_callback = cb;
}
void gfx_animation_unset_update_time_cb(void)
{
update_time_callback = NULL;
}
bool gfx_animation_update(
gfx_animation_t *p_anim,
retro_time_t current_time,
@ -1241,8 +1227,8 @@ bool gfx_animation_update(
* to handle video scaling as it pleases - a callback
* function set by the menu driver is thus used to
* perform menu-specific scaling adjustments */
if (update_time_callback)
update_time_callback(&ticker_pixel_increment,
if (p_anim->updatetime_cb)
p_anim->updatetime_cb(&ticker_pixel_increment,
video_width, video_height);
/* > Update accumulators */
@ -2194,6 +2180,8 @@ void gfx_animation_deinit(gfx_animation_t *p_anim)
return;
RBUF_FREE(p_anim->list);
RBUF_FREE(p_anim->pending);
if (p_anim->updatetime_cb)
p_anim->updatetime_cb = NULL;
memset(p_anim, 0, sizeof(*p_anim));
}

View File

@ -219,6 +219,8 @@ struct gfx_animation
uint64_t ticker_pixel_line_idx; /* updated every frame */
retro_time_t cur_time;
retro_time_t old_time;
update_time_cb updatetime_cb; /* ptr alignment */
/* By default, this should be a NOOP */
struct tween* list;
struct tween* pending;
@ -257,10 +259,6 @@ 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_set_update_time_cb(update_time_cb cb);
void gfx_animation_unset_update_time_cb(void);
void gfx_animation_deinit(gfx_animation_t *p_anim);
gfx_animation_t *anim_get_ptr(void);

View File

@ -7619,6 +7619,7 @@ static void *materialui_init(void **userdata, bool video_is_threaded)
{
unsigned width, height;
settings_t *settings = config_get_ptr();
gfx_animation_t *p_anim = anim_get_ptr();
materialui_handle_t *mui = NULL;
static const char* const ticker_spacer = MUI_TICKER_SPACER;
menu_handle_t *menu = (menu_handle_t*)
@ -7735,19 +7736,20 @@ static void *materialui_init(void **userdata, bool video_is_threaded)
mui->textures.playlist.icons = NULL;
materialui_refresh_playlist_icon_list(mui);
gfx_animation_set_update_time_cb(materialui_menu_animation_update_time);
p_anim->updatetime_cb = materialui_menu_animation_update_time;
return menu;
error:
if (menu)
free(menu);
gfx_animation_unset_update_time_cb();
p_anim->updatetime_cb = NULL;
return NULL;
}
static void materialui_free(void *data)
{
materialui_handle_t *mui = (materialui_handle_t*)data;
materialui_handle_t *mui = (materialui_handle_t*)data;
gfx_animation_t *p_anim = anim_get_ptr();
if (!mui)
return;
@ -7766,7 +7768,7 @@ static void materialui_free(void *data)
materialui_free_playlist_icon_list(mui);
gfx_animation_unset_update_time_cb();
p_anim->updatetime_cb = NULL;
}
static void materialui_context_bg_destroy(materialui_handle_t *mui)

View File

@ -683,6 +683,7 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
unsigned width, height, color_theme = 0;
ozone_handle_t *ozone = NULL;
settings_t *settings = config_get_ptr();
gfx_animation_t *p_anim = anim_get_ptr();
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
const char *directory_assets = settings->paths.directory_assets;
@ -863,7 +864,7 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE_ICONS);
last_use_preferred_system_color_theme = settings->bools.menu_use_preferred_system_color_theme;
gfx_animation_set_update_time_cb(ozone_menu_animation_update_time);
p_anim->updatetime_cb = ozone_menu_animation_update_time;
return menu;
@ -878,14 +879,15 @@ error:
if (menu)
free(menu);
gfx_animation_unset_update_time_cb();
p_anim->updatetime_cb = NULL;
return NULL;
}
static void ozone_free(void *data)
{
ozone_handle_t *ozone = (ozone_handle_t*) data;
ozone_handle_t *ozone = (ozone_handle_t*) data;
gfx_animation_t *p_anim = anim_get_ptr();
if (ozone)
{
@ -913,7 +915,7 @@ static void ozone_free(void *data)
font_driver_bind_block(NULL, NULL);
gfx_animation_unset_update_time_cb();
p_anim->updatetime_cb = NULL;
}
static void ozone_update_thumbnail_image(void *data)

View File

@ -4714,6 +4714,7 @@ static void *rgui_init(void **userdata, bool video_is_threaded)
rgui_t *rgui = NULL;
settings_t *settings = config_get_ptr();
gfx_display_t *p_disp = disp_get_ptr();
gfx_animation_t *p_anim = anim_get_ptr();
#if defined(DINGUX)
unsigned aspect_ratio_lock = RGUI_ASPECT_RATIO_LOCK_NONE;
#else
@ -4821,7 +4822,7 @@ static void *rgui_init(void **userdata, bool video_is_threaded)
* not handle struct initialisation correctly...) */
memset(&rgui->pointer, 0, sizeof(menu_input_pointer_t));
gfx_animation_set_update_time_cb(rgui_menu_animation_update_time);
p_anim->updatetime_cb = rgui_menu_animation_update_time;
return menu;
@ -4833,13 +4834,14 @@ error:
rgui_thumbnail_free(&mini_left_thumbnail);
if (menu)
free(menu);
gfx_animation_unset_update_time_cb();
p_anim->updatetime_cb = NULL;
return NULL;
}
static void rgui_free(void *data)
{
rgui_t *rgui = (rgui_t*)data;
rgui_t *rgui = (rgui_t*)data;
gfx_animation_t *p_anim = anim_get_ptr();
if (rgui)
{
@ -4866,7 +4868,7 @@ static void rgui_free(void *data)
rgui_upscale_buf.data = NULL;
}
gfx_animation_unset_update_time_cb();
p_anim->updatetime_cb = NULL;
}
static void rgui_set_texture(void)

View File

@ -5546,6 +5546,7 @@ static void *xmb_init(void **userdata, bool video_is_threaded)
int i;
xmb_handle_t *xmb = NULL;
settings_t *settings = config_get_ptr();
gfx_animation_t *p_anim = anim_get_ptr();
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
float scale_value = settings->floats.menu_scale_factor * 100.0f;
@ -5681,7 +5682,7 @@ static void *xmb_init(void **userdata, bool video_is_threaded)
xmb->last_use_ps3_layout = xmb->use_ps3_layout;
xmb->last_scale_factor = xmb_get_scale_factor(settings, xmb->use_ps3_layout, width);
gfx_animation_set_update_time_cb(xmb_menu_animation_update_time);
p_anim->updatetime_cb = xmb_menu_animation_update_time;
return menu;
@ -5691,13 +5692,14 @@ error:
xmb_free_list_nodes(&xmb->horizontal_list, false);
file_list_deinitialize(&xmb->selection_buf_old);
file_list_deinitialize(&xmb->horizontal_list);
gfx_animation_unset_update_time_cb();
p_anim->updatetime_cb = NULL;
return NULL;
}
static void xmb_free(void *data)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
xmb_handle_t *xmb = (xmb_handle_t*)data;
gfx_animation_t *p_anim = anim_get_ptr();
if (xmb)
{
@ -5723,7 +5725,7 @@ static void xmb_free(void *data)
font_driver_bind_block(NULL, NULL);
gfx_animation_unset_update_time_cb();
p_anim->updatetime_cb = NULL;
}
static void xmb_context_bg_destroy(xmb_handle_t *xmb)