summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-08-20 15:39:16 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-08-20 15:39:16 +0200
commit67ef1b11ff05a8c09aa6975f29bc28584ce15187 (patch)
tree8b51fd2e18cd9aacf96e162bd0622549a2176988
parenta6c184502eabfdc216f8e6b78ee33fac51b4f598 (diff)
evas: properly fix unref of ector renderer.
Async rendering doesn't have a main loop cleanup function. The only one being called is in the rendering thread. I wrongly assumed in my previous patch that render_post on an object was called after the async render was done which is obviously not the case as pointed by Subhransu. This patch now wait for the async rendering to be done.
-rw-r--r--src/lib/evas/canvas/evas_object_vg.c42
-rw-r--r--src/lib/evas/canvas/evas_vg.eo1
2 files changed, 34 insertions, 9 deletions
diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c
index df4df41bff..628ade6f2c 100644
--- a/src/lib/evas/canvas/evas_object_vg.c
+++ b/src/lib/evas/canvas/evas_object_vg.c
@@ -94,9 +94,29 @@ _evas_vg_root_node_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd)
94 return pd->root; 94 return pd->root;
95} 95}
96 96
97static Eina_Bool
98_cleanup_reference(void *data,
99 Eo *obj EINA_UNUSED,
100 const Eo_Event_Description *desc EINA_UNUSED,
101 void *event_info EINA_UNUSED)
102{
103 Evas_VG_Data *pd = data;
104 Eo *renderer;
105
106 /* unref all renderer and may also destroy them async */
107 while ((renderer = eina_array_pop(&pd->cleanup)))
108 eo_unref(renderer);
109
110 return EO_CALLBACK_CONTINUE;
111}
112
97void 113void
98_evas_vg_eo_base_destructor(Eo *eo_obj, Evas_VG_Data *pd) 114_evas_vg_eo_base_destructor(Eo *eo_obj, Evas_VG_Data *pd)
99{ 115{
116 Evas *e = evas_object_evas_get(eo_obj);
117
118 eo_do(e, eo_event_callback_del(EVAS_CANVAS_EVENT_RENDER_POST, _cleanup_reference, pd));
119
100 eo_unref(pd->root); 120 eo_unref(pd->root);
101 pd->root = NULL; 121 pd->root = NULL;
102 eo_do_super(eo_obj, MY_CLASS, eo_destructor()); 122 eo_do_super(eo_obj, MY_CLASS, eo_destructor());
@@ -123,6 +143,18 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd)
123 return eo_obj; 143 return eo_obj;
124} 144}
125 145
146static Eo_Base *
147_evas_vg_eo_base_finalize(Eo *obj, Evas_VG_Data *pd)
148{
149 Evas *e = evas_object_evas_get(obj);
150
151 // TODO: If we start to have to many Evas_Object_VG per canvas, it may be nice
152 // to actually have one event per canvas and one array per canvas to.
153 eo_do(e, eo_event_callback_add(EVAS_CANVAS_EVENT_RENDER_POST, _cleanup_reference, pd));
154
155 return obj;
156}
157
126static void 158static void
127_evas_vg_render(Evas_Object_Protected_Data *obj, Evas_VG_Data *vd, 159_evas_vg_render(Evas_Object_Protected_Data *obj, Evas_VG_Data *vd,
128 void *output, void *context, void *surface, Efl_VG *n, 160 void *output, void *context, void *surface, Efl_VG *n,
@@ -335,13 +367,8 @@ evas_object_vg_render_pre(Evas_Object *eo_obj,
335static void 367static void
336evas_object_vg_render_post(Evas_Object *eo_obj, 368evas_object_vg_render_post(Evas_Object *eo_obj,
337 Evas_Object_Protected_Data *obj EINA_UNUSED, 369 Evas_Object_Protected_Data *obj EINA_UNUSED,
338 void *type_private_data) 370 void *type_private_data EINA_UNUSED)
339{ 371{
340 Evas_VG_Data *vd = type_private_data;
341 Eo *renderer;
342 Eina_Array_Iterator iterator;
343 unsigned int i;
344
345 /* this moves the current data to the previous state parts of the object */ 372 /* this moves the current data to the previous state parts of the object */
346 /* in whatever way is safest for the object. also if we don't need object */ 373 /* in whatever way is safest for the object. also if we don't need object */
347 /* data anymore we can free it if the object deems this is a good idea */ 374 /* data anymore we can free it if the object deems this is a good idea */
@@ -349,9 +376,6 @@ evas_object_vg_render_post(Evas_Object *eo_obj,
349 evas_object_clip_changes_clean(eo_obj); 376 evas_object_clip_changes_clean(eo_obj);
350 /* move cur to prev safely for object data */ 377 /* move cur to prev safely for object data */
351 evas_object_cur_prev(eo_obj); 378 evas_object_cur_prev(eo_obj);
352 /* unref all renderer and may also destroy them async */
353 EINA_ARRAY_ITER_NEXT((&vd->cleanup), i, renderer, iterator)
354 eo_unref(renderer);
355} 379}
356 380
357static unsigned int 381static unsigned int
diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo
index 9f466d4f1c..6438fe3320 100644
--- a/src/lib/evas/canvas/evas_vg.eo
+++ b/src/lib/evas/canvas/evas_vg.eo
@@ -20,6 +20,7 @@ class Evas.VG (Evas.Object, Efl.Gfx.Fill, Efl.Gfx.View)
20 } 20 }
21 implements { 21 implements {
22 Eo.Base.constructor; 22 Eo.Base.constructor;
23 Eo.Base.finalize;
23 Eo.Base.destructor; 24 Eo.Base.destructor;
24 Efl.Gfx.Fill.fill.set; 25 Efl.Gfx.Fill.fill.set;
25 Efl.Gfx.Fill.fill.get; 26 Efl.Gfx.Fill.fill.get;