From 634eed99ae10b433c7f17407caca6238ced213a7 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Tue, 16 Nov 2021 02:13:49 +0100 Subject: [PATCH] evas vg shape: gradient taken from the proper source When a shape with the gradient is duplicated, the gradient adr was taken from the source obj instead of from the target of the duplication. In TVG, when a shape is duplicated all its properties, like grad, are duplicated as well. EFL created independently a new gradient, which has to be relased first and replaced by the one created in TVG. Change-Id: I0848b0591671b6e69148b0d248a0ba0c8bd66726 --- src/lib/evas/canvas/efl_canvas_vg_shape.c | 36 +++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/lib/evas/canvas/efl_canvas_vg_shape.c b/src/lib/evas/canvas/efl_canvas_vg_shape.c index 54456ce..5ae2a34 100644 --- a/src/lib/evas/canvas/efl_canvas_vg_shape.c +++ b/src/lib/evas/canvas/efl_canvas_vg_shape.c @@ -357,9 +357,15 @@ _shape_dup(Evas_Vg_Shape *obj, Evas_Vg_Shape *dup_from) Efl_Canvas_Vg_Gradient_Data *gd = NULL; Tvg_Gradient *grad = NULL; sd->fill = efl_duplicate(sd_from->fill); - tvg_shape_get_gradient(sd_from->shape, &grad); + tvg_shape_get_gradient(sd->shape, &grad); gd = efl_data_scope_get(sd->fill, EFL_CANVAS_VG_GRADIENT_CLASS); - if (gd) gd->gradient = grad; + if (gd) + { + //During the fill duplication (efl_duplicate) a new Tvg_Gradient object is created. + //It has to be replaced by the one created during the Tvg_Shape duplication (tvg_paint_duplicate). + if (gd->gradient) tvg_gradient_del(gd->gradient); + gd->gradient = grad; + } } if (sd_from->stroke.fill) @@ -367,9 +373,15 @@ _shape_dup(Evas_Vg_Shape *obj, Evas_Vg_Shape *dup_from) Efl_Canvas_Vg_Gradient_Data *gd = NULL; Tvg_Gradient *grad = NULL; sd->stroke.fill = efl_duplicate(sd_from->stroke.fill); - tvg_shape_get_stroke_gradient(sd_from->shape, &grad); + tvg_shape_get_stroke_gradient(sd->shape, &grad); gd = efl_data_scope_get(sd->stroke.fill, EFL_CANVAS_VG_GRADIENT_CLASS); - if (gd) gd->gradient = grad; + if (gd) + { + //During the fill duplication (efl_duplicate) a new Tvg_Gradient object is created. + //It has to be replaced by the one created during the Tvg_Shape duplication (tvg_paint_duplicate). + if (gd->gradient) tvg_gradient_del(gd->gradient); + gd->gradient = grad; + } } sd->curr_ctrl.x = sd_from->curr_ctrl.x; @@ -799,7 +811,13 @@ _efl_canvas_vg_shape_efl_duplicate_duplicate(const Eo *obj, Efl_Canvas_Vg_Shape_ sd->fill = efl_duplicate(pd->fill); tvg_shape_get_gradient(sd->shape, &grad); gd = efl_data_scope_get(sd->fill, EFL_CANVAS_VG_GRADIENT_CLASS); - if (gd) gd->gradient = grad; + if (gd) + { + //During the fill duplication (efl_duplicate) a new Tvg_Gradient object is created. + //It has to be replaced by the one created during the Tvg_Shape duplication (tvg_paint_duplicate). + if (gd->gradient) tvg_gradient_del(gd->gradient); + gd->gradient = grad; + } } if (pd->stroke.fill) @@ -810,7 +828,13 @@ _efl_canvas_vg_shape_efl_duplicate_duplicate(const Eo *obj, Efl_Canvas_Vg_Shape_ sd->stroke.fill = efl_duplicate(pd->stroke.fill); tvg_shape_get_stroke_gradient(sd->shape, &grad); gd = efl_data_scope_get(sd->stroke.fill, EFL_CANVAS_VG_GRADIENT_CLASS); - if (gd) gd->gradient = grad; + if (gd) + { + //During the fill duplication (efl_duplicate) a new Tvg_Gradient object is created. + //It has to be replaced by the one created during the Tvg_Shape duplication (tvg_paint_duplicate). + if (gd->gradient) tvg_gradient_del(gd->gradient); + gd->gradient = grad; + } } sd->curr_ctrl = pd->curr_ctrl; -- 2.7.4