From 8952c3e52444d78504a822bf95d757621891dd41 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Wed, 8 Nov 2017 15:49:37 +0900 Subject: [PATCH] evas/vg: changed the efl_vg_dup api signature. Reviewers: jpeg, cedric Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D5440 --- src/lib/edje/edje_calc.c | 4 +- src/lib/evas/canvas/efl_vg.eo | 6 +-- src/lib/evas/canvas/evas_vg_container.c | 26 ++++------ src/lib/evas/canvas/evas_vg_gradient.c | 21 ++++---- src/lib/evas/canvas/evas_vg_gradient_linear.c | 18 +++---- src/lib/evas/canvas/evas_vg_gradient_radial.c | 20 ++++---- src/lib/evas/canvas/evas_vg_node.c | 70 +++++++++------------------ src/lib/evas/canvas/evas_vg_shape.c | 44 ++++++----------- src/lib/evas/vg/evas_vg_cache.c | 3 +- 9 files changed, 76 insertions(+), 136 deletions(-) diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index d752e23..3cfa5dc 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -3729,9 +3729,7 @@ _edje_svg_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3 EINA_U dest_root = efl_canvas_vg_root_node_get(ep->object); efl_ref(dest_root); - // FIXME: root = dup(), root.interpolate(dest). - root = evas_vg_container_add(NULL); - evas_vg_node_dup(root, src_root); + root = evas_vg_node_dup(src_root); if (!evas_vg_node_interpolate(root, src_root, dest_root, pos)) { diff --git a/src/lib/evas/canvas/efl_vg.eo b/src/lib/evas/canvas/efl_vg.eo index ecb5141..2d64ade 100644 --- a/src/lib/evas/canvas/efl_vg.eo +++ b/src/lib/evas/canvas/efl_vg.eo @@ -103,11 +103,9 @@ abstract Efl.VG (Efl.Object, Efl.Gfx, Efl.Gfx.Stack) @in pos_map: double; [[Interpolate mapping]] } } - dup { + dup @const { [[Duplicate vector graphics object]] - params { - @in from: const(Efl.VG); [[Source object]] - } + return: Efl.VG @owned; } } implements { diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c index 704d6c1..b89d702 100644 --- a/src/lib/evas/canvas/evas_vg_container.c +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -151,28 +151,20 @@ _efl_vg_container_efl_vg_interpolate(Eo *obj, return r; } -static void -_efl_vg_container_efl_vg_dup(Eo *obj, - Efl_VG_Container_Data *pd, - const Efl_VG *from) +EOLIAN static Efl_VG * +_efl_vg_container_efl_vg_dup(const Eo *obj, Efl_VG_Container_Data *pd) { - Efl_VG_Container_Data *fromd; Eina_List *l; - Eo *child; - - efl_vg_dup(efl_super(obj, EFL_VG_CONTAINER_CLASS), from); + Efl_VG *child; + Efl_VG *cn = NULL; - fromd = efl_data_scope_get(from, EFL_VG_CONTAINER_CLASS); - - EINA_LIST_FREE(pd->children, child) - efl_unref(child); - - EINA_LIST_FOREACH(fromd->children, l, child) + cn = efl_vg_dup(efl_super(obj, MY_CLASS)); + EINA_LIST_FOREACH(pd->children, l, child) { - // By setting parent, we automatically reference - // this new object as a child of obj. Magic at work ! - (void) efl_add(efl_class_get(child), obj, efl_vg_dup(efl_added, child)); + // parent_set adds the new node to the list of children of cn + efl_parent_set(efl_vg_dup(child), cn); } + return cn; } EAPI Efl_VG* diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c index 12f8b3d..db59b1b 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.c +++ b/src/lib/evas/canvas/evas_vg_gradient.c @@ -5,6 +5,8 @@ #include +#define MY_CLASS EFL_VG_GRADIENT_CLASS + static void _efl_vg_gradient_efl_gfx_gradient_stop_set(Eo *obj EINA_UNUSED, Efl_VG_Gradient_Data *pd, @@ -94,19 +96,16 @@ _efl_vg_gradient_efl_vg_interpolate(Eo *obj, return EINA_TRUE; } -static void -_efl_vg_gradient_efl_vg_dup(Eo *obj, - Efl_VG_Gradient_Data *pd EINA_UNUSED, - const Efl_VG *from) -{ - Efl_VG_Gradient_Data *fromd; - - efl_vg_dup(efl_super(obj, EFL_VG_GRADIENT_CLASS), from); +EOLIAN static Efl_VG * +_efl_vg_gradient_efl_vg_dup(const Eo *obj, Efl_VG_Gradient_Data *pd) - fromd = efl_data_scope_get(from, EFL_VG_GRADIENT_CLASS); +{ + Efl_VG *cn = NULL; - efl_gfx_gradient_stop_set(obj, fromd->colors, fromd->colors_count); - efl_gfx_gradient_spread_set(obj, fromd->s); + cn = efl_vg_dup(efl_super(obj, MY_CLASS)); + efl_gfx_gradient_stop_set(cn, pd->colors, pd->colors_count); + efl_gfx_gradient_spread_set(cn, pd->s); + return cn; } EAPI void diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index fcefa55..3549faf 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -153,19 +153,15 @@ _efl_vg_gradient_linear_efl_vg_interpolate(Eo *obj, return EINA_TRUE; } -static void -_efl_vg_gradient_linear_efl_vg_dup(Eo *obj, - Efl_VG_Gradient_Linear_Data *pd EINA_UNUSED, - const Efl_VG *from) +EOLIAN static Efl_VG * +_efl_vg_gradient_linear_efl_vg_dup(const Eo *obj, Efl_VG_Gradient_Linear_Data *pd) { - Efl_VG_Gradient_Linear_Data *fromd; - - efl_vg_dup(efl_super(obj, EFL_VG_GRADIENT_LINEAR_CLASS), from); - - fromd = efl_data_scope_get(from, EFL_VG_GRADIENT_LINEAR_CLASS); + Efl_VG *cn = NULL; - efl_gfx_gradient_linear_start_set(obj, fromd->start.x, fromd->start.y); - efl_gfx_gradient_linear_end_set(obj, fromd->end.x, fromd->end.y); + cn = efl_vg_dup(efl_super(obj, MY_CLASS)); + efl_gfx_gradient_linear_start_set(cn, pd->start.x, pd->start.y); + efl_gfx_gradient_linear_end_set(cn, pd->end.x, pd->end.y); + return cn; } EAPI void diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index 3436df2..8108e8a 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -172,20 +172,18 @@ _efl_vg_gradient_radial_efl_vg_interpolate(Eo *obj, return EINA_TRUE; } -static void -_efl_vg_gradient_radial_efl_vg_dup(Eo *obj, - Efl_VG_Gradient_Radial_Data *pd EINA_UNUSED, - const Efl_VG *from) -{ - Efl_VG_Gradient_Radial_Data *fromd; - efl_vg_dup(efl_super(obj, EFL_VG_GRADIENT_RADIAL_CLASS), from); +EOLIAN static Efl_VG * +_efl_vg_gradient_radial_efl_vg_dup(const Eo *obj, Efl_VG_Gradient_Radial_Data *pd) - fromd = efl_data_scope_get(from, EFL_VG_GRADIENT_RADIAL_CLASS); +{ + Efl_VG *cn = NULL; - efl_gfx_gradient_radial_focal_set(obj, fromd->focal.x, fromd->focal.y); - efl_gfx_gradient_radial_center_set(obj, fromd->center.x, fromd->center.y); - efl_gfx_gradient_radial_radius_set(obj, fromd->radius); + cn = efl_vg_dup(efl_super(obj, MY_CLASS)); + efl_gfx_gradient_radial_focal_set(cn, pd->focal.x, pd->focal.y); + efl_gfx_gradient_radial_center_set(cn, pd->center.x, pd->center.y); + efl_gfx_gradient_radial_radius_set(cn, pd->radius); + return cn; } EAPI void diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 04f576e..dbe4abe 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -715,61 +715,35 @@ _efl_vg_interpolate(Eo *obj, return r; } -static void -_efl_vg_dup(Eo *obj, Efl_VG_Data *pd, const Efl_VG *from) +EOLIAN static Efl_VG * +_efl_vg_dup(const Eo *obj, Efl_VG_Data *pd) { - Efl_VG_Container_Data *cd = NULL; - Efl_VG_Data *fromd; - Eo *parent = NULL; - - fromd = efl_data_scope_get(from, EFL_VG_CLASS); - if (pd->name != fromd->name) - { - eina_stringshare_del(pd->name); - pd->name = eina_stringshare_ref(fromd->name); - } - - _efl_vg_parent_checked_get(obj, &parent, &cd); - if (cd) _efl_vg_name_insert(obj, pd, cd); - - if (pd->intp) - { - free(pd->intp); - pd->intp = NULL; - } - - if (pd->renderer) - { - efl_del(pd->renderer); - pd->renderer = NULL; - } + Efl_VG *cn; + Efl_VG_Data *cd; - if (fromd->m) - { - pd->m = pd->m ? pd->m : malloc(sizeof (Eina_Matrix3)) ; - if (pd->m) memcpy(pd->m, fromd->m, sizeof (Eina_Matrix3)); - } - else + cn = efl_add(efl_class_get(obj), NULL); + cd = efl_data_scope_get(cn, MY_CLASS); + EINA_SAFETY_ON_NULL_RETURN_VAL(cd, NULL); + if (pd->name) + cd->name = eina_stringshare_ref(pd->name); + if (pd->m) { - free(pd->m); + cd->m = malloc(sizeof (Eina_Matrix3)) ; + if (cd->m) memcpy(cd->m, pd->m, sizeof (Eina_Matrix3)); } - // We may come from an already duped/initialized node, clean it first - _efl_vg_clean_object(&pd->mask); - if (fromd->mask) - { - pd->mask = efl_add(efl_class_get(fromd->mask), obj, efl_vg_dup(efl_added, pd->mask)); - } + if (pd->mask) + cd->mask = efl_vg_dup(pd->mask); - pd->x = fromd->x; - pd->y = fromd->y; - pd->r = fromd->r; - pd->g = fromd->g; - pd->b = fromd->b; - pd->a = fromd->a; - pd->visibility = fromd->visibility; + cd->x = pd->x; + cd->y = pd->y; + cd->r = pd->r; + cd->g = pd->g; + cd->b = pd->b; + cd->a = pd->a; + cd->visibility = pd->visibility; - _efl_vg_changed(obj); + return cn; } EAPI Eina_Bool diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index a5f0d29..f2137b0 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -181,38 +181,24 @@ _efl_vg_shape_efl_vg_interpolate(Eo *obj, return r; } -static void -_efl_vg_shape_efl_vg_dup(Eo *obj, Efl_VG_Shape_Data *pd EINA_UNUSED, const Efl_VG *from) -{ - Efl_VG_Shape_Data *fromd; - Eo *fill = NULL, *stroke_fill = NULL, *stroke_marker = NULL; - - efl_vg_dup(efl_super(obj, MY_CLASS), from); - - fromd = efl_data_scope_get(from, MY_CLASS); - - if (fromd->fill) - { - fill = efl_add(efl_class_get(fromd->fill), NULL, efl_vg_dup(efl_added, fromd->fill)); - efl_vg_shape_fill_set(obj, fill); - efl_unref(fill); - } - if (fromd->stroke.fill) - { - stroke_fill = efl_add(efl_class_get(fromd->stroke.fill), NULL, efl_vg_dup(efl_added, fromd->stroke.fill)); - efl_vg_shape_stroke_fill_set(obj, stroke_fill); - efl_unref(stroke_fill); - } +EOLIAN static Efl_VG * +_efl_vg_shape_efl_vg_dup(const Eo *obj, Efl_VG_Shape_Data *pd) +{ + Efl_VG *cn = NULL; + Efl_VG_Shape_Data *cd = NULL; - if (fromd->stroke.marker) - { - stroke_marker = efl_add(efl_class_get(fromd->stroke.marker), NULL, efl_vg_dup(efl_added, fromd->stroke.marker)); - efl_vg_shape_stroke_marker_set(obj, stroke_marker); - efl_unref(stroke_marker); - } + cn = efl_vg_dup(efl_super(obj, MY_CLASS)); + cd = efl_data_scope_get(cn, MY_CLASS); + if (pd->fill) + cd->fill = efl_vg_dup(pd->fill); + if (pd->stroke.fill) + cd->stroke.fill = efl_vg_dup(pd->stroke.fill); + if (pd->stroke.marker) + cd->stroke.marker = efl_vg_dup(pd->stroke.marker); - efl_gfx_shape_dup(obj, from); + efl_gfx_shape_dup(cn, obj); + return cn; } EAPI double diff --git a/src/lib/evas/vg/evas_vg_cache.c b/src/lib/evas/vg/evas_vg_cache.c index f3e8f77..a6c3870 100644 --- a/src/lib/evas/vg/evas_vg_cache.c +++ b/src/lib/evas/vg/evas_vg_cache.c @@ -274,8 +274,7 @@ _evas_vg_dup_vg_tree(Vg_File_Data *fd, double w, double h) if (!fd) return NULL; if ( !w || !h ) return NULL; - root = evas_vg_container_add(NULL); - evas_vg_node_dup(root, fd->root); + root = efl_vg_dup(fd->root); _apply_transformation(root, w, h, fd); return root; -- 2.7.4