forked from enlightenment/efl
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
This commit is contained in:
parent
3a77d5bc20
commit
e3ed888aa9
|
@ -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);
|
end = _edje_ref_vector_data(ed, new_svg);
|
||||||
|
|
||||||
// for start vector
|
// for start vector
|
||||||
sx = w/start->w;
|
_apply_transformation(start->vg, w, h, start);
|
||||||
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);
|
|
||||||
|
|
||||||
// for end vector
|
// for end vector
|
||||||
sx = w/end->w;
|
_apply_transformation(end->vg, w, h, end);
|
||||||
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);
|
|
||||||
|
|
||||||
// do the interpolation
|
// do the interpolation
|
||||||
if (!evas_vg_node_interpolate(ep->typedata.vector->cur.vg, start->vg, end->vg, pos))
|
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
|
if (ep->typedata.vector->cur.svg_id == chosen_desc->vg.id) // no svg file change
|
||||||
{
|
{
|
||||||
sx = w/ep->typedata.vector->cur.w;
|
_apply_transformation(ep->typedata.vector->cur.vg, w, h, &ep->typedata.vector->cur);
|
||||||
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);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -2440,7 +2440,8 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply the stroke style property
|
// 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_cap_set(vg, style->stroke.cap);
|
||||||
evas_vg_shape_stroke_join_set(vg, style->stroke.join);
|
evas_vg_shape_stroke_join_set(vg, style->stroke.join);
|
||||||
evas_vg_shape_stroke_scale_set(vg, style->stroke.scale);
|
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;
|
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
|
void
|
||||||
_edje_dupe_vector_data(Edje *ed, int svg_id, double width, double height,
|
_edje_dupe_vector_data(Edje *ed, int svg_id, double width, double height,
|
||||||
Edje_Vector_Data *data)
|
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)
|
if (vector->w && vector->h)
|
||||||
{
|
{
|
||||||
sx = width/vector->w;
|
_apply_transformation(root, width, height, vector);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data->vg = root;
|
data->vg = root;
|
||||||
|
|
|
@ -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,
|
void _edje_dupe_vector_data(Edje *ed, int svg_id, double width, double height,
|
||||||
Edje_Vector_Data *data);
|
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);
|
Edje_Vector_Data * _edje_ref_vector_data(Edje *ed, int svg_id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue