summaryrefslogtreecommitdiff
path: root/src/lib/evas/vg/evas_vg_cache.c
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2019-12-13 17:22:54 +0900
committerHermet Park <hermetpark@gmail.com>2019-12-13 17:25:26 +0900
commit4f99f9f2bf17b437aa975c3875812529c2759707 (patch)
tree755ec556d70a8babf43433fb1786473f23d6bdd2 /src/lib/evas/vg/evas_vg_cache.c
parent3372a701d301fef9b1d033b97df0f38de130456f (diff)
evas vg: revise buffer caching method.
for better precise buffer cache key, We make a unique key name combining root node + size + frame index. Now, we can reuse the root node for animation and caching buffers.
Diffstat (limited to 'src/lib/evas/vg/evas_vg_cache.c')
-rw-r--r--src/lib/evas/vg/evas_vg_cache.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lib/evas/vg/evas_vg_cache.c b/src/lib/evas/vg/evas_vg_cache.c
index 5c0242db23..2ef31bded2 100644
--- a/src/lib/evas/vg/evas_vg_cache.c
+++ b/src/lib/evas/vg/evas_vg_cache.c
@@ -269,12 +269,45 @@ evas_cache_vg_init(void)
269 vg_cache->ref++; 269 vg_cache->ref++;
270} 270}
271 271
272void *
273evas_cache_vg_surface_key_get(Efl_Canvas_Vg_Node *root, int w, int h, int frame_idx)
274{
275 //This make a unique key pointer by arguments.
276 Eina_Strbuf *hash_key = eina_strbuf_new();
277 eina_strbuf_append_printf(hash_key, "%p/%d/%d/%d", root, w, h, frame_idx);
278 const char *new_key = eina_strbuf_string_get(hash_key);
279 if (!new_key) return NULL;
280
281 Eina_List *l;
282 char *key;
283 EINA_LIST_FOREACH(vg_cache->vg_surface_keys, l, key)
284 {
285 //Exisiting key!
286 if (!strcmp(key, new_key))
287 {
288 eina_strbuf_free(hash_key);
289 return key;
290 }
291 }
292
293 //New key comes.
294 key = eina_strbuf_string_steal(hash_key);
295 vg_cache->vg_surface_keys = eina_list_append(vg_cache->vg_surface_keys, key);
296 return (void *) key;
297}
298
272void 299void
273evas_cache_vg_shutdown(void) 300evas_cache_vg_shutdown(void)
274{ 301{
275 if (!vg_cache) return; 302 if (!vg_cache) return;
276 vg_cache->ref--; 303 vg_cache->ref--;
277 if (vg_cache->ref > 0) return; 304 if (vg_cache->ref > 0) return;
305
306 char *key;
307 EINA_LIST_FREE(vg_cache->vg_surface_keys, key)
308 free(key);
309 eina_list_free(vg_cache->vg_surface_keys);
310
278 eina_hash_free(vg_cache->vfd_hash); 311 eina_hash_free(vg_cache->vfd_hash);
279 eina_hash_free(vg_cache->vg_entry_hash); 312 eina_hash_free(vg_cache->vg_entry_hash);
280 free(vg_cache); 313 free(vg_cache);