include Makefile_Efl.am
include Makefile_Eet.am
include Makefile_Eolian.am
-include Makefile_Ector.am
include Makefile_Ecore.am
include Makefile_Ecore_Con.am
include Makefile_Ecore_Ipc.am
lib/evas/canvas/efl_vg_root_node.eo \
lib/evas/canvas/efl_vg_gradient.eo \
lib/evas/canvas/efl_vg_gradient_radial.eo \
- lib/evas/canvas/efl_vg_gradient_linear.eo \
- lib/evas/canvas/efl_vg_image.eo
+ lib/evas/canvas/efl_vg_gradient_linear.eo
evas_eolian_c = $(evas_eolian_files:%.eo=%.eo.c)
evas_eolian_h = $(evas_eolian_files:%.eo=%.eo.h) \
lib/evas/include/evas_mmx.h \
lib/evas/include/evas_common_private.h \
lib/evas/include/evas_blend_ops.h \
-lib/evas/include/evas_filter.h
+lib/evas/include/evas_filter.h \
+lib/evas/canvas/evas_vg_private.h
# Linebreak
lib/evas/canvas/evas_touch_point.c \
lib/evas/canvas/evas_map.c \
lib/evas/canvas/evas_gl.c \
-lib/evas/canvas/evas_out.c \
-lib/evas/canvas/evas_vg_loader_svg.c
+lib/evas/canvas/evas_out.c
# Cache
lib_evas_libevas_la_SOURCES += \
lib/evas/canvas/evas_vg_gradient_linear.c \
lib/evas/canvas/evas_vg_gradient_radial.c \
lib/evas/canvas/evas_vg_utils.c \
-lib/evas/canvas/evas_vg_image.c \
lib/evas/canvas/evas_vg_shape.c
# Engine
* @{
*/
+#ifdef EFL_BETA_API_SUPPORT
+
/**
* @typedef Ector_Surface
* The base type to render content into.
ECTOR_UPDATE_OPAQUE = 8 /* Pushing some opaque pixels (this means that their is no need to read the under layer when blitting this surface) */
} Ector_Update_Type;
-#ifdef EFL_BETA_API_SUPPORT
-
/**
* @brief Init the ector subsystem
* @return @c EINA_TRUE on success.
typedef void cairo_pattern_t;
+typedef struct {
+ double xx; double yx;
+ double xy; double yy;
+ double x0; double y0;
+} cairo_matrix_t;
+
typedef struct _Ector_Cairo_Surface_Data Ector_Cairo_Surface_Data;
+typedef struct _Ector_Renderer_Cairo_Base_Data Ector_Renderer_Cairo_Base_Data;
+
struct _Ector_Cairo_Surface_Data
{
cairo_t *cairo;
Eina_Bool internal : 1;
};
+struct _Ector_Renderer_Cairo_Base_Data
+{
+ Ector_Cairo_Surface_Data *parent;
+ Ector_Renderer_Generic_Base_Data *generic;
+
+ cairo_matrix_t *m;
+};
+
+typedef enum _cairo_extend {
+ CAIRO_EXTEND_NONE,
+ CAIRO_EXTEND_REPEAT,
+ CAIRO_EXTEND_REFLECT,
+ CAIRO_EXTEND_PAD
+} cairo_extend_t;
+
+static inline cairo_extend_t
+_ector_cairo_extent_get(Efl_Gfx_Gradient_Spread s)
+{
+ switch (s)
+ {
+ case EFL_GFX_GRADIENT_SPREAD_PAD:
+ return CAIRO_EXTEND_PAD;
+ case EFL_GFX_GRADIENT_SPREAD_REFLECT:
+ return CAIRO_EXTEND_REFLECT;
+ case EFL_GFX_GRADIENT_SPREAD_REPEAT:
+ return CAIRO_EXTEND_REPEAT;
+ default:
+ return CAIRO_EXTEND_NONE;
+ }
+}
+
#define CHECK_CAIRO(Parent) (!(Parent && Parent->cairo))
#define USE(Obj, Sym, Error) \
typedef struct _cairo_surface_t cairo_surface_t;
-static void (*cairo_translate)(cairo_t *cr, double tx, double ty) = NULL;
static void (*cairo_destroy)(cairo_t *cr) = NULL;
static cairo_surface_t *(*cairo_image_surface_create)(int format,
int width,
Ector_Cairo_Surface_Data *pd,
int x, int y)
{
- if (pd->cairo)
- {
- USE(obj, cairo_translate, );
- cairo_translate(pd->cairo, x, y);
- }
+ pd->current.x = x;
+ pd->current.y = y;
}
static void
#include "ector_private.h"
#include "ector_cairo_private.h"
-typedef struct {
- double xx; double yx;
- double xy; double yy;
- double x0; double y0;
-} cairo_matrix_t;
-
typedef enum {
CAIRO_OPERATOR_CLEAR,
static void (*cairo_set_operator)(cairo_t *cr, cairo_operator_t op) = NULL;
static void (*cairo_matrix_init_identity)(cairo_matrix_t *matrix) = NULL;
-typedef struct _Ector_Renderer_Cairo_Base_Data Ector_Renderer_Cairo_Base_Data;
-struct _Ector_Renderer_Cairo_Base_Data
-{
- Ector_Cairo_Surface_Data *parent;
- Ector_Renderer_Generic_Base_Data *generic;
-
- cairo_matrix_t *m;
-};
+static void (*cairo_new_path)(cairo_t *cr) = NULL;
+static void (*cairo_rectangle)(cairo_t *cr, double x, double y, double width, double height) = NULL;
+static void (*cairo_clip)(cairo_t *cr) = NULL;
+static void (*cairo_device_to_user)(cairo_t *cr, double *x, double *y) = NULL;
static cairo_matrix_t identity;
Ector_Renderer_Cairo_Base_Data *pd,
int r, int g, int b, int a)
{
- ector_color_argb_unpremul(a, &r ,&g, &b);
pd->generic->color.r = r;
pd->generic->color.g = g;
pd->generic->color.b = b;
if (g) *g = pd->generic->color.g;
if (b) *b = pd->generic->color.b;
if (a) *a = pd->generic->color.a;
-
- ector_color_argb_premul(pd->generic->color.a, r, g, b);
}
static Eina_Bool
Eina_Array *clips EINA_UNUSED,
unsigned int mul_col)
{
- double r, g, b, a;
+ int r, g, b, a;
cairo_operator_t cop;
double cx, cy;
break;
}
- r = ((double)((pd->generic->color.r * R_VAL(&mul_col)) >> 8)) / 255;
- g = ((double)((pd->generic->color.g * G_VAL(&mul_col)) >> 8)) / 255;
- b = ((double)((pd->generic->color.b * B_VAL(&mul_col)) >> 8)) / 255;
- a = ((double)((pd->generic->color.a * A_VAL(&mul_col)) >> 8)) / 255;
+ r = ((pd->generic->color.r * R_VAL(&mul_col)) >> 8);
+ g = ((pd->generic->color.g * G_VAL(&mul_col)) >> 8);
+ b = ((pd->generic->color.b * B_VAL(&mul_col)) >> 8);
+ a = ((pd->generic->color.a * A_VAL(&mul_col)) >> 8);
+ ector_color_argb_unpremul(a, &r, &g, &b);
cairo_set_operator(pd->parent->cairo, cop);
+
+
+ USE(obj, cairo_new_path, EINA_FALSE);
+ USE(obj, cairo_rectangle, EINA_FALSE);
+ USE(obj, cairo_clip, EINA_FALSE);
+ USE(obj, cairo_device_to_user, EINA_FALSE);
+ if (clips)
+ {
+ int clip_count = eina_array_count(clips);
+ int i=0;
+ for (; i < clip_count ; i++)
+ {
+ Eina_Rectangle *clip = (Eina_Rectangle *)eina_array_data_get(clips, i);
+ double x = (double)clip->x;
+ double y = (double)clip->y;
+
+ cairo_new_path(pd->parent->cairo);
+ cairo_device_to_user(pd->parent->cairo, &x, &y);
+ cairo_rectangle(pd->parent->cairo, x, y, clip->w, clip->h);
+ }
+ cairo_clip(pd->parent->cairo);
+ }
+
cairo_transform(pd->parent->cairo, &identity);
- if (pd->m) cairo_transform(pd->parent->cairo, pd->m);
- cx = pd->generic->origin.x - pd->parent->current.x;
- cy = pd->generic->origin.y - pd->parent->current.y;
+ cx = pd->generic->origin.x + pd->parent->current.x;
+ cy = pd->generic->origin.y + pd->parent->current.y;
+
cairo_translate(pd->parent->cairo, cx, cy);
- pd->parent->current.x = pd->generic->origin.x;
- pd->parent->current.y = pd->generic->origin.y;
- cairo_set_source_rgba(pd->parent->cairo, r, g, b, a);
+ if (pd->m) cairo_transform(pd->parent->cairo, pd->m);
+
+ cairo_set_source_rgba(pd->parent->cairo, r/255.0, g/255.0, b/255.0, a/255.0);
return EINA_TRUE;
}
double red, double green, double blue, double alpha) = NULL;
static void (*cairo_pattern_destroy)(cairo_pattern_t *pattern) = NULL;
+static void (*cairo_pattern_set_extend)(cairo_pattern_t *pattern, cairo_extend_t extend) = NULL;
+
typedef struct _Ector_Renderer_Cairo_Gradient_Linear_Data Ector_Renderer_Cairo_Gradient_Linear_Data;
struct _Ector_Renderer_Cairo_Gradient_Linear_Data
{
pd->pat = cairo_pattern_create_linear(gld->start.x, gld->start.y,
gld->end.x, gld->end.y);
+ int r,g,b,a;
for (i = 0; i < gd->colors_count; i++)
- cairo_pattern_add_color_stop_rgba(pd->pat, gd->colors[i].offset,
- gd->colors[i].r, gd->colors[i].g,
- gd->colors[i].b, gd->colors[i].a);
+ {
+ r = gd->colors[i].r;
+ g = gd->colors[i].g;
+ b = gd->colors[i].b;
+ a = gd->colors[i].a;
+ ector_color_argb_unpremul(a, &r, &g, &b);
+ cairo_pattern_add_color_stop_rgba(pd->pat, gd->colors[i].offset, r/255.0, g/255.0, b/255.0, a/255.0);
+ }
+
+ USE(obj, cairo_pattern_set_extend, EINA_FALSE);
+ cairo_pattern_set_extend(pd->pat, _ector_cairo_extent_get(gd->s));
if (!pd->parent)
{
Ector_Renderer_Cairo_Gradient_Linear_Data *pd,
Ector_Rop op, Eina_Array *clips, unsigned int mul_col)
{
+ if (pd->pat) return EINA_FALSE;
+
Ector_Renderer_Generic_Gradient_Linear_Data *gld;
// FIXME: don't ignore clipping !
return EINA_TRUE;
}
+static void
+_ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_bounds_get(Eo *obj,
+ Ector_Renderer_Cairo_Gradient_Linear_Data *pd EINA_UNUSED,
+ Eina_Rectangle *r)
+{
+ Ector_Renderer_Generic_Gradient_Linear_Data *gld;
+ Ector_Renderer_Cairo_Base_Data *bd;
+
+ gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN);
+ bd = eo_data_scope_get(obj, ECTOR_RENDERER_CAIRO_BASE_CLASS);
+ EINA_RECTANGLE_SET(r,
+ bd->generic->origin.x + gld->start.x,
+ bd->generic->origin.y + gld->start.y,
+ gld->end.x - gld->start.x,
+ gld->end.y - gld->start.x);
+}
+
void
_ector_renderer_cairo_gradient_linear_eo_base_destructor(Eo *obj,
Ector_Renderer_Cairo_Gradient_Linear_Data *pd)
implements {
Ector.Renderer.Generic.Base.prepare;
Ector.Renderer.Generic.Base.draw;
+ Ector.Renderer.Generic.Base.bounds_get;
Ector.Renderer.Cairo.Base.fill;
Eo.Base.destructor;
Efl.Gfx.Gradient.Base.stop.set;
double red, double green, double blue, double alpha) = NULL;
static void (*cairo_pattern_destroy)(cairo_pattern_t *pattern) = NULL;
+static void (*cairo_pattern_set_extend)(cairo_pattern_t *pattern, cairo_extend_t extend) = NULL;
// FIXME: as long as it is not possible to directly access the parent structure
// this will be duplicated from the linear gradient renderer
pd->pat = cairo_pattern_create_radial(grd->focal.x, grd->focal.y, 0,
grd->radial.x, grd->radial.y, grd->radius);
+
+ int r,g,b,a;
for (i = 0; i < gd->colors_count; i++)
- cairo_pattern_add_color_stop_rgba(pd->pat, gd->colors[i].offset,
- gd->colors[i].r, gd->colors[i].g,
- gd->colors[i].b, gd->colors[i].a);
+ {
+ r = gd->colors[i].r;
+ g = gd->colors[i].g;
+ b = gd->colors[i].b;
+ a = gd->colors[i].a;
+ ector_color_argb_unpremul(a, &r, &g, &b);
+ cairo_pattern_add_color_stop_rgba(pd->pat, gd->colors[i].offset, r/255.0, g/255.0, b/255.0, a/255.0);
+ }
+
+ USE(obj, cairo_pattern_set_extend, EINA_FALSE);
+ cairo_pattern_set_extend(pd->pat, _ector_cairo_extent_get(gd->s));
if (!pd->parent)
{
static Eina_Bool
_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col)
{
+ if (pd->pat) return EINA_FALSE;
+
Ector_Renderer_Generic_Gradient_Radial_Data *gld;
// FIXME: don't ignore clipping !
return EINA_TRUE;
}
+static void
+_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_bounds_get(Eo *obj EINA_UNUSED,
+ Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED,
+ Eina_Rectangle *r)
+{
+ Ector_Renderer_Generic_Gradient_Radial_Data *gld;
+ Ector_Renderer_Cairo_Base_Data *bd;
+
+ gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN);
+ bd = eo_data_scope_get(obj, ECTOR_RENDERER_CAIRO_BASE_CLASS);
+ EINA_RECTANGLE_SET(r,
+ bd->generic->origin.x + gld->radial.x - gld->radius,
+ bd->generic->origin.y + gld->radial.y - gld->radius,
+ gld->radius * 2, gld->radius * 2);
+}
+
void
_ector_renderer_cairo_gradient_radial_eo_base_destructor(Eo *obj,
Ector_Renderer_Cairo_Gradient_Radial_Data *pd)
implements {
Ector.Renderer.Generic.Base.prepare;
Ector.Renderer.Generic.Base.draw;
+ Ector.Renderer.Generic.Base.bounds_get;
Ector.Renderer.Cairo.Base.fill;
Eo.Base.destructor;
Efl.Gfx.Gradient.Base.stop.set;
typedef struct _cairo_path_t cairo_path_t;
+typedef enum _cairo_line_cap {
+ CAIRO_LINE_CAP_BUTT,
+ CAIRO_LINE_CAP_ROUND,
+ CAIRO_LINE_CAP_SQUARE
+} cairo_line_cap_t;
+
+typedef enum _cairo_line_join {
+ CAIRO_LINE_JOIN_MITER,
+ CAIRO_LINE_JOIN_ROUND,
+ CAIRO_LINE_JOIN_BEVEL
+} cairo_line_join_t;
+
static void (*cairo_move_to)(cairo_t *cr, double x, double y) = NULL;
static void (*cairo_line_to)(cairo_t *cr, double x, double y) = NULL;
static void (*cairo_curve_to)(cairo_t *cr,
static void (*cairo_new_path)(cairo_t *cr) = NULL;
static void (*cairo_append_path)(cairo_t *cr, const cairo_path_t *path) = NULL;
+static void (*cairo_set_line_width)(cairo_t *cr, double width) = NULL;
+static void (*cairo_set_line_cap)(cairo_t *cr, cairo_line_cap_t line_cap) = NULL;
+static void (*cairo_set_line_join)(cairo_t *cr, cairo_line_join_t line_join) = NULL;
+
+static void (*cairo_save)(cairo_t *cr) = NULL;
+static void (*cairo_restore)(cairo_t *cr) = NULL;
+
+static void (*cairo_set_dash) (cairo_t *cr, const double *dashes, int num_dashes, double offset) = NULL;
+
typedef struct _Ector_Renderer_Cairo_Shape_Data Ector_Renderer_Cairo_Shape_Data;
struct _Ector_Renderer_Cairo_Shape_Data
{
};
static Eina_Bool
-_ector_renderer_cairo_shape_path_changed(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
+_ector_renderer_cairo_shape_path_changed(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
{
Ector_Renderer_Cairo_Shape_Data *pd = data;
static Eina_Bool
_ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col)
{
+ int r, g, b, a;
if (pd->path == NULL) return EINA_FALSE;
- // FIXME: find a way to set multiple clips
+ USE(obj, cairo_save, EINA_FALSE);
+ cairo_save(pd->parent->cairo);
+
eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_draw(op, clips, mul_col));
USE(obj, cairo_new_path, EINA_FALSE);
if (pd->shape->fill)
eo_do(pd->shape->fill, ector_renderer_cairo_base_fill());
- if (pd->shape->stroke.color.a > 0)
+ if (pd->shape->stroke.fill || pd->shape->stroke.color.a > 0)
{
USE(obj, cairo_fill_preserve, EINA_FALSE);
USE(obj, cairo_set_source_rgba, EINA_FALSE);
USE(obj, cairo_stroke, EINA_FALSE);
+ USE(obj, cairo_set_line_width, EINA_FALSE);
+ USE(obj, cairo_set_line_cap, EINA_FALSE);
+ USE(obj, cairo_set_line_join, EINA_FALSE);
cairo_fill_preserve(pd->parent->cairo);
- cairo_set_source_rgba(pd->parent->cairo,
- pd->shape->stroke.color.r / 255.0,
- pd->shape->stroke.color.g / 255.0,
- pd->shape->stroke.color.b / 255.0,
- pd->shape->stroke.color.a / 255.0);
-
if (pd->shape->stroke.fill)
eo_do(pd->shape->stroke.fill, ector_renderer_cairo_base_fill());
- // Set dash, cap and join
- cairo_stroke(pd->parent->cairo);
+ else
+ {
+ r = (((pd->shape->stroke.color.r * R_VAL(&mul_col)) + 0xff) >> 8);
+ g = (((pd->shape->stroke.color.g * G_VAL(&mul_col)) + 0xff) >> 8);
+ b = (((pd->shape->stroke.color.b * B_VAL(&mul_col)) + 0xff) >> 8);
+ a = (((pd->shape->stroke.color.a * A_VAL(&mul_col)) + 0xff) >> 8);
+ ector_color_argb_unpremul(a, &r, &g, &b);
+ cairo_set_source_rgba(pd->parent->cairo, r/255.0, g/255.0, b/255.0, a/255.0);
+ if (pd->shape->stroke.dash)
+ {
+ unsigned int i = 0;
+ double *dashinfo = (double *) malloc(2 * pd->shape->stroke.dash_length * sizeof(double));
+ for (i = 0 ; i < pd->shape->stroke.dash_length ; i++)
+ {
+ dashinfo[i*2] = pd->shape->stroke.dash[i].length;
+ dashinfo[i*2 + 1] = pd->shape->stroke.dash[i].gap;
+ }
+ USE(obj, cairo_set_dash, EINA_FALSE);
+ cairo_set_dash(pd->parent->cairo, dashinfo, pd->shape->stroke.dash_length * 2, 0);
+ }
+ }
+
+ // Set dash, cap and join
+ cairo_set_line_width(pd->parent->cairo, (pd->shape->stroke.width * pd->shape->stroke.scale * 2));
+ cairo_set_line_cap(pd->parent->cairo, pd->shape->stroke.cap);
+ cairo_set_line_join(pd->parent->cairo, pd->shape->stroke.join);
+ cairo_stroke(pd->parent->cairo);
}
else
{
cairo_fill(pd->parent->cairo);
}
+ USE(obj, cairo_restore, EINA_FALSE);
+ cairo_restore(pd->parent->cairo);
return EINA_TRUE;
}
return EINA_FALSE;
}
+static void
+_ector_renderer_cairo_shape_ector_renderer_generic_base_bounds_get(Eo *obj,
+ Ector_Renderer_Cairo_Shape_Data *pd EINA_UNUSED,
+ Eina_Rectangle *r)
+{
+ Ector_Renderer_Cairo_Base_Data *bd;
+
+ // FIXME: It should be possible to actually ask cairo about that
+ eo_do(obj, efl_gfx_shape_bounds_get(r));
+
+ bd = eo_data_scope_get(obj, ECTOR_RENDERER_CAIRO_BASE_CLASS);
+ r->x += bd->generic->origin.x;
+ r->y += bd->generic->origin.y;
+}
+
void
_ector_renderer_cairo_shape_eo_base_constructor(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd)
{
implements {
Ector.Renderer.Generic.Base.prepare;
Ector.Renderer.Generic.Base.draw;
+ Ector.Renderer.Generic.Base.bounds_get;
Ector.Renderer.Cairo.Base.fill;
Eo.Base.constructor;
Eo.Base.destructor;
@in const(Eo_Class) * type @nonull;
}
}
- update_push {
- return: bool;
- params {
- @in const(Eina_Rectangle) * r @nonull;
- @in Ector_Update_Type type;
- }
- }
- update_reset {
- return: bool;
- }
}
implements {
@virtual .renderer_factory_new;
#endif /* ifdef CRI */
#define CRI(...) EINA_LOG_DOM_CRIT(_ector_log_dom_global, __VA_ARGS__)
+/* The following macro are internal to Ector only at this stage */
+
typedef unsigned char DATA8;
typedef unsigned short DATA16;
(((a) << 24) + ((r) << 16) + ((g) << 8) + (b))
static inline void
-ector_color_argb_premul(int a, int *r, int *g, int *b)
-{
- a++;
- if (r) { *r = (a * *r) >> 8; }
- if (g) { *g = (a * *g) >> 8; }
- if (b) { *b = (a * *b) >> 8; }
-}
-
-static inline void
-ector_color_argb_unpremul(int a, int *r, int *g, int *b)
-{
- if (!a) return;
- if (r) { *r = (255 * *r) / a; }
- if (g) { *g = (255 * *g) / a; }
- if (b) { *b = (255 * *b) / a; }
-}
-
-
-static inline void
_ector_renderer_replace(Ector_Renderer **d, const Ector_Renderer *s)
{
Ector_Renderer *tmp = *d;
#include "ector_private.h"
static void
+_ector_renderer_generic_base_eo_base_destructor(Eo *obj, Ector_Renderer_Generic_Base_Data *pd)
+{
+ if (pd->m) free(pd->m);
+ eo_do_super(obj, ECTOR_RENDERER_GENERIC_BASE_CLASS, eo_destructor());
+}
+
+static void
_ector_renderer_generic_base_transformation_set(Eo *obj EINA_UNUSED,
Ector_Renderer_Generic_Base_Data *pd,
const Eina_Matrix3 *m)
{
- Eina_Matrix3 *tmp = pd->m;
-
- pd->m = NULL;
if (!m)
{
- free(tmp);
- tmp = NULL;
+ free(pd->m);
+ pd->m = NULL;
}
else
{
- if (!tmp) tmp = malloc(sizeof (Eina_Matrix3));
- if (!tmp) return ;
+ if (!pd->m) pd->m = malloc(sizeof (Eina_Matrix3));
+ if (!pd->m) return ;
- memcpy(tmp, m, sizeof (Eina_Matrix3));
+ memcpy(pd->m, m, sizeof (Eina_Matrix3));
}
-
- pd->m = tmp;
}
static const Eina_Matrix3 *
}
methods {
bounds_get {
- return: bool @warn_unused;
params {
- @out Eina_Rectangle *r;
+ @out Eina_Rectangle r;
}
}
draw {
}
}
implements {
+ Eo.Base.destructor;
@virtual .draw;
@virtual .bounds_get;
@virtual .done;
typedef struct _Ector_Generic_Surface_Data Ector_Generic_Surface_Data;
struct _Ector_Generic_Surface_Data
{
+ int w, h;
};
void
-_ector_generic_surface_size_set(Eo *obj,
+_ector_generic_surface_size_set(Eo *obj EINA_UNUSED,
Ector_Generic_Surface_Data *pd,
int w, int h)
{
+ pd->w = w;
+ pd->h = h;
}
void
-_ector_generic_surface_size_get(Eo *obj,
+_ector_generic_surface_size_get(Eo *obj EINA_UNUSED,
Ector_Generic_Surface_Data *pd,
int *w, int *h)
{
-}
-
-Eina_Bool
-_ector_generic_surface_update_push(Eo *obj,
- Ector_Generic_Surface_Data *pd,
- const Eina_Rectangle *r,
- Ector_Update_Type type)
-{
-}
-
-Eina_Bool
-_ector_generic_surface_update_reset(Eo *obj, Ector_Generic_Surface_Data *pd)
-{
+ if (w) *w = pd->w;
+ if (h) *h = pd->h;
}
#include "ector_generic_surface.eo.c"
#ifndef ECTOR_UTIL_H
# define ECTOR_UTIL_H
+static inline void
+ector_color_argb_premul(int a, int *r, int *g, int *b)
+{
+ a++;
+ if (r) { *r = (a * *r) >> 8; }
+ if (g) { *g = (a * *g) >> 8; }
+ if (b) { *b = (a * *b) >> 8; }
+}
+
+static inline void
+ector_color_argb_unpremul(int a, int *r, int *g, int *b)
+{
+ if (!a) return;
+ if (r) { *r = (255 * *r) / a; }
+ if (g) { *g = (255 * *g) / a; }
+ if (b) { *b = (255 * *b) / a; }
+}
+
+
static inline unsigned int
ector_color_multiply(unsigned int c1, unsigned int c2)
{
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <Ector.h>
#include "ector_drawhelper_private.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <Ector.h>
#include "ector_drawhelper_private.h"
static void
_update_linear_data(Ector_Renderer_Software_Gradient_Data *gdata)
{
- update_color_table(gdata);
gdata->linear.x1 = gdata->gld->start.x;
gdata->linear.y1 = gdata->gld->start.y;
_ector_renderer_software_gradient_linear_ector_renderer_software_base_fill(Eo *obj EINA_UNUSED,
Ector_Renderer_Software_Gradient_Data *pd)
{
+ // lazy creation of color table
+ update_color_table(pd);
ector_software_rasterizer_linear_gradient_set(pd->surface->software, pd);
return EINA_TRUE;
static void
_update_radial_data(Ector_Renderer_Software_Gradient_Data *gdata)
{
- update_color_table(gdata);
-
gdata->radial.cx = gdata->grd->radial.x;
gdata->radial.cy = gdata->grd->radial.y;
gdata->radial.cradius = gdata->grd->radius;
static Eina_Bool
_ector_renderer_software_gradient_radial_ector_renderer_software_base_fill(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd)
{
+ // lazy creation of color table
+ update_color_table(pd);
ector_software_rasterizer_radial_gradient_set(pd->surface->software, pd);
return EINA_TRUE;
}
int contours_alloc;
}Outline;
+
+static inline void
+_grow_outline_contour(Outline *outline, int num)
+{
+ if ( outline->ft_outline.n_contours + num > outline->contours_alloc)
+ {
+ outline->contours_alloc += 5;
+ outline->ft_outline.contours = (short *) realloc(outline->ft_outline.contours, outline->contours_alloc * sizeof(short));
+ }
+}
+
+static inline void
+_grow_outline_points(Outline *outline, int num)
+{
+ if ( outline->ft_outline.n_points + num > outline->points_alloc)
+ {
+ outline->points_alloc += 50;
+ outline->ft_outline.points = (SW_FT_Vector *) realloc(outline->ft_outline.points, outline->points_alloc * sizeof(SW_FT_Vector));
+ outline->ft_outline.tags = (char *) realloc(outline->ft_outline.tags, outline->points_alloc * sizeof(char));
+ }
+}
static Outline *
_outline_create()
{
Outline *outline = (Outline *) calloc(1, sizeof(Outline));
-
- outline->ft_outline.points = (SW_FT_Vector *) calloc(50, sizeof(SW_FT_Vector));
- outline->ft_outline.tags = (char *) calloc(50, sizeof(char));
-
- outline->ft_outline.contours = (short *) calloc(5, sizeof(short));
-
- outline->points_alloc = 50;
- outline->contours_alloc = 5;
+ outline->points_alloc = 0;
+ outline->contours_alloc = 0;
+ _grow_outline_contour(outline, 1);
+ _grow_outline_points(outline, 1);
return outline;
}
{
SW_FT_Outline *ft_outline = &outline->ft_outline;
- if (ft_outline->n_contours == outline->contours_alloc)
- {
- outline->contours_alloc += 5;
- ft_outline->contours = (short *) realloc(ft_outline->contours, outline->contours_alloc * sizeof(short));
- }
+ _grow_outline_points(outline, 1);
ft_outline->points[ft_outline->n_points].x = x;
ft_outline->points[ft_outline->n_points].y = y;
ft_outline->tags[ft_outline->n_points] = SW_FT_CURVE_TAG_ON;
if (ft_outline->n_points)
{
+ _grow_outline_contour(outline, 1);
ft_outline->contours[ft_outline->n_contours] = ft_outline->n_points - 1;
ft_outline->n_contours++;
}
{
SW_FT_Outline *ft_outline = &outline->ft_outline;
- if (ft_outline->n_contours == outline->contours_alloc)
- {
- outline->contours_alloc += 1;
- ft_outline->contours = (short *) realloc(ft_outline->contours, outline->contours_alloc * sizeof(short));
- }
+ _grow_outline_contour(outline, 1);
if (ft_outline->n_points)
{
{
SW_FT_Outline *ft_outline = &outline->ft_outline;
- if (ft_outline->n_points == outline->points_alloc)
- {
- outline->points_alloc += 50;
- ft_outline->points = (SW_FT_Vector *) realloc(ft_outline->points, outline->points_alloc * sizeof(SW_FT_Vector));
- ft_outline->tags = (char *) realloc(ft_outline->tags, outline->points_alloc * sizeof(char));
- }
+ _grow_outline_points(outline, 1);
ft_outline->points[ft_outline->n_points].x = x;
ft_outline->points[ft_outline->n_points].y = y;
ft_outline->tags[ft_outline->n_points] = SW_FT_CURVE_TAG_ON;
{
SW_FT_Outline *ft_outline = &outline->ft_outline;
- if (ft_outline->n_points == outline->points_alloc)
- {
- outline->points_alloc += 50;
- ft_outline->points = (SW_FT_Vector *) realloc(ft_outline->points, outline->points_alloc * sizeof(SW_FT_Vector));
- ft_outline->tags = (char *) realloc(ft_outline->tags, outline->points_alloc * sizeof(char));
- }
+ _grow_outline_points(outline, 3);
ft_outline->points[ft_outline->n_points].x = cx1;
ft_outline->points[ft_outline->n_points].y = cy1;
return EINA_TRUE;
}
-static Eina_Bool
-_ector_renderer_software_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Software_Shape_Data *pd)
+static void
+_update_rle(Eo *obj, Ector_Renderer_Software_Shape_Data *pd)
{
const Efl_Gfx_Path_Command *cmds = NULL;
const double *pts = NULL;
-
- // FIXME: shouldn't that be part of the shape generic implementation ?
- if (pd->shape->fill)
- eo_do(pd->shape->fill, ector_renderer_prepare());
- if (pd->shape->stroke.fill)
- eo_do(pd->shape->stroke.fill, ector_renderer_prepare());
- if (pd->shape->stroke.marker)
- eo_do(pd->shape->stroke.marker, ector_renderer_prepare());
-
- // shouldn't that be moved to the software base object
- if (!pd->surface)
- {
- Eo *parent;
- eo_do(obj, parent = eo_parent_get());
- if (!parent) return EINA_FALSE;
- pd->surface = eo_data_xref(parent, ECTOR_SOFTWARE_SURFACE_CLASS, obj);
- if (!pd->surface) return EINA_FALSE;
- }
-
eo_do(obj, efl_gfx_shape_path_get(&cmds, &pts));
if (cmds && (_generate_stroke_data(pd) || _generate_shape_data(pd)))
{
}
_outline_destroy(outline);
}
+}
+
+static Eina_Bool
+_ector_renderer_software_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Software_Shape_Data *pd)
+{
+ // FIXME: shouldn't that be part of the shape generic implementation ?
+ if (pd->shape->fill)
+ eo_do(pd->shape->fill, ector_renderer_prepare());
+ if (pd->shape->stroke.fill)
+ eo_do(pd->shape->stroke.fill, ector_renderer_prepare());
+ if (pd->shape->stroke.marker)
+ eo_do(pd->shape->stroke.marker, ector_renderer_prepare());
+ // shouldn't that be moved to the software base object
+ if (!pd->surface)
+ {
+ Eo *parent;
+ eo_do(obj, parent = eo_parent_get());
+ if (!parent) return EINA_FALSE;
+ pd->surface = eo_data_xref(parent, ECTOR_SOFTWARE_SURFACE_CLASS, obj);
+ if (!pd->surface) return EINA_FALSE;
+ }
return EINA_TRUE;
}
static Eina_Bool
-_ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col)
+_ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Software_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col)
{
int x, y;
+ // do lazy creation of rle
+ _update_rle(obj, pd);
+
// adjust the offset
x = pd->surface->x + (int)pd->base->origin.x;
y = pd->surface->y + (int)pd->base->origin.y;
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <assert.h>
#include <math.h>
{
SW_FT_Raster raster;
SW_FT_Stroker stroker;
-
+ void *mem_pool;
Span_Data fill_data;
Eina_Matrix3 *transform;
Eina_Rectangle system_clip;
-
} Software_Rasterizer;
struct _Ector_Software_Surface_Data
void ector_software_rasterizer_init(Software_Rasterizer *rasterizer)
{
// initialize the rasterizer and stroker
- unsigned char* renderPool = (unsigned char*) malloc(1024 * 100);
+ rasterizer->mem_pool = (unsigned char*) malloc(1024 * 100);
sw_ft_grays_raster.raster_new(&rasterizer->raster);
- sw_ft_grays_raster.raster_reset(rasterizer->raster, renderPool, 1024*100);
+ sw_ft_grays_raster.raster_reset(rasterizer->raster, rasterizer->mem_pool, 1024*100);
SW_FT_Stroker_New(&rasterizer->stroker);
SW_FT_Stroker_Set(rasterizer->stroker, 1<<6,SW_FT_STROKER_LINECAP_BUTT,SW_FT_STROKER_LINEJOIN_MITER,0);
{
sw_ft_grays_raster.raster_done(rasterizer->raster);
SW_FT_Stroker_Done(rasterizer->stroker);
- //TODO free the pool memory
+ free(rasterizer->mem_pool);
}
#include "interfaces/efl_gfx_gradient_linear.eo.h"
#include "interfaces/efl_gfx_gradient_radial.eo.h"
+#endif
+
#if defined ( __cplusplus )
}
#endif
return EINA_TRUE;
}
-void
+static void
_efl_gfx_shape_path_set(Eo *obj, Efl_Gfx_Shape_Data *pd,
const Efl_Gfx_Path_Command *commands,
const double *points)
eo_event_callback_call(EFL_GFX_CHANGED, NULL));
}
-void
+static void
_efl_gfx_shape_path_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd,
const Efl_Gfx_Path_Command **commands,
const double **points)
if (points) *points = pd->points;
}
-void
+static void
_efl_gfx_shape_path_length_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd,
unsigned int *commands, unsigned int *points)
{
if (points) *points = pd->points_count;
}
-void
+static void
+_efl_gfx_shape_bounds_get(Eo *obj EINA_UNUSED,
+ Efl_Gfx_Shape_Data *pd,
+ Eina_Rectangle *r)
+{
+ double minx, miny, maxx, maxy;
+ unsigned int i;
+
+ EINA_RECTANGLE_SET(r, 0, 0, 0, 0);
+
+ if (pd->points_count <= 0) return ;
+
+ minx = pd->points[0];
+ miny = pd->points[1];
+ maxx = pd->points[0];
+ maxy = pd->points[1];
+
+ for (i = 1; i < pd->points_count; i += 2)
+ {
+ minx = minx < pd->points[i] ? minx : pd->points[i];
+ miny = miny < pd->points[i + 1] ? miny : pd->points[i + 1];
+ maxx = maxx > pd->points[i] ? maxx : pd->points[i];
+ maxy = maxy > pd->points[i + 1] ? maxy : pd->points[i + 1];
+ }
+
+ EINA_RECTANGLE_SET(r,
+ minx, miny,
+ maxx - minx, maxy - miny);
+}
+
+static void
_efl_gfx_shape_current_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd,
double *x, double *y)
{
if (y) *y = pd->current.y;
}
-void
+static void
_efl_gfx_shape_current_ctrl_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd,
double *x, double *y)
{
return (from * pos_map) + (to * (1.0 - pos_map));
}
-typedef struct _Efl_Gfx_Stroke Efl_Gfx_Stroke;
-struct _Efl_Gfx_Stroke
+typedef struct _Efl_Gfx_Property Efl_Gfx_Property;
+struct _Efl_Gfx_Property
{
double scale;
int r, g, b, a;
+ int fr, fg, fb, fa;
double w;
double centered;
const Efl_Gfx_Dash *dash;
};
static inline void
-stroke_get(const Eo *obj, Efl_Gfx_Stroke *stroke)
+gfx_property_get(const Eo *obj, Efl_Gfx_Property *property)
{
eo_do(obj,
- stroke->scale = efl_gfx_shape_stroke_scale_get(),
- efl_gfx_shape_stroke_color_get(&stroke->r, &stroke->g, &stroke->b, &stroke->a),
- stroke->w = efl_gfx_shape_stroke_width_get(),
- stroke->centered = efl_gfx_shape_stroke_location_get(),
- efl_gfx_shape_stroke_dash_get(&stroke->dash, &stroke->dash_length),
- stroke->c = efl_gfx_shape_stroke_cap_get(),
- stroke->j = efl_gfx_shape_stroke_join_get());
+ property->scale = efl_gfx_shape_stroke_scale_get(),
+ efl_gfx_shape_stroke_color_get(&property->r, &property->g, &property->b, &property->a),
+ efl_gfx_color_get(&property->fr, &property->fg, &property->fb, &property->fa),
+ property->w = efl_gfx_shape_stroke_width_get(),
+ property->centered = efl_gfx_shape_stroke_location_get(),
+ efl_gfx_shape_stroke_dash_get(&property->dash, &property->dash_length),
+ property->c = efl_gfx_shape_stroke_cap_get(),
+ property->j = efl_gfx_shape_stroke_join_get());
}
-Eina_Bool
+static Eina_Bool
_efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd,
const Eo *from, const Eo *to, double pos_map)
{
Efl_Gfx_Path_Command *cmds;
double *pts, *from_pts, *to_pts;
unsigned int i, j;
- Efl_Gfx_Stroke stroke_from, stroke_to;
- Efl_Gfx_Dash *dash;
+ Efl_Gfx_Property property_from, property_to;
+ Efl_Gfx_Dash *dash = NULL;
from_pd = eo_data_scope_get(from, EFL_GFX_SHAPE_MIXIN);
to_pd = eo_data_scope_get(to, EFL_GFX_SHAPE_MIXIN);
if (!_efl_gfx_shape_equal_commands_internal(from_pd, to_pd))
return EINA_FALSE;
- stroke_get(from, &stroke_from);
- stroke_get(to, &stroke_to);
+ gfx_property_get(from, &property_from);
+ gfx_property_get(to, &property_to);
- if (stroke_from.dash_length != stroke_to.dash_length) return EINA_FALSE;
+ if (property_from.dash_length != property_to.dash_length) return EINA_FALSE;
cmds = realloc(pd->commands,
sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count);
to_pd->current_ctrl.y,
pos_map);
- dash = malloc(sizeof (Efl_Gfx_Dash) * stroke_to.dash_length);
- if (dash)
+ if (property_to.dash_length)
{
- for (i = 0; i < stroke_to.dash_length; i++)
+ dash = malloc(sizeof (Efl_Gfx_Dash) * property_to.dash_length);
+ if (!dash) return EINA_FALSE;
+
+ for (i = 0; i < property_to.dash_length; i++)
{
- dash[i].length = interpolate(stroke_from.dash[i].length,
- stroke_to.dash[i].length, pos_map);
- dash[i].gap = interpolate(stroke_from.dash[i].gap,
- stroke_to.dash[i].gap, pos_map);
+ dash[i].length = interpolate(property_from.dash[i].length,
+ property_to.dash[i].length, pos_map);
+ dash[i].gap = interpolate(property_from.dash[i].gap,
+ property_to.dash[i].gap, pos_map);
}
}
- else
- {
- stroke_to.dash_length = 0;
- }
+
eo_do(obj,
- efl_gfx_shape_stroke_scale_set(interpolate(stroke_to.scale, stroke_from.scale, pos_map)),
- efl_gfx_shape_stroke_color_set(interpolatei(stroke_to.r, stroke_from.r, pos_map),
- interpolatei(stroke_to.g, stroke_from.g, pos_map),
- interpolatei(stroke_to.b, stroke_from.b, pos_map),
- interpolatei(stroke_to.a, stroke_from.a, pos_map)),
- efl_gfx_shape_stroke_width_set(interpolate(stroke_to.w, stroke_from.w, pos_map)),
- efl_gfx_shape_stroke_location_set(interpolate(stroke_to.centered, stroke_from.centered, pos_map)),
- efl_gfx_shape_stroke_dash_set(dash, stroke_to.dash_length),
- efl_gfx_shape_stroke_cap_set(pos_map < 0.5 ? stroke_from.c : stroke_to.c),
- efl_gfx_shape_stroke_join_set(pos_map < 0.5 ? stroke_from.j : stroke_to.j),
+ efl_gfx_shape_stroke_scale_set(interpolate(property_to.scale, property_from.scale, pos_map)),
+ efl_gfx_shape_stroke_color_set(interpolatei(property_to.r, property_from.r, pos_map),
+ interpolatei(property_to.g, property_from.g, pos_map),
+ interpolatei(property_to.b, property_from.b, pos_map),
+ interpolatei(property_to.a, property_from.a, pos_map)),
+ efl_gfx_color_set(interpolatei(property_to.fr, property_from.fr, pos_map),
+ interpolatei(property_to.fg, property_from.fg, pos_map),
+ interpolatei(property_to.fb, property_from.fb, pos_map),
+ interpolatei(property_to.fa, property_from.fa, pos_map)),
+ efl_gfx_shape_stroke_width_set(interpolate(property_to.w, property_from.w, pos_map)),
+ efl_gfx_shape_stroke_location_set(interpolate(property_to.centered, property_from.centered, pos_map)),
+ efl_gfx_shape_stroke_dash_set(dash, property_to.dash_length),
+ efl_gfx_shape_stroke_cap_set(pos_map < 0.5 ? property_from.c : property_to.c),
+ efl_gfx_shape_stroke_join_set(pos_map < 0.5 ? property_from.j : property_to.j),
eo_event_callback_call(EFL_GFX_PATH_CHANGED, NULL),
eo_event_callback_call(EFL_GFX_CHANGED, NULL));
return EINA_TRUE;
}
-Eina_Bool
+static Eina_Bool
_efl_gfx_shape_equal_commands(Eo *obj EINA_UNUSED,
Efl_Gfx_Shape_Data *pd,
const Eo *with)
return _efl_gfx_shape_equal_commands_internal(with_pd, pd);
}
-void
+static void
_efl_gfx_shape_dup(Eo *obj, Efl_Gfx_Shape_Data *pd, Eo *dup_from)
{
const Efl_Gfx_Dash *dash = NULL;
eo_event_callback_call(EFL_GFX_CHANGED, NULL));
}
-void
+static void
_efl_gfx_shape_reset(Eo *obj, Efl_Gfx_Shape_Data *pd)
{
free(pd->commands);
eo_event_callback_call(EFL_GFX_CHANGED, NULL));
}
-void
+static void
_efl_gfx_shape_append_move_to(Eo *obj, Efl_Gfx_Shape_Data *pd,
double x, double y)
{
eo_event_callback_call(EFL_GFX_CHANGED, NULL));
}
-void
+static void
_efl_gfx_shape_append_line_to(Eo *obj, Efl_Gfx_Shape_Data *pd,
double x, double y)
{
eo_event_callback_call(EFL_GFX_CHANGED, NULL));
}
-void
+static void
_efl_gfx_shape_append_cubic_to(Eo *obj, Efl_Gfx_Shape_Data *pd,
double x, double y,
double ctrl_x0, double ctrl_y0,
eo_event_callback_call(EFL_GFX_CHANGED, NULL));
}
-void
+static void
_efl_gfx_shape_append_scubic_to(Eo *obj, Efl_Gfx_Shape_Data *pd,
double x, double y,
double ctrl_x, double ctrl_y)
ctrl_x0, ctrl_y0, ctrl_x, ctrl_y);
}
-void
+static void
_efl_gfx_shape_append_quadratic_to(Eo *obj, Efl_Gfx_Shape_Data *pd,
double x, double y,
double ctrl_x, double ctrl_y)
ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1);
}
-void
+static void
_efl_gfx_shape_append_squadratic_to(Eo *obj, Efl_Gfx_Shape_Data *pd,
double x, double y)
{
/*
* code adapted from enesim which was adapted from moonlight sources
*/
-void
+static void
_efl_gfx_shape_append_arc_to(Eo *obj, Efl_Gfx_Shape_Data *pd,
double x, double y,
double rx, double ry,
}
}
-void
+static void
_efl_gfx_shape_append_close(Eo *obj, Efl_Gfx_Shape_Data *pd)
{
double *offset_point;
eo_event_callback_call(EFL_GFX_CHANGED, NULL));
}
-void
+static void
_efl_gfx_shape_append_circle(Eo *obj, Efl_Gfx_Shape_Data *pd,
- double x, double y, double radius)
+ double xc, double yc, double radius)
{
- _efl_gfx_shape_append_move_to(obj, pd, x - radius, y);
- _efl_gfx_shape_append_arc_to(obj, pd, x + radius, y, radius, radius, 0, EINA_FALSE, EINA_TRUE);
- _efl_gfx_shape_append_arc_to(obj, pd, x, y + radius, radius, radius, 0, EINA_FALSE, EINA_TRUE);
- _efl_gfx_shape_append_arc_to(obj, pd, x - radius, y, radius, radius, 0, EINA_FALSE, EINA_TRUE);
- _efl_gfx_shape_append_arc_to(obj, pd, x, y - radius, radius, radius, 0, EINA_FALSE, EINA_TRUE);
+ _efl_gfx_shape_append_move_to(obj, pd, xc - radius, yc);
+ _efl_gfx_shape_append_arc_to(obj, pd, xc + radius, yc, radius, radius, 0, EINA_TRUE, EINA_TRUE);
+ _efl_gfx_shape_append_arc_to(obj, pd, xc - radius, yc, radius, radius, 0, EINA_TRUE, EINA_TRUE);
}
-void
+static void
_efl_gfx_shape_append_rect(Eo *obj, Efl_Gfx_Shape_Data *pd,
double x, double y, double w, double h,
double rx, double ry)
return EINA_TRUE;
}
-void
+static void
_efl_gfx_shape_append_svg_path(Eo *obj, Efl_Gfx_Shape_Data *pd,
const char *svg_path_data)
{
return ;
break;
case 'z':
+ case 'Z':
_efl_gfx_shape_append_close(obj, pd);
content++;
break;
@in Eo *dup_from; /*@ Shape object from where data will be copied.*/
}
}
+ bounds_get {
+ /*@
+ Compute and return the bounding box of the currently set path
+
+ @since 1.14
+ */
+ params {
+ @out Eina_Rectangle r; /*@ Contain the bounding box of the currently set path */
+ }
+ }
reset {
/*@
Reset the shape data of the shape object.
}
append_move_to {
/*@
- Moves the current point to the given point,
+ Moves the current point to the given point,
implicitly starting a new subpath and closing the previous one.
@see efl_gfx_path_append_close()
append_arc_to {
/*@
Append an arc that connects from the current point int the point list
- to the given point (x,y). The arc is defined by the given radius in
+ to the given point (x,y). The arc is defined by the given radius in
x-direction (rx) and radius in y direction (ry) .
@note Use this api if you know the end point's of the arc otherwise
#include "canvas/efl_vg_gradient.eo.h"
#include "canvas/efl_vg_gradient_linear.eo.h"
#include "canvas/efl_vg_gradient_radial.eo.h"
-#include "canvas/efl_vg_image.eo.h"
* @since 1.14
*/
+#ifdef EFL_BETA_API_SUPPORT
+
/**
* Creates a new vector object on the given Evas @p e canvas.
*
EAPI void evas_vg_gradient_radial_focal_get(Eo *obj, double *x, double *y);
#include "canvas/efl_vg_gradient_radial.eo.legacy.h"
->>>>>>> f359123... ector : integration of ector library in efl1.30.0 branch for tizen2.4
+
+#endif
/**
* @}
} */
}
methods {
- bound_get {
+ bounds_get {
/*@
Give the bounding box in screen coordinate as being drawn.
It will start as the control box until it is refined once the shape
is computed.
@since 1.14
*/
- return: bool @warn_unused;
params {
@out Eina_Rectangle r; /*@ bounding box to be returned */
}
}
- original_bound_get {
- /*@
- Give the bounding box in screen coordinate as defined in
- the file or at the insertion of the object (before any scaling).
- @since 1.14
- */
- return: bool @warn_unused;
- params {
- @out Eina_Rectangle r; /*@ original bounding box to be returned */
- }
- }
}
implements {
Eo.Base.parent.set;
Eo.Base.constructor;
+ Eo.Base.destructor;
Efl.Gfx.Base.visible.set;
Efl.Gfx.Base.visible.get;
Efl.Gfx.Base.color.set;
Efl.Gfx.Stack.stack_above;
Efl.Gfx.Stack.raise;
Efl.Gfx.Stack.lower;
- @virtual .bound_get;
+ @virtual .bounds_get;
}
}
\ No newline at end of file
implements {
Eo.Base.constructor;
Eo.Base.destructor;
- Efl.VG.Base.bound_get;
+ Efl.VG.Base.bounds_get;
}
}
Efl.Gfx.Gradient.Linear.start.get;
Efl.Gfx.Gradient.Linear.end.set;
Efl.Gfx.Gradient.Linear.end.get;
+ Efl.VG.Base.bounds_get;
Eo.Base.constructor;
Eo.Base.destructor;
}
Efl.Gfx.Gradient.Radial.radius.get;
Efl.Gfx.Gradient.Radial.focal.set;
Efl.Gfx.Gradient.Radial.focal.get;
+ Efl.VG.Base.bounds_get;
Eo.Base.constructor;
Eo.Base.destructor;
}
Efl.Gfx.Shape.stroke_join;
Efl.Gfx.Base.color_part.set;
Efl.Gfx.Base.color_part.get;
- Efl.VG.Base.bound_get;
+ Efl.VG.Base.bounds_get;
Eo.Base.constructor;
Eo.Base.destructor;
}
void *engine_data;
Efl_VG *root;
- /* Opening an SVG file (could actually be inside an eet section */
- Eina_File *f;
- const char *key;
-
Eina_Rectangle fill;
unsigned int width, height;
return 0;
}
-
-static Eina_Bool
-_evas_vg_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd,
- const Eina_File *f, const char *key)
-{
- Eina_File *tmp;
-
- if (f == pd->f &&
- ((key == NULL && pd->key == NULL) ||
- (key != NULL && pd->key != NULL && !strcmp(key, pd->key))))
- return EINA_FALSE;
-
- tmp = f ? eina_file_dup(f) : NULL;
-
- if (tmp)
- {
- if (!evas_vg_loader_svg(obj, tmp, NULL))
- {
- eina_file_close(tmp);
- return EINA_FALSE;
- }
- }
-
- // it succeeded.
- if (pd->f) eina_file_close(pd->f);
- pd->f = tmp;
- eina_stringshare_replace(&pd->key, key);
-
- return EINA_TRUE;
-}
-
-static void
-_evas_vg_efl_file_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd,
- const Eina_File **f, const char **key)
-{
- if (f) *f = pd->f;
- if (key) *key = pd->key;
-}
-
-Eina_Bool
-_evas_vg_efl_file_file_set(Eo *obj, Evas_VG_Data *pd EINA_UNUSED,
- const char *file, const char *key)
-{
- Eina_File *f;
- Eina_Bool r = EINA_FALSE;
-
- f = eina_file_open(file, EINA_FALSE);
- if (!f) return EINA_FALSE;
-
- eo_do(obj, efl_file_mmap_set(f, key));
-
- eina_file_close(f);
- return r;
-}
-
-void
-_evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd EINA_UNUSED,
- const char **file, const char **key)
-{
- const Eina_File *f = NULL;
-
- eo_do(obj, efl_file_mmap_get(&f, key));
-
- if (file) *file = eina_file_filename_get(f);
-}
-
void
_evas_vg_efl_gfx_view_size_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd,
int *w, int *h)
-class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill, Efl.Gfx.View)
+class Evas.VG (Evas.Object, Efl.Gfx.Fill, Efl.Gfx.View)
{
legacy_prefix: evas_object_vg;
eo_prefix: evas_obj_vg;
implements {
Eo.Base.constructor;
Eo.Base.destructor;
- Efl.File.file.set;
- Efl.File.file.get;
- Efl.File.mmap.set;
- Efl.File.mmap.get;
Efl.Gfx.Fill.fill.set;
Efl.Gfx.Fill.fill.get;
Efl.Gfx.View.size.set;
eo_do_super(obj, MY_CLASS, eo_destructor());
}
-static Eina_Bool
-_efl_vg_container_efl_vg_base_bound_get(Eo *obj EINA_UNUSED,
+static void
+_efl_vg_container_efl_vg_base_bounds_get(Eo *obj EINA_UNUSED,
Efl_VG_Container_Data *pd,
Eina_Rectangle *r)
{
Eina_List *l;
Eo *child;
- if (!r) return EINA_FALSE;
-
EINA_RECTANGLE_SET(&s, -1, -1, 0, 0);
EINA_LIST_FOREACH(pd->children, l, child)
{
if (first)
{
- eo_do(child, efl_vg_bound_get(r));
+ eo_do(child, efl_vg_bounds_get(r));
first = EINA_FALSE;
}
else
{
- eo_do(child, efl_vg_bound_get(&s));
+ eo_do(child, efl_vg_bounds_get(&s));
eina_rectangle_union(r, &s);
}
}
- // returning EINA_FALSE if no bouding box was found
- return first ? EINA_FALSE : EINA_TRUE;
}
EAPI Efl_VG*
return eo_add(EFL_VG_CONTAINER_CLASS, parent);
}
-
#include "efl_vg_container.eo.c"
nd->data = pd;
}
-void
+static void
_efl_vg_gradient_linear_eo_base_destructor(Eo *obj, Efl_VG_Gradient_Linear_Data *pd EINA_UNUSED)
{
eo_do_super(obj, MY_CLASS, eo_destructor());
}
+static void
+_efl_vg_gradient_linear_efl_vg_base_bounds_get(Eo *obj, Efl_VG_Gradient_Linear_Data *pd, Eina_Rectangle *r)
+{
+ Efl_VG_Base_Data *nd;
+
+ nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS);
+ EINA_RECTANGLE_SET(r,
+ nd->x + pd->start.x, nd->y + pd->start.y,
+ pd->end.x - pd->start.x, pd->end.y - pd->start.x);
+}
+
EAPI void
evas_vg_gradient_linear_start_set(Eo *obj, double x, double y)
{
eo_do_super(obj, MY_CLASS, eo_destructor());
}
+static void
+_efl_vg_gradient_radial_efl_vg_base_bounds_get(Eo *obj, Efl_VG_Gradient_Radial_Data *pd, Eina_Rectangle *r)
+{
+ Efl_VG_Base_Data *nd;
+
+ nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS);
+ EINA_RECTANGLE_SET(r,
+ nd->x + pd->center.x - pd->radius,
+ nd->y + pd->center.y - pd->radius,
+ pd->radius * 2, pd->radius * 2);
+}
+
EAPI void
evas_vg_gradient_radial_center_set(Eo *obj, double x, double y)
{
#include "evas_private.h"
#include "evas_vg_private.h"
+#include "efl_vg_root_node.eo.h"
#include <string.h>
#include <math.h>
return EINA_TRUE;
}
-void
+static void
_efl_vg_base_transformation_set(Eo *obj,
Efl_VG_Base_Data *pd,
const Eina_Matrix3 *m)
return pd->m;
}
-void
+static void
_efl_vg_base_origin_set(Eo *obj,
Efl_VG_Base_Data *pd,
double x, double y)
_efl_vg_base_changed(obj);
}
-void
+static void
_efl_vg_base_origin_get(Eo *obj EINA_UNUSED,
Efl_VG_Base_Data *pd,
double *x, double *y)
if (y) *y = pd->y;
}
-void
+static void
_efl_vg_base_efl_gfx_base_position_set(Eo *obj EINA_UNUSED,
Efl_VG_Base_Data *pd,
int x, int y)
_efl_vg_base_changed(obj);
}
-void
+static void
_efl_vg_base_efl_gfx_base_position_get(Eo *obj EINA_UNUSED,
Efl_VG_Base_Data *pd,
int *x, int *y)
if (y) *y = pd->y;
}
-void
+static void
_efl_vg_base_efl_gfx_base_visible_set(Eo *obj EINA_UNUSED,
Efl_VG_Base_Data *pd, Eina_Bool v)
{
}
-Eina_Bool
+static Eina_Bool
_efl_vg_base_efl_gfx_base_visible_get(Eo *obj EINA_UNUSED,
Efl_VG_Base_Data *pd)
{
return pd->visibility;
}
-void
+static void
_efl_vg_base_efl_gfx_base_color_set(Eo *obj EINA_UNUSED,
Efl_VG_Base_Data *pd,
int r, int g, int b, int a)
_efl_vg_base_changed(obj);
}
-Eina_Bool
+static Eina_Bool
_efl_vg_base_efl_gfx_base_color_part_set(Eo *obj, Efl_VG_Base_Data *pd,
const char *part,
int r, int g, int b, int a)
return EINA_TRUE;
}
-void
+static void
_efl_vg_base_efl_gfx_base_color_get(Eo *obj EINA_UNUSED,
Efl_VG_Base_Data *pd,
int *r, int *g, int *b, int *a)
if (a) *a = pd->a;
}
-Eina_Bool
+static Eina_Bool
_efl_vg_base_efl_gfx_base_color_part_get(Eo *obj, Efl_VG_Base_Data *pd,
const char *part,
int *r, int *g, int *b, int *a)
return EINA_TRUE;
}
-void
+static void
_efl_vg_base_mask_set(Eo *obj EINA_UNUSED,
Efl_VG_Base_Data *pd,
Efl_VG_Base *r)
_efl_vg_base_changed(obj);
}
-Efl_VG_Base*
+static Efl_VG_Base*
_efl_vg_base_mask_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd)
{
return pd->mask;
}
-void
+static void
_efl_vg_base_efl_gfx_base_size_get(Eo *obj,
Efl_VG_Base_Data *pd EINA_UNUSED,
int *w, int *h)
{
- Eina_Rectangle bound = { 0, 0, 0, 0 };
+ Eina_Rectangle r = { 0, 0, 0, 0 };
- eo_do(obj, efl_vg_bound_get(&bound));
- if (w) *w = bound.w;
- if (h) *h = bound.h;
+ eo_do(obj, efl_vg_bounds_get(&r));
+ if (w) *w = r.w;
+ if (h) *h = r.h;
}
// Parent should be a container otherwise dismissing the stacking operation
return EINA_FALSE;
}
-void
+static void
_efl_vg_base_eo_base_constructor(Eo *obj,
Efl_VG_Base_Data *pd)
{
pd->changed = EINA_TRUE;
}
-void
+static void
+_efl_vg_base_eo_base_destructor(Eo *obj, Efl_VG_Base_Data *pd)
+{
+ if (pd->m)
+ {
+ free(pd->m);
+ pd->m = NULL;
+ }
+ eo_do_super(obj, MY_CLASS, eo_destructor());
+}
+
+static void
_efl_vg_base_eo_base_parent_set(Eo *obj,
Efl_VG_Base_Data *pd EINA_UNUSED,
Eo *parent)
return ;
}
-void
+static void
_efl_vg_base_efl_gfx_stack_raise(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED)
{
Efl_VG_Container_Data *cd;
eo_error_set(obj);
}
-void
+static void
_efl_vg_base_efl_gfx_stack_stack_above(Eo *obj,
Efl_VG_Base_Data *pd EINA_UNUSED,
Efl_Gfx_Stack *above)
eo_error_set(obj);
}
-void
+static void
_efl_vg_base_efl_gfx_stack_stack_below(Eo *obj,
Efl_VG_Base_Data *pd EINA_UNUSED,
Efl_Gfx_Stack *below)
eo_error_set(obj);
}
-void
+static void
_efl_vg_base_efl_gfx_stack_lower(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED)
{
Efl_VG_Container_Data *cd;
eo_error_set(obj);
}
-Efl_Gfx_Stack *
-_efl_vg_base_efl_gfx_stack_below_get(Eo *obj, Efl_VG_Base_Data *pd)
+static Eo *
+_efl_vg_base_root_parent_get(Eo *obj)
{
- // FIXME: need to implement bound_get
- return NULL;
+ Eo *parent;
+
+ if (eo_isa(obj, EFL_VG_ROOT_NODE_CLASS))
+ return obj;
+
+ eo_do(obj, parent = eo_parent_get());
+
+ if (!parent) return NULL;
+ return _efl_vg_base_root_parent_get(parent);
}
-Efl_Gfx_Stack *
-_efl_vg_base_efl_gfx_stack_above_get(Eo *obj, Efl_VG_Base_Data *pd)
+static void
+_efl_vg_base_walk_down_at(Eo *root, Eina_Array *a, Eina_Rectangle *r)
{
- // FIXME: need to implement bound_get
- return NULL;
+ Eina_Rectangle bounds;
+
+ eo_do(root, efl_vg_bounds_get(&bounds));
+ if (!eina_rectangles_intersect(&bounds, r)) return ;
+
+ eina_array_push(a, root);
+
+ if (eo_isa(root, EFL_VG_CONTAINER_CLASS))
+ {
+ Efl_VG_Container_Data *cd;
+ Eina_List *l;
+ Eo *child;
+
+ cd = eo_data_scope_get(root, EFL_VG_CONTAINER_CLASS);
+ EINA_LIST_FOREACH(cd->children, l, child)
+ _efl_vg_base_walk_down_at(child, a, r);
+ }
}
-Eina_Bool
-_efl_vg_base_original_bound_get(Eo *obj,
- Efl_VG_Base_Data *pd,
- Eina_Rectangle *r)
+static void
+_efl_vg_base_object_at(Eo *obj, Eina_Array *a, Eina_Rectangle *r)
{
- return EINA_FALSE;
+ Eo *root;
+
+ root = _efl_vg_base_root_parent_get(obj);
+ if (!root) return ;
+
+ _efl_vg_base_walk_down_at(root, a, r);
+}
+
+static Efl_Gfx_Stack *
+_efl_vg_base_efl_gfx_stack_below_get(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED)
+{
+ Eina_Rectangle r;
+ Eina_Array a;
+ Eo *current;
+ Eo *below = NULL;
+ Eina_Array_Iterator iterator;
+ unsigned int i;
+
+ eo_do(obj, efl_vg_bounds_get(&r));
+
+ eina_array_step_set(&a, sizeof (Eina_Array), 8);
+
+ _efl_vg_base_object_at(obj, &a, &r);
+
+ EINA_ARRAY_ITER_NEXT(&a, i, current, iterator)
+ if (current == obj)
+ {
+ i++;
+ if (i < eina_array_count(&a))
+ below = eina_array_data_get(&a, i);
+ break;
+ }
+
+ eina_array_flush(&a);
+
+ return below;
+}
+
+static Efl_Gfx_Stack *
+_efl_vg_base_efl_gfx_stack_above_get(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED)
+{
+ Eina_Rectangle r;
+ Eina_Array a;
+ Eo *current;
+ Eo *above = NULL;
+ Eina_Array_Iterator iterator;
+ unsigned int i;
+
+ eo_do(obj, efl_vg_bounds_get(&r));
+
+ eina_array_step_set(&a, sizeof (Eina_Array), 8);
+
+ _efl_vg_base_object_at(obj, &a, &r);
+
+ EINA_ARRAY_ITER_NEXT(&a, i, current, iterator)
+ if (current == obj)
+ {
+ if (i > 0)
+ above = eina_array_data_get(&a, i - 1);
+ break;
+ }
+
+ eina_array_flush(&a);
+
+ return above;
}
EAPI Eina_Bool
return EINA_TRUE;
}
-void
+static void
_efl_vg_root_node_eo_base_parent_set(Eo *obj,
Efl_VG_Root_Node_Data *pd,
Eo *parent)
}
}
-void
+static void
_efl_vg_root_node_eo_base_constructor(Eo *obj,
Efl_VG_Root_Node_Data *pd)
{
} stroke;
};
-static Eina_Bool
-_efl_vg_shape_efl_vg_base_bound_get(Eo *obj,
- Efl_VG_Shape_Data *pd,
+static void
+_efl_vg_shape_efl_vg_base_bounds_get(Eo *obj,
+ Efl_VG_Shape_Data *pd EINA_UNUSED,
Eina_Rectangle *r)
{
- return EINA_FALSE;
+ // FIXME: Use the renderer bounding box when it has been created instead of an estimation
+ eo_do(obj, efl_gfx_shape_bounds_get(r));
}
static void
unsigned int x = 0;
unsigned int y = 0;
+ // flush the cpu pipeline before ector drawing.
+ evas_common_cpu_end_opt();
+
if (surface)
{
pixels = evas_cache_image_pixels(&surface->cache_entry);
ector_surface_reference_point_set(x, y));
}
- evas_common_cpu_end_opt();
-
eina_mempool_free(_mp_command_ector_surface, ector_surface);
}
NULL, // eng_texture_filter_set
NULL, // eng_texture_filter_get
NULL, // eng_texture_image_set
+ NULL, // eng_output_copy
eng_ector_get,
eng_ector_begin,
eng_ector_renderer_draw,
}
};
-EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_generic);
-
Eina_Bool evas_engine_software_generic_init(void)
{
return evas_module_register(&evas_modapi, EVAS_MODULE_TYPE_ENGINE);
typedef struct _Ector_Cairo_Software_Surface_Data Ector_Cairo_Software_Surface_Data;
struct _Ector_Cairo_Software_Surface_Data
{
+ cairo_surface_t *surface;
+ cairo_t *ctx;
+
+ void *pixels;
+
+ unsigned int width;
+ unsigned int height;
};
void
void
_ector_cairo_software_surface_surface_get(Eo *obj EINA_UNUSED, Ector_Cairo_Software_Surface_Data *pd, void **pixels, unsigned int *width, unsigned int *height)
{
+ if (pixels) *pixels = pd->pixels;
+ if (width) *width = pd->width;
+ if (height) *height = pd->height;
}
#include "ector_cairo_software_surface.eo.c"