evas: add 'has_fixed_size' property for canvas objects
authorMike Blumenkrantz <zmike@samsung.com>
Mon, 13 May 2019 16:14:00 +0000 (12:14 -0400)
committerJaehyun Cho <jae_hyun.cho@samsung.com>
Mon, 12 Aug 2019 07:31:00 +0000 (16:31 +0900)
this provides a hint for rendering that the object is not going to resize
for as long as the flag is set and  allows for some optimizations to
be made during rendering based on this knowledge

@feature

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D8887

src/lib/evas/canvas/efl_canvas_object.eo
src/lib/evas/canvas/evas_clip.c
src/lib/evas/canvas/evas_object_main.c
src/lib/evas/include/evas_private.h

index 7660b73..6062458 100644 (file)
@@ -138,6 +138,23 @@ abstract Efl.Canvas.Object extends Efl.Loop_Consumer implements Efl.Gfx.Entity,
             clipper: Efl.Canvas.Object; [[The object to clip $obj by.]]
          }
       }
+      @property has_fixed_size @beta {
+            [[A hint for an object that its size will not change.
+
+              When this flag is set, various optimizations may be employed by the
+              renderer based on the fixed size of the object.
+
+              It is a user error to change the size of an object while this flag
+              is set.
+
+              @since 1.23
+            ]]
+         set {}
+         get {}
+         values {
+            enable: bool; [[Whether the object size is known to be static.]]
+         }
+      }
       @property repeat_events {
          set {
             [[Set whether an Evas object is to repeat events.
index 04206e5..476183d 100644 (file)
@@ -311,6 +311,28 @@ _efl_canvas_object_clipper_unset_common(Evas_Object_Protected_Data *obj, Eina_Bo
 }
 
 EOLIAN void
+_efl_canvas_object_has_fixed_size_set(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Eina_Bool enable)
+{
+   EVAS_OBJECT_DATA_ALIVE_CHECK(obj);
+
+   enable = !!enable;
+   if (obj->cur->has_fixed_size == enable) return;
+   EINA_COW_STATE_WRITE_BEGIN(obj, state_write, cur)
+     state_write->has_fixed_size = enable;
+   EINA_COW_STATE_WRITE_END(obj, state_write, cur);
+   /* this will take effect next time the object is rendered,
+    * no need to force re-render now.
+    */
+}
+
+EOLIAN Eina_Bool
+_efl_canvas_object_has_fixed_size_get(const Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj)
+{
+   EVAS_OBJECT_DATA_ALIVE_CHECK(obj, EINA_FALSE);
+   return obj->cur->has_fixed_size;
+}
+
+EOLIAN void
 _efl_canvas_object_clipper_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Object *eo_clip)
 {
    Evas_Object_Protected_Data *clip;
index 1305ee3..50234f9 100644 (file)
@@ -1301,6 +1301,18 @@ _efl_canvas_object_efl_gfx_entity_size_set(Eo *eo_obj, Evas_Object_Protected_Dat
    Eina_Bool source_invisible = EINA_FALSE;
    Eina_List *was = NULL;
 
+   if (obj->cur->have_clipees)
+     {
+        const Eina_List *l;
+        Evas_Object_Protected_Data *clipee;
+
+        EINA_LIST_FOREACH(obj->clip.clipees, l, clipee)
+          {
+             if (clipee->cur->has_fixed_size)
+               ERR("resizing static clipper! this is a bug!!!!");
+          }
+     }
+
    if (sz.w < 0) sz.w = 0;
    if (sz.h < 0) sz.h = 0;
 
index 15e50b7..9cfb450 100755 (executable)
@@ -1087,6 +1087,7 @@ struct _Evas_Object_Protected_State
    Eina_Bool             anti_alias : 1;
    Eina_Bool             valid_bounding_box : 1;
    Eina_Bool             snapshot : 1;
+   Eina_Bool             has_fixed_size : 1;
 };
 
 struct _Evas_Object_Pointer_Data {