evas/vector: update vg object to be rendered properly. 23/43223/1
authorChunEon Park <hermet@hermet.pe.kr>
Mon, 2 Feb 2015 14:21:59 +0000 (23:21 +0900)
committerSubhransu Mohanty <sub.mohanty@samsung.com>
Wed, 8 Jul 2015 02:05:26 +0000 (11:05 +0900)
We should make vg object change if one of node states have been changed.

Parent of the Root node is vector object,
While child node is constructed, the vector object is shared to child from root.
And whenever node state is changed, it makes vector object change.

Change-Id: Idb9bd0af04c6ba234505a7918e399aa2b3838cf9

src/lib/evas/canvas/evas_object_vg.c
src/lib/evas/canvas/evas_vg_container.c
src/lib/evas/canvas/evas_vg_gradient.c
src/lib/evas/canvas/evas_vg_gradient_linear.c
src/lib/evas/canvas/evas_vg_gradient_radial.c
src/lib/evas/canvas/evas_vg_node.c
src/lib/evas/canvas/evas_vg_node.eo
src/lib/evas/canvas/evas_vg_private.h
src/lib/evas/canvas/evas_vg_root_node.c
src/lib/evas/canvas/evas_vg_root_node.eo
src/lib/evas/canvas/evas_vg_shape.c

index ac3d372021caf038618b8b5ae2c35c2cb29fa351..43c16c9cca9bcdff7925c66fab0b4475028f9b3c 100644 (file)
@@ -89,16 +89,6 @@ evas_object_vg_add(Evas *e)
    return eo_obj;
 }
 
-void
-_evas_vg_root_node_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, Evas_VG_Node *container)
-{
-   Evas_VG_Node *tmp;
-
-   tmp = pd->root;
-   pd->root = eo_ref(container);
-   eo_unref(tmp);
-}
-
 Evas_VG_Node *
 _evas_vg_root_node_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd)
 {
@@ -120,7 +110,6 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd)
 
    /* root node */
    pd->root = eo_add(EVAS_VG_ROOT_NODE_CLASS, eo_obj);
-
    eo_do(eo_obj, parent = eo_parent_get());
    evas_object_inject(eo_obj, obj, evas_object_evas_get(parent));
 }
index cc679cd86ea464e383b7afdc884f9647a0dec835..0ee31af9c2da0262606fcc8032211037a88d50e2 100644 (file)
@@ -5,7 +5,7 @@
 
 #define MY_CLASS EVAS_VG_CONTAINER_CLASS
 
-static void
+static Eina_Bool
 _evas_vg_container_render_pre(Eo *obj EINA_UNUSED,
                               Eina_Matrix3 *parent,
                               Ector_Surface *s,
@@ -15,10 +15,13 @@ _evas_vg_container_render_pre(Eo *obj EINA_UNUSED,
    Evas_VG_Container_Data *pd = data;
    Eina_List *l;
    Eo *child;
+   Eina_Bool change = EINA_FALSE;
    EVAS_VG_COMPUTE_MATRIX(current, parent, nd);
 
    EINA_LIST_FOREACH(pd->children, l, child)
-     _evas_vg_render_pre(child, s, current);
+     change |= _evas_vg_render_pre(child, s, current);
+
+   return change;
 }
 
 static void
index a63b63606208e8859ced62c5472e50115f5e4bf6..4f766550e39266bc8496cdaffe64302a47c7cefe 100644 (file)
@@ -5,8 +5,10 @@
 
 #include <strings.h>
 
+#define MY_CLASS EVAS_VG_GRADIENT_CLASS
+
 static void
-_evas_vg_gradient_efl_graphics_gradient_stop_set(Eo *obj EINA_UNUSED,
+_evas_vg_gradient_efl_graphics_gradient_stop_set(Eo *obj,
                                                  Evas_VG_Gradient_Data *pd,
                                                  const Efl_Graphics_Gradient_Stop *colors,
                                                  unsigned int length)
@@ -20,6 +22,8 @@ _evas_vg_gradient_efl_graphics_gradient_stop_set(Eo *obj EINA_UNUSED,
 
    memcpy(pd->colors, colors, length * sizeof(Efl_Graphics_Gradient_Stop));
    pd->colors_count = length;
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static void
@@ -33,11 +37,12 @@ _evas_vg_gradient_efl_graphics_gradient_stop_get(Eo *obj EINA_UNUSED,
 }
 
 static void
-_evas_vg_gradient_efl_graphics_gradient_spread_set(Eo *obj EINA_UNUSED,
+_evas_vg_gradient_efl_graphics_gradient_spread_set(Eo *obj,
                                                    Evas_VG_Gradient_Data *pd,
                                                    Efl_Graphics_Gradient_Spread s)
 {
    pd->s = s;
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static Efl_Graphics_Gradient_Spread
index 5d0af64eb9e0fea9028a1450611fa4959e6fea0a..714ecc218dea7e607ede2f5fb2da4033ebfa4f6c 100644 (file)
@@ -16,12 +16,14 @@ struct _Evas_VG_Gradient_Linear_Data
 };
 
 static void
-_evas_vg_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj EINA_UNUSED,
+_evas_vg_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj,
                                    Evas_VG_Gradient_Linear_Data *pd,
                                    double x, double y)
 {
    pd->start.x = x;
    pd->start.y = y;
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static void
@@ -34,12 +36,14 @@ _evas_vg_gradient_linear_efl_graphics_gradient_linear_start_get(Eo *obj EINA_UNU
 }
 
 static void
-_evas_vg_gradient_linear_efl_graphics_gradient_linear_end_set(Eo *obj EINA_UNUSED,
+_evas_vg_gradient_linear_efl_graphics_gradient_linear_end_set(Eo *obj,
                                  Evas_VG_Gradient_Linear_Data *pd,
                                  double x, double y)
 {
    pd->end.x = x;
    pd->end.y = y;
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static void
index e7adce17d988bd2a77dbdb91fa0cf6e64cb0a10b..61e639a2fe16ce751db2d78f02dcacc98581e08b 100644 (file)
@@ -15,12 +15,14 @@ struct _Evas_VG_Gradient_Radial_Data
 };
 
 static void
-_evas_vg_gradient_radial_efl_graphics_gradient_radial_center_set(Eo *obj EINA_UNUSED,
+_evas_vg_gradient_radial_efl_graphics_gradient_radial_center_set(Eo *obj,
                                                  Evas_VG_Gradient_Radial_Data *pd,
                                                  double x, double y)
 {
    pd->center.x = x;
    pd->center.y = y;
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static void
@@ -33,11 +35,12 @@ _evas_vg_gradient_radial_efl_graphics_gradient_radial_center_get(Eo *obj EINA_UN
 }
 
 static void
-_evas_vg_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj EINA_UNUSED,
+_evas_vg_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj,
                                                  Evas_VG_Gradient_Radial_Data *pd,
                                                  double r)
 {
    pd->radius = r;
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static double
@@ -48,12 +51,14 @@ _evas_vg_gradient_radial_efl_graphics_gradient_radial_radius_get(Eo *obj EINA_UN
 }
 
 static void
-_evas_vg_gradient_radial_efl_graphics_gradient_radial_focal_set(Eo *obj EINA_UNUSED,
+_evas_vg_gradient_radial_efl_graphics_gradient_radial_focal_set(Eo *obj,
                                                 Evas_VG_Gradient_Radial_Data *pd,
                                                 double x, double y)
 {
    pd->focal.x = x;
    pd->focal.y = y;
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static void
index 95467a036df39c9f52db364ae12fffb84c17afe8..ff1c9ac1ad58008f6c355e528ae6b45bf1583628 100644 (file)
@@ -117,16 +117,10 @@ _evas_vg_node_parent_checked_get(Eo *obj,
              goto on_error;
           }
      }
-   else if (*parent != NULL)
-     {
-        ERR("Parent of unauthorized class.");
-        goto on_error;
-     }
 
    return EINA_TRUE;
 
  on_error:
-   *parent = NULL;
    *cd = NULL;
    return EINA_FALSE;
 }
@@ -137,12 +131,20 @@ _evas_vg_node_eo_base_constructor(Eo *obj,
 {
    Evas_VG_Container_Data *cd = NULL;
    Eo *parent;
+   Evas_VG_Node_Data *parent_nd = NULL;
 
    eo_do_super(obj, MY_CLASS, eo_constructor());
 
    if (!_evas_vg_node_parent_checked_get(obj, &parent, &cd))
      eo_error_set(obj);
 
+   //Link the vector object
+   if (parent)
+     {
+        parent_nd = eo_data_scope_get(parent, EVAS_VG_NODE_CLASS);
+        pd->eo_vg = parent_nd->eo_vg;
+     }
+
    if (cd)
      cd->children = eina_list_append(cd->children, obj);
 }
@@ -309,4 +311,14 @@ _evas_vg_node_original_bound_get(Eo *obj,
    return EINA_FALSE;
 }
 
+
+void
+_evas_vg_node_changed(Eo *obj, Evas_VG_Node_Data *pd)
+{
+   if (!pd->eo_vg) return;
+   Evas_Object_Protected_Data *obj_vg = eo_data_scope_get(pd->eo_vg,
+                                                          EVAS_OBJECT_CLASS);
+   evas_object_change(pd->eo_vg, obj_vg);
+}
+
 #include "evas_vg_node.eo.c"
index 10a22b0a13fcbe71963ba042d8b11fe514ce22a9..8d775bf0e8957745ba500ffd68b4cdcd712e1662 100644 (file)
@@ -158,6 +158,8 @@ abstract Evas.VG_Node (Eo.Base)
           @see evas_vg_node_stack_below()
           @see evas_vg_node_raise() */
       }
+               changed {
+               }
    }
    implements {
       Eo.Base.parent.set;
index 10e4b6c6c41ee3e7407ed0703c162faaf87ec4f8..647502a331998f5c5db0964001cdffb43f701823 100644 (file)
@@ -12,8 +12,9 @@ struct _Evas_VG_Node_Data
    Eina_Matrix3 *m;
    Evas_VG_Node *mask;
    Ector_Renderer *renderer;
+   Evas_VG *eo_vg;
 
-   void (*render_pre)(Eo *obj, Eina_Matrix3 *parent, Ector_Surface *s, void *data, Evas_VG_Node_Data *nd);
+   Eina_Bool (*render_pre)(Eo *obj, Eina_Matrix3 *parent, Ector_Surface *s, void *data, Evas_VG_Node_Data *nd);
    void *data;
 
    double x, y;
@@ -37,18 +38,17 @@ struct _Evas_VG_Gradient_Data
    Efl_Graphics_Gradient_Spread s;
 };
 
-static inline Evas_VG_Node_Data *
-_evas_vg_render_pre(Evas_VG_Node *child, Ector_Surface *s, Eina_Matrix3 *m)
+static inline Eina_Bool
+_evas_vg_render_pre(Evas_VG_Node *node, Ector_Surface *s, Eina_Matrix3 *m)
 {
-   Evas_VG_Node_Data *child_nd = NULL;
+   Evas_VG_Node_Data *nd;
 
-   // FIXME: Prevent infinite loop
-   if (child)
-     child_nd = eo_data_scope_get(child, EVAS_VG_NODE_CLASS);
-   if (child_nd)
-     child_nd->render_pre(child, m, s, child_nd->data, child_nd);
+   if (!node) return EINA_FALSE;
 
-   return child_nd;
+   // FIXME: Prevent infinite loop
+   nd = eo_data_scope_get(node, EVAS_VG_NODE_CLASS);
+   if (nd->render_pre) return nd->render_pre(node, m, s, nd->data, nd);
+   else return EINA_FALSE;
 }
 
 #define EVAS_VG_COMPUTE_MATRIX(Current, Parent, Nd)              \
@@ -68,5 +68,4 @@ _evas_vg_render_pre(Evas_VG_Node *child, Ector_Surface *s, Eina_Matrix3 *m)
          }                                                              \
     }
 
-
 #endif
index 8fb8b311b26bab213c39a2722a5df9e34b0980aa..92d03f85dbf2532eca1c3efacbbd887452eeca0a 100644 (file)
@@ -1,6 +1,6 @@
 #include "evas_common_private.h"
 #include "evas_private.h"
-
+#include "evas_vg_private.h"
 #include "evas_vg_root_node.eo.h"
 
 #include <string.h>
@@ -12,6 +12,38 @@ struct _Evas_VG_Root_Node_Data
 {
 };
 
+static void
+evas_vg_root_node_vg_set(Evas_VG_Root_Node *root, Evas_VG *vg)
+{
+   Evas_Object_Protected_Data *obj_vg;
+   Evas_VG_Node_Data *nd;
+
+   nd = eo_data_scope_get(root, EVAS_VG_NODE_CLASS);
+   nd->eo_vg = vg;
+   if (!vg) return;
+   obj_vg = eo_data_scope_get(vg, EVAS_OBJECT_CLASS);
+   evas_object_change(vg, obj_vg);
+}
+
+static Eina_Bool
+_evas_vg_root_node_render_pre(Eo *obj EINA_UNUSED,
+                              Eina_Matrix3 *parent,
+                              Ector_Surface *s,
+                              void *data EINA_UNUSED,
+                              Evas_VG_Node_Data *nd)
+{
+   Evas_VG_Container_Data *cd = eo_data_scope_get(obj, EVAS_VG_CONTAINER_CLASS);
+   Eina_List *l;
+   Eo *child;
+   Eina_Bool change = EINA_FALSE;
+   EVAS_VG_COMPUTE_MATRIX(current, parent, nd);
+
+   EINA_LIST_FOREACH(cd->children, l, child)
+     change |= _evas_vg_render_pre(child, s, current);
+
+   return change;
+}
+
 void
 _evas_vg_root_node_eo_base_parent_set(Eo *obj,
                                       Evas_VG_Root_Node_Data *pd EINA_UNUSED,
@@ -28,12 +60,23 @@ _evas_vg_root_node_eo_base_constructor(Eo *obj,
                                        Evas_VG_Root_Node_Data *pd EINA_UNUSED)
 {
    Eo *parent;
+   Evas_VG_Node_Data *nd;
 
    // Nice little hack, jump over parent constructor in Evas_VG_Root
    eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_constructor());
    eo_do(obj, parent = eo_parent_get());
-   if (!eo_isa(parent, EVAS_VG_CLASS))
-     eo_error_set(obj);
+   nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS);
+   nd->render_pre = &_evas_vg_root_node_render_pre;
+
+   evas_vg_root_node_vg_set(obj, parent);
+}
+
+void
+_evas_vg_root_node_eo_base_destructor(Eo *obj,
+                                      Evas_VG_Root_Node_Data *pd EINA_UNUSED)
+{
+   eo_do_super(obj, MY_CLASS, eo_constructor());
+   evas_vg_root_node_vg_set(obj, NULL);
 }
 
 #include "evas_vg_root_node.eo.c"
index 9489c7388f71a31272fdc770869b5bc2b77017dd..32b1c0fc50ec2095f5249aeda75a9368f98e51a2 100644 (file)
@@ -4,5 +4,6 @@ class Evas.VG_Root_Node (Evas.VG_Container)
    implements {
       Eo.Base.parent.set;
       Eo.Base.constructor;
+      Eo.Base.destructor;
    }
 }
index 797712a6a48e9f161677be14c5a2c767ca732ffb..918a13ec344d273b10dbd0108f0477bda80dc7a4 100644 (file)
@@ -32,17 +32,22 @@ struct _Evas_VG_Shape_Data
 };
 
 static Eina_Bool
-_evas_vg_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED,
+_evas_vg_shape_efl_graphics_shape_path_set(Eo *obj,
                                            Evas_VG_Shape_Data *pd,
                                            const Efl_Graphics_Path_Command *ops,
                                            const double *points)
 {
+   Eina_Bool ret;
+
    free(pd->points);
    pd->points = NULL;
    free(pd->ops);
    pd->ops = NULL;
+   ret = efl_graphics_path_dup(&pd->ops, &pd->points, ops, points);
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 
-   return efl_graphics_path_dup(&pd->ops, &pd->points, ops, points);
+   return ret;
 }
 
 static Eina_Bool
@@ -54,7 +59,7 @@ _evas_vg_shape_evas_vg_node_bound_get(Eo *obj,
 }
 
 static void
-_evas_vg_shape_fill_set(Eo *obj EINA_UNUSED,
+_evas_vg_shape_fill_set(Eo *obj,
                         Evas_VG_Shape_Data *pd,
                         Evas_VG_Node *f)
 {
@@ -62,6 +67,8 @@ _evas_vg_shape_fill_set(Eo *obj EINA_UNUSED,
 
    pd->fill = eo_ref(f);
    eo_unref(tmp);
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static Evas_VG_Node *
@@ -71,11 +78,13 @@ _evas_vg_shape_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd)
 }
 
 static void
-_evas_vg_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED,
+_evas_vg_shape_efl_graphics_shape_stroke_scale_set(Eo *obj,
                                                    Evas_VG_Shape_Data *pd,
                                                    double s)
 {
    pd->stroke.scale = s;
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static double
@@ -86,7 +95,7 @@ _evas_vg_shape_efl_graphics_shape_stroke_scale_get(Eo *obj EINA_UNUSED,
 }
 
 static void
-_evas_vg_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED,
+_evas_vg_shape_efl_graphics_shape_stroke_color_set(Eo *obj,
                                                    Evas_VG_Shape_Data *pd,
                                                    int r, int g, int b, int a)
 {
@@ -94,6 +103,7 @@ _evas_vg_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED,
    pd->stroke.g = g;
    pd->stroke.b = b;
    pd->stroke.a = a;
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static void
@@ -108,7 +118,7 @@ _evas_vg_shape_efl_graphics_shape_stroke_color_get(Eo *obj EINA_UNUSED,
 }
 
 static void
-_evas_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED,
+_evas_vg_shape_stroke_fill_set(Eo *obj,
                                Evas_VG_Shape_Data *pd,
                                Evas_VG_Node *f)
 {
@@ -116,6 +126,8 @@ _evas_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED,
 
    pd->stroke.fill = eo_ref(f);
    eo_unref(tmp);
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static Evas_VG_Node *
@@ -126,11 +138,12 @@ _evas_vg_shape_stroke_fill_get(Eo *obj EINA_UNUSED,
 }
 
 static void
-_evas_vg_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED,
+_evas_vg_shape_efl_graphics_shape_stroke_width_set(Eo *obj,
                                                    Evas_VG_Shape_Data *pd,
                                                    double w)
 {
    pd->stroke.width = w;
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static double
@@ -141,11 +154,12 @@ _evas_vg_shape_efl_graphics_shape_stroke_width_get(Eo *obj EINA_UNUSED,
 }
 
 static void
-_evas_vg_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED,
+_evas_vg_shape_efl_graphics_shape_stroke_location_set(Eo *obj,
                                                       Evas_VG_Shape_Data *pd,
                                                       double centered)
 {
    pd->stroke.centered = centered;
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static double
@@ -156,7 +170,7 @@ _evas_vg_shape_efl_graphics_shape_stroke_location_get(Eo *obj EINA_UNUSED,
 }
 
 static void
-_evas_vg_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED,
+_evas_vg_shape_efl_graphics_shape_stroke_dash_set(Eo *obj,
                                                   Evas_VG_Shape_Data *pd,
                                                   const Efl_Graphics_Dash *dash,
                                                   unsigned int length)
@@ -170,6 +184,8 @@ _evas_vg_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED,
 
    memcpy(pd->stroke.dash, dash, sizeof (Efl_Graphics_Dash) * length);
    pd->stroke.dash_count = length;
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static void
@@ -183,7 +199,7 @@ _evas_vg_shape_efl_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED,
 }
 
 static void
-_evas_vg_shape_stroke_marker_set(Eo *obj EINA_UNUSED,
+_evas_vg_shape_stroke_marker_set(Eo *obj,
                                  Evas_VG_Shape_Data *pd,
                                  Evas_VG_Shape *m)
 {
@@ -191,6 +207,8 @@ _evas_vg_shape_stroke_marker_set(Eo *obj EINA_UNUSED,
 
    pd->stroke.marker = eo_ref(m);
    eo_unref(tmp);
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static Evas_VG_Shape *
@@ -206,6 +224,8 @@ _evas_vg_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED,
                                                  Efl_Graphics_Cap c)
 {
    pd->stroke.cap = c;
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static Efl_Graphics_Cap
@@ -221,6 +241,8 @@ _evas_vg_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED,
                                                   Efl_Graphics_Join j)
 {
    pd->stroke.join = j;
+
+   eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
 }
 
 static Efl_Graphics_Join