hermet pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=44d362e1ef9f0ab1375dde2948fa0ba80ee935cf

commit 44d362e1ef9f0ab1375dde2948fa0ba80ee935cf
Author: Hermet Park <hermetp...@gmail.com>
Date:   Tue Sep 24 11:46:50 2019 +0900

    evas vg: fix gradient stroke fill memory leaks.
    
    There were continous creation of gradient objects,
    We can stop it by caching it properly,
    
    Also, fix mismatched ref/unref counts.
---
 src/lib/evas/canvas/efl_canvas_vg_shape.c  |  5 ++++-
 src/static_libs/vg_common/vg_common_json.c | 16 ++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/lib/evas/canvas/efl_canvas_vg_shape.c 
b/src/lib/evas/canvas/efl_canvas_vg_shape.c
index 4abdb13af8..6ddec04869 100644
--- a/src/lib/evas/canvas/efl_canvas_vg_shape.c
+++ b/src/lib/evas/canvas/efl_canvas_vg_shape.c
@@ -23,6 +23,8 @@ _efl_canvas_vg_shape_fill_set(Eo *obj EINA_UNUSED,
                        Efl_Canvas_Vg_Shape_Data *pd,
                        Efl_Canvas_Vg_Node *f)
 {
+   if (pd->fill == f) return;
+
    Efl_Canvas_Vg_Node *tmp = pd->fill;
 
    pd->fill = efl_ref(f);
@@ -40,8 +42,9 @@ _efl_canvas_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED,
                               Efl_Canvas_Vg_Shape_Data *pd,
                               Efl_Canvas_Vg_Node *f)
 {
-   Efl_Canvas_Vg_Node *tmp = pd->fill;
+   if (pd->stroke.fill == f) return;
 
+   Efl_Canvas_Vg_Node *tmp = pd->stroke.fill;
    pd->stroke.fill = efl_ref(f);
    efl_unref(tmp);
 }
diff --git a/src/static_libs/vg_common/vg_common_json.c 
b/src/static_libs/vg_common/vg_common_json.c
index 910a4055e1..3b3d114503 100644
--- a/src/static_libs/vg_common/vg_common_json.c
+++ b/src/static_libs/vg_common/vg_common_json.c
@@ -177,13 +177,25 @@ _construct_drawable_nodes(Efl_Canvas_Vg_Container 
*parent, const LOTLayerNode *l
 
                 if (node->mGradient.type == GradientLinear)
                   {
-                     grad = efl_add(EFL_CANVAS_VG_GRADIENT_LINEAR_CLASS, 
parent);
+                     char *key = _get_key_val(shape);
+                     grad = efl_key_data_get(shape, key);
+                     if (!grad)
+                       {
+                          grad = efl_add(EFL_CANVAS_VG_GRADIENT_LINEAR_CLASS, 
parent);
+                          efl_key_data_set(shape, key, grad);
+                       }
                      efl_gfx_gradient_linear_start_set(grad, 
node->mGradient.start.x, node->mGradient.start.y);
                      efl_gfx_gradient_linear_end_set(grad, 
node->mGradient.end.x, node->mGradient.end.y);
                   }
                 else if (node->mGradient.type == GradientRadial)
                   {
-                     grad = efl_add(EFL_CANVAS_VG_GRADIENT_RADIAL_CLASS, 
parent);
+                     char *key = _get_key_val(shape);
+                     grad = efl_key_data_get(shape, key);
+                     if (!grad)
+                       {
+                          grad = efl_add(EFL_CANVAS_VG_GRADIENT_RADIAL_CLASS, 
parent);
+                          efl_key_data_set(shape, key, grad);
+                       }
                      efl_gfx_gradient_radial_center_set(grad, 
node->mGradient.center.x, node->mGradient.center.y);
                      efl_gfx_gradient_radial_focal_set(grad, 
node->mGradient.focal.x, node->mGradient.focal.y);
                      efl_gfx_gradient_radial_radius_set(grad, 
node->mGradient.cradius);

-- 


Reply via email to