cedric pushed a commit to branch master.

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

commit e8134e868a4369a89e2bb1d65e8ea8dfd72684ad
Author: Cedric BAIL <ced...@osg.samsung.com>
Date:   Thu Jan 28 16:15:20 2016 -0800

    evas: make evas object an animator provider.
---
 src/lib/evas/canvas/evas_object.eo     |  2 +-
 src/lib/evas/canvas/evas_object_main.c | 79 ++++++++++++++++++++++++++++++++++
 src/lib/evas/include/evas_private.h    |  2 +
 3 files changed, 82 insertions(+), 1 deletion(-)

diff --git a/src/lib/evas/canvas/evas_object.eo 
b/src/lib/evas/canvas/evas_object.eo
index 8baa965..5f9bb56 100644
--- a/src/lib/evas/canvas/evas_object.eo
+++ b/src/lib/evas/canvas/evas_object.eo
@@ -1,6 +1,6 @@
 import evas_types;
 
-abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base, 
Efl.Gfx.Stack)
+abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base, 
Efl.Gfx.Stack, Efl.Core.Animator)
 {
    eo_prefix: evas_obj;
    data: Evas_Object_Protected_Data;
diff --git a/src/lib/evas/canvas/evas_object_main.c 
b/src/lib/evas/canvas/evas_object_main.c
index 9f83689..3c986a7 100644
--- a/src/lib/evas/canvas/evas_object_main.c
+++ b/src/lib/evas/canvas/evas_object_main.c
@@ -82,6 +82,83 @@ _init_cow(void)
    return EINA_TRUE;
 }
 
+static Eina_Bool
+_animator_repeater(void *data,
+                   Eo *eo_obj EINA_UNUSED,
+                   const Eo_Event_Description2 *desc EINA_UNUSED,
+                   void *event_info)
+{
+   Evas_Object_Protected_Data *obj = data;
+
+   eo_do(obj->object,
+         eo_event_callback_call(EFL_CORE_ANIMATOR_EVENT_ANIMATOR_TICK, 
event_info));
+   DBG("Emitting animator tick on %p.", obj->object);
+
+   return EO_CALLBACK_CONTINUE;
+}
+
+static Eina_Bool
+_check_event_catcher_add(void *data,
+                         Eo *eo_obj EINA_UNUSED,
+                         const Eo_Event_Description2 *desc EINA_UNUSED,
+                         void *event_info)
+{
+   const Eo_Callback_Array_Item *array = event_info;
+   Evas_Object_Protected_Data *obj = data;
+   int i;
+
+   for (i = 0; array[i].desc != NULL; i++)
+     {
+        if (array[i].desc == EFL_CORE_ANIMATOR_EVENT_ANIMATOR_TICK)
+          {
+             if (obj->animator_ref++ > 0) break;
+
+             eo_do(evas_object_evas_get(obj->object),
+                   
eo_event_callback_add(EFL_CORE_ANIMATOR_EVENT_ANIMATOR_TICK, 
_animator_repeater, obj));
+             INF("Registering an animator tick on canvas %p for object %p.",
+                 evas_object_evas_get(obj->object), obj->object);
+
+             // No need to walk more than once per array as you can not del
+             // a partial array
+             break;
+          }
+     }
+
+   return EO_CALLBACK_CONTINUE;
+}
+
+static Eina_Bool
+_check_event_catcher_del(void *data,
+                         Eo *eo_obj EINA_UNUSED,
+                         const Eo_Event_Description2 *desc EINA_UNUSED,
+                         void *event_info)
+{
+   const Eo_Callback_Array_Item *array = event_info;
+   Evas_Object_Protected_Data *obj = data;
+   int i;
+
+   for (i = 0; array[i].desc != NULL; i++)
+     {
+        if (array[i].desc == EFL_CORE_ANIMATOR_EVENT_ANIMATOR_TICK)
+          {
+             if ((--obj->animator_ref) > 0) break;
+
+             eo_do(evas_object_evas_get(obj->object),
+                   
eo_event_callback_del(EFL_CORE_ANIMATOR_EVENT_ANIMATOR_TICK, 
_animator_repeater, obj));
+             INF("Unregistering an animator tick on canvas %p for object %p.",
+                 evas_object_evas_get(obj->object), obj->object);
+
+             break;
+          }
+     }
+
+   return EO_CALLBACK_CONTINUE;
+}
+
+EO_CALLBACKS_ARRAY_DEFINE(event_catcher_watch,
+                          { EO_BASE_EVENT_CALLBACK_ADD, 
_check_event_catcher_add },
+                          { EO_BASE_EVENT_CALLBACK_DEL, 
_check_event_catcher_del });
+
 EOLIAN static Eo *
 _evas_object_eo_base_constructor(Eo *eo_obj, Evas_Object_Protected_Data *obj)
 {
@@ -110,6 +187,8 @@ _evas_object_eo_base_constructor(Eo *eo_obj, 
Evas_Object_Protected_Data *obj)
 
    evas_object_inject(eo_obj, obj, evas_object_evas_get(parent));
 
+   eo_do(eo_obj, eo_event_callback_array_add(event_catcher_watch(), obj));
+
    return eo_obj;
 }
 
diff --git a/src/lib/evas/include/evas_private.h 
b/src/lib/evas/include/evas_private.h
index 664c144..28f890b 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1072,6 +1072,8 @@ struct _Evas_Object_Protected_Data
 
    unsigned int                ref;
 
+   unsigned int                animator_ref;
+
    unsigned char               delete_me;
 
    struct  {

-- 


Reply via email to