evas vg: improve caching mechanism. 67/197967/2
authorHermet Park <hermetpark@gmail.com>
Thu, 17 Jan 2019 09:00:29 +0000 (18:00 +0900)
committerHermet Park <chuneon.park@samsung.com>
Fri, 18 Jan 2019 04:08:18 +0000 (04:08 +0000)
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
src/lib/evas/vg/evas_vg_cache.c
src/modules/evas/vg_loaders/json/evas_vg_load_json.c

index 7790518..4ee0a95 100755 (executable)
@@ -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
 };
index 9928d9a..e2fc174 100644 (file)
@@ -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;
index 0eba824..ef1ebfe 100644 (file)
@@ -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;