evas: reduce useless allocation during destruction of image.
authorCedric BAIL <cedric.bail@free.fr>
Fri, 6 Dec 2019 00:35:23 +0000 (16:35 -0800)
committerJongmin Lee <jm105.lee@samsung.com>
Wed, 11 Dec 2019 21:23:08 +0000 (06:23 +0900)
Evas image use a GC to reduce duplicated state accross multiple object.
Still during shutdown we do clean it up and free it. There is no point
to push that down the GC if we are to just free it after. Relying on
the fact that dynamic content will avoid triggering the GC altogether
as their content change to frequently and is expected to be uniq among
other objects, we can avoid unecessary allocation during the destruction
by just switching that early on during the destructor.

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10815

src/lib/evas/canvas/evas_object_image.c

index 9764db9..2dbcd99 100755 (executable)
@@ -1704,10 +1704,13 @@ evas_object_image_init(Evas_Object *eo_obj)
 }
 
 EOLIAN static void
-_efl_canvas_image_internal_efl_object_destructor(Eo *eo_obj, Evas_Image_Data *o EINA_UNUSED)
+_efl_canvas_image_internal_efl_object_destructor(Eo *eo_obj, Evas_Image_Data *o)
 {
    Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
 
+   // To avoid unecessary GC storage triggered during shutdown, we mark the content as dynamic
+   o->content_hint = EFL_GFX_IMAGE_CONTENT_HINT_DYNAMIC;
+
    if (obj->legacy.ctor)
      evas_object_image_video_surface_set(eo_obj, NULL);
    efl_gfx_image_stretch_region_set(eo_obj, NULL, NULL);