From c0cb042998450c50685886646ebdad8a780a3788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Tue, 8 Aug 2017 21:05:00 -0300 Subject: [PATCH] (xmb) Improve responsiveness while browsing horizontally --- menu/drivers/xmb.c | 47 +++++++++---------------------------------- menu/menu_animation.c | 4 ++-- menu/menu_animation.h | 4 ++-- 3 files changed, 14 insertions(+), 41 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 004a6d564e..a97d05ed8c 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1394,7 +1394,7 @@ static xmb_node_t* xmb_get_userdata_from_horizontal_list( menu_entries_get_actiondata_at_offset(xmb->horizontal_list, i); } -static void xmb_push_animations(xmb_node_t *node, float ia, float ix) +static void xmb_push_animations(xmb_node_t *node, uintptr_t tag, float ia, float ix) { menu_animation_ctx_entry_t entry; @@ -1402,7 +1402,7 @@ static void xmb_push_animations(xmb_node_t *node, float ia, float ix) entry.target_value = ia; entry.subject = &node->alpha; entry.easing_enum = EASING_OUT_QUAD; - entry.tag = -1; + entry.tag = tag; entry.cb = NULL; if (entry.subject) @@ -1435,7 +1435,7 @@ static void xmb_list_switch_old(xmb_handle_t *xmb, if (!node) continue; - xmb_push_animations(node, ia, -xmb->icon.spacing.horizontal * dir); + xmb_push_animations(node, (uintptr_t)list, ia, -xmb->icon.spacing.horizontal * dir); } } @@ -1501,7 +1501,7 @@ static void xmb_list_switch_new(xmb_handle_t *xmb, if (i == current) ia = xmb->items.active.alpha; - xmb_push_animations(node, ia, 0); + xmb_push_animations(node, (uintptr_t)list, ia, 0); } } @@ -3736,28 +3736,18 @@ static void xmb_list_clear(file_list_t *list) { size_t i; size_t size = list->size; + menu_animation_ctx_tag_t tag = { (uintptr_t)list }; + + menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); for (i = 0; i < size; ++i) { - menu_animation_ctx_subject_t subject; - float *subjects[5]; xmb_node_t *node = (xmb_node_t*) menu_entries_get_userdata_at_offset(list, i); if (!node) continue; - subjects[0] = &node->alpha; - subjects[1] = &node->label_alpha; - subjects[2] = &node->zoom; - subjects[3] = &node->x; - subjects[4] = &node->y; - - subject.count = 5; - subject.data = subjects; - - menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_SUBJECT, &subject); - file_list_free_userdata(list, i); } } @@ -3766,29 +3756,12 @@ static void xmb_list_deep_copy(const file_list_t *src, file_list_t *dst) { size_t i; size_t size = dst->size; + menu_animation_ctx_tag_t tag = { (uintptr_t)dst }; + + menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); for (i = 0; i < size; ++i) { - xmb_node_t *node = (xmb_node_t*) - menu_entries_get_userdata_at_offset(dst, i); - - if (node) - { - menu_animation_ctx_subject_t subject; - float *subjects[5]; - - subjects[0] = &node->alpha; - subjects[1] = &node->label_alpha; - subjects[2] = &node->zoom; - subjects[3] = &node->x; - subjects[4] = &node->y; - - subject.count = 5; - subject.data = subjects; - - menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_SUBJECT, &subject); - } - file_list_free_userdata(dst, i); file_list_free_actiondata(dst, i); /* this one was allocated by us */ } diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 47acd52d29..b6746597b4 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -36,7 +36,7 @@ struct tween float initial_value; float target_value; float *subject; - int tag; + uintptr_t tag; easing_cb easing; tween_cb cb; }; @@ -624,7 +624,7 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data) unsigned i; menu_animation_ctx_tag_t *tag = (menu_animation_ctx_tag_t*)data; - if (!tag || tag->id == -1) + if (!tag || tag->id == (uintptr_t)-1) return false; for (i = 0; i < anim.size; ++i) diff --git a/menu/menu_animation.h b/menu/menu_animation.h index 49d154d305..c010c3971e 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -93,7 +93,7 @@ typedef struct menu_animation_ctx_delta typedef struct menu_animation_ctx_tag { - int id; + uintptr_t id; } menu_animation_ctx_tag_t; typedef struct menu_animation_ctx_subject @@ -108,7 +108,7 @@ typedef struct menu_animation_ctx_entry float target_value; float *subject; enum menu_animation_easing_type easing_enum; - int tag; + uintptr_t tag; tween_cb cb; } menu_animation_ctx_entry_t;