summaryrefslogtreecommitdiff
path: root/src/lib/evas/vg/evas_vg_cache.c
diff options
context:
space:
mode:
authorHermet Park <hermetpark@gmail.com>2019-11-18 11:48:40 +0900
committerHermet Park <hermetpark@gmail.com>2019-11-18 13:08:29 +0900
commit618bce8038b6362c0de232498566ecf97dc2d17e (patch)
tree2ad84932aa737f65b611772daa7d7fa622db6864 /src/lib/evas/vg/evas_vg_cache.c
parent98a3dcd94e43e7d172d1609523467edcaed02c1c (diff)
evas vg: improve caching methods for better precise behaviors.
Previously, json file data won't be shared between instances. Now, objects can share the json data if they use the same file resource.
Diffstat (limited to 'src/lib/evas/vg/evas_vg_cache.c')
-rw-r--r--src/lib/evas/vg/evas_vg_cache.c76
1 files changed, 35 insertions, 41 deletions
diff --git a/src/lib/evas/vg/evas_vg_cache.c b/src/lib/evas/vg/evas_vg_cache.c
index 8ffdfab3f8..68d4e7a634 100644
--- a/src/lib/evas/vg/evas_vg_cache.c
+++ b/src/lib/evas/vg/evas_vg_cache.c
@@ -83,7 +83,9 @@ _vg_load_from_file(const Eina_File *file, const char *key)
83 if (em) 83 if (em)
84 { 84 {
85 loader = em->functions; 85 loader = em->functions;
86 vfd = loader->file_open((Eina_File *) file, key, &error); 86 {
87 vfd = loader->file_open((Eina_File *) file, key, &error);
88 }
87 if (vfd) 89 if (vfd)
88 { 90 {
89 vfd->loader = loader; 91 vfd->loader = loader;
@@ -153,18 +155,13 @@ _evas_cache_vg_entry_free_cb(void *data)
153 155
154 if (vg_entry->vfd->ref <= 0) 156 if (vg_entry->vfd->ref <= 0)
155 { 157 {
156 if (vg_entry->vfd->no_share) 158 Eina_Strbuf *hash_key = eina_strbuf_new();
157 vg_entry->vfd->loader->file_close(vg_entry->vfd); 159 eina_strbuf_append_printf(hash_key, "%s/%s",
158 else 160 eina_file_filename_get(vg_entry->file),
159 { 161 vg_entry->key);
160 Eina_Strbuf *hash_key = eina_strbuf_new(); 162 if (!eina_hash_del(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key), vg_entry->vfd))
161 eina_strbuf_append_printf(hash_key, "%s/%s", 163 ERR("Failed to delete vfd = (%p) from hash", vg_entry->vfd);
162 eina_file_filename_get(vg_entry->file), 164 eina_strbuf_free(hash_key);
163 vg_entry->key);
164 if (!eina_hash_del(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key), vg_entry->vfd))
165 ERR("Failed to delete vfd = (%p) from hash", vg_entry->vfd);
166 eina_strbuf_free(hash_key);
167 }
168 } 165 }
169 } 166 }
170 167
@@ -235,7 +232,7 @@ _cached_root_get(Vg_Cache_Entry *vg_entry, unsigned int frame_num)
235 return NULL; 232 return NULL;
236} 233}
237 234
238static void 235static Efl_VG *
239_caching_root_update(Vg_Cache_Entry *vg_entry) 236_caching_root_update(Vg_Cache_Entry *vg_entry)
240{ 237{
241 Vg_File_Data *vfd = vg_entry->vfd; 238 Vg_File_Data *vfd = vg_entry->vfd;
@@ -251,33 +248,31 @@ _caching_root_update(Vg_Cache_Entry *vg_entry)
251 to this root pointer. */ 248 to this root pointer. */
252 vg_entry->root[0] = efl_duplicate(vfd->root); 249 vg_entry->root[0] = efl_duplicate(vfd->root);
253 } 250 }
254 else if (vg_entry->root[0] != vfd->root) 251 else
255 { 252 {
256 if (vg_entry->root[0]) efl_unref(vg_entry->root[0]); 253 if (vg_entry->root[0]) efl_unref(vg_entry->root[0]);
257 vg_entry->root[0] = efl_ref(vfd->root); 254 vg_entry->root[0] = efl_duplicate(vfd->root);
258 }
259
260 //Animatable?
261 if (!vfd->anim_data) return;
262 255
263 //Start frame 256 //Animatable?
264 if (vfd->anim_data->frame_num == 0) 257 if (vfd->anim_data)
265 {
266 if (vg_entry->root[1] != vfd->root)
267 { 258 {
268 if (vg_entry->root[1]) efl_unref(vg_entry->root[1]); 259 //Start frame
269 vg_entry->root[1] = efl_ref(vfd->root); 260 if (vfd->anim_data->frame_num == 0)
270 } 261 {
271 } 262 if (vg_entry->root[1]) efl_unref(vg_entry->root[1]);
272 //End frame 263 vg_entry->root[1] = efl_duplicate(vfd->root);
273 else if (vfd->anim_data->frame_num == (vfd->anim_data->frame_cnt - 1)) 264 return vg_entry->root[1];
274 { 265 }
275 if (vg_entry->root[2] != vfd->root) 266 //End frame
276 { 267 else if (vfd->anim_data->frame_num == (vfd->anim_data->frame_cnt - 1))
277 if (vg_entry->root[2]) efl_unref(vg_entry->root[2]); 268 {
278 vg_entry->root[2] = efl_ref(vfd->root); 269 if (vg_entry->root[2]) efl_unref(vg_entry->root[2]);
270 vg_entry->root[2] = efl_duplicate(vfd->root);
271 return vg_entry->root[2];
272 }
279 } 273 }
280 } 274 }
275 return vg_entry->root[0];
281} 276}
282 277
283static void 278static void
@@ -351,12 +346,11 @@ evas_cache_vg_file_open(const Eina_File *file, const char *key)
351 hash_key = eina_strbuf_new(); 346 hash_key = eina_strbuf_new();
352 eina_strbuf_append_printf(hash_key, "%s/%s", eina_file_filename_get(file), key); 347 eina_strbuf_append_printf(hash_key, "%s/%s", eina_file_filename_get(file), key);
353 vfd = eina_hash_find(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key)); 348 vfd = eina_hash_find(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key));
354 if (!vfd || vfd->no_share) 349 if (!vfd)
355 { 350 {
356 vfd = _vg_load_from_file(file, key); 351 vfd = _vg_load_from_file(file, key);
357 //File exists. 352 //File exists.
358 if (vfd && !vfd->no_share) 353 if (vfd) eina_hash_add(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key), vfd);
359 eina_hash_add(vg_cache->vfd_hash, eina_strbuf_string_get(hash_key), vfd);
360 } 354 }
361 eina_strbuf_free(hash_key); 355 eina_strbuf_free(hash_key);
362 return vfd; 356 return vfd;
@@ -507,11 +501,11 @@ evas_cache_vg_tree_get(Vg_Cache_Entry *vg_entry, unsigned int frame_num)
507 501
508 if (!vfd->loader->file_data(vfd)) return NULL; 502 if (!vfd->loader->file_data(vfd)) return NULL;
509 503
510 _caching_root_update(vg_entry); 504 root = _caching_root_update(vg_entry);
511 505
512 _local_transform(vg_entry->root[0], vg_entry->w, vg_entry->h, vfd); 506 _local_transform(root, vg_entry->w, vg_entry->h, vfd);
513 507
514 return vg_entry->root[0]; 508 return root;
515} 509}
516 510
517void 511void