aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/evas/canvas
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-04-03 16:30:42 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-04-03 16:30:42 +0200
commit0f6328b04feca2e583a3d74b30d636af4f6b6965 (patch)
tree7827a750d77bd2421cf49cde89cd3c244120fbbc /src/lib/evas/canvas
parentefl: trigger EFL_GFX_CHANGED on path change. (diff)
downloadefl-0f6328b04feca2e583a3d74b30d636af4f6b6965.tar.gz
efl: introduce EFL_GFX_CHANGED event and properly propagate up to Evas.
Diffstat (limited to 'src/lib/evas/canvas')
-rw-r--r--src/lib/evas/canvas/evas_vg_container.c4
-rw-r--r--src/lib/evas/canvas/evas_vg_gradient.c4
-rw-r--r--src/lib/evas/canvas/evas_vg_gradient_linear.c11
-rw-r--r--src/lib/evas/canvas/evas_vg_gradient_radial.c13
-rw-r--r--src/lib/evas/canvas/evas_vg_image.c8
-rw-r--r--src/lib/evas/canvas/evas_vg_node.c53
-rw-r--r--src/lib/evas/canvas/evas_vg_private.h6
-rw-r--r--src/lib/evas/canvas/evas_vg_root_node.c32
-rw-r--r--src/lib/evas/canvas/evas_vg_shape.c24
9 files changed, 139 insertions, 16 deletions
diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c
index cc679cd86e..3b368f03fe 100644
--- a/src/lib/evas/canvas/evas_vg_container.c
+++ b/src/lib/evas/canvas/evas_vg_container.c
@@ -15,6 +15,10 @@ _evas_vg_container_render_pre(Eo *obj EINA_UNUSED,
Evas_VG_Container_Data *pd = data;
Eina_List *l;
Eo *child;
+
+ if (!nd->changed) return ;
+ nd->changed = EINA_FALSE;
+
EVAS_VG_COMPUTE_MATRIX(current, parent, nd);
EINA_LIST_FOREACH(pd->children, l, child)
diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c
index 41f2ea98e0..4df0b255ff 100644
--- a/src/lib/evas/canvas/evas_vg_gradient.c
+++ b/src/lib/evas/canvas/evas_vg_gradient.c
@@ -20,6 +20,8 @@ _evas_vg_gradient_efl_gfx_gradient_base_stop_set(Eo *obj EINA_UNUSED,
memcpy(pd->colors, colors, length * sizeof(Efl_Gfx_Gradient_Stop));
pd->colors_count = length;
+
+ _evas_vg_node_changed(obj);
}
static void
@@ -38,6 +40,8 @@ _evas_vg_gradient_efl_gfx_gradient_base_spread_set(Eo *obj EINA_UNUSED,
Efl_Gfx_Gradient_Spread s)
{
pd->s = s;
+
+ _evas_vg_node_changed(obj);
}
static Efl_Gfx_Gradient_Spread
diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c
index 71d5e0c712..c1d8ffc461 100644
--- a/src/lib/evas/canvas/evas_vg_gradient_linear.c
+++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c
@@ -22,6 +22,8 @@ _evas_vg_gradient_linear_efl_gfx_gradient_linear_start_set(Eo *obj EINA_UNUSED,
{
pd->start.x = x;
pd->start.y = y;
+
+ _evas_vg_node_changed(obj);
}
static void
@@ -40,6 +42,8 @@ _evas_vg_gradient_linear_efl_gfx_gradient_linear_end_set(Eo *obj EINA_UNUSED,
{
pd->end.x = x;
pd->end.y = y;
+
+ _evas_vg_node_changed(obj);
}
static void
@@ -59,7 +63,12 @@ _evas_vg_gradient_linear_render_pre(Eo *obj,
Evas_VG_Node_Data *nd)
{
Evas_VG_Gradient_Linear_Data *pd = data;
- Evas_VG_Gradient_Data *gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS);
+ Evas_VG_Gradient_Data *gd;
+
+ if (!nd->changed) return ;
+ nd->changed = EINA_FALSE;
+
+ gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS);
EVAS_VG_COMPUTE_MATRIX(current, parent, nd);
if (!nd->renderer)
diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c
index ad199659a6..ead0a49d98 100644
--- a/src/lib/evas/canvas/evas_vg_gradient_radial.c
+++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c
@@ -21,6 +21,8 @@ _evas_vg_gradient_radial_efl_gfx_gradient_radial_center_set(Eo *obj EINA_UNUSED,
{
pd->center.x = x;
pd->center.y = y;
+
+ _evas_vg_node_changed(obj);
}
static void
@@ -38,6 +40,8 @@ _evas_vg_gradient_radial_efl_gfx_gradient_radial_radius_set(Eo *obj EINA_UNUSED,
double r)
{
pd->radius = r;
+
+ _evas_vg_node_changed(obj);
}
static double
@@ -54,6 +58,8 @@ _evas_vg_gradient_radial_efl_gfx_gradient_radial_focal_set(Eo *obj EINA_UNUSED,
{
pd->focal.x = x;
pd->focal.y = y;
+
+ _evas_vg_node_changed(obj);
}
static void
@@ -73,7 +79,12 @@ _evas_vg_gradient_radial_render_pre(Eo *obj,
Evas_VG_Node_Data *nd)
{
Evas_VG_Gradient_Radial_Data *pd = data;
- Evas_VG_Gradient_Data *gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS);
+ Evas_VG_Gradient_Data *gd;
+
+ if (!nd->changed) return ;
+ nd->changed = EINA_FALSE;
+
+ gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS);
EVAS_VG_COMPUTE_MATRIX(current, parent, nd);
if (!nd->renderer)
diff --git a/src/lib/evas/canvas/evas_vg_image.c b/src/lib/evas/canvas/evas_vg_image.c
index 62f02ece28..523c1fc098 100644
--- a/src/lib/evas/canvas/evas_vg_image.c
+++ b/src/lib/evas/canvas/evas_vg_image.c
@@ -3,6 +3,8 @@
#include <strings.h>
+#include "evas_vg_private.h"
+
typedef struct _Evas_VG_Image_Data Evas_VG_Image_Data;
struct _Evas_VG_Image_Data
{
@@ -19,6 +21,8 @@ _evas_vg_image_position_set(Eo *obj, Evas_VG_Image_Data *pd, int x, int y)
{
pd->x = x;
pd->y = y;
+
+ _evas_vg_node_changed(obj);
}
static void
@@ -34,6 +38,8 @@ _evas_vg_image_size_set(Eo *obj, Evas_VG_Image_Data *pd,
{
pd->w = w;
pd->h = h;
+
+ _evas_vg_node_changed(obj);
}
static void
@@ -54,6 +60,8 @@ _evas_vg_image_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd,
eina_file_close(tmp);
eina_stringshare_replace(&pd->key, key);
+ _evas_vg_node_changed(obj);
+
return EINA_TRUE;
}
diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c
index 40166a6767..c5ac1100b0 100644
--- a/src/lib/evas/canvas/evas_vg_node.c
+++ b/src/lib/evas/canvas/evas_vg_node.c
@@ -8,13 +8,22 @@
#define MY_CLASS EVAS_VG_NODE_CLASS
-// FIXME:
-// - share private structure with evas_object_vg
-// - mark parent canvas evas_object dirty after any change on the object
-// - add a virtual render function as part of the private data field
+static Eina_Bool
+_evas_vg_node_property_changed(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
+{
+ Evas_VG_Node_Data *pd = data;
+ Eo *parent;
+
+ if (pd->changed) return EINA_TRUE;
+ pd->changed = EINA_TRUE;
+
+ eo_do(obj, parent = eo_parent_get());
+ eo_do(parent, eo_event_callback_call(desc, event_info));
+ return EINA_TRUE;
+}
void
-_evas_vg_node_transformation_set(Eo *obj EINA_UNUSED,
+_evas_vg_node_transformation_set(Eo *obj,
Evas_VG_Node_Data *pd,
const Eina_Matrix3 *m)
{
@@ -24,6 +33,8 @@ _evas_vg_node_transformation_set(Eo *obj EINA_UNUSED,
if (!pd->m) return ;
}
memcpy(pd->m, m, sizeof (Eina_Matrix3));
+
+ _evas_vg_node_changed(obj);
}
const Eina_Matrix3 *
@@ -33,12 +44,14 @@ _evas_vg_node_transformation_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd)
}
void
-_evas_vg_node_origin_set(Eo *obj EINA_UNUSED,
+_evas_vg_node_origin_set(Eo *obj,
Evas_VG_Node_Data *pd,
double x, double y)
{
pd->x = x;
pd->y = y;
+
+ _evas_vg_node_changed(obj);
}
void
@@ -57,6 +70,8 @@ _evas_vg_node_efl_gfx_base_position_set(Eo *obj EINA_UNUSED,
{
pd->x = lrint(x);
pd->y = lrint(y);
+
+ _evas_vg_node_changed(obj);
}
void
@@ -73,6 +88,8 @@ _evas_vg_node_efl_gfx_base_visible_set(Eo *obj EINA_UNUSED,
Evas_VG_Node_Data *pd, Eina_Bool v)
{
pd->visibility = v;
+
+ _evas_vg_node_changed(obj);
}
@@ -92,6 +109,8 @@ _evas_vg_node_efl_gfx_base_color_set(Eo *obj EINA_UNUSED,
pd->g = g;
pd->b = b;
pd->a = a;
+
+ _evas_vg_node_changed(obj);
}
Eina_Bool
@@ -136,6 +155,8 @@ _evas_vg_node_mask_set(Eo *obj EINA_UNUSED,
pd->mask = eo_ref(r);
eo_unref(tmp);
+
+ _evas_vg_node_changed(obj);
}
Evas_VG_Node*
@@ -159,9 +180,12 @@ _evas_vg_node_efl_gfx_base_size_get(Eo *obj,
// Parent should be a container otherwise dismissing the stacking operation
static Eina_Bool
_evas_vg_node_parent_checked_get(Eo *obj,
- Eo **parent, Evas_VG_Container_Data **cd)
+ Eo **parent,
+ Evas_VG_Container_Data **cd)
{
+ *cd = NULL;
eo_do(obj, *parent = eo_parent_get());
+
if (eo_isa(*parent, EVAS_VG_CONTAINER_CLASS))
{
*cd = eo_data_scope_get(*parent, EVAS_VG_CONTAINER_CLASS);
@@ -187,7 +211,7 @@ _evas_vg_node_parent_checked_get(Eo *obj,
void
_evas_vg_node_eo_base_constructor(Eo *obj,
- Evas_VG_Node_Data *pd EINA_UNUSED)
+ Evas_VG_Node_Data *pd)
{
Evas_VG_Container_Data *cd = NULL;
Eo *parent;
@@ -199,6 +223,9 @@ _evas_vg_node_eo_base_constructor(Eo *obj,
if (cd)
cd->children = eina_list_append(cd->children, obj);
+
+ eo_do(obj, eo_event_callback_add(EFL_GFX_CHANGED, _evas_vg_node_property_changed, pd));
+ pd->changed = EINA_TRUE;
}
void
@@ -219,7 +246,7 @@ _evas_vg_node_eo_base_parent_set(Eo *obj,
goto on_error;
}
}
- else if (parent != NULL && !eo_isa(parent, EVAS_VG_CLASS))
+ else if (parent != NULL)
{
ERR("%p not even an EVAS_VG_CLASS.", parent);
goto on_error;
@@ -236,6 +263,10 @@ _evas_vg_node_eo_base_parent_set(Eo *obj,
if (cd)
cd->children = eina_list_append(cd->children, obj);
+ _evas_vg_node_changed(old_parent);
+ _evas_vg_node_changed(obj);
+ _evas_vg_node_changed(parent);
+
return ;
on_error:
@@ -264,6 +295,7 @@ _evas_vg_node_efl_gfx_stack_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED)
cd->children = eina_list_remove_list(cd->children, lookup);
cd->children = eina_list_append_relative_list(cd->children, obj, next);
+ _evas_vg_node_changed(parent);
return ;
on_error:
@@ -293,6 +325,7 @@ _evas_vg_node_efl_gfx_stack_stack_above(Eo *obj,
cd->children = eina_list_remove_list(cd->children, lookup);
cd->children = eina_list_append_relative_list(cd->children, obj, ref);
+ _evas_vg_node_changed(parent);
return ;
on_error:
@@ -322,6 +355,7 @@ _evas_vg_node_efl_gfx_stack_stack_below(Eo *obj,
cd->children = eina_list_remove_list(cd->children, lookup);
cd->children = eina_list_prepend_relative_list(cd->children, obj, ref);
+ _evas_vg_node_changed(parent);
return ;
on_error:
@@ -349,6 +383,7 @@ _evas_vg_node_efl_gfx_stack_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED)
cd->children = eina_list_remove_list(cd->children, lookup);
cd->children = eina_list_prepend_relative_list(cd->children, obj, prev);
+ _evas_vg_node_changed(parent);
return ;
on_error:
diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h
index 58c1cfec01..1c7d516615 100644
--- a/src/lib/evas/canvas/evas_vg_private.h
+++ b/src/lib/evas/canvas/evas_vg_private.h
@@ -51,6 +51,12 @@ _evas_vg_render_pre(Evas_VG_Node *child, Ector_Surface *s, Eina_Matrix3 *m)
return child_nd;
}
+static inline void
+_evas_vg_node_changed(Eo *obj)
+{
+ eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL));
+}
+
#define EVAS_VG_COMPUTE_MATRIX(Current, Parent, Nd) \
Eina_Matrix3 *Current = Nd->m; \
Eina_Matrix3 _matrix_tmp; \
diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c
index 8fb8b311b2..1566a18cfa 100644
--- a/src/lib/evas/canvas/evas_vg_root_node.c
+++ b/src/lib/evas/canvas/evas_vg_root_node.c
@@ -10,30 +10,52 @@
typedef struct _Evas_VG_Root_Node_Data Evas_VG_Root_Node_Data;
struct _Evas_VG_Root_Node_Data
{
+ Evas_Object *parent;
+ Evas_Object_Protected_Data *data;
};
+static Eina_Bool
+_evas_vg_root_node_changed(void *data, Eo *obj EINA_UNUSED,
+ const Eo_Event_Description *desc EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Evas_VG_Root_Node_Data *pd = data;
+
+ evas_object_change(pd->parent, pd->data);
+ return EINA_TRUE;
+}
+
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,
Eo *parent)
{
// Nice little hack, jump over parent parent_set in Evas_VG_Root
eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_parent_set(parent));
if (parent && !eo_isa(parent, EVAS_VG_CLASS))
- eo_error_set(obj);
+ {
+ eo_error_set(obj);
+ }
+ else
+ {
+ pd->parent = parent;
+ pd->data = eo_data_scope_get(parent, EVAS_OBJECT_CLASS);
+ }
}
void
_evas_vg_root_node_eo_base_constructor(Eo *obj,
- Evas_VG_Root_Node_Data *pd EINA_UNUSED)
+ Evas_VG_Root_Node_Data *pd)
{
Eo *parent;
- // Nice little hack, jump over parent constructor in Evas_VG_Root
- eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_constructor());
+ // Nice little hack, jump over parent constructor in Efl_VG_Root
+ eo_do_super(obj, EFL_VG_BASE_CLASS, eo_constructor());
eo_do(obj, parent = eo_parent_get());
if (!eo_isa(parent, EVAS_VG_CLASS))
eo_error_set(obj);
+
+ eo_do(obj, eo_event_callback_add(EFL_GFX_CHANGED, _evas_vg_root_node_changed, pd));
}
#include "evas_vg_root_node.eo.c"
diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c
index a560029dde..2a577b89be 100644
--- a/src/lib/evas/canvas/evas_vg_shape.c
+++ b/src/lib/evas/canvas/evas_vg_shape.c
@@ -45,6 +45,8 @@ _evas_vg_shape_fill_set(Eo *obj EINA_UNUSED,
pd->fill = eo_ref(f);
eo_unref(tmp);
+
+ _evas_vg_node_changed(obj);
}
static Evas_VG_Node *
@@ -59,6 +61,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_scale_set(Eo *obj EINA_UNUSED,
double s)
{
pd->stroke.scale = s;
+
+ _evas_vg_node_changed(obj);
}
static double
@@ -77,6 +81,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_color_set(Eo *obj EINA_UNUSED,
pd->stroke.g = g;
pd->stroke.b = b;
pd->stroke.a = a;
+
+ _evas_vg_node_changed(obj);
}
static Eina_Bool
@@ -137,6 +143,8 @@ _evas_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED,
pd->stroke.fill = eo_ref(f);
eo_unref(tmp);
+
+ _evas_vg_node_changed(obj);
}
static Evas_VG_Node *
@@ -152,6 +160,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_width_set(Eo *obj EINA_UNUSED,
double w)
{
pd->stroke.width = w;
+
+ _evas_vg_node_changed(obj);
}
static double
@@ -167,6 +177,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_location_set(Eo *obj EINA_UNUSED,
double centered)
{
pd->stroke.centered = centered;
+
+ _evas_vg_node_changed(obj);
}
static double
@@ -191,6 +203,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_dash_set(Eo *obj EINA_UNUSED,
memcpy(pd->stroke.dash, dash, sizeof (Efl_Gfx_Dash) * length);
pd->stroke.dash_count = length;
+
+ _evas_vg_node_changed(obj);
}
static void
@@ -212,6 +226,8 @@ _evas_vg_shape_stroke_marker_set(Eo *obj EINA_UNUSED,
pd->stroke.marker = eo_ref(m);
eo_unref(tmp);
+
+ _evas_vg_node_changed(obj);
}
static Evas_VG_Shape *
@@ -227,6 +243,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_cap_set(Eo *obj EINA_UNUSED,
Efl_Gfx_Cap c)
{
pd->stroke.cap = c;
+
+ _evas_vg_node_changed(obj);
}
static Efl_Gfx_Cap
@@ -242,6 +260,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_join_set(Eo *obj EINA_UNUSED,
Efl_Gfx_Join j)
{
pd->stroke.join = j;
+
+ _evas_vg_node_changed(obj);
}
static Efl_Gfx_Join
@@ -260,6 +280,10 @@ _evas_vg_shape_render_pre(Eo *obj EINA_UNUSED,
{
Evas_VG_Shape_Data *pd = data;
Evas_VG_Node_Data *fill, *stroke_fill, *stroke_marker, *mask;
+
+ if (!nd->changed) return ;
+ nd->changed = EINA_FALSE;
+
EVAS_VG_COMPUTE_MATRIX(current, parent, nd);
fill = _evas_vg_render_pre(pd->fill, s, current);