evas vector: Fix stroke's width scaling 87/250787/4
authorPiotr Kalota <p.kalota@samsung.com>
Mon, 4 Jan 2021 13:01:31 +0000 (14:01 +0100)
committerHermet Park <chuneon.park@samsung.com>
Mon, 11 Jan 2021 02:06:32 +0000 (02:06 +0000)
Since the scale value was multiplied by current stroke's width, scaling
worked diffrently than implementation without thorvg. Stroke's width field in
_Efl_Canvas_Vg_Shape_Data allows us to multiply scale value by the base width
set in the evas_vg_node_shape_stroke_set and now this implementation
works correctly

Change-Id: I88b009878d69dc7ed558a6035fa2b7c2ec06e103

src/lib/evas/canvas/efl_canvas_vg_shape.c

index e2e2ef5..2213a63 100644 (file)
@@ -51,6 +51,10 @@ struct _Efl_Canvas_Vg_Shape_Data
    Tvg_Point start;
    Efl_Tvg_Path_Cmd_Type cmd_prev;
 
+   //Storage for stroke's width passed in evas_vg_shape_stroke_width_set. Width variable is used to implement stroke
+   //scaling using scale * width
+   double width;
+
    //Stroke scale is not supported by TVG. Scale variable is used to implement stroke
    //scaling using scale * width
    double scale;
@@ -798,6 +802,7 @@ _efl_canvas_vg_shape_efl_object_constructor(Eo *obj, Efl_Canvas_Vg_Shape_Data *p
    nd->render_pre_tvg = _efl_canvas_vg_shape_render_pre_tvg;
    pd->shape = tvg_shape_new();
    pd->scale = 1.0;
+   pd->width = 0;
 
    //default EFL implementation. We don't want to draw invisible shapes.
    //when object is visible, renderer changes opacity to valid value.
@@ -957,18 +962,15 @@ EAPI void
 evas_vg_shape_stroke_scale_set(Evas_Vg_Shape *obj, double s)
 {
 #ifdef HAVE_THORVG
-   float width = 0;
    Efl_Canvas_Vg_Shape_Data *sd = NULL;
    if (!obj) return;
 
    sd = _get_shape_data(obj);
    if (!sd) return;
 
-   tvg_shape_get_stroke_width(sd->shape, &width);
-   width = width * s;
    sd->scale = s;
 
-   tvg_shape_set_stroke_width(sd->shape, width);
+   tvg_shape_set_stroke_width(sd->shape, sd->scale * sd->width);
 #else
    efl_gfx_shape_stroke_scale_set(obj, s);
 #endif
@@ -1018,7 +1020,15 @@ EAPI void
 evas_vg_shape_stroke_width_set(Evas_Vg_Shape *obj, double w)
 {
 #ifdef HAVE_THORVG
-   tvg_shape_set_stroke_width(_get_tvg_shape(obj), w);
+   Efl_Canvas_Vg_Shape_Data *sd = NULL;
+   if (!obj) return;
+
+   sd = _get_shape_data(obj);
+   if (!sd) return;
+
+   sd->width = w;
+
+   tvg_shape_set_stroke_width(_get_tvg_shape(obj), sd->scale * sd->width);
 #else
    efl_gfx_shape_stroke_width_set(obj, w);
 #endif