summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-07-29 12:01:43 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-07-31 10:17:42 +0200
commit8d034f08e8322921b1b059cc2e93e10f7b0550f1 (patch)
tree482760fe75da6e909ebff28b2978a91fda2b770f
parent4e24854f4624f8cdc73f25cda28508b58745d9ac (diff)
efl_ui_focus_manager: reduce the amount of relying on events
with this commit we are not replying on event invocations anymore, but rather on direct flag observation in the focus manager itself. This reduces the amount of events that are emitted as a consequence to elements beeing marked dirty segnificantly. startup time of elementary_test goes from 0.50 to 0.46s. Differential Revision: https://phab.enlightenment.org/D12072
-rw-r--r--src/lib/elementary/efl_ui_focus_manager.eo9
-rw-r--r--src/lib/elementary/efl_ui_focus_manager_calc.c20
-rw-r--r--src/lib/elementary/efl_ui_focus_manager_calc.eo1
-rw-r--r--src/lib/elementary/efl_ui_focus_manager_sub.c15
4 files changed, 27 insertions, 18 deletions
diff --git a/src/lib/elementary/efl_ui_focus_manager.eo b/src/lib/elementary/efl_ui_focus_manager.eo
index dd95256b6d..080edaaf7a 100644
--- a/src/lib/elementary/efl_ui_focus_manager.eo
+++ b/src/lib/elementary/efl_ui_focus_manager.eo
@@ -96,6 +96,15 @@ interface Efl.Ui.Focus.Manager {
96 over the border objects.]] 96 over the border objects.]]
97 } 97 }
98 } 98 }
99 @property border_elements_changed {
100 [[Return $true if the border elements have changed since the last invocation of @.border_elements.get]]
101 get {
102
103 }
104 values {
105 changed : bool; [[$true if there was a change, $false if not]]
106 }
107 }
99 @property viewport_elements { 108 @property viewport_elements {
100 [[Elements that are at the border of the viewport 109 [[Elements that are at the border of the viewport
101 110
diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c
index 173a663d79..7fb80c38c2 100644
--- a/src/lib/elementary/efl_ui_focus_manager_calc.c
+++ b/src/lib/elementary/efl_ui_focus_manager_calc.c
@@ -85,6 +85,7 @@ typedef struct {
85 int freeze; 85 int freeze;
86 86
87 Node *root; 87 Node *root;
88 Eina_Bool border_elements_changed;
88} Efl_Ui_Focus_Manager_Calc_Data; 89} Efl_Ui_Focus_Manager_Calc_Data;
89 90
90static Eina_Mempool *_node_mempool; 91static Eina_Mempool *_node_mempool;
@@ -247,7 +248,6 @@ node_item_free(Node *item)
247 Eina_List *l; 248 Eina_List *l;
248 Eo *obj = item->manager; 249 Eo *obj = item->manager;
249 FOCUS_DATA(obj); 250 FOCUS_DATA(obj);
250 Eina_Bool dirty_added = EINA_FALSE;
251 251
252 /*cleanup graph parts*/ 252 /*cleanup graph parts*/
253 253
@@ -264,7 +264,7 @@ node_item_free(Node *item)
264 if (partner->type != NODE_TYPE_ONLY_LOGICAL) \ 264 if (partner->type != NODE_TYPE_ONLY_LOGICAL) \
265 { \ 265 { \
266 dirty_add(obj, pd, partner); \ 266 dirty_add(obj, pd, partner); \
267 dirty_added = EINA_TRUE; \ 267 pd->border_elements_changed = EINA_TRUE; \
268 } \ 268 } \
269 } 269 }
270 270
@@ -278,7 +278,7 @@ node_item_free(Node *item)
278 } 278 }
279 279
280 //the unregistering of a item should ever result in atleast a coords_dirty call 280 //the unregistering of a item should ever result in atleast a coords_dirty call
281 if (dirty_added) 281 if (pd->border_elements_changed)
282 efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_COORDS_DIRTY, NULL); 282 efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_COORDS_DIRTY, NULL);
283 283
284 /*cleanup manager householdings*/ 284 /*cleanup manager householdings*/
@@ -475,7 +475,9 @@ dirty_add(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Node *dirty)
475 pd->dirty = eina_list_append(pd->dirty, dirty); 475 pd->dirty = eina_list_append(pd->dirty, dirty);
476 dirty->on_list = EINA_TRUE; 476 dirty->on_list = EINA_TRUE;
477 477
478 efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_COORDS_DIRTY, NULL); 478 if (!pd->border_elements_changed)
479 efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_COORDS_DIRTY, NULL);
480 pd->border_elements_changed = EINA_TRUE;
479} 481}
480 482
481 483
@@ -924,6 +926,7 @@ _efl_ui_focus_manager_calc_efl_object_constructor(Eo *obj, Efl_Ui_Focus_Manager_
924 pd->node_hash = eina_hash_pointer_new(_free_node); 926 pd->node_hash = eina_hash_pointer_new(_free_node);
925 927
926 pd->graph_ctx.offset_focusable = offsetof(Node, focusable); 928 pd->graph_ctx.offset_focusable = offsetof(Node, focusable);
929 pd->border_elements_changed = EINA_TRUE;
927 930
928 return obj; 931 return obj;
929} 932}
@@ -1110,9 +1113,18 @@ _elements_iterator_new(const Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd)
1110EOLIAN static Eina_Iterator* 1113EOLIAN static Eina_Iterator*
1111_efl_ui_focus_manager_calc_efl_ui_focus_manager_border_elements_get(const Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd) 1114_efl_ui_focus_manager_calc_efl_ui_focus_manager_border_elements_get(const Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd)
1112{ 1115{
1116 pd->border_elements_changed = EINA_FALSE;
1113 return (Eina_Iterator*) _elements_iterator_new(obj, pd); 1117 return (Eina_Iterator*) _elements_iterator_new(obj, pd);
1114} 1118}
1115 1119
1120
1121EOLIAN static Eina_Bool
1122_efl_ui_focus_manager_calc_efl_ui_focus_manager_border_elements_changed_get(const Eo *obj EINA_UNUSED, Efl_Ui_Focus_Manager_Calc_Data *pd)
1123{
1124 return pd->border_elements_changed;
1125}
1126
1127
1116EOLIAN static Eina_Iterator* 1128EOLIAN static Eina_Iterator*
1117_efl_ui_focus_manager_calc_efl_ui_focus_manager_viewport_elements_get(const Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Eina_Rect viewport) 1129_efl_ui_focus_manager_calc_efl_ui_focus_manager_viewport_elements_get(const Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Eina_Rect viewport)
1118{ 1130{
diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.eo b/src/lib/elementary/efl_ui_focus_manager_calc.eo
index ed86b7b05c..d7f9124fe8 100644
--- a/src/lib/elementary/efl_ui_focus_manager_calc.eo
+++ b/src/lib/elementary/efl_ui_focus_manager_calc.eo
@@ -70,6 +70,7 @@ class @beta Efl.Ui.Focus.Manager_Calc extends Efl.Object implements Efl.Ui.Focus
70 Efl.Ui.Focus.Manager.manager_focus {get; set;} 70 Efl.Ui.Focus.Manager.manager_focus {get; set;}
71 Efl.Ui.Focus.Manager.redirect {set; get;} 71 Efl.Ui.Focus.Manager.redirect {set; get;}
72 Efl.Ui.Focus.Manager.border_elements {get;} 72 Efl.Ui.Focus.Manager.border_elements {get;}
73 Efl.Ui.Focus.Manager.border_elements_changed {get;}
73 Efl.Ui.Focus.Manager.viewport_elements {get;} 74 Efl.Ui.Focus.Manager.viewport_elements {get;}
74 Efl.Ui.Focus.Manager.root {set; get;} 75 Efl.Ui.Focus.Manager.root {set; get;}
75 Efl.Ui.Focus.Manager.request_subchild; 76 Efl.Ui.Focus.Manager.request_subchild;
diff --git a/src/lib/elementary/efl_ui_focus_manager_sub.c b/src/lib/elementary/efl_ui_focus_manager_sub.c
index 7a2de74003..2d4a872d74 100644
--- a/src/lib/elementary/efl_ui_focus_manager_sub.c
+++ b/src/lib/elementary/efl_ui_focus_manager_sub.c
@@ -9,7 +9,6 @@
9#define MY_DATA(o, p) Efl_Ui_Focus_Manager_Sub_Data *p = efl_data_scope_get(o, MY_CLASS); 9#define MY_DATA(o, p) Efl_Ui_Focus_Manager_Sub_Data *p = efl_data_scope_get(o, MY_CLASS);
10typedef struct { 10typedef struct {
11 Efl_Ui_Focus_Manager *manager;//the manager where current_border is currently registered 11 Efl_Ui_Focus_Manager *manager;//the manager where current_border is currently registered
12 Eina_Bool self_dirty;
13 Eina_List *current_border; //the current set of widgets which is registered as borders 12 Eina_List *current_border; //the current set of widgets which is registered as borders
14} Efl_Ui_Focus_Manager_Sub_Data; 13} Efl_Ui_Focus_Manager_Sub_Data;
15 14
@@ -94,7 +93,6 @@ _border_flush(Eo *obj, Efl_Ui_Focus_Manager_Sub_Data *pd)
94 93
95 eina_list_free(pd->current_border); 94 eina_list_free(pd->current_border);
96 pd->current_border = selection; 95 pd->current_border = selection;
97 pd->self_dirty = EINA_FALSE;
98} 96}
99 97
100static void 98static void
@@ -116,7 +114,7 @@ _parent_manager_pre_flush(void *data, const Efl_Event *ev EINA_UNUSED)
116{ 114{
117 MY_DATA(data, pd); 115 MY_DATA(data, pd);
118 116
119 if (!pd->self_dirty) return; //we are not interested 117 if (!efl_ui_focus_manager_border_elements_changed_get(data)) return;
120 118
121 _border_flush(data, pd); 119 _border_flush(data, pd);
122} 120}
@@ -152,14 +150,6 @@ EFL_CALLBACKS_ARRAY_DEFINE(parent_manager,
152); 150);
153 151
154static void 152static void
155_self_manager_dirty(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
156{
157 MY_DATA(data, pd);
158
159 pd->self_dirty = EINA_TRUE;
160}
161
162static void
163_logical_manager_change(void *data EINA_UNUSED, const Efl_Event *ev) 153_logical_manager_change(void *data EINA_UNUSED, const Efl_Event *ev)
164{ 154{
165 MY_DATA(data, pd); 155 MY_DATA(data, pd);
@@ -217,7 +207,6 @@ _manager_change(void *data, const Efl_Event *ev EINA_UNUSED)
217} 207}
218 208
219EFL_CALLBACKS_ARRAY_DEFINE(self_manager, 209EFL_CALLBACKS_ARRAY_DEFINE(self_manager,
220 {EFL_UI_FOCUS_MANAGER_EVENT_COORDS_DIRTY, _self_manager_dirty},
221 {EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_PARENT_CHANGED, _logical_manager_change}, 210 {EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_PARENT_CHANGED, _logical_manager_change},
222 {EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_MANAGER_CHANGED, _manager_change} 211 {EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_MANAGER_CHANGED, _manager_change}
223); 212);
@@ -228,8 +217,6 @@ _efl_ui_focus_manager_sub_efl_object_constructor(Eo *obj, Efl_Ui_Focus_Manager_S
228 obj = efl_constructor(efl_super(obj, MY_CLASS)); 217 obj = efl_constructor(efl_super(obj, MY_CLASS));
229 efl_event_callback_array_add(obj, self_manager(), obj); 218 efl_event_callback_array_add(obj, self_manager(), obj);
230 219
231 pd->self_dirty = EINA_TRUE;
232
233 return obj; 220 return obj;
234} 221}
235 222