aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubhransu Mohanty <sub.mohanty@samsung.com>2016-07-26 14:31:44 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-07-26 14:33:15 +0900
commite3ed888aa994d96007da15be89649a92c12bcbae (patch)
treeb30d55ce1f70c06ddda8333c2831b312e77519af
parentedje examples - when you cp also just assume success if same file (diff)
downloadefl-e3ed888aa994d96007da15be89649a92c12bcbae.tar.gz
edje: fixed issue with applying transformation and stroke width
Reviewers: cedric, jpeg Reviewed By: jpeg Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4192
-rw-r--r--src/lib/edje/edje_calc.c21
-rw-r--r--src/lib/edje/edje_load.c49
-rw-r--r--src/lib/edje/edje_private.h2
3 files changed, 47 insertions, 25 deletions
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index b4a04c4a5c..ca7a2cdbc7 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -3295,20 +3295,10 @@ _edje_svg_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_U
end = _edje_ref_vector_data(ed, new_svg);
// for start vector
- sx = w/start->w;
- sy = h/start->h;
- eina_matrix3_identity(&matrix);
- eina_matrix3_scale(&matrix, sx, sy);
- eina_matrix3_translate(&matrix, -start->x, -start->y);
- evas_vg_node_transformation_set(start->vg, &matrix);
+ _apply_transformation(start->vg, w, h, start);
// for end vector
- sx = w/end->w;
- sy = h/end->h;
- eina_matrix3_identity(&matrix);
- eina_matrix3_scale(&matrix, sx, sy);
- eina_matrix3_translate(&matrix, -end->x, -end->y);
- evas_vg_node_transformation_set(end->vg, &matrix);
+ _apply_transformation(end->vg, w, h, end);
// do the interpolation
if (!evas_vg_node_interpolate(ep->typedata.vector->cur.vg, start->vg, end->vg, pos))
@@ -3327,12 +3317,7 @@ _edje_svg_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_U
{
if (ep->typedata.vector->cur.svg_id == chosen_desc->vg.id) // no svg file change
{
- sx = w/ep->typedata.vector->cur.w;
- sy = h/ep->typedata.vector->cur.h;
- eina_matrix3_identity(&matrix);
- eina_matrix3_scale(&matrix, sx, sy);
- eina_matrix3_translate(&matrix, -ep->typedata.vector->cur.x, -ep->typedata.vector->cur.y);
- evas_vg_node_transformation_set(ep->typedata.vector->cur.vg, &matrix);
+ _apply_transformation(ep->typedata.vector->cur.vg, w, h, &ep->typedata.vector->cur);
return;
}
else
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index 50a1a3b194..fbf85fb95f 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -2440,7 +2440,8 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg)
}
// apply the stroke style property
- evas_vg_shape_stroke_width_set(vg, style->stroke.width);
+ //@TODO HACK, fix the below api to take the stroke width as pixels
+ evas_vg_shape_stroke_width_set(vg, style->stroke.width/2.0);
evas_vg_shape_stroke_cap_set(vg, style->stroke.cap);
evas_vg_shape_stroke_join_set(vg, style->stroke.join);
evas_vg_shape_stroke_scale_set(vg, style->stroke.scale);
@@ -2602,6 +2603,45 @@ _edje_ref_vector_data(Edje *ed, int svg_id)
return vector;
}
+static void
+_apply_stroke_scale(Efl_VG *node, double scale)
+{
+ Efl_VG *child;
+ Eina_Iterator *itr;
+
+ if (eo_isa(node, EFL_VG_CONTAINER_CLASS))
+ {
+ itr = efl_vg_container_children_get(node);
+ EINA_ITERATOR_FOREACH(itr, child)
+ _apply_stroke_scale(child, scale);
+ eina_iterator_free(itr);
+ }
+ else
+ {
+ evas_vg_shape_stroke_scale_set(node, scale);
+ }
+}
+
+void
+_apply_transformation(Efl_VG *root, double w, double h, Edje_Vector_Data *vg_data)
+{
+ double sx, sy, scale;
+ Eina_Matrix3 m;
+
+ sx = w/vg_data->w;
+ sy = h/vg_data->h;
+ scale = sx < sy ? sx: sy;
+ eina_matrix3_identity(&m);
+ // allign hcenter and vcenter
+ //@TODO take care of the preserveaspectratio attribute
+ eina_matrix3_translate(&m, (w - vg_data->w * scale)/2.0, (h - vg_data->h * scale)/2.0);
+ eina_matrix3_scale(&m, scale, scale);
+ eina_matrix3_translate(&m, -vg_data->x, -vg_data->y);
+ evas_vg_node_transformation_set(root, &m);
+ _apply_stroke_scale(root, scale);
+}
+
+
void
_edje_dupe_vector_data(Edje *ed, int svg_id, double width, double height,
Edje_Vector_Data *data)
@@ -2623,12 +2663,7 @@ _edje_dupe_vector_data(Edje *ed, int svg_id, double width, double height,
if (vector->w && vector->h)
{
- sx = width/vector->w;
- sy = height/vector->h;
- eina_matrix3_identity(&matrix);
- eina_matrix3_scale(&matrix, sx, sy);
- eina_matrix3_translate(&matrix, -vector->x, -vector->y);
- evas_vg_node_transformation_set(root, &matrix);
+ _apply_transformation(root, width, height, vector);
}
data->vg = root;
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index bc25e94383..da75f175de 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -3271,6 +3271,8 @@ void _edje_svg_node_destroy_eet(void);
void _edje_dupe_vector_data(Edje *ed, int svg_id, double width, double height,
Edje_Vector_Data *data);
+void _apply_transformation(Efl_VG *root, double w, double h,
+ Edje_Vector_Data *vg_data);
Edje_Vector_Data * _edje_ref_vector_data(Edje *ed, int svg_id);