summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_vg_node.c
blob: e5883e465a6f8b9d6d86d8cdf8f5d185a8265e60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
#include "evas_common_private.h"
#include "evas_private.h"

#include "evas_vg_private.h"

#include <string.h>
#include <math.h>

#define MY_CLASS EFL_VG_CLASS

static const Efl_VG_Interpolation interpolation_identity = {
  { 0, 0, 0, 1 },
  { 0, 0, 0, 1 },
  { 0, 0, 0 },
  { 1, 1, 1 },
  { 0, 0, 0 }
};

static void
_efl_vg_property_changed(void *data, const Efl_Event *event EINA_UNUSED)
{
   Efl_VG_Data *pd = data;
   Eo *parent;

   if (!pd->flags) pd->flags = EFL_GFX_CHANGE_FLAG_ALL;

   parent = efl_parent_get(event->object);
   efl_event_callback_call(parent, event->desc, event->info);
}

static void
_efl_vg_transformation_set(Eo *obj,
                                Efl_VG_Data *pd,
                                const Eina_Matrix3 *m)
{
   if (pd->intp)
     {
        free(pd->intp);
        pd->intp = NULL;
     }

   if (m)
     {
        if (!pd->m)
          {
             pd->m = malloc(sizeof (Eina_Matrix3));
             if (!pd->m) return;
          }
        memcpy(pd->m, m, sizeof (Eina_Matrix3));
     }
   else
     {
        free(pd->m);
        pd->m = NULL;
     }

   pd->flags |= EFL_GFX_CHANGE_FLAG_MATRIX;
   _efl_vg_changed(obj);
}

const Eina_Matrix3 *
_efl_vg_transformation_get(Eo *obj EINA_UNUSED, Efl_VG_Data *pd)
{
   return pd->m;
}

static void
_efl_vg_origin_set(Eo *obj,
                        Efl_VG_Data *pd,
                        double x, double y)
{
   pd->x = x;
   pd->y = y;

   _efl_vg_changed(obj);
}

static void
_efl_vg_origin_get(Eo *obj EINA_UNUSED,
                        Efl_VG_Data *pd,
                        double *x, double *y)
{
   if (x) *x = pd->x;
   if (y) *y = pd->y;
}

static void
_efl_vg_efl_gfx_position_set(Eo *obj EINA_UNUSED, Efl_VG_Data *pd, Eina_Position2D pos)
{
   pd->x = (double) pos.x;
   pd->y = (double) pos.y;

   _efl_vg_changed(obj);
}

static Eina_Position2D
_efl_vg_efl_gfx_position_get(Eo *obj EINA_UNUSED, Efl_VG_Data *pd)
{
   // NOTE: This casts double to int!
   return EINA_POSITION2D(pd->x, pd->y);
}

static void
_efl_vg_efl_gfx_visible_set(Eo *obj EINA_UNUSED,
                                      Efl_VG_Data *pd, Eina_Bool v)
{
   pd->visibility = v;

   _efl_vg_changed(obj);
}


static Eina_Bool
_efl_vg_efl_gfx_visible_get(Eo *obj EINA_UNUSED,
                                      Efl_VG_Data *pd)
{
   return pd->visibility;
}

static void
_efl_vg_efl_gfx_color_color_set(Eo *obj EINA_UNUSED,
                                    Efl_VG_Data *pd,
                                    int r, int g, int b, int a)
{
   if (r > 255) r = 255;
   if (r < 0) r = 0;
   if (g > 255) g = 255;
   if (g < 0) g = 0;
   if (b > 255) b = 255;
   if (b < 0) b = 0;
   if (a > 255) a = 255;
   if (a < 0) a = 0;
   if (r > a)
     {
        r = a;
        ERR("Evas only handles pre multiplied colors!");
     }
   if (g > a)
     {
        g = a;
        ERR("Evas only handles pre multiplied colors!");
     }
   if (b > a)
     {
        b = a;
        ERR("Evas only handles pre multiplied colors!");
     }

   pd->r = r;
   pd->g = g;
   pd->b = b;
   pd->a = a;

   _efl_vg_changed(obj);
}

