From: Marcel Hollerbach Date: Sat, 8 Dec 2018 13:54:48 +0000 (+0100) Subject: efl_ui_focus_manager: performance optimize order setting X-Git-Tag: submit/tizen/20181218.080725~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f14c9b412438d9b7258411003a0fccb1934f1cc;p=platform%2Fupstream%2Fefl.git efl_ui_focus_manager: performance optimize order setting setting the order is a little bit expensive, this performance optimizes order setting in the focus manager. We don't need to set the order each time something is registered, it is enough to set it once we need the correct order. We don't need to evalulate the state in the Manager_Root_Focus if the rect is not registered. If its not, then another new element cannot cause the rect to be registered. Reviewed-by: YeongJong Lee Differential Revision: https://phab.enlightenment.org/D7450 --- diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c index b5bf40b..b2b8356 100644 --- a/src/lib/elementary/efl_ui_focus_manager_calc.c +++ b/src/lib/elementary/efl_ui_focus_manager_calc.c @@ -60,6 +60,7 @@ struct _Node{ Node *parent; //the parent of the tree Eina_List *children; //this saves the original set of elements Eina_List *saved_order; + Eina_Bool clean_apply; //set if there was no new registration after a "update_order" call }tree; struct _Graph_Node { @@ -511,6 +512,7 @@ _register(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Object *chil { T(node).parent = parent; T(parent).children = eina_list_append(T(parent).children, node); + T(parent).clean_apply = EINA_FALSE; } node->type = NODE_TYPE_ONLY_LOGICAL; node->redirect_manager = redirect; @@ -582,15 +584,6 @@ _efl_ui_focus_manager_calc_register(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, //mark dirty dirty_add(obj, pd, node); - //set again - if (T(pnode).saved_order) - { - Eina_List *tmp; - - tmp = eina_list_clone(T(pnode).saved_order); - efl_ui_focus_manager_calc_update_order(obj, parent, tmp); - } - return EINA_TRUE; } @@ -689,6 +682,7 @@ _efl_ui_focus_manager_calc_update_order(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data ELM_SAFE_FREE(T(pnode).saved_order, eina_list_free); T(pnode).saved_order = order; + T(pnode).clean_apply = EINA_TRUE; //get all nodes from the subset EINA_LIST_FOREACH(order, n, o) @@ -713,6 +707,7 @@ _efl_ui_focus_manager_calc_update_order(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data eina_list_free(T(pnode).children); T(pnode).children = eina_list_merge(node_order, not_ordered); } + T(pnode).clean_apply = EINA_TRUE; return; } @@ -1291,7 +1286,7 @@ _prev(Node *node) static Node* -_logical_movement(Efl_Ui_Focus_Manager_Calc_Data *pd EINA_UNUSED, Node *upper, Efl_Ui_Focus_Direction direction, Eina_Bool accept_logical) +_logical_movement(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd EINA_UNUSED, Node *upper, Efl_Ui_Focus_Direction direction, Eina_Bool accept_logical) { Node* (*deliver)(Node *n); Node *result; @@ -1319,7 +1314,17 @@ _logical_movement(Efl_Ui_Focus_Manager_Calc_Data *pd EINA_UNUSED, Node *upper, E stack = eina_list_append(stack, result); if (direction == EFL_UI_FOCUS_DIRECTION_NEXT) - efl_ui_focus_object_prepare_logical(result->focusable); + { + //set again + if (T(result).saved_order && !T(result).clean_apply) + { + Eina_List *tmp; + + tmp = eina_list_clone(T(result).saved_order); + efl_ui_focus_manager_calc_update_order(obj, result->focusable, tmp); + } + efl_ui_focus_object_prepare_logical(result->focusable); + } result = deliver(result); if (accept_logical) @@ -1350,7 +1355,7 @@ _request_move(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Directio if (direction == EFL_UI_FOCUS_DIRECTION_PREVIOUS || direction == EFL_UI_FOCUS_DIRECTION_NEXT) - dir = _logical_movement(pd, upper, direction, accept_logical); + dir = _logical_movement(obj, pd, upper, direction, accept_logical); else dir = _coords_movement(obj, pd, upper, direction); diff --git a/src/lib/elementary/efl_ui_focus_manager_root_focus.c b/src/lib/elementary/efl_ui_focus_manager_root_focus.c index 4a2fd4d..f8a4c86 100644 --- a/src/lib/elementary/efl_ui_focus_manager_root_focus.c +++ b/src/lib/elementary/efl_ui_focus_manager_root_focus.c @@ -68,7 +68,7 @@ _efl_ui_focus_manager_root_focus_efl_ui_focus_manager_calc_register(Eo *obj, Efl { if (efl_ui_focus_manager_calc_register(efl_super(obj, MY_CLASS), child, parent, redirect)) { - if (child != pd->rect) + if (child != pd->rect && pd->rect_registered) _state_eval(obj, pd); return EINA_TRUE; @@ -81,7 +81,7 @@ _efl_ui_focus_manager_root_focus_efl_ui_focus_manager_calc_register_logical(Eo * { if (efl_ui_focus_manager_calc_register_logical(efl_super(obj, MY_CLASS), child, parent, redirect)) { - if (redirect) + if (redirect && pd->rect_registered) _state_eval(obj, pd); return EINA_TRUE;