summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-07-20 22:24:31 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-07-20 22:24:31 +0100
commitb158abfabba220201ddb573d75ba4a48b586f152 (patch)
tree34dcdf3211ac6b22d7b93c1e72a65eedcbe24d4b
parent2a2da5254c8905922f4fe0840e855e3508846be8 (diff)
elm - genlist+gird - use item specific realize/unrealize not eo callback
this saves a lot of cpu overhead to specialize this with func ptrs in the widget item struct instead of everyone listening on the parent gengrid/genlist widget and eo having to walk lots of callbacks and call them all... major optimization @opt
-rw-r--r--src/lib/elementary/elm_gengrid.c7
-rw-r--r--src/lib/elementary/elm_genlist.c6
-rw-r--r--src/lib/elementary/elm_widget.h5
-rw-r--r--src/lib/elementary/elm_widget_item_static_focus.c56
4 files changed, 33 insertions, 41 deletions
diff --git a/src/lib/elementary/elm_gengrid.c b/src/lib/elementary/elm_gengrid.c
index b550f4e2cd..cf5bdaa4ad 100644
--- a/src/lib/elementary/elm_gengrid.c
+++ b/src/lib/elementary/elm_gengrid.c
@@ -1264,7 +1264,10 @@ _elm_gengrid_item_unrealize(Elm_Gen_Item *it,
1264 elm_wdg_item_track_cancel(EO_OBJ(it)); 1264 elm_wdg_item_track_cancel(EO_OBJ(it));
1265 1265
1266 if (!calc) 1266 if (!calc)
1267 efl_event_callback_legacy_call(WIDGET(it), ELM_GENGRID_EVENT_UNREALIZED, EO_OBJ(it)); 1267 {
1268 if (it->base->func.unrealized) it->base->func.unrealized(EO_OBJ(it));
1269 efl_event_callback_legacy_call(WIDGET(it), ELM_GENGRID_EVENT_UNREALIZED, EO_OBJ(it));
1270 }
1268 1271
1269 it->unrealize_cb(it); 1272 it->unrealize_cb(it);
1270 1273
@@ -1973,6 +1976,7 @@ _item_place(Elm_Gen_Item *it,
1973 if (!was_realized) 1976 if (!was_realized)
1974 { 1977 {
1975 _elm_gengrid_item_index_update(it); 1978 _elm_gengrid_item_index_update(it);
1979 if (it->base->func.realized) it->base->func.realized(EO_OBJ(it));
1976 efl_event_callback_legacy_call 1980 efl_event_callback_legacy_call
1977 (WIDGET(it), ELM_GENGRID_EVENT_REALIZED, EO_OBJ(it)); 1981 (WIDGET(it), ELM_GENGRID_EVENT_REALIZED, EO_OBJ(it));
1978 _flush_focus_on_realization(WIDGET(it), it); 1982 _flush_focus_on_realization(WIDGET(it), it);
@@ -2179,6 +2183,7 @@ _group_item_place(Elm_Gengrid_Pan_Data *psd)
2179 if (!was_realized) 2183 if (!was_realized)
2180 { 2184 {
2181 _elm_gengrid_item_index_update(it); 2185 _elm_gengrid_item_index_update(it);
2186 if (it->base->func.realized) it->base->func.realized(EO_OBJ(it));
2182 efl_event_callback_legacy_call 2187 efl_event_callback_legacy_call
2183 (WIDGET(it), ELM_GENGRID_EVENT_REALIZED, EO_OBJ(it)); 2188 (WIDGET(it), ELM_GENGRID_EVENT_REALIZED, EO_OBJ(it));
2184 _flush_focus_on_realization(WIDGET(it), it); 2189 _flush_focus_on_realization(WIDGET(it), it);
diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c
index d6125594fe..a00bef3480 100644
--- a/src/lib/elementary/elm_genlist.c
+++ b/src/lib/elementary/elm_genlist.c
@@ -716,7 +716,10 @@ _elm_genlist_item_unrealize(Elm_Gen_Item *it,
716 elm_wdg_item_track_cancel(EO_OBJ(it)); 716 elm_wdg_item_track_cancel(EO_OBJ(it));
717 717
718 if (!calc) 718 if (!calc)
719 efl_event_callback_legacy_call(WIDGET(it), ELM_GENLIST_EVENT_UNREALIZED, EO_OBJ(it)); 719 {
720 if (it->base->func.unrealized) it->base->func.unrealized(EO_OBJ(it));
721 efl_event_callback_legacy_call(WIDGET(it), ELM_GENLIST_EVENT_UNREALIZED, EO_OBJ(it));
722 }
720 723
721 _item_unrealize(it); 724 _item_unrealize(it);
722 725
@@ -2053,6 +2056,7 @@ _item_realize(Elm_Gen_Item *it, const int index, Eina_Bool calc)
2053 2056
2054 } 2057 }
2055 2058
2059 if (it->base->func.realized) it->base->func.realized(EO_OBJ(it));
2056 efl_event_callback_legacy_call(WIDGET(it), ELM_GENLIST_EVENT_REALIZED, EO_OBJ(it)); 2060 efl_event_callback_legacy_call(WIDGET(it), ELM_GENLIST_EVENT_REALIZED, EO_OBJ(it));
2057 } 2061 }
2058 2062
diff --git a/src/lib/elementary/elm_widget.h b/src/lib/elementary/elm_widget.h
index 88e3ff6b39..233c526ddc 100644
--- a/src/lib/elementary/elm_widget.h
+++ b/src/lib/elementary/elm_widget.h
@@ -585,6 +585,11 @@ struct _Elm_Widget_Item_Data
585 Eina_Hash *labels; 585 Eina_Hash *labels;
586 Evas_Object *track_obj; 586 Evas_Object *track_obj;
587 587
588 struct {
589 void (*realized) (Eo *obj);
590 void (*unrealized) (Eo *obj);
591 } func;
592
588 Eina_Bool disabled : 1; 593 Eina_Bool disabled : 1;
589 Eina_Bool on_deletion : 1; 594 Eina_Bool on_deletion : 1;
590 Eina_Bool on_translate : 1; 595 Eina_Bool on_translate : 1;
diff --git a/src/lib/elementary/elm_widget_item_static_focus.c b/src/lib/elementary/elm_widget_item_static_focus.c
index f040cbcf4c..cb8d10bcd0 100644
--- a/src/lib/elementary/elm_widget_item_static_focus.c
+++ b/src/lib/elementary/elm_widget_item_static_focus.c
@@ -27,43 +27,35 @@ _realized_set(Elm_Widget_Item_Static_Focus *f)
27} 27}
28 28
29static void 29static void
30_list_realized_cb(void *data, const Efl_Event *ev) 30_list_realized_cb(Eo *obj)
31{ 31{
32 if (ev->info != data) return; 32 _realized_set(obj);
33 33
34 _realized_set(data); 34 if (!elm_object_item_disabled_get(obj) &&
35 35 elm_genlist_item_type_get(obj) != ELM_GENLIST_ITEM_GROUP)
36 if (!elm_object_item_disabled_get(data) && 36 efl_ui_focus_object_setup_order(obj);
37 elm_genlist_item_type_get(data) != ELM_GENLIST_ITEM_GROUP)
38 efl_ui_focus_object_setup_order(data);
39} 37}
40 38
41static void 39static void
42_grid_realized_cb(void *data, const Efl_Event *ev) 40_grid_realized_cb(Eo *obj)
43{ 41{
44 const Elm_Gen_Item_Class *itc; 42 const Elm_Gen_Item_Class *itc;
45 Eina_Bool is_group = EINA_FALSE; 43 Eina_Bool is_group = EINA_FALSE;
46 44
47 if (ev->info != data) return; 45 _realized_set(obj);
48
49 _realized_set(data);
50 46
51 itc = elm_gengrid_item_item_class_get(data); 47 itc = elm_gengrid_item_item_class_get(obj);
52 48
53 is_group = (itc && itc->item_style && !strcmp(itc->item_style, "group_index")); 49 is_group = (itc && itc->item_style && !strcmp(itc->item_style, "group_index"));
54 50
55 if (!elm_object_item_disabled_get(data) && !is_group) 51 if (!elm_object_item_disabled_get(obj) && !is_group)
56 { 52 efl_ui_focus_object_setup_order(obj);
57 efl_ui_focus_object_setup_order(data);
58 }
59} 53}
60 54
61static void 55static void
62_unrealized_cb(void *data, const Efl_Event *ev EINA_UNUSED) 56_unrealized_cb(Eo *obj)
63{ 57{
64 Elm_Widget_Item_Static_Focus_Data *pd = efl_data_scope_get(data, MY_CLASS); 58 Elm_Widget_Item_Static_Focus_Data *pd = efl_data_scope_get(obj, MY_CLASS);
65
66 if (ev->info != data) return;
67 59
68 if (pd) /* if the obect is dead pd is NULL */ 60 if (pd) /* if the obect is dead pd is NULL */
69 { 61 {
@@ -145,15 +137,10 @@ _elm_widget_item_static_focus_efl_object_constructor(Eo *obj, Elm_Widget_Item_St
145 Eo *ret = efl_constructor(efl_super(obj, MY_CLASS)); 137 Eo *ret = efl_constructor(efl_super(obj, MY_CLASS));
146 138
147 if (efl_isa(wpd->widget, ELM_GENLIST_CLASS)) 139 if (efl_isa(wpd->widget, ELM_GENLIST_CLASS))
148 { 140 wpd->func.realized = _list_realized_cb;
149 efl_event_callback_add(wpd->widget, ELM_GENLIST_EVENT_REALIZED, _list_realized_cb, obj);
150 efl_event_callback_add(wpd->widget, ELM_GENLIST_EVENT_UNREALIZED, _unrealized_cb, obj);
151 }
152 else 141 else
153 { 142 wpd->func.realized = _grid_realized_cb;
154 efl_event_callback_add(wpd->widget, ELM_GENGRID_EVENT_REALIZED, _grid_realized_cb, obj); 143 wpd->func.unrealized = _unrealized_cb;
155 efl_event_callback_add(wpd->widget, ELM_GENGRID_EVENT_UNREALIZED, _unrealized_cb, obj);
156 }
157 return ret; 144 return ret;
158} 145}
159 146
@@ -161,17 +148,8 @@ EOLIAN static void
161_elm_widget_item_static_focus_efl_object_destructor(Eo *obj, Elm_Widget_Item_Static_Focus_Data *pd EINA_UNUSED) 148_elm_widget_item_static_focus_efl_object_destructor(Eo *obj, Elm_Widget_Item_Static_Focus_Data *pd EINA_UNUSED)
162{ 149{
163 Elm_Widget_Item_Data *wpd = efl_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS); 150 Elm_Widget_Item_Data *wpd = efl_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
164 if (efl_isa(wpd->widget, ELM_GENLIST_CLASS)) 151 wpd->func.realized = NULL;
165 { 152 wpd->func.unrealized = NULL;
166 efl_event_callback_del(wpd->widget, ELM_GENLIST_EVENT_REALIZED, _list_realized_cb, obj);
167 efl_event_callback_del(wpd->widget, ELM_GENLIST_EVENT_UNREALIZED, _unrealized_cb, obj);
168 }
169 else
170 {
171 efl_event_callback_del(wpd->widget, ELM_GENGRID_EVENT_REALIZED, _grid_realized_cb, obj);
172 efl_event_callback_del(wpd->widget, ELM_GENGRID_EVENT_UNREALIZED, _unrealized_cb, obj);
173 }
174
175 if (pd->adapter) 153 if (pd->adapter)
176 efl_del(pd->adapter); 154 efl_del(pd->adapter);
177 155