zmike pushed a commit to branch master.

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

commit dc5c17a104c9be1939881852ee76668d7bf693ac
Author: Mike Blumenkrantz <zm...@samsung.com>
Date:   Mon Oct 14 09:30:17 2019 -0400

    evas/render: selectively inhibit render callbacks
    
    Summary:
    only call these if they are subscribed to now
    
    ref T8321
    
    Reviewers: cedric
    
    Reviewed By: cedric
    
    Subscribers: cedric, #reviewers, #committers
    
    Tags: #efl
    
    Maniphest Tasks: T8321
    
    Differential Revision: https://phab.enlightenment.org/D10361
---
 src/lib/evas/canvas/evas_main.c     | 36 ++++++++++++++++++++++++++++++++++++
 src/lib/evas/canvas/evas_render.c   | 32 ++++++++++++++++++++++++--------
 src/lib/evas/include/evas_private.h |  5 +++++
 3 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index d246bdc60b..92c9ed2334 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -2014,5 +2014,41 @@ EWAPI const Efl_Event_Description 
_EVAS_CANVAS_EVENT_AXIS_UPDATE =
 EWAPI const Efl_Event_Description _EVAS_CANVAS_EVENT_VIEWPORT_RESIZE =
    EFL_EVENT_DESCRIPTION("viewport,resize");
 
+#define CHECK_ADD(var, ev, member) \
+  if ((var) == (ev)) \
+    { \
+       e->member = EINA_TRUE; \
+    }
+
+
+EOLIAN static Eina_Bool
+_evas_canvas_efl_object_event_callback_priority_add(Eo *obj, Evas_Public_Data 
*e, const Efl_Event_Description *desc, Efl_Callback_Priority priority, 
Efl_Event_Cb func, const void *user_data)
+{
+   CHECK_ADD(desc, EVAS_CANVAS_EVENT_RENDER_FLUSH_PRE, cb_render_flush_pre)
+   else CHECK_ADD(desc, EVAS_CANVAS_EVENT_RENDER_FLUSH_POST, 
cb_render_flush_post)
+   else CHECK_ADD(desc, EFL_CANVAS_SCENE_EVENT_RENDER_PRE, cb_render_pre)
+   else CHECK_ADD(desc, EFL_CANVAS_SCENE_EVENT_RENDER_POST, cb_render_post)
+
+   return efl_event_callback_priority_add(efl_super(obj, MY_CLASS), desc, 
priority, func, user_data);
+}
+
+EOLIAN static Eina_Bool
+_evas_canvas_efl_object_event_callback_array_priority_add(Eo *obj, 
Evas_Public_Data *e, const Efl_Callback_Array_Item *array, 
Efl_Callback_Priority priority, const void *user_data)
+{
+   for (int i = 0; array[i].desc; ++i)
+     {
+        CHECK_ADD(array[i].desc, EVAS_CANVAS_EVENT_RENDER_FLUSH_PRE, 
cb_render_flush_pre)
+        else CHECK_ADD(array[i].desc, EVAS_CANVAS_EVENT_RENDER_FLUSH_POST, 
cb_render_flush_post)
+        else CHECK_ADD(array[i].desc, EFL_CANVAS_SCENE_EVENT_RENDER_PRE, 
cb_render_pre)
+        else CHECK_ADD(array[i].desc, EFL_CANVAS_SCENE_EVENT_RENDER_POST, 
cb_render_post)
+     }
+   return efl_event_callback_array_priority_add(efl_super(obj, MY_CLASS), 
array, priority, user_data);
+}
+#undef CHECK_ADD
+#define EVAS_CANVAS_EXTRA_OPS \
+   EFL_OBJECT_OP_FUNC(efl_event_callback_priority_add, 
_evas_canvas_efl_object_event_callback_priority_add), \
+   EFL_OBJECT_OP_FUNC(efl_event_callback_array_priority_add, 
_evas_canvas_efl_object_event_callback_array_priority_add)
+
+
 #include "evas_stack.x"
 #include "canvas/evas_canvas_eo.c"
diff --git a/src/lib/evas/canvas/evas_render.c 
b/src/lib/evas/canvas/evas_render.c
index 4895517c1a..70ed55a953 100644
--- a/src/lib/evas/canvas/evas_render.c
+++ b/src/lib/evas/canvas/evas_render.c
@@ -2762,10 +2762,26 @@ _drop_image_cache_ref(const void *container 
EINA_UNUSED, void *data, void *fdata
 }
 
 static void