static void
_efl_vg_efl_gfx_color_color_get(Eo *obj EINA_UNUSED,
                                    Efl_VG_Data *pd,
                                    int *r, int *g, int *b, int *a)
{
   if (r) *r = pd->r;
   if (g) *g = pd->g;
   if (b) *b = pd->b;
   if (a) *a = pd->a;
}

static void
_efl_vg_mask_set(Eo *obj EINA_UNUSED,
                       Efl_VG_Data *pd,
                       Efl_VG *r)
{
   Efl_VG *tmp = pd->mask;

   pd->mask = efl_ref(r);
   efl_unref(tmp);

   _efl_vg_changed(obj);
}

static Efl_VG*
_efl_vg_mask_get(Eo *obj EINA_UNUSED, Efl_VG_Data *pd)
{
   return pd->mask;
}

static Eina_Size2D
_efl_vg_efl_gfx_size_get(Eo *obj, Efl_VG_Data *pd EINA_UNUSED)
{
   Eina_Rect r;

   efl_vg_bounds_get(obj, &r);
   return r.size;
}

EOLIAN static Eina_Rect
_efl_vg_efl_gfx_geometry_get(Eo *obj, Efl_VG_Data *pd EINA_UNUSED)
{
   Eina_Rect r;
   r.pos = efl_gfx_position_get(obj);
   r.size = efl_gfx_size_get(obj);
   return r;
}

// Parent should be a container otherwise dismissing the stacking operation
static Eina_Bool
_efl_vg_parent_checked_get(Eo *obj,
                                Eo **parent,
                                Efl_VG_Container_Data **cd)
{
   *cd = NULL;
   *parent = efl_parent_get(obj);

   if (efl_isa(*parent, EFL_VG_CONTAINER_CLASS))
     {
        *cd = efl_data_scope_get(*parent, EFL_VG_CONTAINER_CLASS);
        if (!*cd)
          {
             ERR("Can't get EFL_VG_CONTAINER_CLASS data.");
             goto on_error;
          }
     }
   else if (efl_isa(*parent, EFL_CANVAS_VG_CLASS))
     {
        goto on_error;
     }
   else if (*parent != NULL)
     {
        ERR("Parent of unauthorized class '%s'.", efl_class_name_get(efl_class_get(*parent)));
        goto on_error;
     }

   return EINA_TRUE;

 on_error:
   *parent = NULL;
   *cd = NULL;
   return EINA_FALSE;
}

static Eo *
_efl_vg_efl_object_constructor(Eo *obj,
                                 Efl_VG_Data *pd)
{
   Efl_VG_Container_Data *cd = NULL;
   Eo *parent;

   obj = efl_constructor(efl_super(obj, MY_CLASS));

   if (!_efl_vg_parent_checked_get(obj, &parent, &cd)) {
        ERR("Failed");
        return NULL;
   }

   efl_event_callback_add(obj, EFL_GFX_PATH_EVENT_CHANGED, _efl_vg_property_changed, pd);
   pd->flags = EFL_GFX_CHANGE_FLAG_ALL;
   pd->changed = EINA_TRUE;

   return obj;
}

static void
_efl_vg_efl_object_destructor(Eo *obj, Efl_VG_Data *pd)
{
   if (pd->m)
     {
        free(pd->m);
        pd->m = NULL;
     }

   if (pd->renderer)
     {
        efl_del(pd->renderer);
        pd->renderer = NULL;
     }
   if (pd->intp)
     {
        free(pd->intp);
        pd->intp = NULL;
     }

   efl_destructor(efl_super(obj, MY_CLASS));
}

