From 1d2add804d3ff0b8742513cb19d25fb3178bdfe0 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 17 Jan 2019 18:00:29 +0900 Subject: [PATCH] evas vg: improve caching mechanism. json loader doesn't proper to share the file loader data, since the loader need to track animation frame data. If some instances open a same resource, but have different animation frames, This won't be the best. So, don't share file loader instance by loader demand. Change-Id: If7a86375dc8d669a197c280d9b301f353048c42d --- src/lib/evas/include/evas_private.h | 1 + src/lib/evas/vg/evas_vg_cache.c | 7 ++++--- src/modules/evas/vg_loaders/json/evas_vg_load_json.c | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 7790518..4ee0a95 100755 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1532,6 +1532,7 @@ struct _Vg_File_Data void *loader_data; //loader specific local data + Eina_Bool no_share : 1; //Shareable VFD through multiple file open requests. Eina_Bool static_viewbox: 1; Eina_Bool preserve_aspect : 1; //Used in SVG }; diff --git a/src/lib/evas/vg/evas_vg_cache.c b/src/lib/evas/vg/evas_vg_cache.c index 9928d9a..e2fc174 100644 --- a/src/lib/evas/vg/evas_vg_cache.c +++ b/src/lib/evas/vg/evas_vg_cache.c @@ -150,7 +150,7 @@ _evas_cache_vg_entry_free_cb(void *data) if (vg_entry->vfd) { vg_entry->vfd->ref--; - if (vg_entry->vfd->ref <= 0) + if (vg_entry->vfd->ref <= 0 && !vg_entry->vfd->no_share) { Eina_Strbuf *hash_key = eina_strbuf_new(); eina_strbuf_append_printf(hash_key, "%s/%s", @@ -361,11 +361,12 @@ evas_cache_vg_file_open(const Eina_File *file, const char *key, Eina_Bool mmap) hash_key = eina_strbuf_new(); eina_strbuf_append_printf(hash_key, "%s/%s", eina_file_filename_get(file), key); vfd = eina_hash_find(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key)); - if (!vfd) + if (!vfd || vfd->no_share) { vfd = _vg_load_from_file(file, key, mmap); //File exists. - if (vfd) eina_hash_add(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key), vfd); + if (vfd && !vfd->no_share) + eina_hash_add(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key), vfd); } eina_strbuf_free(hash_key); return vfd; diff --git a/src/modules/evas/vg_loaders/json/evas_vg_load_json.c b/src/modules/evas/vg_loaders/json/evas_vg_load_json.c index 0eba824..ef1ebfe 100644 --- a/src/modules/evas/vg_loaders/json/evas_vg_load_json.c +++ b/src/modules/evas/vg_loaders/json/evas_vg_load_json.c @@ -80,6 +80,7 @@ evas_vg_load_file_open_json(Eina_File *file, vfd->h = (int) h; vfd->loader_data = (void *) lot_anim; + vfd->no_share = EINA_TRUE; return vfd; -- 2.7.4