forked from enlightenment/efl
edje: use the file_set api from vg canvas to load and parse svg file.
This commit is contained in:
parent
ad4e133e08
commit
d5c8822107
|
@ -168,13 +168,6 @@ struct _Sound_Write
|
||||||
int i;
|
int i;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Vector_Write
|
|
||||||
{
|
|
||||||
Eet_File *ef;
|
|
||||||
Svg_Node *root;
|
|
||||||
int i;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _Mo_Write
|
struct _Mo_Write
|
||||||
{
|
{
|
||||||
Eet_File *ef;
|
Eet_File *ef;
|
||||||
|
@ -1270,19 +1263,25 @@ static void
|
||||||
data_write_vectors(Eet_File *ef, int *vector_num)
|
data_write_vectors(Eet_File *ef, int *vector_num)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
Svg_Node *root;
|
|
||||||
Eet_Data_Descriptor *svg_node_eet;
|
|
||||||
Eina_List *ll;
|
Eina_List *ll;
|
||||||
char *s;
|
char *s;
|
||||||
Eina_File *f = NULL;
|
Eina_File *f = NULL;
|
||||||
Edje_Vector_Directory_Entry *vector;
|
Edje_Vector_Directory_Entry *vector;
|
||||||
Eina_Strbuf *buf;
|
char buf[100];
|
||||||
Eina_Bool found = EINA_FALSE;
|
Eina_Bool found = EINA_FALSE;
|
||||||
|
Ecore_Evas *ee;
|
||||||
|
Evas *evas;
|
||||||
|
Evas_Object *vg;
|
||||||
|
|
||||||
if (!((edje_file) && (edje_file->image_dir))) return;
|
if (!((edje_file) && (edje_file->image_dir))) return;
|
||||||
|
|
||||||
svg_node_eet = _edje_svg_node_eet();
|
ecore_evas_init();
|
||||||
buf = eina_strbuf_new();
|
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++)
|
for (i = 0; i < edje_file->image_dir->vectors_count; i++)
|
||||||
{
|
{
|
||||||
if (!beta)
|
if (!beta)
|
||||||
|
@ -1291,29 +1290,28 @@ data_write_vectors(Eet_File *ef, int *vector_num)
|
||||||
vector = &edje_file->image_dir->vectors[i];
|
vector = &edje_file->image_dir->vectors[i];
|
||||||
EINA_LIST_FOREACH(img_dirs, ll, s)
|
EINA_LIST_FOREACH(img_dirs, ll, s)
|
||||||
{
|
{
|
||||||
eina_strbuf_reset(buf);
|
sprintf(buf, "%s/%s", s, vector->entry);
|
||||||
eina_strbuf_append_printf(buf, "%s/%s", s, vector->entry);
|
|
||||||
f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
|
f = eina_file_open(buf, EINA_FALSE);
|
||||||
if (!f) continue;
|
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);
|
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;
|
found = EINA_TRUE;
|
||||||
_edje_svg_node_free(root);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
error_and_abort(ef, "Unable to find the svg :%s", vector->entry);
|
error_and_abort(ef, "Unable to find the svg :%s", vector->entry);
|
||||||
found = EINA_FALSE;
|
found = EINA_FALSE;
|
||||||
}
|
}
|
||||||
eina_strbuf_free(buf);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#define EFL_GFX_FILTER_BETA
|
#define EFL_GFX_FILTER_BETA
|
||||||
#define EFL_GFX_SIZE_HINT_PROTECTED
|
#define EFL_GFX_SIZE_HINT_PROTECTED
|
||||||
|
#define EVAS_VG_BETA
|
||||||
|
|
||||||
#include "edje_private.h"
|
#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
|
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)
|
_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 w, h;
|
||||||
int new_svg = -1;
|
char src_key[20], dest_key[20];
|
||||||
Eina_Matrix3 matrix;
|
Efl_VG *src_root, *dest_root, *root;
|
||||||
Edje_Vector_Data *start, *end;
|
|
||||||
|
|
||||||
evas_object_geometry_get(ep->object, NULL, NULL, &w, &h);
|
evas_object_geometry_get(ep->object, NULL, NULL, &w, &h);
|
||||||
|
|
||||||
if( (w == 0) || (h == 0)) return;
|
if( (w == 0) || (h == 0)) return;
|
||||||
|
|
||||||
|
sprintf(src_key, "edje/vectors/%i", chosen_desc->vg.id);
|
||||||
|
|
||||||
if (ep->param2)
|
if (ep->param2)
|
||||||
{
|
{
|
||||||
Edje_Part_Description_Vector *next_state = (Edje_Part_Description_Vector *)ep->param2->description;
|
Edje_Part_Description_Vector *next_state = (Edje_Part_Description_Vector *)ep->param2->description;
|
||||||
if (chosen_desc->vg.id != next_state->vg.id)
|
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);
|
efl_file_set(ep->object, ed->file->path, src_key);
|
||||||
end = _edje_ref_vector_data(ed, new_svg);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(dest_key, "edje/vectors/%i", new_svg);
|
||||||
|
|
||||||
// for start vector
|
efl_file_set(ep->object, ed->file->path, src_key);
|
||||||
_apply_transformation(start->vg, w, h, start);
|
src_root = efl_canvas_vg_root_node_get(ep->object);
|
||||||
|
|
||||||
// for end vector
|
efl_file_set(ep->object, ed->file->path, dest_key);
|
||||||
_apply_transformation(end->vg, w, h, end);
|
dest_root = efl_canvas_vg_root_node_get(ep->object);
|
||||||
|
|
||||||
// do the interpolation
|
root = evas_vg_container_add(NULL);
|
||||||
if (!evas_vg_node_interpolate(ep->typedata.vector->cur.vg, start->vg, end->vg, pos))
|
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");
|
ERR(" Can't interpolate check the svg file \n");
|
||||||
}
|
}
|
||||||
// performance hack
|
efl_canvas_vg_root_node_set(ep->object, root);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue