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.
This commit is contained in:
Hermet Park 2019-01-17 18:00:29 +09:00
parent 346a21ef1c
commit bff0cfd0a4
3 changed files with 6 additions and 3 deletions

View File

@ -1524,6 +1524,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
};

View 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;

View 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;