summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-08-19 16:40:57 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-08-26 10:18:01 +0900
commitef4859d5bdab3a9d8c5d7e2114c1d42bcc94f50f (patch)
tree21114975dd54d60370bec5dcc51e8c70c18c2bbd
parent57f0c850ec5011313b5ac2f3407b547ef149ac18 (diff)
evas: Optimize out most callback call events
This sets a bit whenever a callback listener is added. I couldn't get any profiling data easily (too small for valgrind). Note: This removes the proper refcounting on the "move" event listeners. I believe this is not a problem as most times the move_ref goes to 0, it is because the object is deleted. Worst case, we just trigger a callback_call with no listeners. This adds 32 bits to each evas object private data.
-rw-r--r--src/lib/evas/canvas/evas_callbacks.c27
-rw-r--r--src/lib/evas/include/evas_inline.x6
-rw-r--r--src/lib/evas/include/evas_private.h2
3 files changed, 26 insertions, 9 deletions
diff --git a/src/lib/evas/canvas/evas_callbacks.c b/src/lib/evas/canvas/evas_callbacks.c
index 6c6f9026df..3e848b281b 100644
--- a/src/lib/evas/canvas/evas_callbacks.c
+++ b/src/lib/evas/canvas/evas_callbacks.c
@@ -73,6 +73,20 @@ DEFINE_EVAS_CALLBACKS(_legacy_evas_callback_table, EVAS_CALLBACK_LAST,
73 EVAS_CANVAS_EVENT_AXIS_UPDATE, 73 EVAS_CANVAS_EVENT_AXIS_UPDATE,
74 EVAS_CANVAS_EVENT_VIEWPORT_RESIZE ); 74 EVAS_CANVAS_EVENT_VIEWPORT_RESIZE );
75 75
76static inline Evas_Callback_Type
77_legacy_evas_callback_type(const Efl_Event_Description *desc)
78{
79 Evas_Callback_Type type;
80
81 for (type = 0; type < EVAS_CALLBACK_LAST; type++)
82 {
83 if (_legacy_evas_callback_table(type) == desc)
84 return type;
85 }
86
87 return EVAS_CALLBACK_LAST;
88}
89
76typedef struct 90typedef struct
77{ 91{
78 EINA_INLIST; 92 EINA_INLIST;
@@ -288,7 +302,7 @@ evas_object_event_callback_call(Evas_Object *eo_obj, Evas_Object_Protected_Data
288 302
289 _evas_walk(e); 303 _evas_walk(e);
290 304
291 if ((type == EVAS_CALLBACK_MOVE) && (obj->move_ref == 0)) 305 if (!_evas_object_callback_has_by_type(obj, type))
292 goto nothing_here; 306 goto nothing_here;
293 307
294 if ((type == EVAS_CALLBACK_MOUSE_DOWN) || (type == EVAS_CALLBACK_MOUSE_UP)) 308 if ((type == EVAS_CALLBACK_MOUSE_DOWN) || (type == EVAS_CALLBACK_MOUSE_UP))
@@ -315,7 +329,7 @@ evas_object_event_callback_call(Evas_Object *eo_obj, Evas_Object_Protected_Data
315 if ((type == EVAS_CALLBACK_MOUSE_DOWN) || (type == EVAS_CALLBACK_MOUSE_UP)) 329 if ((type == EVAS_CALLBACK_MOUSE_DOWN) || (type == EVAS_CALLBACK_MOUSE_UP))
316 efl_event_pointer_button_flags_set(efl_event_info, flags); 330 efl_event_pointer_button_flags_set(efl_event_info, flags);
317 331
318 nothing_here: 332nothing_here:
319 if (!obj->no_propagate) 333 if (!obj->no_propagate)
320 { 334 {
321 if ((obj->smart.parent) && (type != EVAS_CALLBACK_FREE) && 335 if ((obj->smart.parent) && (type != EVAS_CALLBACK_FREE) &&
@@ -593,6 +607,7 @@ _check_event_catcher_add(void *data, const Eo_Event *event)
593{ 607{
594 const Efl_Callback_Array_Item *array = event->info; 608 const Efl_Callback_Array_Item *array = event->info;
595 Evas_Object_Protected_Data *obj = data; 609 Evas_Object_Protected_Data *obj = data;
610 Evas_Callback_Type type = EVAS_CALLBACK_LAST;
596 int i; 611 int i;
597 612
598 for (i = 0; array[i].desc != NULL; i++) 613 for (i = 0; array[i].desc != NULL; i++)
@@ -605,9 +620,9 @@ _check_event_catcher_add(void *data, const Eo_Event *event)
605 INF("Registering an animator tick on canvas %p for object %p.", 620 INF("Registering an animator tick on canvas %p for object %p.",
606 obj->layer->evas->evas, obj->object); 621 obj->layer->evas->evas, obj->object);
607 } 622 }
608 else if (array[i].desc == EFL_GFX_EVENT_MOVE) 623 else if ((type = _legacy_evas_callback_type(array[i].desc)) != EVAS_CALLBACK_LAST)
609 { 624 {
610 obj->move_ref++; 625 obj->callback_mask |= (1 << type);
611 } 626 }
612 } 627 }
613} 628}
@@ -629,10 +644,6 @@ _check_event_catcher_del(void *data, const Eo_Event *event)
629 INF("Unregistering an animator tick on canvas %p for object %p.", 644 INF("Unregistering an animator tick on canvas %p for object %p.",
630 obj->layer->evas->evas, obj->object); 645 obj->layer->evas->evas, obj->object);
631 } 646 }
632 else if (array[i].desc == EFL_GFX_EVENT_MOVE)
633 {
634 obj->move_ref--;
635 }
636 } 647 }
637} 648}
638 649
diff --git a/src/lib/evas/include/evas_inline.x b/src/lib/evas/include/evas_inline.x
index 1906fbc208..d7c94db49a 100644
--- a/src/lib/evas/include/evas_inline.x
+++ b/src/lib/evas/include/evas_inline.x
@@ -22,6 +22,12 @@ _evas_object_event_new(void)
22 return (++_evas_event_counter); 22 return (++_evas_event_counter);
23} 23}
24 24
25static inline Eina_Bool
26_evas_object_callback_has_by_type(Evas_Object_Protected_Data *obj, Evas_Callback_Type type)
27{
28 return (obj->callback_mask & (1 << type)) != 0;
29}
30
25static inline int 31static inline int
26evas_object_was_visible(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj) 32evas_object_was_visible(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
27{ 33{
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 5964a66f1c..ceac5872ad 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1124,7 +1124,7 @@ struct _Evas_Object_Protected_Data
1124 unsigned int ref; 1124 unsigned int ref;
1125 1125
1126 unsigned int animator_ref; 1126 unsigned int animator_ref;
1127 unsigned int move_ref; 1127 uint64_t callback_mask;
1128 1128
1129 unsigned char delete_me; 1129 unsigned char delete_me;
1130 1130