efl_ui_focus_manager: introduce a new API
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Thu, 22 Nov 2018 14:41:31 +0000 (15:41 +0100)
committerHermet Park <hermetpark@gmail.com>
Wed, 5 Dec 2018 05:43:46 +0000 (14:43 +0900)
the new api can be used to freeze the cache. This means, when the
widgets of the focus manager are all equally moved, the cache can stay,
cause the relative positions did not change, this enables a whole new
set of available optimizations.

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

src/lib/elementary/efl_ui_focus_manager.eo
src/lib/elementary/efl_ui_focus_manager_calc.c
src/lib/elementary/efl_ui_focus_manager_calc.eo
src/lib/elementary/elm_main.c

index f2bddfb..767c0b6 100644 (file)
@@ -158,6 +158,18 @@ interface Efl.Ui.Focus.Manager {
              entry : Efl.Ui.Focus.Object; [[The object that caused this manager to be redirect]]
            }
         }
+        dirty_logic_freeze {
+          [[This disables the cache invalidation when a object is moved.
+
+            Even the object is moved, the focus manager will not recalculate its relations, this can be used when you know that the set of widgets in the focus manager is equally moved. so the relations between the widets in the set do not change.
+          ]]
+        }
+        dirty_logic_unfreeze {
+          [[This enables the cache invalidation when a object is moved.
+
+            This is the counter part to @.dirty_logic_freeze
+          ]]
+        }
     }
     events {
         redirect,changed : Efl.Ui.Focus.Manager; [[Emitted when the redirect
@@ -167,5 +179,6 @@ interface Efl.Ui.Focus.Manager {
             potential changes in border_elements you want to know about]]
         focus,changed : Efl.Ui.Focus.Object; [[Emitted if the manager has focused an
             object, the passed focus object is the last focused object]]
+        dirty_logic_freeze,changed : bool; [[Called when this focus manager is frozen or unfrozen, even_info beeing $true indicates that it is now frozen, $false indicates that it is unfrozen.]]
     }
 }
index 18643f9..1906ddd 100644 (file)
@@ -79,6 +79,7 @@ typedef struct {
     Efl_Ui_Focus_Object *redirect_entry;
     Eina_List *dirty;
     Efl_Ui_Focus_Graph_Context graph_ctx;
+    int freeze;
 
     Node *root;
 } Efl_Ui_Focus_Manager_Calc_Data;
@@ -447,6 +448,10 @@ _node_new_geometry_cb(void *data, const Efl_Event *event)
    Node *node;
    FOCUS_DATA(data)
 
+   if (pd->freeze > 0) {
+     return;
+   }
+
    node = node_get(data, pd, event->object);
    if (!node)
       return;
@@ -1838,6 +1843,24 @@ _efl_ui_focus_manager_calc_efl_object_dbg_info_get(Eo *obj, Efl_Ui_Focus_Manager
    eina_iterator_free(iter);
 }
 
+EOLIAN static void
+_efl_ui_focus_manager_calc_efl_ui_focus_manager_dirty_logic_freeze(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd)
+{
+  pd->freeze ++;
+  if (pd->freeze == 1)
+    efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_DIRTY_LOGIC_FREEZE_CHANGED, (void*)EINA_TRUE);
+}
+
+
+EOLIAN static void
+_efl_ui_focus_manager_calc_efl_ui_focus_manager_dirty_logic_unfreeze(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd)
+{
+  pd->freeze --;
+  if (!pd->freeze)
+    efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_DIRTY_LOGIC_FREEZE_CHANGED, (void*)EINA_FALSE);
+}
+
+
 #define EFL_UI_FOCUS_MANAGER_CALC_EXTRA_OPS \
    EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _efl_ui_focus_manager_calc_efl_object_dbg_info_get)
 
index cfaffd8..ba4addf 100644 (file)
@@ -102,6 +102,8 @@ class Efl.Ui.Focus.Manager_Calc (Efl.Object, Efl.Ui.Focus.Manager) {
         Efl.Ui.Focus.Manager.reset_history;
         Efl.Ui.Focus.Manager.pop_history_stack;
         Efl.Ui.Focus.Manager.setup_on_first_touch;
+        Efl.Ui.Focus.Manager.dirty_logic_freeze;
+        Efl.Ui.Focus.Manager.dirty_logic_unfreeze;
         Efl.Object.constructor;
         Efl.Object.finalize;
         Efl.Object.provider_find;
index 665b18b..3236e3d 100644 (file)
@@ -64,6 +64,7 @@ _efl_ui_focus_manager_redirect_events_del(Efl_Ui_Focus_Manager *manager, Eo *obj
    efl_event_callback_forwarder_del(manager, EFL_UI_FOCUS_MANAGER_EVENT_REDIRECT_CHANGED, obj);
    efl_event_callback_forwarder_del(manager, EFL_UI_FOCUS_MANAGER_EVENT_FOCUS_CHANGED , obj);
    efl_event_callback_forwarder_del(manager, EFL_UI_FOCUS_MANAGER_EVENT_COORDS_DIRTY, obj);
+   efl_event_callback_forwarder_del(manager, EFL_UI_FOCUS_MANAGER_EVENT_DIRTY_LOGIC_FREEZE_CHANGED, obj);
 }
 
 void
@@ -73,6 +74,7 @@ _efl_ui_focus_manager_redirect_events_add(Efl_Ui_Focus_Manager *manager, Eo *obj
    efl_event_callback_forwarder_add(manager, EFL_UI_FOCUS_MANAGER_EVENT_REDIRECT_CHANGED, obj);
    efl_event_callback_forwarder_add(manager, EFL_UI_FOCUS_MANAGER_EVENT_FOCUS_CHANGED , obj);
    efl_event_callback_forwarder_add(manager, EFL_UI_FOCUS_MANAGER_EVENT_COORDS_DIRTY, obj);
+   efl_event_callback_forwarder_add(manager, EFL_UI_FOCUS_MANAGER_EVENT_DIRTY_LOGIC_FREEZE_CHANGED, obj);
 }
 
 Eina_Bool