summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas
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/canvas
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/canvas')
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_object.c58
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg_object.eo1
-rw-r--r--src/lib/evas/canvas/evas_vg_private.h7
3 files changed, 45 insertions, 21 deletions
diff --git a/src/lib/evas/canvas/efl_canvas_vg_object.c b/src/lib/evas/canvas/efl_canvas_vg_object.c
index abff8069aa..9fc2d5e6f8 100644
--- a/src/lib/evas/canvas/efl_canvas_vg_object.c
+++ b/src/lib/evas/canvas/efl_canvas_vg_object.c
@@ -245,25 +245,54 @@ _efl_canvas_vg_object_viewbox_align_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Vg
245} 245}
246 246
247EOLIAN static Eina_Error 247EOLIAN static Eina_Error
248_efl_canvas_vg_object_efl_file_load(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd) 248_efl_canvas_vg_object_efl_file_file_set(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd EINA_UNUSED, const char *file)
249{ 249{
250 Vg_Cache_Entry *old_entry; 250 /* Careful: delete previous vg entry.
251 const char *file; 251 When a new efl file is set, ex-file will be invalid.
252 Since vg cache hashes all file entries,
253 we must remove it from vg cache before we lost file handle. */
254 if (efl_file_loaded_get(eo_obj))
255 {
256 const char *pname = efl_file_get(eo_obj);
257 int pl = pname ? strlen(pname) : 0;
258 int cl = file ? strlen(file) : 0;
259
260 if ((pl != cl) || strcmp(pname, file))
261 {
262 Evas_Object_Protected_Data *obj;
263 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
264 evas_cache_vg_entry_del(pd->vg_entry);
265 evas_object_change(eo_obj, obj);
266 pd->vg_entry = NULL;
267 evas_object_change(eo_obj, obj);
268 }
269 }
252 270
253 file = efl_file_get(eo_obj); 271 Eina_Error err;
254 if (!file) return ENOENT; 272 err = efl_file_set(efl_super(eo_obj, MY_CLASS), file);
273 if (err) return err;
255 274
256 old_entry = pd->vg_entry; 275 return 0;
276}
257 277
278EOLIAN static Eina_Error
279_efl_canvas_vg_object_efl_file_load(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd)
280{
281 Eina_Error err;
282 if (efl_file_loaded_get(eo_obj)) return 0;
283
284 err = efl_file_load(efl_super(eo_obj, MY_CLASS));
285 if (err) return err;
286
287 const Eina_File *file = efl_file_mmap_get(eo_obj);
288 const char *key = efl_file_key_get(eo_obj);
258 Evas_Object_Protected_Data *obj; 289 Evas_Object_Protected_Data *obj;
259 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
260 290
261 pd->vg_entry = evas_cache_vg_entry_create(file, efl_file_key_get(eo_obj), 291 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
292 pd->vg_entry = evas_cache_vg_entry_create(file, key,
262 obj->cur->geometry.w, 293 obj->cur->geometry.w,
263 obj->cur->geometry.h); 294 obj->cur->geometry.h);
264
265 evas_object_change(eo_obj, obj); 295 evas_object_change(eo_obj, obj);
266 evas_cache_vg_entry_del(old_entry);
267 296
268 return 0; 297 return 0;
269} 298}
@@ -271,18 +300,13 @@ _efl_canvas_vg_object_efl_file_load(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd)
271EOLIAN static void 300EOLIAN static void
272_efl_canvas_vg_object_efl_file_unload(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd) 301_efl_canvas_vg_object_efl_file_unload(Eo *eo_obj, Efl_Canvas_Vg_Object_Data *pd)
273{ 302{
274 Vg_Cache_Entry *old_entry;
275
276 if (!efl_file_loaded_get(eo_obj)) return; 303 if (!efl_file_loaded_get(eo_obj)) return;
277 old_entry = pd->vg_entry;
278 304
279 Evas_Object_Protected_Data *obj; 305 Evas_Object_Protected_Data *obj;
280 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); 306 obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
281 307 evas_cache_vg_entry_del(pd->vg_entry);
282 pd->vg_entry = NULL;
283
284 evas_object_change(eo_obj, obj); 308 evas_object_change(eo_obj, obj);
285 evas_cache_vg_entry_del(old_entry); 309 pd->vg_entry = NULL;
286} 310}
287 311
288EOLIAN static Eina_Bool 312EOLIAN static Eina_Bool
diff --git a/src/lib/evas/canvas/efl_canvas_vg_object.eo b/src/lib/evas/canvas/efl_canvas_vg_object.eo
index f46f32e20c..02562a4f56 100644
--- a/src/lib/evas/canvas/efl_canvas_vg_object.eo
+++ b/src/lib/evas/canvas/efl_canvas_vg_object.eo
@@ -74,6 +74,7 @@ class @beta Efl.Canvas.Vg.Object extends Efl.Canvas.Object implements Efl.File,
74 Efl.Object.destructor; 74 Efl.Object.destructor;
75 Efl.File.load; 75 Efl.File.load;
76 Efl.File.unload; 76 Efl.File.unload;
77 Efl.File.file { set; }
77 Efl.File_Save.save; 78 Efl.File_Save.save;
78 } 79 }
79} 80}
diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h
index 7fb62d4827..f4c47de4bb 100644
--- a/src/lib/evas/canvas/evas_vg_private.h
+++ b/src/lib/evas/canvas/evas_vg_private.h
@@ -19,14 +19,13 @@ typedef struct _Vg_Cache
19typedef struct _Vg_Cache_Entry 19typedef struct _Vg_Cache_Entry
20{ 20{
21 char *hash_key; 21 char *hash_key;
22 Eina_Stringshare *file; 22 const Eina_File *file;
23 Eina_Stringshare *key; 23 Eina_Stringshare *key;
24 int w; 24 int w;
25 int h; 25 int h;
26 Efl_VG *root; 26 Efl_VG *root;
27 int ref; 27 int ref;
28 Vg_File_Data *vfd; 28 Vg_File_Data *vfd;
29
30} Vg_Cache_Entry; 29} Vg_Cache_Entry;
31 30
32// holds the vg tree info set by the user 31// holds the vg tree info set by the user
@@ -119,10 +118,10 @@ struct _Efl_Canvas_Vg_Interpolation
119void evas_cache_vg_init(void); 118void evas_cache_vg_init(void);
120void evas_cache_vg_shutdown(void); 119void evas_cache_vg_shutdown(void);
121Vg_Cache_Entry* evas_cache_vg_entry_resize(Vg_Cache_Entry *entry, int w, int h); 120Vg_Cache_Entry* evas_cache_vg_entry_resize(Vg_Cache_Entry *entry, int w, int h);
122Vg_Cache_Entry* evas_cache_vg_entry_create(const char *file, const char *key, int w, int h); 121Vg_Cache_Entry* evas_cache_vg_entry_create(const Eina_File *file, const char *key, int w, int h);
123Efl_VG* evas_cache_vg_tree_get(Vg_Cache_Entry *vg_entry); 122Efl_VG* evas_cache_vg_tree_get(Vg_Cache_Entry *vg_entry);
124void evas_cache_vg_entry_del(Vg_Cache_Entry *vg_entry); 123void evas_cache_vg_entry_del(Vg_Cache_Entry *vg_entry);
125Vg_File_Data * evas_cache_vg_file_open(const char *file, const char *key); 124Vg_File_Data * evas_cache_vg_file_open(const Eina_File *file, const char *key);
126Eina_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); 125Eina_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);
127Eina_Bool evas_cache_vg_entry_file_save(Vg_Cache_Entry *vg_entry, const char *file, const char *key, const Efl_File_Save_Info *info); 126Eina_Bool evas_cache_vg_entry_file_save(Vg_Cache_Entry *vg_entry, const char *file, const char *key, const Efl_File_Save_Info *info);
128void efl_canvas_vg_node_vg_obj_set(Efl_VG *node, Efl_VG *vg_obj, Efl_Canvas_Vg_Object_Data *vd); 127void efl_canvas_vg_node_vg_obj_set(Efl_VG *node, Efl_VG *vg_obj, Efl_Canvas_Vg_Object_Data *vd);