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
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)
{
/* 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));
}
#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,
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
#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)
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
}
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
};
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
}
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
};
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
}
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
}
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
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;
}
{
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);
}
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"
@see evas_vg_node_stack_below()
@see evas_vg_node_raise() */
}
+ changed {
+ }
}
implements {
Eo.Base.parent.set;
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;
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) \
} \
}
-
#endif
#include "evas_common_private.h"
#include "evas_private.h"
-
+#include "evas_vg_private.h"
#include "evas_vg_root_node.eo.h"
#include <string.h>
{
};
+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,
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"
implements {
Eo.Base.parent.set;
Eo.Base.constructor;
+ Eo.Base.destructor;
}
}
};
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
}
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)
{
pd->fill = eo_ref(f);
eo_unref(tmp);
+
+ eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
}
static Evas_VG_Node *
}
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
}
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)
{
pd->stroke.g = g;
pd->stroke.b = b;
pd->stroke.a = a;
+ eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
}
static void
}
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)
{
pd->stroke.fill = eo_ref(f);
eo_unref(tmp);
+
+ eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
}
static Evas_VG_Node *
}
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
}
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
}
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)
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
}
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)
{
pd->stroke.marker = eo_ref(m);
eo_unref(tmp);
+
+ eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
}
static Evas_VG_Shape *
Efl_Graphics_Cap c)
{
pd->stroke.cap = c;
+
+ eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
}
static Efl_Graphics_Cap
Efl_Graphics_Join j)
{
pd->stroke.join = j;
+
+ eo_do_super(obj, MY_CLASS, evas_vg_node_changed());
}
static Efl_Graphics_Join