-_cb_always_call(Evas *eo_e, Evas_Callback_Type type, void *event_info)
+_cb_always_call(Evas *eo_e, Evas_Public_Data *e, Evas_Callback_Type type, void 
*event_info)
 {
    int freeze_num = 0, i;
 
+   switch (type)
+     {
+      case EVAS_CALLBACK_RENDER_PRE:
+        if (!e->cb_render_pre) return;
+        break;
+      case EVAS_CALLBACK_RENDER_POST:
+        if (!e->cb_render_post) return;
+        break;
+      case EVAS_CALLBACK_RENDER_FLUSH_PRE:
+        if (!e->cb_render_flush_pre) return;
+        break;
+      case EVAS_CALLBACK_RENDER_FLUSH_POST:
+        if (!e->cb_render_flush_post) return;
+        break;
+      default: break;
+     }
    freeze_num = efl_event_freeze_count_get(eo_e);
    for (i = 0; i < freeze_num; i++) efl_event_thaw(eo_e);
    evas_event_callback_call(eo_e, type, event_info);
@@ -3277,7 +3293,7 @@ evas_render_updates_internal(Evas *eo_e,
 
    RD(0, "[--- RENDER EVAS (size: %ix%i): %p (eo %p)\n", e->viewport.w, 
e->viewport.h, e, eo_e);
 
-   _cb_always_call(eo_e, EVAS_CALLBACK_RENDER_PRE, NULL);
+   _cb_always_call(eo_e, e, EVAS_CALLBACK_RENDER_PRE, NULL);
 
    /* Check if the modified object mean recalculating every thing */
    if (!e->invalidate)
@@ -3596,7 +3612,7 @@ evas_render_updates_internal(Evas *eo_e,
                   efl_ref(eo_e);
                   _rendering_evases = eina_list_prepend(_rendering_evases, e);
                   e->rendering = _rendering_evases;
-                  _cb_always_call(eo_e, EVAS_CALLBACK_RENDER_FLUSH_PRE, NULL);
+                  _cb_always_call(eo_e, e, EVAS_CALLBACK_RENDER_FLUSH_PRE, 
NULL);
                   
evas_thread_queue_flush((Evas_Thread_Command_Cb)evas_render_pipe_wakeup, e);
                   eina_evlog("-render_output_async_flush", eo_e, 0.0, NULL);
                }
@@ -3607,11 +3623,11 @@ evas_render_updates_internal(Evas *eo_e,
                     {
                        _evas_object_image_video_overlay_do(eo_obj);
                     }
-                  _cb_always_call(eo_e, EVAS_CALLBACK_RENDER_FLUSH_PRE, NULL);
+                  _cb_always_call(eo_e, e, EVAS_CALLBACK_RENDER_FLUSH_PRE, 
NULL);
                   EINA_LIST_FOREACH(e->outputs, l, out)
                     if (out->output)
                       ENFN->output_flush(ENC, out->output, 
EVAS_RENDER_MODE_SYNC);
-                  _cb_always_call(eo_e, EVAS_CALLBACK_RENDER_FLUSH_POST, NULL);
+                  _cb_always_call(eo_e, e, EVAS_CALLBACK_RENDER_FLUSH_POST, 
NULL);
                   _deferred_callbacks_process(eo_e, evas);
                   eina_evlog("-render_output_flush", eo_e, 0.0, NULL);
                }
@@ -3766,7 +3782,7 @@ evas_render_updates_internal(Evas *eo_e,
           }
         eina_spinlock_take(&(e->render.lock));
         e->inside_post_render = EINA_TRUE;
-        _cb_always_call(eo_e, EVAS_CALLBACK_RENDER_POST, &post);
+        _cb_always_call(eo_e, e, EVAS_CALLBACK_RENDER_POST, &post);
         e->inside_post_render = EINA_FALSE;
         eina_spinlock_release(&(e->render.lock));
         if (post.updated_area) eina_list_free(post.updated_area);
@@ -3835,7 +3851,7 @@ evas_render_wakeup(Evas *eo_e)
           {
              _evas_object_image_video_overlay_do(eo_obj);
           }
-        _cb_always_call(eo_e, EVAS_CALLBACK_RENDER_FLUSH_POST, NULL);
+        _cb_always_call(eo_e, evas, EVAS_CALLBACK_RENDER_FLUSH_POST, NULL);
      }
 
    /* clear redraws */
@@ -3878,7 +3894,7 @@ evas_render_wakeup(Evas *eo_e)
    evas->rendering = NULL;
 
    post.updated_area = ret_updates;
-   _cb_always_call(eo_e, EVAS_CALLBACK_RENDER_POST, &post);
+   _cb_always_call(eo_e, evas, EVAS_CALLBACK_RENDER_POST, &post);
    evas->inside_post_render = EINA_FALSE;
    _deferred_callbacks_process(eo_e, evas);
 
diff --git a/src/lib/evas/include/evas_private.h 
b/src/lib/evas/include/evas_private.h
index 86bb885ce3..39bb3acd0d 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -912,6 +912,11 @@ struct _Evas_Public_Data
    Eina_Bool      is_frozen : 1;
    Eina_Bool      inside_post_render : 1;
    Eina_Bool      devices_modified : 1;
+   Eina_Bool      cb_render_pre : 1;
+
+   Eina_Bool      cb_render_post : 1;
+   Eina_Bool      cb_render_flush_pre : 1;
+   Eina_Bool      cb_render_flush_post : 1;
 };
 
 struct _Evas_Layer

-- 


Reply via email to