static void
_efl_vg_name_insert(Eo *obj, Efl_VG_Data *pd, Efl_VG_Container_Data *cd)
{
   Eo *set;

   if (!pd->name) return ;

   set = eina_hash_find(cd->names, pd->name);
   if (set == obj) return ;

   if (set)
     {
        eina_stringshare_del(pd->name);
        pd->name = NULL;
     }
   else
     {
        eina_hash_direct_add(cd->names, pd->name, obj);
     }
}

static void
_efl_vg_name_set(Eo *obj, Efl_VG_Data *pd, const char *name)
{
   Efl_VG_Container_Data *cd = NULL;
   Eo *parent = NULL;

   if (_efl_vg_parent_checked_get(obj, &parent, &cd))
     {
        if (pd->name) eina_hash_del(cd->names, pd->name, obj);
     }

   eina_stringshare_replace(&pd->name, name);

   if (cd) _efl_vg_name_insert(obj, pd, cd);
}

static const char *
_efl_vg_name_get(Eo *obj EINA_UNUSED, Efl_VG_Data *pd)
{
   return pd->name;
}

static void
_efl_vg_efl_object_parent_set(Eo *obj,
                                Efl_VG_Data *pd EINA_UNUSED,
                                Eo *parent)
{
   Efl_VG_Container_Data *cd = NULL;
   Efl_VG_Container_Data *old_cd = NULL;
   Eo *old_parent;

   if (efl_isa(parent, EFL_VG_CONTAINER_CLASS))
     {
        cd = efl_data_scope_get(parent, EFL_VG_CONTAINER_CLASS);
        if (!cd)
          {
             ERR("Can't get EFL_VG_CONTAINER_CLASS data from %p.", parent);
             goto on_error;
          }
     }
   else if (parent != NULL)
     {
        ERR("%p not even an EVAS_VG_CLASS.", parent);
        goto on_error;
     }

   if (!_efl_vg_parent_checked_get(obj, &old_parent, &old_cd))
     {
        ERR("Can't check the old parent of %p.", obj);
        goto on_error;
     }

   // FIXME: this may become slow with to much object
   if (old_cd)
     {
        old_cd->children = eina_list_remove(old_cd->children, obj);

        if (pd->name) eina_hash_del(old_cd->names, pd->name, obj);
     }

   efl_parent_set(efl_super(obj, MY_CLASS), parent);
   if (cd)
     {
        cd->children = eina_list_append(cd->children, obj);

        _efl_vg_name_insert(obj, pd, cd);
     }

   _efl_vg_changed(old_parent);
   _efl_vg_changed(obj);
   _efl_vg_changed(parent);

   return ;

 on_error:
   return ;
}

static void
_efl_vg_efl_gfx_stack_raise(Eo *obj, Efl_VG_Data *pd EINA_UNUSED)
{
   Efl_VG_Container_Data *cd;
   Eina_List *lookup, *next;
   Eo *parent;

   parent = efl_parent_get(obj);
   if (!efl_isa(parent, EFL_VG_CONTAINER_CLASS)) goto on_error;
   cd = efl_data_scope_get(parent, EFL_VG_CONTAINER_CLASS);

   // FIXME: this could become slow with to much object
   lookup = eina_list_data_find_list(cd->children, obj);
   if (!lookup) goto on_error;

   next = eina_list_next(lookup);
   if (!next) return ;

   cd->children = eina_list_remove_list(cd->children, lookup);
   cd->children = eina_list_append_relative_list(cd->children, obj, next);

   _efl_vg_changed(parent);
   return ;

 on_error:
   ERR("Err");
}

static void
_efl_vg_efl_gfx_stack_stack_above(Eo *obj,
                                       Efl_VG_Data *pd EINA_UNUSED,
                                       Efl_Gfx_Stack *above)
{
   Efl_VG_Container_Data *cd;
   Eina_List *lookup, *ref;
   Eo *parent;

   parent = efl_parent_get(obj);
   if (!efl_isa(parent, EFL_VG_CONTAINER_CLASS)) goto on_error;
   cd = efl_data_scope_get(parent, EFL_VG_CONTAINER_CLASS);

   // FIXME: this could become slow with to much object
   lookup = eina_list_data_find_list(cd->children, obj);
   if (!lookup) goto on_error;

   ref = eina_list_data_find_list(cd->children, above);
   if (!ref) goto on_error;

   cd->children = eina_list_remove_list(cd->children, lookup);
   cd->children = eina_list_append_relative_list(cd->children, obj, ref);

   _efl_vg_changed(parent);
   return ;

 on_error:
   ERR("Err");
}

static void
_efl_vg_efl_gfx_stack_stack_below(Eo *obj,
                                       Efl_VG_Data *pd EINA_UNUSED,
                                       Efl_Gfx_Stack *below)
{
   Efl_VG_Container_Data *cd;
   Eina_List *lookup, *ref;
   Eo *parent;

   parent = efl_parent_get(obj);
   if (!efl_isa(parent, EFL_VG_CONTAINER_CLASS)) goto on_error;
   cd = efl_data_scope_get(parent, EFL_VG_CONTAINER_CLASS);

   // FIXME: this could become slow with to much object
   lookup = eina_list_data_find_list(cd->children, obj);
   if (!lookup) goto on_error;

   ref = eina_list_data_find_list(cd->children, below);
   if (!ref) goto on_error;

   cd->children = eina_list_remove_list(cd->children, lookup);
   cd->children = eina_list_prepend_relative_list(cd->children, obj, ref);

   _efl_vg_changed(parent);
   return ;

 on_error:
   ERR("Err");
}

static void
_efl_vg_efl_gfx_stack_lower(Eo *obj, Efl_VG_Data *pd EINA_UNUSED)
{
   Efl_VG_Container_Data *cd;
   Eina_List *lookup, *prev;
   Eo *parent;

   parent = efl_parent_get(obj);
   if (!efl_isa(parent, EFL_VG_CONTAINER_CLASS)) goto on_error;
   cd = efl_data_scope_get(parent, EFL_VG_CONTAINER_CLASS);

   // FIXME: this could become slow with to much object
   lookup = eina_list_data_find_list(cd->children, obj);
   if (!lookup) goto on_error;

   prev = eina_list_prev(lookup);
   if (!prev) return ;

   cd->children = eina_list_remove_list(cd->children, lookup);
   cd->children = eina_list_prepend_relative_list(cd->children, obj, prev);

   _efl_vg_changed(parent);
   return ;

 on_error:
   ERR("Err");
}

static Eo *
_efl_vg_root_parent_get(Eo *obj)
{
   Eo *parent;

   parent = efl_parent_get(obj);

   if (!parent) return obj;
   return _efl_vg_root_parent_get(parent);
}

static void
_efl_vg_walk_down_at(Eo *root, Eina_Array *a, Eina_Rectangle *r)
{
   Eina_Rect bounds;

   efl_vg_bounds_get(root, &bounds);
   if (!eina_rectangles_intersect(&bounds.rect, r)) return ;

   eina_array_push(a, root);

   if (efl_isa(root, EFL_VG_CONTAINER_CLASS))
     {
        Efl_VG_Container_Data *cd;
        Eina_List *l;
        Eo *child;

        cd = efl_data_scope_get(root, EFL_VG_CONTAINER_CLASS);
        EINA_LIST_FOREACH(cd->children, l, child)
          _efl_vg_walk_down_at(child, a, r);
     }
}

static void
_efl_vg_object_at(Eo *obj, Eina_Array *a, Eina_Rectangle *r)
{
   Eo *root;

   root = _efl_vg_root_parent_get(obj);
   if (!root) return ;

   _efl_vg_walk_down_at(root, a, r);
}

