forked from enlightenment/efl
evas: add logic to duplicate recursively an Efl_VG_Node tree.
This commit is contained in:
parent
126edbb48c
commit
05fdfcc76a
|
@ -96,6 +96,11 @@ abstract Efl.VG.Base (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack)
|
|||
@in pos_map: double;
|
||||
}
|
||||
}
|
||||
dup {
|
||||
params {
|
||||
@in from: const(Efl.VG.Base)*;
|
||||
}
|
||||
}
|
||||
}
|
||||
implements {
|
||||
Eo.Base.parent.set;
|
||||
|
|
|
@ -17,5 +17,6 @@ class Efl.VG.Container (Efl.VG.Base)
|
|||
Eo.Base.destructor;
|
||||
Efl.VG.Base.bounds_get;
|
||||
Efl.VG.Base.interpolate;
|
||||
Efl.VG.Base.dup;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,5 +7,6 @@ abstract Efl.VG.Gradient (Efl.VG.Base, Efl.Gfx.Gradient.Base)
|
|||
Efl.Gfx.Gradient.Base.spread.set;
|
||||
Efl.Gfx.Gradient.Base.spread.get;
|
||||
Efl.VG.Base.interpolate;
|
||||
Efl.VG.Base.dup;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ class Efl.VG.Gradient_Linear (Efl.VG.Gradient, Efl.Gfx.Gradient.Linear)
|
|||
Efl.Gfx.Gradient.Linear.end.get;
|
||||
Efl.VG.Base.bounds_get;
|
||||
Efl.VG.Base.interpolate;
|
||||
Efl.VG.Base.dup;
|
||||
Eo.Base.constructor;
|
||||
Eo.Base.destructor;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ class Efl.VG.Gradient_Radial (Efl.VG.Gradient, Efl.Gfx.Gradient.Radial)
|
|||
Efl.Gfx.Gradient.Radial.focal.get;
|
||||
Efl.VG.Base.bounds_get;
|
||||
Efl.VG.Base.interpolate;
|
||||
Efl.VG.Base.dup;
|
||||
Eo.Base.constructor;
|
||||
Eo.Base.destructor;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ class Efl.VG.Shape (Efl.VG.Base, Efl.Gfx.Shape)
|
|||
Efl.Gfx.Base.color_part.get;
|
||||
Efl.VG.Base.bounds_get;
|
||||
Efl.VG.Base.interpolate;
|
||||
Efl.VG.Base.dup;
|
||||
Eo.Base.constructor;
|
||||
Eo.Base.destructor;
|
||||
}
|
||||
|
|
|
@ -135,6 +135,32 @@ _efl_vg_container_efl_vg_base_interpolate(Eo *obj,
|
|||
return r;
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_vg_container_efl_vg_base_dup(Eo *obj,
|
||||
Efl_VG_Container_Data *pd,
|
||||
const Efl_VG_Base *from)
|
||||
{
|
||||
Efl_VG_Container_Data *fromd;
|
||||
Eina_List *l;
|
||||
Eo *child;
|
||||
|
||||
eo_do_super(obj, EFL_VG_CONTAINER_CLASS, efl_vg_dup(from));
|
||||
|
||||
fromd = eo_data_scope_get(from, EFL_VG_CONTAINER_CLASS);
|
||||
|
||||
EINA_LIST_FREE(pd->children, child)
|
||||
eo_unref(child);
|
||||
|
||||
EINA_LIST_FOREACH(fromd->children, l, child)
|
||||
{
|
||||
// By setting parent, we automatically reference
|
||||
// this new object as a child of obj. Magic at work !
|
||||
eo_add_ref(eo_class_get(child),
|
||||
obj,
|
||||
efl_vg_dup(child));
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Efl_VG*
|
||||
evas_vg_container_add(Efl_VG *parent)
|
||||
{
|
||||
|
|
|
@ -94,6 +94,22 @@ _efl_vg_gradient_efl_vg_base_interpolate(Eo *obj,
|
|||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_vg_gradient_efl_vg_base_dup(Eo *obj,
|
||||
Efl_VG_Gradient_Data *pd EINA_UNUSED,
|
||||
const Efl_VG_Base *from)
|
||||
{
|
||||
Efl_VG_Gradient_Data *fromd;
|
||||
|
||||
eo_do_super(obj, EFL_VG_GRADIENT_CLASS, efl_vg_dup(from));
|
||||
|
||||
fromd = eo_data_scope_get(from, EFL_VG_GRADIENT_CLASS);
|
||||
|
||||
eo_do(obj,
|
||||
efl_gfx_gradient_stop_set(fromd->colors, fromd->colors_count),
|
||||
efl_gfx_gradient_spread_set(fromd->s));
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_vg_gradient_stop_set(Eo *obj, const Efl_Gfx_Gradient_Stop *colors, unsigned int length)
|
||||
{
|
||||
|
|
|
@ -151,6 +151,22 @@ _efl_vg_gradient_linear_efl_vg_base_interpolate(Eo *obj,
|
|||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_vg_gradient_linear_efl_vg_base_dup(Eo *obj,
|
||||
Efl_VG_Gradient_Linear_Data *pd EINA_UNUSED,
|
||||
const Efl_VG_Base *from)
|
||||
{
|
||||
Efl_VG_Gradient_Linear_Data *fromd;
|
||||
|
||||
eo_do_super(obj, EFL_VG_GRADIENT_LINEAR_CLASS, efl_vg_dup(from));
|
||||
|
||||
fromd = eo_data_scope_get(from, EFL_VG_GRADIENT_LINEAR_CLASS);
|
||||
|
||||
eo_do(obj,
|
||||
efl_gfx_gradient_linear_start_set(fromd->start.x, fromd->start.y),
|
||||
efl_gfx_gradient_linear_end_set(fromd->end.x, fromd->end.y));
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_vg_gradient_linear_start_set(Eo *obj, double x, double y)
|
||||
{
|
||||
|
|
|
@ -170,6 +170,23 @@ _efl_vg_gradient_radial_efl_vg_base_interpolate(Eo *obj,
|
|||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_vg_gradient_radial_efl_vg_base_dup(Eo *obj,
|
||||
Efl_VG_Gradient_Radial_Data *pd EINA_UNUSED,
|
||||
const Efl_VG_Base *from)
|
||||
{
|
||||
Efl_VG_Gradient_Radial_Data *fromd;
|
||||
|
||||
eo_do_super(obj, EFL_VG_GRADIENT_RADIAL_CLASS, efl_vg_dup(from));
|
||||
|
||||
fromd = eo_data_scope_get(from, EFL_VG_GRADIENT_RADIAL_CLASS);
|
||||
|
||||
eo_do(obj,
|
||||
efl_gfx_gradient_radial_focal_set(fromd->focal.x, fromd->focal.y),
|
||||
efl_gfx_gradient_radial_center_set(fromd->center.x, fromd->center.y),
|
||||
efl_gfx_gradient_radial_radius_set(fromd->radius));
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_vg_gradient_radial_center_set(Eo *obj, double x, double y)
|
||||
{
|
||||
|
|
|
@ -744,7 +744,11 @@ _efl_vg_base_dup(Eo *obj, Efl_VG_Base_Data *pd, const Efl_VG_Base *from)
|
|||
Eo *parent = NULL;
|
||||
|
||||
fromd = eo_data_scope_get(from, EFL_VG_BASE_CLASS);
|
||||
pd->name = eina_stringshare_ref(fromd->name);
|
||||
if (pd->name != fromd->name)
|
||||
{
|
||||
eina_stringshare_del(pd->name);
|
||||
pd->name = eina_stringshare_ref(fromd->name);
|
||||
}
|
||||
|
||||
_efl_vg_base_parent_checked_get(obj, &parent, &cd);
|
||||
if (cd) _efl_vg_base_name_insert(obj, pd, cd);
|
||||
|
@ -755,6 +759,12 @@ _efl_vg_base_dup(Eo *obj, Efl_VG_Base_Data *pd, const Efl_VG_Base *from)
|
|||
pd->intp = NULL;
|
||||
}
|
||||
|
||||
if (pd->renderer)
|
||||
{
|
||||
eo_del(pd->renderer);
|
||||
pd->renderer = NULL;
|
||||
}
|
||||
|
||||
if (fromd->m)
|
||||
{
|
||||
pd->m = pd->m ? pd->m : malloc(sizeof (Eina_Matrix3)) ;
|
||||
|
|
|
@ -73,6 +73,24 @@ _efl_vg_base_changed(Eo *obj)
|
|||
eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL));
|
||||
}
|
||||
|
||||
static inline void *
|
||||
_efl_vg_realloc(void *from, unsigned int sz)
|
||||
{
|
||||
void *result;
|
||||
|
||||
result = sz > 0 ? realloc(from, sz) : NULL;
|
||||
if (!result) free(from);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_efl_vg_clean_object(Eo **obj)
|
||||
{
|
||||
if (*obj) eo_unref(*obj);
|
||||
*obj = NULL;
|
||||
}
|
||||
|
||||
#define EFL_VG_COMPUTE_MATRIX(Current, Parent, Nd) \
|
||||
Eina_Matrix3 *Current = Nd->m; \
|
||||
Eina_Matrix3 _matrix_tmp; \
|
||||
|
|
|
@ -375,6 +375,47 @@ _efl_vg_shape_efl_vg_base_interpolate(Eo *obj,
|
|||
return r;
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_vg_shape_efl_vg_base_dup(Eo *obj, Efl_VG_Shape_Data *pd EINA_UNUSED, const Efl_VG_Base *from)
|
||||
{
|
||||
Efl_VG_Shape_Data *fromd;
|
||||
Eo *parent;
|
||||
Eo *fill = NULL, *stroke_fill = NULL, *stroke_marker = NULL;
|
||||
|
||||
eo_do_super(obj, MY_CLASS, efl_vg_dup(from));
|
||||
|
||||
eo_do(obj, parent = eo_parent_get());
|
||||
|
||||
fromd = eo_data_scope_get(from, MY_CLASS);
|
||||
|
||||
if (fromd->fill)
|
||||
{
|
||||
fill = eo_add(eo_class_get(fromd->fill),
|
||||
parent,
|
||||
efl_vg_dup(fromd->fill));
|
||||
}
|
||||
|
||||
if (fromd->stroke.fill)
|
||||
{
|
||||
stroke_fill = eo_add(eo_class_get(fromd->stroke.fill),
|
||||
parent,
|
||||
efl_vg_dup(fromd->stroke.fill));
|
||||
}
|
||||
|
||||
if (fromd->stroke.marker)
|
||||
{
|
||||
stroke_marker = eo_add(eo_class_get(fromd->stroke.marker),
|
||||
parent,
|
||||
efl_vg_dup(fromd->stroke.marker));
|
||||
}
|
||||
|
||||
eo_do(obj,
|
||||
efl_vg_shape_fill_set(fill),
|
||||
efl_vg_shape_stroke_fill_set(stroke_fill),
|
||||
efl_vg_shape_stroke_marker_set(stroke_marker),
|
||||
efl_gfx_shape_dup(from));
|
||||
}
|
||||
|
||||
EAPI double
|
||||
evas_vg_shape_stroke_scale_get(Eo *obj)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue