summaryrefslogtreecommitdiff
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
parent3a77d5bc20d08a79af30c03c17eec46a244db621 (diff)
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
3295 end = _edje_ref_vector_data(ed, new_svg); 3295 end = _edje_ref_vector_data(ed, new_svg);
3296 3296
3297 // for start vector 3297 // for start vector
3298 sx = w/start->w; 3298 _apply_transformation(start->vg, w, h, start);
3299 sy = h/start->h;
3300 eina_matrix3_identity(&matrix);
3301 eina_matrix3_scale(&matrix, sx, sy);
3302 eina_matrix3_translate(&matrix, -start->x, -start->y);
3303 evas_vg_node_transformation_set(start->vg, &matrix);
3304 3299
3305 // for end vector 3300 // for end vector
3306 sx = w/end->w; 3301 _apply_transformation(end->vg, w, h, end);
3307 sy = h/end->h;
3308 eina_matrix3_identity(&matrix);
3309 eina_matrix3_scale(&matrix, sx, sy);
3310 eina_matrix3_translate(&matrix, -end->x, -end->y);
3311 evas_vg_node_transformation_set(end->vg, &matrix);
3312 3302
3313 // do the interpolation 3303 // do the interpolation
3314 if (!evas_vg_node_interpolate(ep->typedata.vector->cur.vg, start->vg, end->vg, pos)) 3304 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
3327 { 3317 {
3328 if (ep->typedata.vector->cur.svg_id == chosen_desc->vg.id) // no svg file change 3318 if (ep->typedata.vector->cur.svg_id == chosen_desc->vg.id) // no svg file change
3329 { 3319 {
3330 sx = w/ep->typedata.vector->cur.w; 3320 _apply_transformation(ep->typedata.vector->cur.vg, w, h, &ep->typedata.vector->cur);
3331 sy = h/ep->typedata.vector->cur.h;
3332 eina_matrix3_identity(&matrix);
3333 eina_matrix3_scale(&matrix, sx, sy);
3334 eina_matrix3_translate(&matrix, -ep->typedata.vector->cur.x, -ep->typedata.vector->cur.y);
3335 evas_vg_node_transformation_set(ep->typedata.vector->cur.vg, &matrix);
3336 return; 3321 return;
3337 } 3322 }
3338 else 3323 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)
2440 } 2440 }
2441 2441
2442 // apply the stroke style property 2442 // apply the stroke style property
2443 evas_vg_shape_stroke_width_set(vg, style->stroke.width); 2443 //@TODO HACK, fix the below api to take the stroke width as pixels
2444 evas_vg_shape_stroke_width_set(vg, style->stroke.width/2.0);
2444 evas_vg_shape_stroke_cap_set(vg, style->stroke.cap); 2445 evas_vg_shape_stroke_cap_set(vg, style->stroke.cap);
2445 evas_vg_shape_stroke_join_set(vg, style->stroke.join); 2446 evas_vg_shape_stroke_join_set(vg, style->stroke.join);
2446 evas_vg_shape_stroke_scale_set(vg, style->stroke.scale); 2447 evas_vg_shape_stroke_scale_set(vg, style->stroke.scale);
@@ -2602,6 +2603,45 @@ _edje_ref_vector_data(Edje *ed, int svg_id)
2602 return vector; 2603 return vector;
2603} 2604}
2604 2605
2606static void
2607_apply_stroke_scale(Efl_VG *node, double scale)
2608{
2609 Efl_VG *child;
2610 Eina_Iterator *itr;
2611
2612 if (eo_isa(node, EFL_VG_CONTAINER_CLASS))
2613 {
2614 itr = efl_vg_container_children_get(node);
2615 EINA_ITERATOR_FOREACH(itr, child)
2616 _apply_stroke_scale(child, scale);
2617 eina_iterator_free(itr);
2618 }
2619 else
2620 {
2621 evas_vg_shape_stroke_scale_set(node, scale);
2622 }
2623}
2624
2625void
2626_apply_transformation(Efl_VG *root, double w, double h, Edje_Vector_Data *vg_data)
2627{
2628 double sx, sy, scale;
2629 Eina_Matrix3 m;
2630
2631 sx = w/vg_data->w;
2632 sy = h/vg_data->h;
2633 scale = sx < sy ? sx: sy;
2634 eina_matrix3_identity(&m);
2635 // allign hcenter and vcenter
2636 //@TODO take care of the preserveaspectratio attribute
2637 eina_matrix3_translate(&m, (w - vg_data->w * scale)/2.0, (h - vg_data->h * scale)/2.0);
2638 eina_matrix3_scale(&m, scale, scale);
2639 eina_matrix3_translate(&m, -vg_data->x, -vg_data->y);
2640 evas_vg_node_transformation_set(root, &m);
2641 _apply_stroke_scale(root, scale);
2642}
2643
2644
2605void 2645void
2606_edje_dupe_vector_data(Edje *ed, int svg_id, double width, double height, 2646_edje_dupe_vector_data(Edje *ed, int svg_id, double width, double height,
2607 Edje_Vector_Data *data) 2647 Edje_Vector_Data *data)
@@ -2623,12 +2663,7 @@ _edje_dupe_vector_data(Edje *ed, int svg_id, double width, double height,
2623 2663
2624 if (vector->w && vector->h) 2664 if (vector->w && vector->h)
2625 { 2665 {
2626 sx = width/vector->w; 2666 _apply_transformation(root, width, height, vector);
2627 sy = height/vector->h;
2628 eina_matrix3_identity(&matrix);
2629 eina_matrix3_scale(&matrix, sx, sy);
2630 eina_matrix3_translate(&matrix, -vector->x, -vector->y);
2631 evas_vg_node_transformation_set(root, &matrix);
2632 } 2667 }
2633 2668
2634 data->vg = root; 2669 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);
3271 3271
3272void _edje_dupe_vector_data(Edje *ed, int svg_id, double width, double height, 3272void _edje_dupe_vector_data(Edje *ed, int svg_id, double width, double height,
3273 Edje_Vector_Data *data); 3273 Edje_Vector_Data *data);
3274void _apply_transformation(Efl_VG *root, double w, double h,
3275 Edje_Vector_Data *vg_data);
3274 3276
3275Edje_Vector_Data * _edje_ref_vector_data(Edje *ed, int svg_id); 3277Edje_Vector_Data * _edje_ref_vector_data(Edje *ed, int svg_id);
3276 3278