static Efl_Gfx_Stack *
_efl_vg_efl_gfx_stack_below_get(Eo *obj, Efl_VG_Data *pd EINA_UNUSED)
{
   Eina_Rect r;
   Eina_Array a;
   Eo *current;
   Eo *below = NULL;
   Eina_Array_Iterator iterator;
   unsigned int i;

   efl_vg_bounds_get(obj, &r);

   eina_array_step_set(&a, sizeof (Eina_Array), 8);

   _efl_vg_object_at(obj, &a, &r.rect);

   EINA_ARRAY_ITER_NEXT(&a, i, current, iterator)
     if (current == obj)
       {
          i++;
          if (i < eina_array_count(&a))
            below = eina_array_data_get(&a, i);
          break;
       }

   eina_array_flush(&a);

   return below;
}

static Efl_Gfx_Stack *
_efl_vg_efl_gfx_stack_above_get(Eo *obj, Efl_VG_Data *pd EINA_UNUSED)
{
   Eina_Rect r;
   Eina_Array a;
   Eo *current;
   Eo *above = NULL;
   Eina_Array_Iterator iterator;
   unsigned int i;

   efl_vg_bounds_get(obj, &r);

   eina_array_step_set(&a, sizeof (Eina_Array), 8);

   _efl_vg_object_at(obj, &a, &r.rect);

   EINA_ARRAY_ITER_NEXT(&a, i, current, iterator)
     if (current == obj)
       {
          if (i > 0)
            above = eina_array_data_get(&a, i - 1);
          break;
       }

   eina_array_flush(&a);

   return above;
}

static Efl_VG_Interpolation *
_efl_vg_interpolation_get(Efl_VG_Data *pd)
{
   Eina_Matrix4 m;

   if (!pd->m) return NULL;
   if (pd->intp) return pd->intp;

   pd->intp = calloc(1, sizeof (Efl_VG_Interpolation));
   if (!pd->intp) return NULL;

   eina_matrix3_matrix4_to(&m, pd->m);

   if (eina_matrix4_quaternion_to(&pd->intp->rotation,
                                  &pd->intp->perspective,
                                  &pd->intp->translation,
                                  &pd->intp->scale,
                                  &pd->intp->skew,
                                  &m))
     return pd->intp;

   free(pd->intp);
   pd->intp = NULL;

   return NULL;
}

static inline void
_efl_vg_interpolate_point(Eina_Point_3D *d,
                          const Eina_Point_3D *a, const Eina_Point_3D *b,
                          double pos_map, double from_map)
{
   d->x = a->x * from_map + b->x * pos_map;
   d->y = a->y * from_map + b->y * pos_map;
   d->z = a->z * from_map + b->z * pos_map;
}

