edje: block "recalc" event emission if it isn't being subscribed to
authorMike Blumenkrantz <zmike@samsung.com>
Mon, 14 Oct 2019 13:29:50 +0000 (09:29 -0400)
committerWonki Kim <wonki_.kim@samsung.com>
Mon, 11 Nov 2019 02:18:25 +0000 (11:18 +0900)
Summary:
this gets called a ton

ref T8321
Depends on D10356

Reviewers: bu5hm4n, cedric

Reviewed By: bu5hm4n, cedric

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8321

Differential Revision: https://phab.enlightenment.org/D10357

src/lib/edje/edje_calc.c
src/lib/edje/edje_private.h
src/lib/edje/edje_smart.c

index 98b6049..bc5fd07 100644 (file)
@@ -1003,7 +1003,7 @@ _edje_recalc_do(Edje *ed)
 #endif
    if (!ed->calc_only)
      {
-        if (ed->recalc_call)
+        if (ed->recalc_call && ed->has_recalc_event_cb)
           efl_event_callback_legacy_call(ed->obj, EFL_LAYOUT_EVENT_RECALC, NULL);
      }
    else
index c1012c1..d1db304 100644 (file)
@@ -1883,6 +1883,7 @@ struct _Edje
    Eina_Bool          need_map_update : 1;
    Eina_Bool          canvas_animator : 1;
    Eina_Bool          has_state_clip : 1;
+   Eina_Bool          has_recalc_event_cb : 1;
 };
 
 struct _Edje_Calc_Params_Map
index 78d85a7..4599fb0 100644 (file)
@@ -651,9 +651,33 @@ _efl_canvas_layout_efl_player_playback_speed_get(const Eo *obj EINA_UNUSED, Edje
 }
 
 /* Internal EO APIs and hidden overrides */
+EOLIAN static Eina_Bool
+_efl_canvas_layout_efl_object_event_callback_priority_add(Eo *obj, Edje *pd, const Efl_Event_Description *desc, Efl_Callback_Priority priority, Efl_Event_Cb func, const void *user_data)
+{
+  if (desc == EFL_LAYOUT_EVENT_RECALC)
+    {
+       pd->has_recalc_event_cb = EINA_TRUE;
+    }
+
+  return efl_event_callback_priority_add(efl_super(obj, MY_CLASS), desc, priority, func, user_data);
+}
 
+EOLIAN static Eina_Bool
+_efl_canvas_layout_efl_object_event_callback_array_priority_add(Eo *obj, Edje *pd, const Efl_Callback_Array_Item *array, Efl_Callback_Priority priority, const void *user_data)
+{
+   for (int i = 0; array[i].desc; ++i)
+     {
+        if (array[i].desc == EFL_LAYOUT_EVENT_RECALC)
+          {
+             pd->has_recalc_event_cb = EINA_TRUE;
+          }
+     }
+   return efl_event_callback_array_priority_add(efl_super(obj, MY_CLASS), array, priority, user_data);
+}
 #define EFL_CANVAS_LAYOUT_EXTRA_OPS \
    EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_canvas_layout), \
+   EFL_OBJECT_OP_FUNC(efl_event_callback_priority_add, _efl_canvas_layout_efl_object_event_callback_priority_add), \
+   EFL_OBJECT_OP_FUNC(efl_event_callback_array_priority_add, _efl_canvas_layout_efl_object_event_callback_array_priority_add), \
    EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _efl_canvas_layout_efl_object_dbg_info_get)
 
 #include "efl_canvas_layout.eo.c"