summaryrefslogtreecommitdiff
path: root/src/lib/evas/vg/evas_vg_cache.c
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2019-03-12 12:53:35 +0900
committerHermet Park <hermetpark@gmail.com>2019-03-12 12:58:31 +0900
commitd45e3df689d39c572786385a79e8fceded2dfdc6 (patch)
tree36ca873537b3ef8ea06452f7d6438bdda6018368 /src/lib/evas/vg/evas_vg_cache.c
parent305749f049ceb73071febe2ac723dadff7b69dbc (diff)
evas vg: replace to eina_file instance caching by vg.
Here is a replacement to use eina_file from a vg obj instance to map file data by vg loaders. This brings a benefit that integrated access to load data between vg object and vg loaders.
Diffstat (limited to 'src/lib/evas/vg/evas_vg_cache.c')
-rw-r--r--src/lib/evas/vg/evas_vg_cache.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/lib/evas/vg/evas_vg_cache.c b/src/lib/evas/vg/evas_vg_cache.c
index 6022982557..534dca2748 100644
--- a/src/lib/evas/vg/evas_vg_cache.c
+++ b/src/lib/evas/vg/evas_vg_cache.c
@@ -70,7 +70,7 @@ _find_loader_module(const char *file)
70} 70}
71 71
72static Vg_File_Data * 72static Vg_File_Data *
73_vg_load_from_file(const char *file, const char *key) 73_vg_load_from_file(const Eina_File *file, const char *key)
74{ 74{
75 Evas_Module *em; 75 Evas_Module *em;
76 Evas_Vg_Load_Func *loader; 76 Evas_Vg_Load_Func *loader;
@@ -78,11 +78,12 @@ _vg_load_from_file(const char *file, const char *key)
78 Vg_File_Data *vfd; 78 Vg_File_Data *vfd;
79 unsigned int i; 79 unsigned int i;
80 80
81 em = _find_loader_module(file); 81 const char *file_name = eina_file_filename_get(file);
82 em = _find_loader_module(file_name);
82 if (em) 83 if (em)
83 { 84 {
84 loader = em->functions; 85 loader = em->functions;
85 vfd = loader->file_open(file, key, &error); 86 vfd = loader->file_open((Eina_File *) file, key, &error);
86 if (vfd) 87 if (vfd)
87 { 88 {
88 vfd->loader = loader; 89 vfd->loader = loader;
@@ -97,7 +98,8 @@ _vg_load_from_file(const char *file, const char *key)
97 if (em) 98 if (em)
98 { 99 {
99 loader = em->functions; 100 loader = em->functions;
100 vfd = loader->file_open(file, key, &error); 101 vfd = loader->file_open((Eina_File *) file, key, &error);
102 if (vfd)
101 { 103 {
102 vfd->loader = loader; 104 vfd->loader = loader;
103 return vfd; 105 return vfd;
@@ -105,7 +107,7 @@ _vg_load_from_file(const char *file, const char *key)
105 } 107 }
106 } 108 }
107 } 109 }
108 WRN("Exhausted all means to load vector file = %s", file); 110 WRN("Exhausted all means to load vector file = %s", file_name);
109 return NULL; 111 return NULL;
110} 112}
111 113
@@ -148,11 +150,12 @@ _evas_cache_vg_entry_free_cb(void *data)
148 if (vg_entry->vfd) 150 if (vg_entry->vfd)
149 { 151 {
150 vg_entry->vfd->ref--; 152 vg_entry->vfd->ref--;
153
151 if (vg_entry->vfd->ref <= 0) 154 if (vg_entry->vfd->ref <= 0)
152 { 155 {
153 Eina_Strbuf *hash_key = eina_strbuf_new(); 156 Eina_Strbuf *hash_key = eina_strbuf_new();
154 eina_strbuf_append_printf(hash_key, "%s/%s", 157 eina_strbuf_append_printf(hash_key, "%s/%s",
155 vg_entry->file, 158 eina_file_filename_get(vg_entry->file),
156 vg_entry->key); 159 vg_entry->key);
157 if (!eina_hash_del(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key), vg_entry->vfd)) 160 if (!eina_hash_del(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key), vg_entry->vfd))
158 ERR("Failed to delete vfd = (%p) from hash", vg_entry->vfd); 161 ERR("Failed to delete vfd = (%p) from hash", vg_entry->vfd);
@@ -283,13 +286,13 @@ evas_cache_vg_shutdown(void)
283} 286}
284 287
285Vg_File_Data * 288Vg_File_Data *
286evas_cache_vg_file_open(const char *file, const char *key) 289evas_cache_vg_file_open(const Eina_File *file, const char *key)
287{ 290{
288 Vg_File_Data *vfd; 291 Vg_File_Data *vfd;
289 Eina_Strbuf *hash_key; 292 Eina_Strbuf *hash_key;
290 293
291 hash_key = eina_strbuf_new(); 294 hash_key = eina_strbuf_new();
292 eina_strbuf_append_printf(hash_key, "%s/%s", file, key); 295 eina_strbuf_append_printf(hash_key, "%s/%s", eina_file_filename_get(file), key);
293 vfd = eina_hash_find(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key)); 296 vfd = eina_hash_find(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key));
294 if (!vfd) 297 if (!vfd)
295 { 298 {
@@ -308,7 +311,7 @@ evas_cache_vg_entry_resize(Vg_Cache_Entry *vg_entry, int w, int h)
308} 311}
309 312
310Vg_Cache_Entry* 313Vg_Cache_Entry*
311evas_cache_vg_entry_create(const char *file, 314evas_cache_vg_entry_create(const Eina_File *file,
312 const char *key, 315 const char *key,
313 int w, int h) 316 int w, int h)
314{ 317{
@@ -320,7 +323,7 @@ evas_cache_vg_entry_create(const char *file,
320 //TODO: zero-sized entry is useless. how to skip it? 323 //TODO: zero-sized entry is useless. how to skip it?
321 324
322 hash_key = eina_strbuf_new(); 325 hash_key = eina_strbuf_new();
323 eina_strbuf_append_printf(hash_key, "%s/%s/%d/%d", file, key, w, h); 326 eina_strbuf_append_printf(hash_key, "%p/%s/%d/%d", file, key, w, h);
324 vg_entry = eina_hash_find(vg_cache->vg_entry_hash, eina_strbuf_string_get(hash_key)); 327 vg_entry = eina_hash_find(vg_cache->vg_entry_hash, eina_strbuf_string_get(hash_key));
325 if (!vg_entry) 328 if (!vg_entry)
326 { 329 {
@@ -331,7 +334,7 @@ evas_cache_vg_entry_create(const char *file,
331 eina_strbuf_free(hash_key); 334 eina_strbuf_free(hash_key);
332 return NULL; 335 return NULL;
333 } 336 }
334 vg_entry->file = eina_stringshare_add(file); 337 vg_entry->file = file;
335 vg_entry->key = eina_stringshare_add(key); 338 vg_entry->key = eina_stringshare_add(key);
336 vg_entry->w = w; 339 vg_entry->w = w;
337 vg_entry->h = h; 340 vg_entry->h = h;