static Eina_Bool
_efl_vg_interpolate(Eo *obj,
                         Efl_VG_Data *pd, const Efl_VG *from, const Efl_VG *to,
                         double pos_map)
{
   Efl_VG_Data *fromd, *tod;
   double from_map;
   Eina_Bool r = EINA_TRUE;

   fromd = efl_data_scope_get(from, EFL_VG_CLASS);
   tod = efl_data_scope_get(to, EFL_VG_CLASS);
   from_map = 1.0 - pos_map;

   efl_del(pd->renderer);
   pd->renderer = NULL;

   if (fromd->m || tod->m)
     {
        if (!pd->m) pd->m = malloc(sizeof (Eina_Matrix3));
        if (pd->m)
          {
             const Efl_VG_Interpolation *fi, *ti;
             Efl_VG_Interpolation result;
             Eina_Matrix4 m;

             fi = _efl_vg_interpolation_get(fromd);
             if (!fi) fi = &interpolation_identity;
             ti = _efl_vg_interpolation_get(tod);
             if (!ti) ti = &interpolation_identity;

             eina_quaternion_slerp(&result.rotation,
                                   &fi->rotation, &ti->rotation,
                                   pos_map);
             _efl_vg_interpolate_point(&result.translation,
                                       &fi->translation, &ti->translation,
                                       pos_map, from_map);
             _efl_vg_interpolate_point(&result.scale,
                                       &fi->scale, &ti->scale,
                                       pos_map, from_map);
             _efl_vg_interpolate_point(&result.skew,
                                       &fi->skew, &ti->skew,
                                       pos_map, from_map);

             result.perspective.x = fi->perspective.x * from_map + ti->perspective.x * pos_map;
             result.perspective.y = fi->perspective.y * from_map + ti->perspective.y * pos_map;
             result.perspective.z = fi->perspective.z * from_map + ti->perspective.z * pos_map;
             result.perspective.w = fi->perspective.w * from_map + ti->perspective.w * pos_map;

             eina_quaternion_matrix4_to(&m,
                                        &result.rotation,
                                        &result.perspective,
                                        &result.translation,
                                        &result.scale,
                                        &result.skew);
             eina_matrix4_matrix3_to(pd->m, &m);
          }
     }

   pd->x = fromd->x * from_map + tod->x * pos_map;
   pd->y = fromd->y * from_map + tod->y * pos_map;

   pd->r = fromd->r * from_map + tod->r * pos_map;
   pd->g = fromd->g * from_map + tod->g * pos_map;
   pd->b = fromd->b * from_map + tod->b * pos_map;
   pd->a = fromd->a * from_map + tod->a * pos_map;

   pd->visibility = pos_map >= 0.5 ? tod->visibility : fromd->visibility;

   if (fromd->mask && tod->mask && pd->mask)
     {
        r &= efl_vg_interpolate(pd->mask, fromd->mask, tod->mask, pos_map);
     }

   _efl_vg_changed(obj);

   return r;
}

EOLIAN static Efl_VG *
_efl_vg_efl_duplicate_duplicate(const Eo *obj, Efl_VG_Data *pd)
{
   Efl_VG *cn;
   Efl_VG_Data *cd;

   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)
     {
        cd->m = malloc(sizeof (Eina_Matrix3)) ;
        if (cd->m) memcpy(cd->m, pd->m, sizeof (Eina_Matrix3));
     }

   if (pd->mask)
     cd->mask = efl_duplicate(pd->mask);

   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;

   return cn;
}

EAPI Eina_Bool
evas_vg_node_visible_get(Eo *obj)
{
   return efl_gfx_visible_get(obj);
}

EAPI void
evas_vg_node_visible_set(Eo *obj, Eina_Bool v)
{
   efl_gfx_visible_set(obj, v);
}

EAPI void
evas_vg_node_color_get(Eo *obj, int *r, int *g, int *b, int *a)
{
   efl_gfx_color_get(obj, r, g, b, a);
}

EAPI void
evas_vg_node_color_set(Eo *obj, int r, int g, int b, int a)
{
   efl_gfx_color_set(obj, r, g, b, a);
}

EAPI void
evas_vg_node_geometry_get(Eo *obj, int *x, int *y, int *w, int *h)
{
   Eina_Rect r;
   r.pos = efl_gfx_position_get(obj);
   r.size = efl_gfx_size_get(obj);
   if (x) *x = r.x;
   if (y) *y = r.y;
   if (w) *w = r.w;
   if (h) *h = r.h;
}

EAPI void
evas_vg_node_geometry_set(Eo *obj, int x, int y, int w, int h)
{
   efl_gfx_position_set(obj, EINA_POSITION2D(x, y));
   efl_gfx_size_set(obj, EINA_SIZE2D(w,  h));
}

EAPI void
evas_vg_node_stack_below(Eo *obj, Eo *below)
{
   efl_gfx_stack_below(obj, below);
}

EAPI void
evas_vg_node_stack_above(Eo *obj, Eo *above)
{
   efl_gfx_stack_above(obj, above);
}

EAPI void
evas_vg_node_raise(Eo *obj)
{
   efl_gfx_stack_raise(obj);
}

EAPI void
evas_vg_node_lower(Eo *obj)
{
   efl_gfx_stack_lower(obj);
}

#include "efl_vg.eo.c"