// drop any surface cache attached to it.
Evas_Object_Protected_Data *eobj = efl_data_scope_get(obj, EFL_CANVAS_OBJECT_CLASS);
eobj->layer->evas->engine.func->ector_surface_cache_drop(_evas_engine_context(eobj->layer->evas),
- pd->user_entry);
+ pd->cache_key);
free(pd->user_entry);
pd->user_entry = NULL;
}
evas_common_draw_context_free(context);
if (buffer_created)
- obj->layer->evas->engine.func->ector_surface_cache_set(engine, key, buffer);
+ {
+ pd->cache_key = key;
+ obj->layer->evas->engine.func->ector_surface_cache_set(engine, key, buffer);
+ }
return buffer;
}
}
root = evas_cache_vg_tree_get(vg_entry, pd->frame_index);
if (!root) return;
- buffer = obj->layer->evas->engine.func->ector_surface_cache_get(engine, root);
+ buffer = obj->layer->evas->engine.func->ector_surface_cache_get(engine, pd->cache_key);
// if the buffer is not created yet
if (!buffer)
do_async);
}
else
- obj->layer->evas->engine.func->ector_surface_cache_drop(engine, root);
+ obj->layer->evas->engine.func->ector_surface_cache_drop(engine, pd->cache_key);
_render_buffer_to_screen(obj,
engine, output, context, surface,
Vg_User_Entry *user_entry = pd->user_entry;
void *buffer;
- // if the size dosen't match
+ //if the size dosen't match
if ((user_entry->w != w ) ||
(user_entry->h != h))
{
user_entry->h = h;
pd->user_entry = user_entry;
}
- // if the buffer is not created yet
- buffer = obj->layer->evas->engine.func->ector_surface_cache_get(engine, user_entry);
+
+ //if the buffer is not created yet
+ buffer = obj->layer->evas->engine.func->ector_surface_cache_get(engine, pd->cache_key);
if (!buffer)
{
// render to the buffer
user_entry,
buffer,
do_async);
- obj->layer->evas->engine.func->ector_surface_cache_drop(engine, user_entry);
+ obj->layer->evas->engine.func->ector_surface_cache_drop(engine, pd->cache_key);
}
_render_buffer_to_screen(obj,
int frame_index)
{
//TODO: Validate frame_index range
-
if (pd->frame_index == frame_index) return EINA_TRUE;
+ //Image is changed, drop previous cached image.
+ pd->cache_key = NULL;
pd->frame_index = frame_index;
pd->changed = EINA_TRUE;
evas_object_change(eo_obj, efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS));
#include "evas_common_private.h"
+#define LRU_CACHE_LIMIT 50
+
EAPI Generic_Cache*
generic_cache_new(void *user_data, Generic_Cache_Free func)
{
eina_hash_add(cache->hash, &key, entry);
cache->lru_list = eina_list_prepend(cache->lru_list, entry);
count = eina_list_count(cache->lru_list);
- if (count > 50)
+ if (count > LRU_CACHE_LIMIT)
{
entry = eina_list_data_get(eina_list_last(cache->lru_list));
- // if its still being ref.
- if (entry->ref) return;
eina_hash_del(cache->hash, &entry->key, entry);
cache->lru_list = eina_list_remove_list(cache->lru_list, eina_list_last(cache->lru_list));
cache->free_func(cache->user_data, entry->data);
entry = eina_hash_find(cache->hash, &key);
if (entry)
{
- // update the ref
- entry->ref += 1;
- // promote in lru
+ ++entry->ref;
+
+ //promote in lru
EINA_LIST_FOREACH(cache->lru_list, l, lru_data)
{
if (lru_data == entry)
entry = eina_hash_find(cache->hash, &key);
if (entry)
{
- entry->ref -= 1;
- // if its still being ref.
- if (entry->ref) return;
+ if (--entry->ref > 0) return;
+
eina_hash_del(cache->hash, &entry->key, entry);
// find and remove from lru list
cache->lru_list = eina_list_remove(cache->lru_list, entry);