summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-06-19 11:26:46 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-08-21 16:40:31 +0200
commit05fdfcc76a7eb57d00ae52d3ab2b9a1eb3ee0db9 (patch)
tree1e56e909ecaaf0d69b422f5173ea514b56dd84dc
parent126edbb48c4f065fe68cb4d60760102498d93ad2 (diff)
evas: add logic to duplicate recursively an Efl_VG_Node tree.
-rw-r--r--src/lib/evas/canvas/efl_vg_base.eo5
-rw-r--r--src/lib/evas/canvas/efl_vg_container.eo1
-rw-r--r--src/lib/evas/canvas/efl_vg_gradient.eo1
-rw-r--r--src/lib/evas/canvas/efl_vg_gradient_linear.eo1
-rw-r--r--src/lib/evas/canvas/efl_vg_gradient_radial.eo1
-rw-r--r--src/lib/evas/canvas/efl_vg_shape.eo1
-rw-r--r--src/lib/evas/canvas/evas_vg_container.c26
-rw-r--r--src/lib/evas/canvas/evas_vg_gradient.c16
-rw-r--r--src/lib/evas/canvas/evas_vg_gradient_linear.c16
-rw-r--r--src/lib/evas/canvas/evas_vg_gradient_radial.c17
-rw-r--r--src/lib/evas/canvas/evas_vg_node.c12
-rw-r--r--src/lib/evas/canvas/evas_vg_private.h18
-rw-r--r--src/lib/evas/canvas/evas_vg_shape.c41
13 files changed, 155 insertions, 1 deletions
diff --git a/src/lib/evas/canvas/efl_vg_base.eo b/src/lib/evas/canvas/efl_vg_base.eo
index 7ddfce5..15a8913 100644
--- a/src/lib/evas/canvas/efl_vg_base.eo
+++ b/src/lib/evas/canvas/efl_vg_base.eo
@@ -96,6 +96,11 @@ abstract Efl.VG.Base (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack)
96 @in pos_map: double; 96 @in pos_map: double;
97 } 97 }
98 } 98 }
99 dup {
100 params {
101 @in from: const(Efl.VG.Base)*;
102 }
103 }
99 } 104 }
100 implements { 105 implements {
101 Eo.Base.parent.set; 106 Eo.Base.parent.set;
diff --git a/src/lib/evas/canvas/efl_vg_container.eo b/src/lib/evas/canvas/efl_vg_container.eo
index b3a6ec4..21bb5e7 100644
--- a/src/lib/evas/canvas/efl_vg_container.eo
+++ b/src/lib/evas/canvas/efl_vg_container.eo
@@ -17,5 +17,6 @@ class Efl.VG.Container (Efl.VG.Base)
17 Eo.Base.destructor; 17 Eo.Base.destructor;
18 Efl.VG.Base.bounds_get; 18 Efl.VG.Base.bounds_get;
19 Efl.VG.Base.interpolate; 19 Efl.VG.Base.interpolate;
20 Efl.VG.Base.dup;
20 } 21 }
21} 22}
diff --git a/src/lib/evas/canvas/efl_vg_gradient.eo b/src/lib/evas/canvas/efl_vg_gradient.eo
index 959da5b..7f794cb 100644
--- a/src/lib/evas/canvas/efl_vg_gradient.eo
+++ b/src/lib/evas/canvas/efl_vg_gradient.eo
@@ -7,5 +7,6 @@ abstract Efl.VG.Gradient (Efl.VG.Base, Efl.Gfx.Gradient.Base)
7 Efl.Gfx.Gradient.Base.spread.set; 7 Efl.Gfx.Gradient.Base.spread.set;
8 Efl.Gfx.Gradient.Base.spread.get; 8 Efl.Gfx.Gradient.Base.spread.get;
9 Efl.VG.Base.interpolate; 9 Efl.VG.Base.interpolate;
10 Efl.VG.Base.dup;
10 } 11 }
11} 12}
diff --git a/src/lib/evas/canvas/efl_vg_gradient_linear.eo b/src/lib/evas/canvas/efl_vg_gradient_linear.eo
index aecfe4e..381ddb6 100644
--- a/src/lib/evas/canvas/efl_vg_gradient_linear.eo
+++ b/src/lib/evas/canvas/efl_vg_gradient_linear.eo
@@ -8,6 +8,7 @@ class Efl.VG.Gradient_Linear (Efl.VG.Gradient, Efl.Gfx.Gradient.Linear)
8 Efl.Gfx.Gradient.Linear.end.get; 8 Efl.Gfx.Gradient.Linear.end.get;
9 Efl.VG.Base.bounds_get; 9 Efl.VG.Base.bounds_get;
10 Efl.VG.Base.interpolate; 10 Efl.VG.Base.interpolate;
11 Efl.VG.Base.dup;
11 Eo.Base.constructor; 12 Eo.Base.constructor;
12 Eo.Base.destructor; 13 Eo.Base.destructor;
13 } 14 }
diff --git a/src/lib/evas/canvas/efl_vg_gradient_radial.eo b/src/lib/evas/canvas/efl_vg_gradient_radial.eo
index bd99848..860c4f7 100644
--- a/src/lib/evas/canvas/efl_vg_gradient_radial.eo
+++ b/src/lib/evas/canvas/efl_vg_gradient_radial.eo
@@ -10,6 +10,7 @@ class Efl.VG.Gradient_Radial (Efl.VG.Gradient, Efl.Gfx.Gradient.Radial)
10 Efl.Gfx.Gradient.Radial.focal.get; 10 Efl.Gfx.Gradient.Radial.focal.get;
11 Efl.VG.Base.bounds_get; 11 Efl.VG.Base.bounds_get;
12 Efl.VG.Base.interpolate; 12 Efl.VG.Base.interpolate;
13 Efl.VG.Base.dup;
13 Eo.Base.constructor; 14 Eo.Base.constructor;
14 Eo.Base.destructor; 15 Eo.Base.destructor;
15 } 16 }
diff --git a/src/lib/evas/canvas/efl_vg_shape.eo b/src/lib/evas/canvas/efl_vg_shape.eo
index e2d5c27..053a374 100644
--- a/src/lib/evas/canvas/efl_vg_shape.eo
+++ b/src/lib/evas/canvas/efl_vg_shape.eo
@@ -42,6 +42,7 @@ class Efl.VG.Shape (Efl.VG.Base, Efl.Gfx.Shape)
42 Efl.Gfx.Base.color_part.get; 42 Efl.Gfx.Base.color_part.get;
43 Efl.VG.Base.bounds_get; 43 Efl.VG.Base.bounds_get;
44 Efl.VG.Base.interpolate; 44 Efl.VG.Base.interpolate;
45 Efl.VG.Base.dup;
45 Eo.Base.constructor; 46 Eo.Base.constructor;
46 Eo.Base.destructor; 47 Eo.Base.destructor;
47 } 48 }
diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c
index 683f5ce..32ffbfa 100644
--- a/src/lib/evas/canvas/evas_vg_container.c
+++ b/src/lib/evas/canvas/evas_vg_container.c
@@ -135,6 +135,32 @@ _efl_vg_container_efl_vg_base_interpolate(Eo *obj,
135 return r; 135 return r;
136} 136}
137 137
138static void
139_efl_vg_container_efl_vg_base_dup(Eo *obj,
140 Efl_VG_Container_Data *pd,
141 const Efl_VG_Base *from)
142{
143 Efl_VG_Container_Data *fromd;
144 Eina_List *l;
145 Eo *child;
146
147 eo_do_super(obj, EFL_VG_CONTAINER_CLASS, efl_vg_dup(from));
148
149 fromd = eo_data_scope_get(from, EFL_VG_CONTAINER_CLASS);
150
151 EINA_LIST_FREE(pd->children, child)
152 eo_unref(child);
153
154 EINA_LIST_FOREACH(fromd->children, l, child)
155 {
156 // By setting parent, we automatically reference
157 // this new object as a child of obj. Magic at work !
158 eo_add_ref(eo_class_get(child),
159 obj,
160 efl_vg_dup(child));
161 }
162}
163
138EAPI Efl_VG* 164EAPI Efl_VG*
139evas_vg_container_add(Efl_VG *parent) 165evas_vg_container_add(Efl_VG *parent)
140{ 166{
diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c
index 495a493..dff4738 100644
--- a/src/lib/evas/canvas/evas_vg_gradient.c
+++ b/src/lib/evas/canvas/evas_vg_gradient.c
@@ -94,6 +94,22 @@ _efl_vg_gradient_efl_vg_base_interpolate(Eo *obj,
94 return EINA_TRUE; 94 return EINA_TRUE;
95} 95}
96 96
97static void
98_efl_vg_gradient_efl_vg_base_dup(Eo *obj,
99 Efl_VG_Gradient_Data *pd EINA_UNUSED,
100 const Efl_VG_Base *from)
101{
102 Efl_VG_Gradient_Data *fromd;
103
104 eo_do_super(obj, EFL_VG_GRADIENT_CLASS, efl_vg_dup(from));
105
106 fromd = eo_data_scope_get(from, EFL_VG_GRADIENT_CLASS);
107
108 eo_do(obj,
109 efl_gfx_gradient_stop_set(fromd->colors, fromd->colors_count),
110 efl_gfx_gradient_spread_set(fromd->s));
111}
112
97EAPI void 113EAPI void
98evas_vg_gradient_stop_set(Eo *obj, const Efl_Gfx_Gradient_Stop *colors, unsigned int length) 114evas_vg_gradient_stop_set(Eo *obj, const Efl_Gfx_Gradient_Stop *colors, unsigned int length)
99{ 115{
diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c
index 609dc7a..7234d4b 100644
--- a/src/lib/evas/canvas/evas_vg_gradient_linear.c
+++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c
@@ -151,6 +151,22 @@ _efl_vg_gradient_linear_efl_vg_base_interpolate(Eo *obj,
151 return EINA_TRUE; 151 return EINA_TRUE;
152} 152}
153 153
154static void
155_efl_vg_gradient_linear_efl_vg_base_dup(Eo *obj,
156 Efl_VG_Gradient_Linear_Data *pd EINA_UNUSED,
157 const Efl_VG_Base *from)
158{
159 Efl_VG_Gradient_Linear_Data *fromd;
160
161 eo_do_super(obj, EFL_VG_GRADIENT_LINEAR_CLASS, efl_vg_dup(from));
162
163 fromd = eo_data_scope_get(from, EFL_VG_GRADIENT_LINEAR_CLASS);
164
165 eo_do(obj,
166 efl_gfx_gradient_linear_start_set(fromd->start.x, fromd->start.y),
167 efl_gfx_gradient_linear_end_set(fromd->end.x, fromd->end.y));
168}
169
154EAPI void 170EAPI void
155evas_vg_gradient_linear_start_set(Eo *obj, double x, double y) 171evas_vg_gradient_linear_start_set(Eo *obj, double x, double y)
156{ 172{
diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c
index 52ed957..d6d62c5 100644
--- a/src/lib/evas/canvas/evas_vg_gradient_radial.c
+++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c
@@ -170,6 +170,23 @@ _efl_vg_gradient_radial_efl_vg_base_interpolate(Eo *obj,
170 return EINA_TRUE; 170 return EINA_TRUE;
171} 171}
172 172
173static void
174_efl_vg_gradient_radial_efl_vg_base_dup(Eo *obj,
175 Efl_VG_Gradient_Radial_Data *pd EINA_UNUSED,
176 const Efl_VG_Base *from)
177{
178 Efl_VG_Gradient_Radial_Data *fromd;
179
180 eo_do_super(obj, EFL_VG_GRADIENT_RADIAL_CLASS, efl_vg_dup(from));
181
182 fromd = eo_data_scope_get(from, EFL_VG_GRADIENT_RADIAL_CLASS);
183
184 eo_do(obj,
185 efl_gfx_gradient_radial_focal_set(fromd->focal.x, fromd->focal.y),
186 efl_gfx_gradient_radial_center_set(fromd->center.x, fromd->center.y),
187 efl_gfx_gradient_radial_radius_set(fromd->radius));
188}
189
173EAPI void 190EAPI void
174evas_vg_gradient_radial_center_set(Eo *obj, double x, double y) 191evas_vg_gradient_radial_center_set(Eo *obj, double x, double y)
175{ 192{
diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c
index 901e550..d160b45 100644
--- a/src/lib/evas/canvas/evas_vg_node.c
+++ b/src/lib/evas/canvas/evas_vg_node.c
@@ -744,7 +744,11 @@ _efl_vg_base_dup(Eo *obj, Efl_VG_Base_Data *pd, const Efl_VG_Base *from)
744 Eo *parent = NULL; 744 Eo *parent = NULL;
745 745
746 fromd = eo_data_scope_get(from, EFL_VG_BASE_CLASS); 746 fromd = eo_data_scope_get(from, EFL_VG_BASE_CLASS);
747 pd->name = eina_stringshare_ref(fromd->name); 747 if (pd->name != fromd->name)
748 {
749 eina_stringshare_del(pd->name);
750 pd->name = eina_stringshare_ref(fromd->name);
751 }
748 752
749 _efl_vg_base_parent_checked_get(obj, &parent, &cd); 753 _efl_vg_base_parent_checked_get(obj, &parent, &cd);
750 if (cd) _efl_vg_base_name_insert(obj, pd, cd); 754 if (cd) _efl_vg_base_name_insert(obj, pd, cd);
@@ -755,6 +759,12 @@ _efl_vg_base_dup(Eo *obj, Efl_VG_Base_Data *pd, const Efl_VG_Base *from)
755 pd->intp = NULL; 759 pd->intp = NULL;
756 } 760 }
757 761
762 if (pd->renderer)
763 {
764 eo_del(pd->renderer);
765 pd->renderer = NULL;
766 }
767
758 if (fromd->m) 768 if (fromd->m)
759 { 769 {
760 pd->m = pd->m ? pd->m : malloc(sizeof (Eina_Matrix3)) ; 770 pd->m = pd->m ? pd->m : malloc(sizeof (Eina_Matrix3)) ;
diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h
index 8ee62b6..102de5b 100644
--- a/src/lib/evas/canvas/evas_vg_private.h
+++ b/src/lib/evas/canvas/evas_vg_private.h
@@ -73,6 +73,24 @@ _efl_vg_base_changed(Eo *obj)
73 eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); 73 eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL));
74} 74}
75 75
76static inline void *
77_efl_vg_realloc(void *from, unsigned int sz)
78{
79 void *result;
80
81 result = sz > 0 ? realloc(from, sz) : NULL;
82 if (!result) free(from);
83
84 return result;
85}
86
87static inline void
88_efl_vg_clean_object(Eo **obj)
89{
90 if (*obj) eo_unref(*obj);
91 *obj = NULL;
92}
93
76#define EFL_VG_COMPUTE_MATRIX(Current, Parent, Nd) \ 94#define EFL_VG_COMPUTE_MATRIX(Current, Parent, Nd) \
77 Eina_Matrix3 *Current = Nd->m; \ 95 Eina_Matrix3 *Current = Nd->m; \
78 Eina_Matrix3 _matrix_tmp; \ 96 Eina_Matrix3 _matrix_tmp; \
diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c
index d17268d..520c684 100644
--- a/src/lib/evas/canvas/evas_vg_shape.c
+++ b/src/lib/evas/canvas/evas_vg_shape.c
@@ -375,6 +375,47 @@ _efl_vg_shape_efl_vg_base_interpolate(Eo *obj,
375 return r; 375 return r;
376} 376}
377 377
378static void
379_efl_vg_shape_efl_vg_base_dup(Eo *obj, Efl_VG_Shape_Data *pd EINA_UNUSED, const Efl_VG_Base *from)
380{
381 Efl_VG_Shape_Data *fromd;
382 Eo *parent;
383 Eo *fill = NULL, *stroke_fill = NULL, *stroke_marker = NULL;
384
385 eo_do_super(obj, MY_CLASS, efl_vg_dup(from));
386
387 eo_do(obj, parent = eo_parent_get());
388
389 fromd = eo_data_scope_get(from, MY_CLASS);
390
391 if (fromd->fill)
392 {
393 fill = eo_add(eo_class_get(fromd->fill),
394 parent,
395 efl_vg_dup(fromd->fill));
396 }
397
398 if (fromd->stroke.fill)
399 {
400 stroke_fill = eo_add(eo_class_get(fromd->stroke.fill),
401 parent,
402 efl_vg_dup(fromd->stroke.fill));
403 }
404
405 if (fromd->stroke.marker)
406 {
407 stroke_marker = eo_add(eo_class_get(fromd->stroke.marker),
408 parent,
409 efl_vg_dup(fromd->stroke.marker));
410 }
411
412 eo_do(obj,
413 efl_vg_shape_fill_set(fill),
414 efl_vg_shape_stroke_fill_set(stroke_fill),
415 efl_vg_shape_stroke_marker_set(stroke_marker),
416 efl_gfx_shape_dup(from));
417}
418
378EAPI double 419EAPI double
379evas_vg_shape_stroke_scale_get(Eo *obj) 420evas_vg_shape_stroke_scale_get(Eo *obj)
380{ 421{