jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=ef4859d5bdab3a9d8c5d7e2114c1d42bcc94f50f

commit ef4859d5bdab3a9d8c5d7e2114c1d42bcc94f50f
Author: Jean-Philippe Andre <[email protected]>
Date:   Fri Aug 19 16:40:57 2016 +0900

    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.
---
 src/lib/evas/canvas/evas_callbacks.c | 27 +++++++++++++++++++--------
 src/lib/evas/include/evas_inline.x   |  6 ++++++
 src/lib/evas/include/evas_private.h  |  2 +-
 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 6c6f902..3e848b2 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,
                       EVAS_CANVAS_EVENT_AXIS_UPDATE,
                       EVAS_CANVAS_EVENT_VIEWPORT_RESIZE );
 
+static inline Evas_Callback_Type
+_legacy_evas_callback_type(const Efl_Event_Description *desc)
+{
+   Evas_Callback_Type type;
+
+   for (type = 0; type < EVAS_CALLBACK_LAST; type++)
+     {
+        if (_legacy_evas_callback_table(type) == desc)
+          return type;
+     }
+
+   return EVAS_CALLBACK_LAST;
+}
+
 typedef struct
 {
    EINA_INLIST;
@@ -288,7 +302,7 @@ evas_object_event_callback_call(Evas_Object *eo_obj, 
Evas_Object_Protected_Data
 
    _evas_walk(e);
 
-   if ((type == EVAS_CALLBACK_MOVE) && (obj->move_ref == 0))
+   if (!_evas_object_callback_has_by_type(obj, type))
      goto nothing_here;
 
    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
    if ((type == EVAS_CALLBACK_MOUSE_DOWN) || (type == EVAS_CALLBACK_MOUSE_UP))
      efl_event_pointer_button_flags_set(efl_event_info, flags);
 
- nothing_here:
+nothing_here:
    if (!obj->no_propagate)
      {
         if ((obj->smart.parent) && (type != EVAS_CALLBACK_FREE) &&
@@ -593,6 +607,7 @@ _check_event_catcher_add(void *data, const Eo_Event *event)
 {
    const Efl_Callback_Array_Item *array = event->info;
    Evas_Object_Protected_Data *obj = data;
+   Evas_Callback_Type type = EVAS_CALLBACK_LAST;
    int i;
 
    for (i = 0; array[i].desc != NULL; i++)
@@ -605,9 +620,9 @@ _check_event_catcher_add(void *data, const Eo_Event *event)
              INF("Registering an animator tick on canvas %p for object %p.",
                  obj->layer->evas->evas, obj->object);
           }
-        else if (array[i].desc == EFL_GFX_EVENT_MOVE)
+        else if ((type = _legacy_evas_callback_type(array[i].desc)) != 
EVAS_CALLBACK_LAST)
           {
-             obj->move_ref++;
+             obj->callback_mask |= (1 << type);
           }
      }
 }
@@ -629,10 +644,6 @@ _check_event_catcher_del(void *data, const Eo_Event *event)
              INF("Unregistering an animator tick on canvas %p for object %p.",
                  obj->layer->evas->evas, obj->object);
           }
-        else if (array[i].desc == EFL_GFX_EVENT_MOVE)
-          {
-             obj->move_ref--;
-          }
      }
 }
 
diff --git a/src/lib/evas/include/evas_inline.x 
b/src/lib/evas/include/evas_inline.x
index 1906fbc..d7c94db 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)
    return (++_evas_event_counter);
 }
 
+static inline Eina_Bool
+_evas_object_callback_has_by_type(Evas_Object_Protected_Data *obj, 
Evas_Callback_Type type)
+{
+   return (obj->callback_mask & (1 << type)) != 0;
+}
+
 static inline int
 evas_object_was_visible(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
 {
diff --git a/src/lib/evas/include/evas_private.h 
b/src/lib/evas/include/evas_private.h
index 5964a66..ceac587 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
    unsigned int                ref;
 
    unsigned int                animator_ref;
-   unsigned int                move_ref;
+   uint64_t                    callback_mask;
 
    unsigned char               delete_me;
 

-- 


Reply via email to