From d5c882210744eafb75ebec057eadbedd748777fa Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Fri, 27 Oct 2017 09:21:48 +0900 Subject: [PATCH] edje: use the file_set api from vg canvas to load and parse svg file. --- src/bin/edje/edje_cc_out.c | 50 ++++++++++++++--------------- src/lib/edje/edje_calc.c | 65 +++++++++++++++----------------------- 2 files changed, 49 insertions(+), 66 deletions(-) diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c index d793cacc8b..7803f781a8 100644 --- a/src/bin/edje/edje_cc_out.c +++ b/src/bin/edje/edje_cc_out.c @@ -168,13 +168,6 @@ struct _Sound_Write int i; }; -struct _Vector_Write -{ - Eet_File *ef; - Svg_Node *root; - int i; -}; - struct _Mo_Write { Eet_File *ef; @@ -1270,19 +1263,25 @@ static void data_write_vectors(Eet_File *ef, int *vector_num) { unsigned int i; - Svg_Node *root; - Eet_Data_Descriptor *svg_node_eet; Eina_List *ll; char *s; Eina_File *f = NULL; Edje_Vector_Directory_Entry *vector; - Eina_Strbuf *buf; + char buf[100]; Eina_Bool found = EINA_FALSE; + Ecore_Evas *ee; + Evas *evas; + Evas_Object *vg; if (!((edje_file) && (edje_file->image_dir))) return; - svg_node_eet = _edje_svg_node_eet(); - buf = eina_strbuf_new(); + ecore_evas_init(); + ee = ecore_evas_buffer_new(1, 1); + if (!ee) + error_and_abort(ef, "Cannot create buffer engine canvas for image load."); + evas = ecore_evas_get(ee); + vg = evas_object_vg_add(evas); + for (i = 0; i < edje_file->image_dir->vectors_count; i++) { if (!beta) @@ -1291,29 +1290,28 @@ data_write_vectors(Eet_File *ef, int *vector_num) vector = &edje_file->image_dir->vectors[i]; EINA_LIST_FOREACH(img_dirs, ll, s) { - eina_strbuf_reset(buf); - eina_strbuf_append_printf(buf, "%s/%s", s, vector->entry); - f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE); + sprintf(buf, "%s/%s", s, vector->entry); + + f = eina_file_open(buf, EINA_FALSE); if (!f) continue; - root = _svg_load(f, NULL); - if(!root) - error_and_abort(ef, "Failed to parse svg : %s", vector->entry); - eina_strbuf_reset(buf); - eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id); - if(!eet_data_write(ef, svg_node_eet, eina_strbuf_string_get(buf), root, compress_mode)) - error_and_abort(ef, "Failed to write data in Eet for svg :%s", vector->entry); - *vector_num += 1; eina_file_close(f); + + if (!efl_file_set(vg, buf, NULL)) + error_and_abort(ef, "Failed to parse svg : %s", vector->entry); + + sprintf(buf, "edje/vectors/%i", vector->id); + + if(!efl_file_save(vg, eet_file_get(ef), buf, NULL)) + error_and_abort(ef, "Failed to write data in Eet for svg :%s", vector->entry); + + *vector_num += 1; found = EINA_TRUE; - _edje_svg_node_free(root); break; } if (!found) error_and_abort(ef, "Unable to find the svg :%s", vector->entry); found = EINA_FALSE; } - eina_strbuf_free(buf); - } static void diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index ba5b4742dc..0a9efdcfc9 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -1,5 +1,6 @@ #define EFL_GFX_FILTER_BETA #define EFL_GFX_SIZE_HINT_PROTECTED +#define EVAS_VG_BETA #include "edje_private.h" @@ -3693,63 +3694,47 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj static void _edje_svg_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_UNUSED, Edje_Part_Description_Vector *chosen_desc, FLOAT_T pos) { + int new_svg = -1; //invalid svg int w, h; - int new_svg = -1; - Eina_Matrix3 matrix; - Edje_Vector_Data *start, *end; + char src_key[20], dest_key[20]; + Efl_VG *src_root, *dest_root, *root; evas_object_geometry_get(ep->object, NULL, NULL, &w, &h); - if( (w == 0) || (h == 0)) return; + sprintf(src_key, "edje/vectors/%i", chosen_desc->vg.id); + if (ep->param2) { Edje_Part_Description_Vector *next_state = (Edje_Part_Description_Vector *)ep->param2->description; if (chosen_desc->vg.id != next_state->vg.id) - { - new_svg = next_state->vg.id; - } + new_svg = next_state->vg.id; + else + pos = 0; } - if (new_svg >= 0) // animation with svg id change + + if (new_svg < 0) { - start = _edje_ref_vector_data(ed, chosen_desc->vg.id); - end = _edje_ref_vector_data(ed, new_svg); + efl_file_set(ep->object, ed->file->path, src_key); + } + else + { + sprintf(dest_key, "edje/vectors/%i", new_svg); - // for start vector - _apply_transformation(start->vg, w, h, start); + efl_file_set(ep->object, ed->file->path, src_key); + src_root = efl_canvas_vg_root_node_get(ep->object); - // for end vector - _apply_transformation(end->vg, w, h, end); + efl_file_set(ep->object, ed->file->path, dest_key); + dest_root = efl_canvas_vg_root_node_get(ep->object); - // do the interpolation - if (!evas_vg_node_interpolate(ep->typedata.vector->cur.vg, start->vg, end->vg, pos)) + root = evas_vg_container_add(NULL); + evas_vg_node_dup(root, src_root); + + if (!evas_vg_node_interpolate(root, src_root, dest_root, pos)) { ERR(" Can't interpolate check the svg file \n"); } - // performance hack - // instead of duplicating the tree and applying the transformation - // i just updated the transformation matrix and reset it back to null. - // assumption is that the root vg will never have a transformation - eina_matrix3_identity(&matrix); - evas_vg_node_transformation_set(start->vg, &matrix); - evas_vg_node_transformation_set(end->vg, &matrix); - } - else - { - if (ep->typedata.vector->cur.svg_id == chosen_desc->vg.id) // no svg file change - { - _apply_transformation(ep->typedata.vector->cur.vg, w, h, &ep->typedata.vector->cur); - return; - } - else - { - if (ep->typedata.vector->cur.vg) - efl_del(ep->typedata.vector->cur.vg); - - _edje_dupe_vector_data(ed, chosen_desc->vg.id, w, h, &ep->typedata.vector->cur); - - evas_object_vg_root_node_set(ep->object, ep->typedata.vector->cur.vg); - } + efl_canvas_vg_root_node_set(ep->object, root); } }