canvas vg: drop vg cache buffers if object were destroyed.

Previous vg didn't take care of cached buffers which were
allocated in it's lifetime because the cache buffers are managed
by its own cache buffer mgr, it has a limitation count of buffers also
buffers can be cleared when engine is shutdown.

This behavior is actually working properly but not well optimized
since it lost a chance to clear grown buffers.

Now vg do clear used buffers when object is invalidated.
This commit is contained in:
Hermet Park 2020-03-23 14:16:48 +09:00
parent e1e7272d89
commit 69fd72af2c
2 changed files with 27 additions and 1 deletions

View File

@ -352,6 +352,15 @@ _efl_canvas_vg_object_efl_object_invalidate(Eo *eo_obj, Efl_Canvas_Vg_Object_Dat
free(pd->user_entry);
}
pd->user_entry = NULL;
//Drop cache buffers
if (pd->vg_entry)
{
if (pd->ckeys[0])
ENFN->ector_surface_cache_drop(_evas_engine_context(obj->layer->evas), pd->ckeys[0]);
if (pd->ckeys[1])
ENFN->ector_surface_cache_drop(_evas_engine_context(obj->layer->evas), pd->ckeys[1]);
}
evas_cache_vg_entry_del(pd->vg_entry);
efl_invalidate(efl_super(eo_obj, MY_CLASS));
@ -541,7 +550,23 @@ _render_to_buffer(Evas_Object_Protected_Data *obj, Efl_Canvas_Vg_Object_Data *pd
evas_common_draw_context_free(context);
if (buffer_created && ckey)
ENFN->ector_surface_cache_set(engine, ckey, buffer);
{
//Drop ex invalid cache buffers.
if (pd->frame_idx == 0 && ckey != pd->ckeys[0])
{
if (pd->ckeys[0])
ENFN->ector_surface_cache_drop(engine, ckey);
pd->ckeys[0] = ckey;
}
else if (pd->frame_idx == (int) (evas_cache_vg_anim_frame_count_get(pd->vg_entry) - 1)
&& ckey != pd->ckeys[1])
{
if (pd->ckeys[1])
ENFN->ector_surface_cache_drop(engine, ckey);
pd->ckeys[1] = ckey;
}
ENFN->ector_surface_cache_set(engine, ckey, buffer);
}
return buffer;
}

View File

@ -53,6 +53,7 @@ struct _Efl_Canvas_Vg_Object_Data
double align_x, align_y;
Efl_Canvas_Vg_Fill_Mode fill_mode;
int frame_idx;
void *ckeys[2]; //cache keys for first, last frames if animation
Eina_Bool changed : 1;
};