summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-06-05 10:54:13 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-08-21 16:40:31 +0200
commitd595324a8dbccabf80d13d8f22e59c6166b4c2b6 (patch)
tree34159a6dab956ca255443bc986196cf60a2e8c2c
parentc73ccef4a753bc29e3d6589a38d1e65f462183fd (diff)
evas: add an unique name for each Efl.VG.Base object and make it possible to find it from parent.
-rw-r--r--src/lib/evas/canvas/efl_vg_base.eo45
-rw-r--r--src/lib/evas/canvas/efl_vg_container.eo11
-rw-r--r--src/lib/evas/canvas/evas_vg_container.c23
-rw-r--r--src/lib/evas/canvas/evas_vg_node.c55
-rw-r--r--src/lib/evas/canvas/evas_vg_private.h4
-rw-r--r--src/lib/evas/canvas/evas_vg_root_node.c13
6 files changed, 133 insertions, 18 deletions
diff --git a/src/lib/evas/canvas/efl_vg_base.eo b/src/lib/evas/canvas/efl_vg_base.eo
index 19464646d6..1567f5adcb 100644
--- a/src/lib/evas/canvas/efl_vg_base.eo
+++ b/src/lib/evas/canvas/efl_vg_base.eo
@@ -3,6 +3,27 @@ abstract Efl.VG.Base (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack)
3 eo_prefix: efl_vg; 3 eo_prefix: efl_vg;
4 legacy_prefix: evas_vg_node; 4 legacy_prefix: evas_vg_node;
5 methods { 5 methods {
6 @property name {
7 set {
8 /*@
9 Set an unique name from the parent point of view. @c NULL means
10 no name.
11 @since 1.15
12 */
13 }
14 get {
15 /*@
16 Get an unique name from the parent point of view . @c NULL means
17 no name. When set a parent after the name what defined, it might
18 be forced back to NULL if the parent already has a node of that
19 name.
20 @since 1.15
21 */
22 }
23 values {
24 name: const(char) *;
25 }
26 }
6 @property transformation { 27 @property transformation {
7 set { 28 set {
8 [[Sets the transformation matrix to be used for this node object. 29 [[Sets the transformation matrix to be used for this node object.
@@ -40,21 +61,21 @@ abstract Efl.VG.Base (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack)
40 } 61 }
41 @property mask { 62 @property mask {
42 set { 63 set {
43 } 64 }
44 get { 65 get {
45 } 66 }
46 values { 67 values {
47 m: Efl_VG *; 68 m: Efl_VG *;
48 } 69 }
49 } 70 }
50/* quality { 71/* quality {
51 set { 72 set {
52 } 73 }
53 get { 74 get {
54 } 75 }
55 values { 76 values {
56 Evas_VG_Quality q; 77 Evas_VG_Quality q;
57 } 78 }
58 } */ 79 } */
59 bounds_get { 80 bounds_get {
60 [[Give the bounding box in screen coordinate as being drawn. 81 [[Give the bounding box in screen coordinate as being drawn.
diff --git a/src/lib/evas/canvas/efl_vg_container.eo b/src/lib/evas/canvas/efl_vg_container.eo
index 0c954e2696..19a7b30cca 100644
--- a/src/lib/evas/canvas/efl_vg_container.eo
+++ b/src/lib/evas/canvas/efl_vg_container.eo
@@ -1,6 +1,17 @@
1class Efl.VG.Container (Efl.VG.Base) 1class Efl.VG.Container (Efl.VG.Base)
2{ 2{
3 legacy_prefix: evas_vg_container; 3 legacy_prefix: evas_vg_container;
4 methods {
5 child_get {
6 params {
7 @in name: const(char)*;
8 }
9 return: Efl.VG.Base *;
10 }
11 children_get {
12 return: free(own(iterator<Efl.VG.Base *>*), eina_iterator_free) @warn_unused;
13 }
14 }
4 implements { 15 implements {
5 Eo.Base.constructor; 16 Eo.Base.constructor;
6 Eo.Base.destructor; 17 Eo.Base.destructor;
diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c
index f3ee7c9962..e31126015b 100644
--- a/src/lib/evas/canvas/evas_vg_container.c
+++ b/src/lib/evas/canvas/evas_vg_container.c
@@ -31,6 +31,8 @@ _efl_vg_container_eo_base_constructor(Eo *obj,
31{ 31{
32 Efl_VG_Base_Data *nd; 32 Efl_VG_Base_Data *nd;
33 33
34 pd->names = eina_hash_stringshared_new(NULL);
35
34 obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor()); 36 obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
35 37
36 nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS); 38 nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS);
@@ -45,6 +47,9 @@ _efl_vg_container_eo_base_destructor(Eo *obj,
45 Efl_VG_Container_Data *pd EINA_UNUSED) 47 Efl_VG_Container_Data *pd EINA_UNUSED)
46{ 48{
47 eo_do_super(obj, MY_CLASS, eo_destructor()); 49 eo_do_super(obj, MY_CLASS, eo_destructor());
50
51 eina_hash_free(pd->names);
52 pd->names = NULL;
48} 53}
49 54
50static void 55static void
@@ -74,6 +79,24 @@ _efl_vg_container_efl_vg_base_bounds_get(Eo *obj EINA_UNUSED,
74 } 79 }
75} 80}
76 81
82static Efl_VG_Base *
83_efl_vg_container_child_get(Eo *obj EINA_UNUSED, Efl_VG_Container_Data *pd, const char *name)
84{
85 const char *tmp = eina_stringshare_add(name);
86 Efl_VG_Base *r;
87
88 r = eina_hash_find(pd->names, tmp);
89 eina_stringshare_del(tmp);
90
91 return r;
92}
93
94static Eina_Iterator *
95_efl_vg_container_children_get(Eo *obj EINA_UNUSED, Efl_VG_Container_Data *pd)
96{
97 return eina_list_iterator_new(pd->children);
98}
99
77EAPI Efl_VG* 100EAPI Efl_VG*
78evas_vg_container_add(Efl_VG *parent) 101evas_vg_container_add(Efl_VG *parent)
79{ 102{
diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c
index b1c8cbb5f7..b54b7ba771 100644
--- a/src/lib/evas/canvas/evas_vg_node.c
+++ b/src/lib/evas/canvas/evas_vg_node.c
@@ -277,6 +277,49 @@ _efl_vg_base_eo_base_destructor(Eo *obj, Efl_VG_Base_Data *pd)
277} 277}
278 278
279static void 279static void
280_efl_vg_base_name_insert(Eo *obj, Efl_VG_Base_Data *pd, Efl_VG_Container_Data *cd)
281{
282 Eo *set;
283
284 if (!pd->name) return ;
285
286 set = eina_hash_find(cd->names, pd->name);
287 if (set == obj) return ;
288
289 if (set)
290 {
291 eina_stringshare_del(pd->name);
292 pd->name = NULL;
293 }
294 else
295 {
296 eina_hash_direct_add(cd->names, pd->name, obj);
297 }
298}
299
300static void
301_efl_vg_base_name_set(Eo *obj, Efl_VG_Base_Data *pd, const char *name)
302{
303 Efl_VG_Container_Data *cd = NULL;
304 Eo *parent = NULL;
305
306 if (_efl_vg_base_parent_checked_get(obj, &parent, &cd))
307 {
308 if (pd->name) eina_hash_del(cd->names, pd->name, obj);
309 }
310
311 eina_stringshare_replace(&pd->name, name);
312
313 if (cd) _efl_vg_base_name_insert(obj, pd, cd);
314}
315
316static const char *
317_efl_vg_base_name_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd)
318{
319 return pd->name;
320}
321
322static void
280_efl_vg_base_eo_base_parent_set(Eo *obj, 323_efl_vg_base_eo_base_parent_set(Eo *obj,
281 Efl_VG_Base_Data *pd EINA_UNUSED, 324 Efl_VG_Base_Data *pd EINA_UNUSED,
282 Eo *parent) 325 Eo *parent)
@@ -308,11 +351,19 @@ _efl_vg_base_eo_base_parent_set(Eo *obj,
308 351
309 // FIXME: this may become slow with to much object 352 // FIXME: this may become slow with to much object
310 if (old_cd) 353 if (old_cd)
311 old_cd->children = eina_list_remove(old_cd->children, obj); 354 {
355 old_cd->children = eina_list_remove(old_cd->children, obj);
356
357 if (pd->name) eina_hash_del(old_cd->names, pd->name, obj);
358 }
312 359
313 eo_do_super(obj, MY_CLASS, eo_parent_set(parent)); 360 eo_do_super(obj, MY_CLASS, eo_parent_set(parent));
314 if (cd) 361 if (cd)
315 cd->children = eina_list_append(cd->children, obj); 362 {
363 cd->children = eina_list_append(cd->children, obj);
364
365 _efl_vg_base_name_insert(obj, pd, cd);
366 }
316 367
317 _efl_vg_base_changed(old_parent); 368 _efl_vg_base_changed(old_parent);
318 _efl_vg_base_changed(obj); 369 _efl_vg_base_changed(obj);
diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h
index af4912ae72..cc5222f8f3 100644
--- a/src/lib/evas/canvas/evas_vg_private.h
+++ b/src/lib/evas/canvas/evas_vg_private.h
@@ -9,6 +9,8 @@ typedef struct _Efl_VG_Gradient_Data Efl_VG_Gradient_Data;
9 9
10struct _Efl_VG_Base_Data 10struct _Efl_VG_Base_Data
11{ 11{
12 const char *name;
13
12 Eina_Matrix3 *m; 14 Eina_Matrix3 *m;
13 Efl_VG *mask; 15 Efl_VG *mask;
14 Ector_Renderer *renderer; 16 Ector_Renderer *renderer;
@@ -26,6 +28,8 @@ struct _Efl_VG_Base_Data
26struct _Efl_VG_Container_Data 28struct _Efl_VG_Container_Data
27{ 29{
28 Eina_List *children; 30 Eina_List *children;
31
32 Eina_Hash *names;
29}; 33};
30 34
31struct _Efl_VG_Gradient_Data 35struct _Efl_VG_Gradient_Data
diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c
index 0f06d46fe7..6e50cdb430 100644
--- a/src/lib/evas/canvas/evas_vg_root_node.c
+++ b/src/lib/evas/canvas/evas_vg_root_node.c
@@ -73,17 +73,22 @@ _efl_vg_root_node_eo_base_constructor(Eo *obj,
73 Efl_VG_Base_Data *nd; 73 Efl_VG_Base_Data *nd;
74 Eo *parent; 74 Eo *parent;
75 75
76 // We are copying here the code of the vg container to make it possible to
77 // enforce that the root node is the only one to attach to an Evas_Object_VG
78 cd = eo_data_scope_get(obj, EFL_VG_CONTAINER_CLASS);
79 cd->children = NULL;
80 cd->names = eina_hash_stringshared_new(NULL);
81
76 // Nice little hack, jump over parent constructor in Efl_VG_Root 82 // Nice little hack, jump over parent constructor in Efl_VG_Root
77 obj = eo_do_super_ret(obj, EFL_VG_BASE_CLASS, obj, eo_constructor()); 83 obj = eo_do_super_ret(obj, EFL_VG_BASE_CLASS, obj, eo_constructor());
78 eo_do(obj, parent = eo_parent_get()); 84 eo_do(obj,
85 parent = eo_parent_get(),
86 efl_vg_name_set("root"));
79 if (!eo_isa(parent, EVAS_VG_CLASS)) { 87 if (!eo_isa(parent, EVAS_VG_CLASS)) {
80 ERR("Parent of VG_ROOT_NODE must be a VG_CLASS"); 88 ERR("Parent of VG_ROOT_NODE must be a VG_CLASS");
81 return NULL; 89 return NULL;
82 } 90 }
83 91
84 cd = eo_data_scope_get(obj, EFL_VG_CONTAINER_CLASS);
85 cd->children = NULL;
86
87 nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS); 92 nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS);
88 nd->render_pre = _evas_vg_root_node_render_pre; 93 nd->render_pre = _evas_vg_root_node_render_pre;
89 nd->data = cd; 94 nd->data = cd;