2015-04-03 07:12:59 -07:00
|
|
|
#include "evas_common_private.h"
|
|
|
|
#include "evas_private.h"
|
|
|
|
|
2015-04-03 07:14:50 -07:00
|
|
|
#include "evas_vg_private.h"
|
|
|
|
|
2015-04-03 07:12:59 -07:00
|
|
|
#define MY_CLASS EVAS_VG_SHAPE_CLASS
|
|
|
|
|
|
|
|
typedef struct _Evas_VG_Shape_Data Evas_VG_Shape_Data;
|
|
|
|
struct _Evas_VG_Shape_Data
|
|
|
|
{
|
2015-04-03 07:22:58 -07:00
|
|
|
Efl_Graphics_Path_Command *ops;
|
2015-04-03 07:12:59 -07:00
|
|
|
double *points;
|
2015-04-03 07:14:51 -07:00
|
|
|
|
|
|
|
Evas_VG_Node *fill;
|
|
|
|
|
|
|
|
struct {
|
2015-04-03 07:15:02 -07:00
|
|
|
Efl_Graphics_Dash *dash;
|
2015-04-03 07:14:51 -07:00
|
|
|
Evas_VG_Node *fill;
|
|
|
|
Evas_VG_Node *marker;
|
|
|
|
|
|
|
|
double scale;
|
|
|
|
double width;
|
|
|
|
double centered; // from 0 to 1
|
|
|
|
|
|
|
|
int r, g, b, a;
|
|
|
|
|
|
|
|
unsigned int dash_count;
|
|
|
|
|
2015-04-03 07:15:02 -07:00
|
|
|
Efl_Graphics_Cap cap;
|
|
|
|
Efl_Graphics_Join join;
|
2015-04-03 07:14:51 -07:00
|
|
|
} stroke;
|
2015-04-03 07:12:59 -07:00
|
|
|
};
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static Eina_Bool
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd,
|
2015-04-03 07:22:58 -07:00
|
|
|
const Efl_Graphics_Path_Command *ops,
|
2015-04-03 07:14:55 -07:00
|
|
|
const double *points)
|
2015-04-03 07:12:59 -07:00
|
|
|
{
|
2015-04-03 07:13:13 -07:00
|
|
|
free(pd->points);
|
|
|
|
pd->points = NULL;
|
2015-04-03 07:22:58 -07:00
|
|
|
free(pd->ops);
|
|
|
|
pd->ops = NULL;
|
2015-04-03 07:13:13 -07:00
|
|
|
|
2015-04-03 07:22:58 -07:00
|
|
|
return efl_graphics_path_dup(&pd->ops, &pd->points, ops, points);
|
2015-04-03 07:12:59 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static Eina_Bool
|
2015-04-03 07:22:58 -07:00
|
|
|
_evas_vg_shape_evas_vg_node_bound_get(Eo *obj,
|
|
|
|
Evas_VG_Shape_Data *pd,
|
|
|
|
Eina_Rectangle *r)
|
2015-04-03 07:12:59 -07:00
|
|
|
{
|
2015-04-03 07:14:50 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:14:51 -07:00
|
|
|
_evas_vg_shape_fill_set(Eo *obj EINA_UNUSED,
|
|
|
|
Evas_VG_Shape_Data *pd,
|
|
|
|
Evas_VG_Node *f)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
Evas_VG_Node *tmp = pd->fill;
|
|
|
|
|
|
|
|
pd->fill = eo_ref(f);
|
|
|
|
eo_unref(tmp);
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static Evas_VG_Node *
|
2015-04-03 07:14:51 -07:00
|
|
|
_evas_vg_shape_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
return pd->fill;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd,
|
|
|
|
double s)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
pd->stroke.scale = s;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static double
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_scale_get(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
return pd->stroke.scale;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd,
|
|
|
|
int r, int g, int b, int a)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
pd->stroke.r = r;
|
|
|
|
pd->stroke.g = g;
|
|
|
|
pd->stroke.b = b;
|
|
|
|
pd->stroke.a = a;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_color_get(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd,
|
|
|
|
int *r, int *g, int *b, int *a)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
if (r) *r = pd->stroke.r;
|
|
|
|
if (g) *g = pd->stroke.g;
|
|
|
|
if (b) *b = pd->stroke.b;
|
|
|
|
if (a) *a = pd->stroke.a;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:14:51 -07:00
|
|
|
_evas_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED,
|
|
|
|
Evas_VG_Shape_Data *pd,
|
|
|
|
Evas_VG_Node *f)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
Evas_VG_Node *tmp = pd->fill;
|
|
|
|
|
|
|
|
pd->stroke.fill = eo_ref(f);
|
|
|
|
eo_unref(tmp);
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static Evas_VG_Node *
|
2015-04-03 07:14:51 -07:00
|
|
|
_evas_vg_shape_stroke_fill_get(Eo *obj EINA_UNUSED,
|
|
|
|
Evas_VG_Shape_Data *pd)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
return pd->stroke.fill;
|
2015-04-03 07:12:59 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd,
|
|
|
|
double w)
|
2015-04-03 07:12:59 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
pd->stroke.width = w;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static double
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_width_get(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
return pd->stroke.width;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd,
|
|
|
|
double centered)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
pd->stroke.centered = centered;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static double
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_location_get(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
return pd->stroke.centered;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd,
|
2015-04-03 07:15:02 -07:00
|
|
|
const Efl_Graphics_Dash *dash,
|
2015-04-03 07:14:55 -07:00
|
|
|
unsigned int length)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
free(pd->stroke.dash);
|
|
|
|
pd->stroke.dash = NULL;
|
|
|
|
pd->stroke.dash_count = 0;
|
|
|
|
|
2015-04-03 07:15:02 -07:00
|
|
|
pd->stroke.dash = malloc(sizeof (Efl_Graphics_Dash) * length);
|
2015-04-03 07:14:51 -07:00
|
|
|
if (!pd->stroke.dash) return ;
|
|
|
|
|
2015-04-03 07:15:02 -07:00
|
|
|
memcpy(pd->stroke.dash, dash, sizeof (Efl_Graphics_Dash) * length);
|
2015-04-03 07:14:51 -07:00
|
|
|
pd->stroke.dash_count = length;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd,
|
2015-04-03 07:15:02 -07:00
|
|
|
const Efl_Graphics_Dash **dash,
|
2015-04-03 07:14:55 -07:00
|
|
|
unsigned int *length)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
if (dash) *dash = pd->stroke.dash;
|
|
|
|
if (length) *length = pd->stroke.dash_count;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
2015-04-03 07:12:59 -07:00
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:14:51 -07:00
|
|
|
_evas_vg_shape_stroke_marker_set(Eo *obj EINA_UNUSED,
|
|
|
|
Evas_VG_Shape_Data *pd,
|
2015-04-03 07:14:50 -07:00
|
|
|
Evas_VG_Shape *m)
|
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
Evas_VG_Node *tmp = pd->stroke.marker;
|
|
|
|
|
|
|
|
pd->stroke.marker = eo_ref(m);
|
|
|
|
eo_unref(tmp);
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static Evas_VG_Shape *
|
2015-04-03 07:14:51 -07:00
|
|
|
_evas_vg_shape_stroke_marker_get(Eo *obj EINA_UNUSED,
|
|
|
|
Evas_VG_Shape_Data *pd)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
return pd->stroke.marker;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
2015-04-03 07:12:59 -07:00
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd,
|
2015-04-03 07:15:02 -07:00
|
|
|
Efl_Graphics_Cap c)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
pd->stroke.cap = c;
|
2015-04-03 07:12:59 -07:00
|
|
|
}
|
2015-04-03 07:14:50 -07:00
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static Efl_Graphics_Cap
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_cap_get(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
return pd->stroke.cap;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static void
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd,
|
2015-04-03 07:15:02 -07:00
|
|
|
Efl_Graphics_Join j)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
pd->stroke.join = j;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:57 -07:00
|
|
|
static Efl_Graphics_Join
|
2015-04-03 07:15:02 -07:00
|
|
|
_evas_vg_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED,
|
2015-04-03 07:14:55 -07:00
|
|
|
Evas_VG_Shape_Data *pd)
|
2015-04-03 07:14:50 -07:00
|
|
|
{
|
2015-04-03 07:14:51 -07:00
|
|
|
return pd->stroke.join;
|
2015-04-03 07:14:50 -07:00
|
|
|
}
|
|
|
|
|
2015-04-03 07:22:58 -07:00
|
|
|
static void
|
|
|
|
_evas_vg_shape_render_pre(Eo *obj EINA_UNUSED,
|
|
|
|
Ector_Surface *s,
|
|
|
|
void *data,
|
|
|
|
Evas_VG_Node_Data *nd)
|
|
|
|
{
|
|
|
|
Evas_VG_Shape_Data *pd = data;
|
|
|
|
|
|
|
|
_evas_vg_render_pre(pd->fill, s);
|
|
|
|
_evas_vg_render_pre(pd->stroke.fill, s);
|
|
|
|
_evas_vg_render_pre(pd->stroke.marker, s);
|
|
|
|
_evas_vg_render_pre(nd->mask, s);
|
|
|
|
|
|
|
|
if (!nd->renderer)
|
|
|
|
{
|
|
|
|
eo_do(s, nd->renderer = ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_SHAPE_CLASS));
|
|
|
|
}
|
|
|
|
|
|
|
|
eo_do(nd->renderer,
|
|
|
|
ector_renderer_transformation_set(nd->m),
|
|
|
|
ector_renderer_origin_set(nd->x, nd->y),
|
|
|
|
ector_renderer_color_set(nd->r, nd->g, nd->b, nd->a),
|
|
|
|
ector_renderer_visibility_set(nd->visibility),
|
|
|
|
ector_renderer_mask_set(nd->mask),
|
|
|
|
ector_renderer_shape_fill_set(pd->fill),
|
|
|
|
ector_renderer_shape_stroke_fill_set(pd->stroke.fill),
|
|
|
|
ector_renderer_shape_stroke_marker_set(pd->stroke.marker),
|
|
|
|
efl_graphics_shape_stroke_scale_set(pd->stroke.scale),
|
|
|
|
efl_graphics_shape_stroke_color_set(pd->stroke.r,
|
|
|
|
pd->stroke.g,
|
|
|
|
pd->stroke.b,
|
|
|
|
pd->stroke.a),
|
|
|
|
efl_graphics_shape_stroke_width_set(pd->stroke.width),
|
|
|
|
efl_graphics_shape_stroke_location_set(pd->stroke.centered),
|
|
|
|
efl_graphics_shape_stroke_dash_set(pd->stroke.dash, pd->stroke.dash_count),
|
|
|
|
efl_graphics_shape_stroke_cap_set(pd->stroke.cap),
|
|
|
|
efl_graphics_shape_stroke_join_set(pd->stroke.join),
|
|
|
|
efl_graphics_shape_path_set(pd->ops, pd->points),
|
|
|
|
ector_renderer_prepare());
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd)
|
|
|
|
{
|
|
|
|
Evas_VG_Node_Data *nd;
|
|
|
|
|
|
|
|
eo_do_super(obj, MY_CLASS, eo_constructor());
|
|
|
|
|
|
|
|
pd->stroke.cap = EFL_GRAPHICS_CAP_BUTT;
|
|
|
|
pd->stroke.join = EFL_GRAPHICS_JOIN_MITER;
|
|
|
|
pd->stroke.scale = 1;
|
|
|
|
pd->stroke.a = 1;
|
|
|
|
pd->stroke.centered = 0.5;
|
|
|
|
|
|
|
|
nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS);
|
|
|
|
nd->render_pre = _evas_vg_shape_render_pre;
|
|
|
|
nd->data = pd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_vg_shape_eo_base_destructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
eo_do_super(obj, MY_CLASS, eo_destructor());
|
|
|
|
}
|
|
|
|
|
2015-04-03 07:14:50 -07:00
|
|
|
#include "evas_vg_shape.eo.c"
|