mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-31 08:33:40 +00:00
Merge pull request #5290 from heuripedes/xmb-improv
More xmb improvements
This commit is contained in:
commit
782b9eef0e
@ -73,6 +73,8 @@
|
||||
#define XMB_DEBUG
|
||||
#endif
|
||||
|
||||
/* NOTE: If you change this you HAVE to update
|
||||
* xmb_alloc_node() and xmb_copy_node() */
|
||||
typedef struct
|
||||
{
|
||||
float alpha;
|
||||
@ -407,6 +409,40 @@ const char* xmb_theme_ident(void)
|
||||
return "monochrome";
|
||||
}
|
||||
|
||||
/* NOTE: This exists because calloc()ing xmb_node_t is expensive
|
||||
* when you can have big lists like MAME and fba playlists */
|
||||
static xmb_node_t *xmb_alloc_node(void)
|
||||
{
|
||||
xmb_node_t *node = (xmb_node_t*)malloc(sizeof(*node));
|
||||
|
||||
node->alpha = node->label_alpha = 0;
|
||||
node->zoom = node->x = node->y = 0;
|
||||
node->icon = node->content_icon = 0;
|
||||
node->fullpath[0] = 0;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/* NOTE: This is faster than memcpy()ing xmb_node_t in most cases
|
||||
* because most nodes have small (less than 200 bytes) fullpath */
|
||||
static xmb_node_t *xmb_copy_node(void *p)
|
||||
{
|
||||
xmb_node_t *old_node = (xmb_node_t*)p;
|
||||
xmb_node_t *new_node = (xmb_node_t*)malloc(sizeof(*new_node));
|
||||
|
||||
new_node->alpha = old_node->alpha;
|
||||
new_node->label_alpha = old_node->label_alpha;
|
||||
new_node->zoom = old_node->zoom;
|
||||
new_node->x = old_node->x;
|
||||
new_node->y = old_node->y;
|
||||
new_node->icon = old_node->icon;
|
||||
new_node->content_icon = old_node->content_icon;
|
||||
|
||||
strlcpy(new_node->fullpath, old_node->fullpath, sizeof(old_node->fullpath));
|
||||
|
||||
return new_node;
|
||||
}
|
||||
|
||||
static const char *xmb_thumbnails_ident(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -1354,7 +1390,7 @@ static void xmb_list_open_new(xmb_handle_t *xmb,
|
||||
|
||||
static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, unsigned i)
|
||||
{
|
||||
xmb_node_t *node = (xmb_node_t*)calloc(1, sizeof(xmb_node_t));
|
||||
xmb_node_t *node = xmb_alloc_node();
|
||||
|
||||
if (!node)
|
||||
{
|
||||
@ -3683,7 +3719,7 @@ static void xmb_list_insert(void *userdata,
|
||||
node = (xmb_node_t*)menu_entries_get_userdata_at_offset(list, i);
|
||||
|
||||
if (!node)
|
||||
node = (xmb_node_t*)calloc(1, sizeof(xmb_node_t));
|
||||
node = xmb_alloc_node();
|
||||
|
||||
if (!node)
|
||||
{
|
||||
@ -3756,11 +3792,7 @@ static void xmb_list_deep_copy(const file_list_t *src, file_list_t *dst)
|
||||
void *src_adata = (void*)menu_entries_get_actiondata_at_offset(src, i);
|
||||
|
||||
if (src_udata)
|
||||
{
|
||||
void *data = malloc(sizeof(xmb_node_t));
|
||||
memcpy(data, src_udata, sizeof(xmb_node_t));
|
||||
file_list_set_userdata(dst, i, data);
|
||||
}
|
||||
file_list_set_userdata(dst, i, xmb_copy_node(src_udata));
|
||||
|
||||
if (src_adata)
|
||||
{
|
||||
|
@ -44,6 +44,7 @@ struct tween
|
||||
struct menu_animation
|
||||
{
|
||||
struct tween *list;
|
||||
bool need_defrag;
|
||||
|
||||
size_t capacity;
|
||||
size_t size;
|
||||
@ -459,6 +460,8 @@ bool menu_animation_push(menu_animation_ctx_entry_t *entry)
|
||||
|
||||
*target = t;
|
||||
|
||||
anim.need_defrag = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -486,6 +489,7 @@ static void menu_animation_defrag()
|
||||
}
|
||||
|
||||
anim.first_dead = anim.size;
|
||||
anim.need_defrag = false;
|
||||
}
|
||||
|
||||
bool menu_animation_update(float delta_time)
|
||||
@ -511,6 +515,7 @@ bool menu_animation_update(float delta_time)
|
||||
{
|
||||
*tween->subject = tween->target_value;
|
||||
tween->alive = false;
|
||||
anim.need_defrag = true;
|
||||
|
||||
if (tween->cb)
|
||||
tween->cb();
|
||||
@ -520,12 +525,14 @@ bool menu_animation_update(float delta_time)
|
||||
active_tweens += 1;
|
||||
}
|
||||
|
||||
if (active_tweens)
|
||||
if (anim.need_defrag)
|
||||
menu_animation_defrag();
|
||||
else
|
||||
|
||||
if (!active_tweens)
|
||||
{
|
||||
anim.size = 0;
|
||||
anim.first_dead = 0;
|
||||
anim.need_defrag = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -663,6 +670,8 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
|
||||
|
||||
if (i < anim.first_dead)
|
||||
anim.first_dead = i;
|
||||
|
||||
anim.need_defrag = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -690,6 +699,7 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
|
||||
anim.first_dead = i;
|
||||
|
||||
killed++;
|
||||
anim.need_defrag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -448,7 +448,11 @@ void menu_entries_append_enum(file_list_t *list, const char *path,
|
||||
file_list_set_actiondata(list, idx, cbs);
|
||||
|
||||
cbs->enum_idx = enum_idx;
|
||||
cbs->setting = menu_setting_find_enum(enum_idx);
|
||||
|
||||
if (enum_idx != MENU_ENUM_LABEL_PLAYLIST_ENTRY
|
||||
&& enum_idx != MENU_ENUM_LABEL_PLAYLIST_COLLECTION_ENTRY) {
|
||||
cbs->setting = menu_setting_find_enum(enum_idx);
|
||||
}
|
||||
|
||||
menu_cbs_init(list, cbs, path, label, type, idx);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user