hermet pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=53991e0ef6efdbf7df2919bad75618cfbea85105

commit 53991e0ef6efdbf7df2919bad75618cfbea85105
Author: JunsuChoi <[email protected]>
Date:   Tue Jun 9 10:57:20 2020 +0900

    evas_vg_cache: Don't caching vg file if value_provider is applied.
    
    Summary:
    value_provider can change the value of the property received from VG file.
    When a file is cached, the changed properties are applied to all other 
objects using the same file.
    So. If value provider is applied, evas_vg_cache is not caching vg file.
    
    Test Plan: N/A
    
    Reviewers: Hermet, herb, kimcinoo
    
    Reviewed By: Hermet
    
    Subscribers: cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D11924
---
 src/lib/evas/canvas/evas_vg_private.h |  2 +-
 src/lib/evas/include/evas_private.h   |  2 ++
 src/lib/evas/vg/evas_vg_cache.c       | 52 +++++++++++++++++++++++------------
 3 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/src/lib/evas/canvas/evas_vg_private.h 
b/src/lib/evas/canvas/evas_vg_private.h
index c20ed2a1eb..aba4e9d27b 100644
--- a/src/lib/evas/canvas/evas_vg_private.h
+++ b/src/lib/evas/canvas/evas_vg_private.h
@@ -137,7 +137,7 @@ Vg_Cache_Entry*             evas_cache_vg_entry_create(Evas 
*evas, const Eina_Fi
 Efl_VG*                     evas_cache_vg_tree_get(Vg_Cache_Entry *vg_entry, 
unsigned int frame_num);
 void                        
evas_cache_vg_entry_value_provider_update(Vg_Cache_Entry *vg_entry, Eina_List 
*vp_list);
 void                        evas_cache_vg_entry_del(Vg_Cache_Entry *vg_entry);
-Vg_File_Data *              evas_cache_vg_file_open(const Eina_File *file, 
const char *key, Evas *e);
+Vg_File_Data *              evas_cache_vg_file_open(const Eina_File *file, 
const char *key, Evas *e, Eina_Bool shareable);
 Eina_Bool                   evas_cache_vg_file_save(Efl_VG *root, int w, int 
h, const char *file, const char *key, const Efl_File_Save_Info *info);
 Eina_Bool                   evas_cache_vg_entry_file_save(Vg_Cache_Entry 
*vg_entry, const char *file, const char *key, const Efl_File_Save_Info *info);
 double                      evas_cache_vg_anim_duration_get(const 
Vg_Cache_Entry *vg_entry);
diff --git a/src/lib/evas/include/evas_private.h 
b/src/lib/evas/include/evas_private.h
index 6d00cd7a21..147e2ae0d1 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1140,6 +1140,8 @@ struct _Vg_File_Data
 
    Eina_Bool       static_viewbox: 1;
    Eina_Bool       preserve_aspect : 1;    //Used in SVG
+
+   Eina_Bool       shareable: 1;
 };
 
 struct _Evas_Vg_Load_Func
diff --git a/src/lib/evas/vg/evas_vg_cache.c b/src/lib/evas/vg/evas_vg_cache.c
index 86c23dfb31..3b3bfaeb96 100644
--- a/src/lib/evas/vg/evas_vg_cache.c
+++ b/src/lib/evas/vg/evas_vg_cache.c
@@ -153,14 +153,21 @@ _evas_cache_vg_entry_free_cb(void *data)
 
         if (vg_entry->vfd->ref <= 0)
           {
-             Eina_Strbuf *hash_key = eina_strbuf_new();
-             eina_strbuf_append_printf(hash_key, "%s/%s/%p",
-                                       eina_file_filename_get(vg_entry->file),
-                                       vg_entry->key,
-                                       vg_entry->evas);
-             if (!eina_hash_del(vg_cache->vfd_hash, 
eina_strbuf_string_get(hash_key), vg_entry->vfd))
-               ERR("Failed to delete vfd = (%p) from hash", vg_entry->vfd);
-             eina_strbuf_free(hash_key);
+             if (vg_entry->vfd->shareable)
+               {
+                  Eina_Strbuf *hash_key = eina_strbuf_new();
+                  eina_strbuf_append_printf(hash_key, "%s/%s/%p",
+                                            
eina_file_filename_get(vg_entry->file),
+                                            vg_entry->key,
+                                            vg_entry->evas);
+                  if (!eina_hash_del(vg_cache->vfd_hash, 
eina_strbuf_string_get(hash_key), vg_entry->vfd))
+                    ERR("Failed to delete vfd = (%p) from hash", 
vg_entry->vfd);
+                  eina_strbuf_free(hash_key);
+               }
+             else
+               {
+                  vg_entry->vfd->loader->file_close(vg_entry->vfd);
+               }
           }
      }
 
@@ -322,21 +329,29 @@ evas_cache_vg_shutdown(void)
 }
 
 Vg_File_Data *
-evas_cache_vg_file_open(const Eina_File *file, const char *key, Evas *e)
+evas_cache_vg_file_open(const Eina_File *file, const char *key, Evas *e, 
Eina_Bool shareable)
 {
    Vg_File_Data *vfd;
    Eina_Strbuf *hash_key;
 
-   hash_key = eina_strbuf_new();
-   eina_strbuf_append_printf(hash_key, "%s/%s/%p", 
eina_file_filename_get(file), key, e);
-   vfd = eina_hash_find(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key));
-   if (!vfd)
+   if (shareable)
+     {
+        hash_key = eina_strbuf_new();
+        eina_strbuf_append_printf(hash_key, "%s/%s/%p", 
eina_file_filename_get(file), key, e);
+        vfd = eina_hash_find(vg_cache->vfd_hash, 
eina_strbuf_string_get(hash_key));
+        if (!vfd)
+          {
+             vfd = _vg_load_from_file(file, key);
+             //File exists.
+             if (vfd) eina_hash_add(vg_cache->vfd_hash, 
eina_strbuf_string_get(hash_key), vfd);
+          }
+        eina_strbuf_free(hash_key);
+     }
+   else
      {
         vfd = _vg_load_from_file(file, key);
-        //File exists.
-        if (vfd) eina_hash_add(vg_cache->vfd_hash, 
eina_strbuf_string_get(hash_key), vfd);
      }
-   eina_strbuf_free(hash_key);
+   if (vfd) vfd->shareable = shareable;
    return vfd;
 }
 
@@ -380,7 +395,7 @@ evas_cache_vg_entry_create(Evas *evas,
      }
    eina_strbuf_free(hash_key);
    vg_entry->ref++;
-   vg_entry->vfd = evas_cache_vg_file_open(file, key, vg_entry->evas);
+   vg_entry->vfd = evas_cache_vg_file_open(file, key, vg_entry->evas, vp_list 
? EINA_FALSE : EINA_TRUE);
    //No File??
    if (!vg_entry->vfd)
      {
@@ -536,7 +551,8 @@ Eina_Bool
 evas_cache_vg_entry_file_save(Vg_Cache_Entry *vg_entry, const char *file, 
const char *key, const Efl_File_Save_Info *info)
 {
    Vg_File_Data *vfd =
-      evas_cache_vg_file_open(vg_entry->file, vg_entry->key, vg_entry->evas);
+      evas_cache_vg_file_open(vg_entry->file, vg_entry->key, vg_entry->evas
+                              ,vg_entry->vfd ? (vg_entry->vfd->vp_list ? 
EINA_FALSE : EINA_TRUE): EINA_TRUE);
 
    if (!vfd) return EINA_FALSE;
 

-- 


Reply via email to