summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-10-27 14:31:37 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-10-27 14:58:38 +0900
commitec1acca74d2422165d9bb229043922d3f87a8790 (patch)
tree2907bc7a3471a3b5d207ae53a4ce58b1242ab6a0
parent8329c98d5f5c3b3b8c974f39a461ef22f069c174 (diff)
evas vg: Add FIXME and fix strbuf use
This is the result of a really quick review of the new VG code. Most of it was moved around, but this merge includes the following: - Move logic from edje to evas - Create static lib for common VG handling - Add file_set() API - Add a basic VG cache in evas side - Add savers modules, implement loaders and savers.
Diffstat (limited to '')
-rw-r--r--src/bin/edje/edje_cc_out.c19
-rw-r--r--src/lib/edje/edje_calc.c13
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg.c24
-rw-r--r--src/lib/evas/canvas/efl_canvas_vg.eo1
-rw-r--r--src/lib/evas/vg/evas_vg_cache.c1
5 files changed, 30 insertions, 28 deletions
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index 7803f781a8..da36943c4c 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -1267,7 +1267,7 @@ data_write_vectors(Eet_File *ef, int *vector_num)
1267 char *s; 1267 char *s;
1268 Eina_File *f = NULL; 1268 Eina_File *f = NULL;
1269 Edje_Vector_Directory_Entry *vector; 1269 Edje_Vector_Directory_Entry *vector;
1270 char buf[100]; 1270 Eina_Strbuf *buf;
1271 Eina_Bool found = EINA_FALSE; 1271 Eina_Bool found = EINA_FALSE;
1272 Ecore_Evas *ee; 1272 Ecore_Evas *ee;
1273 Evas *evas; 1273 Evas *evas;
@@ -1281,7 +1281,7 @@ data_write_vectors(Eet_File *ef, int *vector_num)
1281 error_and_abort(ef, "Cannot create buffer engine canvas for image load."); 1281 error_and_abort(ef, "Cannot create buffer engine canvas for image load.");
1282 evas = ecore_evas_get(ee); 1282 evas = ecore_evas_get(ee);
1283 vg = evas_object_vg_add(evas); 1283 vg = evas_object_vg_add(evas);
1284 1284 buf = eina_strbuf_new();
1285 for (i = 0; i < edje_file->image_dir->vectors_count; i++) 1285 for (i = 0; i < edje_file->image_dir->vectors_count; i++)
1286 { 1286 {
1287 if (!beta) 1287 if (!beta)
@@ -1290,18 +1290,18 @@ data_write_vectors(Eet_File *ef, int *vector_num)
1290 vector = &edje_file->image_dir->vectors[i]; 1290 vector = &edje_file->image_dir->vectors[i];
1291 EINA_LIST_FOREACH(img_dirs, ll, s) 1291 EINA_LIST_FOREACH(img_dirs, ll, s)
1292 { 1292 {
1293 sprintf(buf, "%s/%s", s, vector->entry); 1293 eina_strbuf_reset(buf);
1294 1294 eina_strbuf_append_printf(buf, "%s" EINA_PATH_SEP_S "%s", s, vector->entry);
1295 f = eina_file_open(buf, EINA_FALSE); 1295 f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
1296 if (!f) continue; 1296 if (!f) continue;
1297 eina_file_close(f); 1297 eina_file_close(f);
1298 1298
1299 if (!efl_file_set(vg, buf, NULL)) 1299 if (!efl_file_set(vg, eina_strbuf_string_get(buf), NULL))
1300 error_and_abort(ef, "Failed to parse svg : %s", vector->entry); 1300 error_and_abort(ef, "Failed to parse svg : %s", vector->entry);
1301 1301
1302 sprintf(buf, "edje/vectors/%i", vector->id); 1302 eina_strbuf_reset(buf);
1303 1303 eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id);
1304 if(!efl_file_save(vg, eet_file_get(ef), buf, NULL)) 1304 if (!efl_file_save(vg, eet_file_get(ef), eina_strbuf_string_get(buf), NULL))
1305 error_and_abort(ef, "Failed to write data in Eet for svg :%s", vector->entry); 1305 error_and_abort(ef, "Failed to write data in Eet for svg :%s", vector->entry);
1306 1306
1307 *vector_num += 1; 1307 *vector_num += 1;
@@ -1312,6 +1312,7 @@ data_write_vectors(Eet_File *ef, int *vector_num)
1312 error_and_abort(ef, "Unable to find the svg :%s", vector->entry); 1312 error_and_abort(ef, "Unable to find the svg :%s", vector->entry);
1313 found = EINA_FALSE; 1313 found = EINA_FALSE;
1314 } 1314 }
1315 eina_strbuf_free(buf);
1315} 1316}
1316 1317
1317static void 1318static void
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index 0a9efdcfc9..d752e2360a 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -3696,13 +3696,13 @@ _edje_svg_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_U
3696{ 3696{
3697 int new_svg = -1; //invalid svg 3697 int new_svg = -1; //invalid svg
3698 int w, h; 3698 int w, h;
3699 char src_key[20], dest_key[20]; 3699 char src_key[32], dest_key[32];
3700 Efl_VG *src_root, *dest_root, *root; 3700 Efl_VG *src_root, *dest_root, *root;
3701 3701
3702 evas_object_geometry_get(ep->object, NULL, NULL, &w, &h); 3702 evas_object_geometry_get(ep->object, NULL, NULL, &w, &h);
3703 if( (w == 0) || (h == 0)) return; 3703 if( (w == 0) || (h == 0)) return;
3704 3704
3705 sprintf(src_key, "edje/vectors/%i", chosen_desc->vg.id); 3705 snprintf(src_key, sizeof(src_key), "edje/vectors/%i", chosen_desc->vg.id);
3706 3706
3707 if (ep->param2) 3707 if (ep->param2)
3708 { 3708 {
@@ -3719,22 +3719,27 @@ _edje_svg_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_U
3719 } 3719 }
3720 else 3720 else
3721 { 3721 {
3722 sprintf(dest_key, "edje/vectors/%i", new_svg); 3722 snprintf(dest_key, sizeof(dest_key), "edje/vectors/%i", new_svg);
3723 3723
3724 efl_file_set(ep->object, ed->file->path, src_key); 3724 efl_file_set(ep->object, ed->file->path, src_key);
3725 src_root = efl_canvas_vg_root_node_get(ep->object); 3725 src_root = efl_canvas_vg_root_node_get(ep->object);
3726 efl_ref(src_root);
3726 3727
3727 efl_file_set(ep->object, ed->file->path, dest_key); 3728 efl_file_set(ep->object, ed->file->path, dest_key);
3728 dest_root = efl_canvas_vg_root_node_get(ep->object); 3729 dest_root = efl_canvas_vg_root_node_get(ep->object);
3730 efl_ref(dest_root);
3729 3731
3732 // FIXME: root = dup(), root.interpolate(dest).
3730 root = evas_vg_container_add(NULL); 3733 root = evas_vg_container_add(NULL);
3731 evas_vg_node_dup(root, src_root); 3734 evas_vg_node_dup(root, src_root);
3732 3735
3733 if (!evas_vg_node_interpolate(root, src_root, dest_root, pos)) 3736 if (!evas_vg_node_interpolate(root, src_root, dest_root, pos))
3734 { 3737 {
3735 ERR(" Can't interpolate check the svg file \n"); 3738 ERR("Can't interpolate check the svg file");
3736 } 3739 }
3737 efl_canvas_vg_root_node_set(ep->object, root); 3740 efl_canvas_vg_root_node_set(ep->object, root);
3741 efl_unref(src_root);
3742 efl_unref(dest_root);
3738 } 3743 }
3739} 3744}
3740 3745
diff --git a/src/lib/evas/canvas/efl_canvas_vg.c b/src/lib/evas/canvas/efl_canvas_vg.c
index 15d0eb21b9..a869308651 100644
--- a/src/lib/evas/canvas/efl_canvas_vg.c
+++ b/src/lib/evas/canvas/efl_canvas_vg.c
@@ -244,22 +244,18 @@ _efl_canvas_vg_viewbox_align_get(Eo *obj EINA_UNUSED, Efl_Canvas_Vg_Data *pd, do
244EOLIAN static Eina_Bool 244EOLIAN static Eina_Bool
245_efl_canvas_vg_efl_file_file_set(Eo *obj, Efl_Canvas_Vg_Data *pd, const char *file, const char *key) 245_efl_canvas_vg_efl_file_file_set(Eo *obj, Efl_Canvas_Vg_Data *pd, const char *file, const char *key)
246{ 246{
247 Evas_Cache_Vg_Entry *old_entry;
247 int w, h; 248 int w, h;
248 Evas_Cache_Vg_Entry *entry;
249 249
250 if (!file) return EINA_FALSE; 250 if (!file) return EINA_FALSE;
251 251
252 old_entry = pd->vg_entry;
252 evas_object_geometry_get(obj, NULL, NULL, &w, &h); 253 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
253 entry = evas_cache_vg_entry_find(file, key, w, h); 254 pd->vg_entry = evas_cache_vg_entry_find(file, key, w, h);
254 if (entry != pd->vg_entry) 255 if (pd->vg_entry != old_entry)
255 { 256 evas_object_change(obj, efl_data_scope_get(obj, EFL_CANVAS_OBJECT_CLASS));
256 if (pd->vg_entry) 257 evas_cache_vg_entry_del(old_entry);
257 { 258
258 evas_cache_vg_entry_del(pd->vg_entry);
259 }
260 pd->vg_entry = entry;
261 }
262 evas_object_change(obj, efl_data_scope_get(obj, EFL_CANVAS_OBJECT_CLASS));
263 return EINA_TRUE; 259 return EINA_TRUE;
264} 260}
265 261
@@ -276,7 +272,7 @@ _efl_canvas_vg_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_Canvas_Vg_Data *pd, co
276EOLIAN static Eina_Bool 272EOLIAN static Eina_Bool
277_efl_canvas_vg_efl_file_save(const Eo *obj, Efl_Canvas_Vg_Data *pd, const char *file, const char *key, const char *flags) 273_efl_canvas_vg_efl_file_save(const Eo *obj, Efl_Canvas_Vg_Data *pd, const char *file, const char *key, const char *flags)
278{ 274{
279 Vg_File_Data tmp; 275 Vg_File_Data tmp = {};
280 Vg_File_Data *info = &tmp; 276 Vg_File_Data *info = &tmp;
281 277
282 if (pd->vg_entry && pd->vg_entry->file) 278 if (pd->vg_entry && pd->vg_entry->file)
@@ -291,8 +287,7 @@ _efl_canvas_vg_efl_file_save(const Eo *obj, Efl_Canvas_Vg_Data *pd, const char *
291 info->root = pd->root; 287 info->root = pd->root;
292 info->preserve_aspect = EINA_FALSE; 288 info->preserve_aspect = EINA_FALSE;
293 } 289 }
294 evas_vg_save_to_file(info, file, key, flags); 290 return evas_vg_save_to_file(info, file, key, flags);
295 return EINA_TRUE;
296} 291}
297 292
298static void 293static void
@@ -431,7 +426,6 @@ _efl_canvas_vg_render(Evas_Object *eo_obj EINA_UNUSED,
431 { 426 {
432 root = vd->root; 427 root = vd->root;
433 } 428 }
434 //obj->layer->evas->engine.func->ector_begin(output, context,
435 obj->layer->evas->engine.func->ector_begin(engine, context, 429 obj->layer->evas->engine.func->ector_begin(engine, context,
436 ector, surface, 430 ector, surface,
437 vd->engine_data, 431 vd->engine_data,
diff --git a/src/lib/evas/canvas/efl_canvas_vg.eo b/src/lib/evas/canvas/efl_canvas_vg.eo
index c9fee6dd10..398dd6cf2c 100644
--- a/src/lib/evas/canvas/efl_canvas_vg.eo
+++ b/src/lib/evas/canvas/efl_canvas_vg.eo
@@ -73,6 +73,7 @@ class Efl.Canvas.Vg (Efl.Canvas.Object, Efl.File)
73 Efl.Object.constructor; 73 Efl.Object.constructor;
74 Efl.Object.finalize; 74 Efl.Object.finalize;
75 Efl.Object.destructor; 75 Efl.Object.destructor;
76 // FIXME: Implement mmap only (also fix cache keys)
76 Efl.File.file { get; set; } 77 Efl.File.file { get; set; }
77 Efl.File.save; 78 Efl.File.save;
78 } 79 }
diff --git a/src/lib/evas/vg/evas_vg_cache.c b/src/lib/evas/vg/evas_vg_cache.c
index dae36cc290..aa32a6f826 100644
--- a/src/lib/evas/vg/evas_vg_cache.c
+++ b/src/lib/evas/vg/evas_vg_cache.c
@@ -324,5 +324,6 @@ evas_cache_vg_entry_del(Evas_Cache_Vg_Entry *svg_entry)
324 if (!svg_entry) return; 324 if (!svg_entry) return;
325 325
326 svg_entry->ref--; 326 svg_entry->ref--;
327 // FIXME implement delete logic (LRU)
327} 328}
328 329