ector: removed cairo backend.

For reducing maintainability burden,
We drop supporting cairo backend.

The default backend is to software implementation from now.
It's well maintained so far and works good.x
This commit is contained in:
Hermet Park 2019-09-11 13:12:08 +09:00
parent 3d50083f41
commit dc0056ca93
22 changed files with 24 additions and 1597 deletions

View File

@ -58,9 +58,6 @@ _on_delete(Ecore_Evas *ee EINA_UNUSED)
int
main(void)
{
//Cairo backend is not supported.
putenv("ECTOR_BACKEND=default");
if (!ecore_evas_init())
return EXIT_FAILURE;

View File

@ -52,7 +52,7 @@ extern "C" {
*
* Ector is a retained mode drawing library designed to work
* for and with a scenegraph such as Evas, which supports several
* types of rendering surface including software, cairo, and gl.
* types of rendering surface including software and gl.
*
* @section ector_main_compiling How to compile the library
*

View File

@ -1,55 +0,0 @@
#ifndef ECTOR_CAIRO_H_
# define ECTOR_CAIRO_H_
#include <Ector.h>
#ifdef EAPI
# undef EAPI
#endif
#ifdef _WIN32
# ifdef EFL_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif
# else
# define EAPI __declspec(dllimport)
# endif
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif
#ifdef EFL_BETA_API_SUPPORT
#ifndef _ECTOR_CAIRO_SURFACE_EO_CLASS_TYPE
#define _ECTOR_CAIRO_SURFACE_EO_CLASS_TYPE
typedef Eo Ector_Cairo_Surface;
#endif
typedef struct _cairo_t cairo_t;
#include "cairo/ector_cairo_surface.eo.h"
#include "cairo/ector_cairo_software_surface.eo.h"
#include "cairo/ector_renderer_cairo.eo.h"
#include "cairo/ector_renderer_cairo_shape.eo.h"
#include "cairo/ector_renderer_cairo_gradient_linear.eo.h"
#include "cairo/ector_renderer_cairo_gradient_radial.eo.h"
#endif
#undef EAPI
#define EAPI
#endif

View File

@ -1,95 +0,0 @@
#ifndef ECTOR_CAIRO_PRIVATE_H_
# define ECTOR_CAIRO_PRIVATE_H_
#include "draw.h"
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_Data Ector_Renderer_Cairo_Data;
struct _Ector_Cairo_Surface_Data
{
cairo_t *cairo;
struct {
double x, y;
} current;
};
struct _Ector_Renderer_Cairo_Data
{
Ector_Cairo_Surface_Data *parent;
Ector_Renderer_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) \
if (!Sym) Sym = _ector_cairo_symbol_get(Obj, #Sym); \
if (!Sym) return Error;
static inline void *
_ector_cairo_symbol_get(Ector_Renderer_Data *base,
const char *name)
{
void *sym;
sym = ector_cairo_surface_symbol_get(base->surface, name);
return sym;
}
extern void (*cairo_pattern_add_color_stop_rgba)(cairo_pattern_t *pattern, double offset,
double red, double green, double blue, double alpha);
static inline void
_ector_renderer_cairo_gradient_prepare(cairo_pattern_t *pat,
Ector_Renderer_Gradient_Data *src,
unsigned int mul_col)
{
unsigned int i;
for (i = 0; i < src->colors_count; i++)
{
int r,g,b,a;
r = ((src->colors[i].r * R_VAL(&mul_col)) >> 8);
g = ((src->colors[i].g * G_VAL(&mul_col)) >> 8);
b = ((src->colors[i].b * B_VAL(&mul_col)) >> 8);
a = ((src->colors[i].a * A_VAL(&mul_col)) >> 8);
ector_color_argb_unpremul(a, &r, &g, &b);
cairo_pattern_add_color_stop_rgba(pat, src->colors[i].offset, r/255.0, g/255.0, b/255.0, a/255.0);
}
}
#endif

View File

@ -1,120 +0,0 @@
#ifdef HAVE_CONFIG_H
#include "config.h" /* so that EAPI in Evas.h is correctly defined */
#endif
#include "Ector_Cairo.h"
#include "ector_private.h"
#include <software/Ector_Software.h>
#include "ector_cairo_software_surface.eo.h"
#define MY_CLASS ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS
#define USE(Obj, Sym, Error) \
if (!Sym) Sym = _ector_cairo_symbol_get(Obj, #Sym); \
if (!Sym) return Error;
static inline void *
_ector_cairo_symbol_get(Eo *ector_surface, const char *name)
{
void *sym;
sym = ector_cairo_surface_symbol_get(ector_surface, name);
return sym;
}
typedef struct _cairo_surface_t cairo_surface_t;
typedef enum {
CAIRO_FORMAT_INVALID = -1,
CAIRO_FORMAT_ARGB32 = 0,
CAIRO_FORMAT_RGB24 = 1,
CAIRO_FORMAT_A8 = 2,
CAIRO_FORMAT_A1 = 3,
CAIRO_FORMAT_RGB16_565 = 4,
CAIRO_FORMAT_RGB30 = 5
} cairo_format_t;
static cairo_surface_t *(*cairo_image_surface_create_for_data)(unsigned char *data,
cairo_format_t format,
int width,
int height,
int stride) = NULL;
static void (*cairo_surface_destroy)(cairo_surface_t *surface) = NULL;
static cairo_t *(*cairo_create)(cairo_surface_t *target) = NULL;
static void (*cairo_destroy)(cairo_t *cr) = NULL;
typedef struct _Ector_Cairo_Software_Surface_Data Ector_Cairo_Software_Surface_Data;
struct _Ector_Cairo_Software_Surface_Data
{
cairo_surface_t *surface;
Ector_Software_Buffer_Base_Data *base;
};
EOLIAN static Eina_Bool
_ector_cairo_software_surface_ector_buffer_pixels_set(Eo *obj, Ector_Cairo_Software_Surface_Data *pd,
void *pixels, int width, int height, int stride,
Efl_Gfx_Colorspace cspace, Eina_Bool writable)
{
cairo_t *ctx = NULL;
Eina_Bool ok = EINA_FALSE;
if ((cspace != EFL_GFX_COLORSPACE_ARGB8888) || !writable)
{
ERR("Unsupported surface type!");
return EINA_FALSE;
}
USE(obj, cairo_image_surface_create_for_data, EINA_FALSE);
USE(obj, cairo_surface_destroy, EINA_FALSE);
USE(obj, cairo_create, EINA_FALSE);
USE(obj, cairo_destroy, EINA_FALSE);
if (pd->surface)
cairo_surface_destroy(pd->surface);
pd->surface = NULL;
ok = ector_buffer_pixels_set(efl_super(obj, MY_CLASS), pixels, width, height, stride, cspace, writable);
if (ok && pixels)
{
pd->surface = cairo_image_surface_create_for_data(pixels,
CAIRO_FORMAT_ARGB32,
width, height, pd->base->stride);
if (!pd->surface) goto end;
ctx = cairo_create(pd->surface);
}
end:
/* evas_common_cpu_end_opt(); // do we need this? */
ector_cairo_surface_context_set(obj, ctx);
return ok;
}
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->base->pixels.u8;
if (width) *width = pd->base->generic->w;
if (height) *height = pd->base->generic->h;
}
static Efl_Object *
_ector_cairo_software_surface_efl_object_constructor(Eo *obj, Ector_Cairo_Software_Surface_Data *pd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
if (!obj) return NULL;
pd->base = efl_data_ref(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN);
pd->base->generic = efl_data_ref(obj, ECTOR_BUFFER_MIXIN);
pd->base->generic->eo = obj;
return obj;
}
EOLIAN static void
_ector_cairo_software_surface_efl_object_destructor(Eo *obj, Ector_Cairo_Software_Surface_Data *pd)
{
efl_data_unref(obj, pd->base);
efl_destructor(efl_super(obj, MY_CLASS));
}
#include "ector_cairo_software_surface.eo.c"

View File

@ -1,14 +0,0 @@
class @beta Ector.Cairo.Software.Surface extends Ector.Cairo.Surface implements Ector.Software.Buffer.Base
{
[[Ector surface on a cairo software backend
Used to render ector content into a cairo software backend.
]]
c_prefix: ector_cairo_software_surface;
methods {}
implements {
Ector.Buffer.pixels_set;
Efl.Object.constructor;
Efl.Object.destructor;
}
}

View File

@ -1,146 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Eina.h>
#include <Ector.h>
#include <cairo/Ector_Cairo.h>
#include "ector_private.h"
#include "ector_cairo_private.h"
static unsigned int _cairo_count = 0;
static Eina_Module *_cairo_so = NULL;
static void *
_ector_cairo_surface_symbol_get(Eo *obj EINA_UNUSED,
Ector_Cairo_Surface_Data *pd EINA_UNUSED,
const char *name)
{
if (!_cairo_so)
{
#define LOAD(x) \
if (!_cairo_so) \
{ \
_cairo_so = eina_module_new(x); \
if (_cairo_so && \
!eina_module_load(_cairo_so)) \
{ \
eina_module_free(_cairo_so); \
_cairo_so = NULL; \
} \
}
#if defined(_WIN32) || defined(__CYGWIN__)
LOAD("libcairo-2.dll");
LOAD("libcairo.dll");
#elif defined(__APPLE__) && defined(__MACH__)
LOAD("libcairo.dylib");
LOAD("libcairo.so");
#else
LOAD("libcairo.so");
#endif
#undef LOAD
}
if (!_cairo_so)
{
ERR("Couldn't find cairo library. Please make sure that your system can locate it.");
return NULL;
}
return eina_module_symbol_get(_cairo_so, name);
}
#undef USE
#define USE(Obj, Sym, Error) \
if (!Sym) Sym = _ector_cairo_surface_symbol_get(Obj, NULL, #Sym); \
if (!Sym) return Error;
static Ector_Renderer *
_ector_cairo_surface_ector_surface_renderer_factory_new(Eo *obj,
Ector_Cairo_Surface_Data *pd EINA_UNUSED,
const Efl_Class *type)
{
if (type == ECTOR_RENDERER_SHAPE_MIXIN)
return efl_add_ref(ECTOR_RENDERER_CAIRO_SHAPE_CLASS, NULL, ector_renderer_surface_set(efl_added, obj));
else if (type == ECTOR_RENDERER_GRADIENT_LINEAR_MIXIN)
return efl_add_ref(ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, NULL, ector_renderer_surface_set(efl_added, obj));
else if (type == ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN)
return efl_add_ref(ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, NULL, ector_renderer_surface_set(efl_added, obj));
ERR("Couldn't find class for type: %s\n", efl_class_name_get(type));
return NULL;
}
typedef struct _cairo_surface_t cairo_surface_t;
static void (*cairo_destroy)(cairo_t *cr) = NULL;
static cairo_surface_t *(*cairo_image_surface_create)(int format,
int width,
int height) = NULL;
static cairo_t *(*cairo_create)(cairo_surface_t *target) = NULL;
static cairo_surface_t *internal = NULL;
static void
_ector_cairo_surface_context_set(Eo *obj EINA_UNUSED,
Ector_Cairo_Surface_Data *pd,
cairo_t *ctx)
{
if (pd->cairo) cairo_destroy(pd->cairo);
if (!ctx)
{
if (!internal) internal = cairo_image_surface_create(0, 1, 1);
ctx = cairo_create(internal);
}
pd->current.x = pd->current.y = 0;
pd->cairo = ctx;
}
static cairo_t *
_ector_cairo_surface_context_get(const Eo *obj EINA_UNUSED,
Ector_Cairo_Surface_Data *pd)
{
return pd->cairo;
}
static void
_ector_cairo_surface_ector_surface_reference_point_set(Eo *obj EINA_UNUSED,
Ector_Cairo_Surface_Data *pd,
int x, int y)
{
pd->current.x = x;
pd->current.y = y;
}
static Eo *
_ector_cairo_surface_efl_object_constructor(Eo *obj,
Ector_Cairo_Surface_Data *pd)
{
USE(obj, cairo_destroy, NULL);
USE(obj, cairo_image_surface_create, NULL);
USE(obj, cairo_create, NULL);
obj = efl_constructor(efl_super(obj, ECTOR_CAIRO_SURFACE_CLASS));
if (!obj) return NULL;
_cairo_count++;
_ector_cairo_surface_context_set(obj, pd, NULL);
return obj;
}
static void
_ector_cairo_surface_efl_object_destructor(Eo *obj EINA_UNUSED,
Ector_Cairo_Surface_Data *pd EINA_UNUSED)
{
efl_destructor(efl_super(obj, ECTOR_CAIRO_SURFACE_CLASS));
if (--_cairo_count) return ;
if (_cairo_so) eina_module_free(_cairo_so);
_cairo_so = NULL;
}
#include "ector_cairo_surface.eo.c"

View File

@ -1,35 +0,0 @@
struct @extern cairo_t; [[cairo_t type]]
class @beta Ector.Cairo.Surface extends Efl.Object implements Ector.Surface
{
[[Ector surface on a cairo backend
Used to render ector content into a cairo backend.
]]
c_prefix: ector_cairo_surface;
methods {
@property context {
[[Cairo context]]
set {
}
get {
}
values {
ctx: ptr(cairo_t); [[Cairo context]]
}
}
symbol_get {
[[Lookup symbal name in cairo lib]]
return: void_ptr @no_unused; [[Pointer to cairo lib with this symbol]]
params {
@in name: string; [[Symbol name]]
}
}
}
implements {
Ector.Surface.renderer_factory_new;
Ector.Surface.reference_point { set; }
Efl.Object.destructor;
Efl.Object.constructor;
}
}

View File

@ -1,229 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <math.h>
#include <float.h>
#include <Eina.h>
#include <Ector.h>
#include <cairo/Ector_Cairo.h>
#include "ector_private.h"
#include "ector_cairo_private.h"
typedef enum {
CAIRO_OPERATOR_CLEAR,
CAIRO_OPERATOR_SOURCE,
CAIRO_OPERATOR_OVER,
CAIRO_OPERATOR_IN,
CAIRO_OPERATOR_OUT,
CAIRO_OPERATOR_ATOP,
CAIRO_OPERATOR_DEST,
CAIRO_OPERATOR_DEST_OVER,
CAIRO_OPERATOR_DEST_IN,
CAIRO_OPERATOR_DEST_OUT,
CAIRO_OPERATOR_DEST_ATOP,
CAIRO_OPERATOR_XOR,
CAIRO_OPERATOR_ADD,
CAIRO_OPERATOR_SATURATE,
CAIRO_OPERATOR_MULTIPLY,
CAIRO_OPERATOR_SCREEN,
CAIRO_OPERATOR_OVERLAY,
CAIRO_OPERATOR_DARKEN,
CAIRO_OPERATOR_LIGHTEN,
CAIRO_OPERATOR_COLOR_DODGE,
CAIRO_OPERATOR_COLOR_BURN,
CAIRO_OPERATOR_HARD_LIGHT,
CAIRO_OPERATOR_SOFT_LIGHT,
CAIRO_OPERATOR_DIFFERENCE,
CAIRO_OPERATOR_EXCLUSION,
CAIRO_OPERATOR_HSL_HUE,
CAIRO_OPERATOR_HSL_SATURATION,
CAIRO_OPERATOR_HSL_COLOR,
CAIRO_OPERATOR_HSL_LUMINOSITY
} cairo_operator_t;
static void (*cairo_translate)(cairo_t *cr, double tx, double ty) = NULL;
static void (*cairo_matrix_init)(cairo_matrix_t *matrix,
double xx, double yx,
double xy, double yy,
double x0, double y0) = NULL;
static void (*cairo_transform)(cairo_t *cr, const cairo_matrix_t *matrix) = NULL;
static void (*cairo_set_source_rgba)(cairo_t *cr,
double red, double green, double blue,
double alpha) = NULL;
static void (*cairo_set_operator)(cairo_t *cr, cairo_operator_t op) = NULL;
static void (*cairo_matrix_init_identity)(cairo_matrix_t *matrix) = NULL;
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;
// This routine is shared for all gradient types to use
void (*cairo_pattern_add_color_stop_rgba)(cairo_pattern_t *pattern, double offset,
double red, double green, double blue, double alpha) = NULL;
static cairo_matrix_t identity;
// Cairo needs unpremultiplied color, so force unpremul here
void
_ector_renderer_cairo_ector_renderer_color_set(Eo *obj EINA_UNUSED,
Ector_Renderer_Cairo_Data *pd,
int r, int g, int b, int a)
{
pd->generic->color.r = r;
pd->generic->color.g = g;
pd->generic->color.b = b;
pd->generic->color.a = a;
}
void
_ector_renderer_cairo_ector_renderer_color_get(const Eo *obj EINA_UNUSED,
Ector_Renderer_Cairo_Data *pd,
int *r, int *g, int *b, int *a)
{
if (r) *r = pd->generic->color.r;
if (g) *g = pd->generic->color.g;
if (b) *b = pd->generic->color.b;
if (a) *a = pd->generic->color.a;
}
static Eina_Bool
_ector_renderer_cairo_ector_renderer_prepare(Eo *obj, Ector_Renderer_Cairo_Data *pd)
{
if (!pd->parent)
{
pd->parent = efl_data_xref(pd->generic->surface, ECTOR_CAIRO_SURFACE_CLASS, obj);
}
if (pd->generic->m)
{
if (!pd->m) pd->m = malloc(sizeof (cairo_matrix_t));
cairo_matrix_init(pd->m,
pd->generic->m->xx, pd->generic->m->yx,
pd->generic->m->xy, pd->generic->m->yy,
pd->generic->m->xz, pd->generic->m->yz);
}
else
{
free(pd->m);
pd->m = NULL;
}
return EINA_TRUE;
}
static Eina_Bool
_ector_renderer_cairo_ector_renderer_draw(Eo *obj EINA_UNUSED,
Ector_Renderer_Cairo_Data *pd,
Efl_Gfx_Render_Op op,
Eina_Array *clips EINA_UNUSED,
unsigned int mul_col)
{
int r, g, b, a;
cairo_operator_t cop;
double cx, cy;
switch (op)
{
case EFL_GFX_RENDER_OP_BLEND:
cop = CAIRO_OPERATOR_OVER;
break;
case EFL_GFX_RENDER_OP_COPY:
default:
cop = CAIRO_OPERATOR_SOURCE;
break;
}
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);
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);
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);
if (pd->m) cairo_transform(pd->parent->cairo, pd->m);
else cairo_transform(pd->parent->cairo, &identity);
cairo_set_source_rgba(pd->parent->cairo, r/255.0, g/255.0, b/255.0, a/255.0);
return EINA_TRUE;
}
static Eo *
_ector_renderer_cairo_efl_object_constructor(Eo *obj, Ector_Renderer_Cairo_Data *pd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, ECTOR_RENDERER_CAIRO_CLASS));
if (!obj) return NULL;
pd->generic = efl_data_xref(obj, ECTOR_RENDERER_CLASS, obj);
return obj;
}
static Efl_Object *
_ector_renderer_cairo_efl_object_finalize(Eo *obj, Ector_Renderer_Cairo_Data *pd)
{
obj = efl_finalize(efl_super(obj, ECTOR_RENDERER_CAIRO_CLASS));
if (!obj) return NULL;
USE(pd->generic, cairo_matrix_init, NULL);
USE(pd->generic, cairo_translate, NULL);
USE(pd->generic, cairo_set_source_rgba, NULL);
USE(pd->generic, cairo_transform, NULL);
USE(pd->generic, cairo_set_operator, NULL);
USE(pd->generic, cairo_new_path, NULL);
USE(pd->generic, cairo_rectangle, NULL);
USE(pd->generic, cairo_clip, NULL);
USE(pd->generic, cairo_device_to_user, NULL);
USE(pd->generic, cairo_matrix_init_identity, NULL);
cairo_matrix_init_identity(&identity);
return obj;
}
static void
_ector_renderer_cairo_efl_object_destructor(Eo *obj, Ector_Renderer_Cairo_Data *pd)
{
Ector_Renderer_Data *base;
base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
efl_data_xunref(base->surface, pd->parent, obj);
efl_data_xunref(obj, pd->generic, obj);
free(pd->m);
efl_destructor(efl_super(obj, ECTOR_RENDERER_CAIRO_CLASS));
}
#include "ector_renderer_cairo.eo.c"

View File

@ -1,21 +0,0 @@
abstract @beta Ector.Renderer.Cairo extends Ector.Renderer
{
[[Ector cairo renderer abstract class]]
methods {
op_fill @pure_virtual {
[[Fill operation]]
return: bool; [[$true on success, $false otherwise]]
params {
@in mul_col: uint; [[Premultiplied color]]
}
}
}
implements {
Ector.Renderer.prepare;
Ector.Renderer.draw;
Ector.Renderer.color { get; set; }
Efl.Object.constructor;
Efl.Object.finalize;
Efl.Object.destructor;
}
}

View File

@ -1,197 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Eina.h>
#include <Ector.h>
#include <cairo/Ector_Cairo.h>
#include "ector_private.h"
#include "ector_cairo_private.h"
static cairo_pattern_t *(*cairo_pattern_create_linear)(double x0, double y0,
double x1, double y1) = NULL;
static void (*cairo_set_source)(cairo_t *cr, cairo_pattern_t *source) = NULL;
static void (*cairo_fill)(cairo_t *cr) = NULL;
static void (*cairo_rectangle)(cairo_t *cr,
double x, double y,
double width, double height) = 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
{
Ector_Cairo_Surface_Data *parent;
};
static cairo_pattern_t *
_ector_renderer_cairo_gradient_linear_prepare(Eo *obj EINA_UNUSED,
Ector_Renderer_Gradient_Linear_Data *gld,
Ector_Renderer_Gradient_Data *gd,
unsigned int mul_col)
{
cairo_pattern_t *pat;
pat = cairo_pattern_create_linear(gld->start.x, gld->start.y,
gld->end.x, gld->end.y);
if (!pat) return NULL;
_ector_renderer_cairo_gradient_prepare(pat, gd, mul_col);
cairo_pattern_set_extend(pat, _ector_cairo_extent_get(gd->s));
return pat;
}
static Eina_Bool
_ector_renderer_cairo_gradient_linear_ector_renderer_prepare(Eo *obj,
Ector_Renderer_Cairo_Gradient_Linear_Data *pd)
{
ector_renderer_prepare(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS));
if (!pd->parent)
{
Ector_Renderer_Data *base;
base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
pd->parent = efl_data_xref(base->surface, ECTOR_CAIRO_SURFACE_CLASS, obj);
}
return EINA_FALSE;
}
static Eina_Bool
_ector_renderer_cairo_gradient_linear_ector_renderer_draw(Eo *obj,
Ector_Renderer_Cairo_Gradient_Linear_Data *pd,
Efl_Gfx_Render_Op op, Eina_Array *clips, unsigned int mul_col)
{
Ector_Renderer_Gradient_Linear_Data *gld;
Ector_Renderer_Gradient_Data *gd;
cairo_pattern_t *pat;
// FIXME: don't ignore clipping !
gld = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_LINEAR_MIXIN);
gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN);
if (!gd || !gld) return EINA_FALSE;
pat = _ector_renderer_cairo_gradient_linear_prepare(obj, gld, gd, mul_col);
if (!pat) return EINA_FALSE;
ector_renderer_draw(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS), op, clips, mul_col);
cairo_rectangle(pd->parent->cairo, gld->start.x, gld->start.y,
gld->end.x - gld->start.x,
gld->end.y - gld->start.y);
cairo_set_source(pd->parent->cairo, pat);
cairo_fill(pd->parent->cairo);
cairo_pattern_destroy(pat);
return EINA_TRUE;
}
static Eina_Bool
_ector_renderer_cairo_gradient_linear_ector_renderer_cairo_op_fill(Eo *obj,
Ector_Renderer_Cairo_Gradient_Linear_Data *pd,
unsigned int mul_col)
{
Ector_Renderer_Gradient_Linear_Data *gld;
Ector_Renderer_Gradient_Data *gd;
cairo_pattern_t *pat;
gld = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_LINEAR_MIXIN);
gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN);
if (!gd || !gld) return EINA_FALSE;
pat = _ector_renderer_cairo_gradient_linear_prepare(obj, gld, gd, mul_col);
if (!pat) return EINA_FALSE;
cairo_set_source(pd->parent->cairo, pat);
cairo_pattern_destroy(pat);
return EINA_TRUE;
}
static void
_ector_renderer_cairo_gradient_linear_efl_gfx_path_bounds_get(const Eo *obj,
Ector_Renderer_Cairo_Gradient_Linear_Data *pd EINA_UNUSED,
Eina_Rect *r)
{
Ector_Renderer_Gradient_Linear_Data *gld;
Ector_Renderer_Cairo_Data *bd;
gld = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN);
bd = efl_data_scope_get(obj, ECTOR_RENDERER_CAIRO_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.y);
}
static Efl_Object *
_ector_renderer_cairo_gradient_linear_efl_object_finalize(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd EINA_UNUSED)
{
Ector_Renderer_Data *base;
obj = efl_finalize(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS));
if (!obj) return NULL;
base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
USE(base, cairo_set_source, NULL);
USE(base, cairo_pattern_destroy, NULL);
USE(base, cairo_rectangle, NULL);
USE(base, cairo_fill, NULL);
USE(base, cairo_pattern_destroy, NULL);
USE(base, cairo_set_source, NULL);
USE(base, cairo_pattern_set_extend, NULL);
USE(base, cairo_pattern_create_linear, NULL);
USE(base, cairo_pattern_add_color_stop_rgba, NULL);
return obj;
}
static void
_ector_renderer_cairo_gradient_linear_efl_object_destructor(Eo *obj,
Ector_Renderer_Cairo_Gradient_Linear_Data *pd)
{
Ector_Renderer_Data *base;
base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
efl_data_xunref(base->surface, pd->parent, obj);
efl_destructor(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS));
}
static void
_ector_renderer_cairo_gradient_linear_efl_gfx_gradient_stop_set(Eo *obj,
Ector_Renderer_Cairo_Gradient_Linear_Data *pd EINA_UNUSED,
const Efl_Gfx_Gradient_Stop *colors,
unsigned int length)
{
efl_gfx_gradient_stop_set(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS), colors, length);
}
static unsigned int
_ector_renderer_cairo_gradient_linear_ector_renderer_crc_get(const Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd EINA_UNUSED)
{
Ector_Renderer_Gradient_Linear_Data *gld;
Ector_Renderer_Gradient_Data *gd;
unsigned int crc;
crc = ector_renderer_crc_get(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS));
gld = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_LINEAR_MIXIN);
gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN);
if (!gd || !gld) return crc;
crc = eina_crc((void*) gd->s, sizeof (Efl_Gfx_Gradient_Spread), crc, EINA_FALSE);
if (gd->colors_count)
crc = eina_crc((void*) gd->colors, sizeof (Efl_Gfx_Gradient_Stop) * gd->colors_count, crc, EINA_FALSE);
crc = eina_crc((void*) gld, sizeof (Ector_Renderer_Gradient_Linear_Data), crc, EINA_FALSE);
return crc;
}
#include "ector_renderer_cairo_gradient_linear.eo.c"

View File

@ -1,15 +0,0 @@
class @beta Ector.Renderer.Cairo.Gradient.Linear extends Ector.Renderer.Cairo implements Ector.Renderer.Gradient, Ector.Renderer.Gradient.Linear, Efl.Gfx.Path
{
[[Ector cairo renderer gradient linear]]
c_prefix: ector_renderer_cairo_gradient_linear;
implements {
Ector.Renderer.prepare;
Ector.Renderer.draw;
Efl.Gfx.Path.bounds_get;
Ector.Renderer.crc { get; }
Ector.Renderer.Cairo.op_fill;
Efl.Object.finalize;
Efl.Object.destructor;
Efl.Gfx.Gradient.stop { set; }
}
}

View File

@ -1,220 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <Eina.h>
#include <Ector.h>
#include <cairo/Ector_Cairo.h>
#include "ector_private.h"
#include "ector_cairo_private.h"
static cairo_pattern_t *(*cairo_pattern_create_radial)(double cx0, double cy0,
double radius0,
double cx1, double cy1,
double radius1) = NULL;
static void (*cairo_set_source)(cairo_t *cr, cairo_pattern_t *source) = NULL;
static void (*cairo_fill)(cairo_t *cr) = NULL;
static void (*cairo_arc)(cairo_t *cr,
double xc, double yc,
double radius,
double angle1, double angle2) = 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;
static void (*cairo_pattern_set_matrix)(cairo_t *cr, cairo_matrix_t *matrix) = NULL;
static void (*cairo_matrix_init)(cairo_matrix_t *matrix,
double xx, double yx,
double xy, double yy,
double x0, double y0) = NULL;
// FIXME: as long as it is not possible to directly access the parent structure
// this will be duplicated from the linear gradient renderer
typedef struct _Ector_Renderer_Cairo_Gradient_Radial_Data Ector_Renderer_Cairo_Gradient_Radial_Data;
struct _Ector_Renderer_Cairo_Gradient_Radial_Data
{
Ector_Cairo_Surface_Data *parent;
};
static Eina_Bool
_ector_renderer_cairo_gradient_radial_ector_renderer_prepare(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd)
{
ector_renderer_prepare(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS));
if (!pd->parent)
{
Ector_Renderer_Data *base;
base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
pd->parent = efl_data_xref(base->surface, ECTOR_CAIRO_SURFACE_CLASS, obj);
}
return EINA_FALSE;
}
static cairo_pattern_t *
_ector_renderer_cairo_gradient_radial_prepare(Eo *obj,
Ector_Renderer_Gradient_Radial_Data *grd,
Ector_Renderer_Gradient_Data *gd,
unsigned int mul_col)
{
Ector_Renderer_Data *pd = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
cairo_pattern_t *pat;
cairo_matrix_t pd_m;
pat = cairo_pattern_create_radial(grd->focal.x, grd->focal.y, 0,
grd->radial.x, grd->radial.y, grd->radius);
if (!pat) return NULL;
_ector_renderer_cairo_gradient_prepare(pat, gd, mul_col);
cairo_pattern_set_extend(pat, _ector_cairo_extent_get(gd->s));
if (pd->m)
{
cairo_matrix_init(&pd_m,
pd->m->xx, pd->m->yx,
pd->m->xy, pd->m->yy,
pd->m->xz, pd->m->yz);
cairo_pattern_set_matrix(pat, &pd_m);
}
return pat;
}
// Clearly duplicated and should be in a common place...
static Eina_Bool
_ector_renderer_cairo_gradient_radial_ector_renderer_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Efl_Gfx_Render_Op op, Eina_Array *clips, unsigned int mul_col)
{
Ector_Renderer_Gradient_Radial_Data *grd;
Ector_Renderer_Gradient_Data *gd;
cairo_pattern_t *pat;
// FIXME: Handle clipping and generally make it work :-)
grd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN);
gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN);
if (!grd || !gd) return EINA_FALSE;
pat = _ector_renderer_cairo_gradient_radial_prepare(obj, grd, gd, mul_col);
if (!pat) return EINA_FALSE;
ector_renderer_draw(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS), op, clips, mul_col);
cairo_arc(pd->parent->cairo,
grd->radial.x, grd->radial.y,
grd->radius,
0, 2 * M_PI);
cairo_set_source(pd->parent->cairo, pat);
cairo_fill(pd->parent->cairo);
cairo_pattern_destroy(pat);
return EINA_TRUE;
}
// Clearly duplicated and should be in a common place...
static Eina_Bool
_ector_renderer_cairo_gradient_radial_ector_renderer_cairo_op_fill(Eo *obj,
Ector_Renderer_Cairo_Gradient_Radial_Data *pd,
unsigned int mul_col)
{
Ector_Renderer_Gradient_Radial_Data *grd;
Ector_Renderer_Gradient_Data *gd;
cairo_pattern_t *pat;
grd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN);
gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN);
if (!grd || !gd) return EINA_FALSE;
pat = _ector_renderer_cairo_gradient_radial_prepare(obj, grd, gd, mul_col);
if (!pat) return EINA_FALSE;
cairo_set_source(pd->parent->cairo, pat);
cairo_pattern_destroy(pat);
return EINA_TRUE;
}
static void
_ector_renderer_cairo_gradient_radial_efl_gfx_path_bounds_get(const Eo *obj EINA_UNUSED,
Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED,
Eina_Rect *r)
{
Ector_Renderer_Gradient_Radial_Data *gld;
Ector_Renderer_Cairo_Data *bd;
gld = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN);
bd = efl_data_scope_get(obj, ECTOR_RENDERER_CAIRO_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);
}
static Efl_Object *
_ector_renderer_cairo_gradient_radial_efl_object_finalize(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED)
{
Ector_Renderer_Data *base;
obj = efl_finalize(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS));
if (!obj) return NULL;
base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
USE(base, cairo_set_source, NULL);
USE(base, cairo_pattern_destroy, NULL);
USE(base, cairo_arc, NULL);
USE(base, cairo_fill, NULL);
USE(base, cairo_matrix_init, NULL);
USE(base, cairo_set_source, NULL);
USE(base, cairo_pattern_destroy, NULL);
USE(base, cairo_pattern_set_extend, NULL);
USE(base, cairo_pattern_set_matrix, NULL);
USE(base, cairo_pattern_create_radial, NULL);
USE(base, cairo_pattern_add_color_stop_rgba, NULL);
return obj;
}
static void
_ector_renderer_cairo_gradient_radial_efl_object_destructor(Eo *obj,
Ector_Renderer_Cairo_Gradient_Radial_Data *pd)
{
Ector_Renderer_Data *base;
base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
efl_data_xunref(base->surface, pd->parent, obj);
efl_destructor(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS));
}
static void
_ector_renderer_cairo_gradient_radial_efl_gfx_gradient_stop_set(Eo *obj,
Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED,
const Efl_Gfx_Gradient_Stop *colors,
unsigned int length)
{
efl_gfx_gradient_stop_set(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS), colors, length);
}
static unsigned int
_ector_renderer_cairo_gradient_radial_ector_renderer_crc_get(const Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED)
{
Ector_Renderer_Gradient_Radial_Data *grd;
Ector_Renderer_Gradient_Data *gd;
unsigned int crc;
crc = ector_renderer_crc_get(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS));
grd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN);
gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN);
if (!grd || !gd) return crc;
crc = eina_crc((void*) gd->s, sizeof (Efl_Gfx_Gradient_Spread), crc, EINA_FALSE);
if (gd->colors_count)
crc = eina_crc((void*) gd->colors, sizeof (Efl_Gfx_Gradient_Stop) * gd->colors_count, crc, EINA_FALSE);
crc = eina_crc((void*) grd, sizeof (Ector_Renderer_Gradient_Radial_Data), crc, EINA_FALSE);
return crc;
}
#include "ector_renderer_cairo_gradient_radial.eo.c"

View File

@ -1,15 +0,0 @@
class @beta Ector.Renderer.Cairo.Gradient.Radial extends Ector.Renderer.Cairo implements Ector.Renderer.Gradient, Ector.Renderer.Gradient.Radial, Efl.Gfx.Path
{
[[Ector cairo renderer gradient radial]]
c_prefix: ector_renderer_cairo_gradient_radial;
implements {
Ector.Renderer.prepare;
Ector.Renderer.draw;
Efl.Gfx.Path.bounds_get;
Ector.Renderer.crc { get; }
Ector.Renderer.Cairo.op_fill;
Efl.Object.destructor;
Efl.Object.finalize;
Efl.Gfx.Gradient.stop { set; }
}
}

View File

@ -1,331 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <math.h>
#include <float.h>
#include <Eina.h>
#include <Ector.h>
#include <cairo/Ector_Cairo.h>
#include "ector_private.h"
#include "ector_cairo_private.h"
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;
typedef enum _cairo_fill_rule {
CAIRO_FILL_RULE_WINDING,
CAIRO_FILL_RULE_EVEN_ODD
} cairo_fill_rule_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,
double x1, double y1,
double x2, double y2,
double x3, double y3) = NULL;
static void (*cairo_close_path)(cairo_t *cr) = NULL;
static void (*cairo_fill)(cairo_t *cr) = NULL;
static void (*cairo_fill_preserve)(cairo_t *cr) = NULL;
static void (*cairo_stroke)(cairo_t *cr) = NULL;
static void (*cairo_set_source_rgba)(cairo_t *cr,
double red, double green,
double blue, double alpha) = NULL;
static cairo_path_t *(*cairo_copy_path)(cairo_t *cr) = NULL;
static void (*cairo_path_destroy)(cairo_path_t *path) = NULL;
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;
static void (*cairo_set_fill_rule) (cairo_t *cr, cairo_fill_rule_t fill_rule);
typedef struct _Ector_Renderer_Cairo_Shape_Data Ector_Renderer_Cairo_Shape_Data;
struct _Ector_Renderer_Cairo_Shape_Data
{
Efl_Gfx_Shape_Public *public_shape;
Ector_Cairo_Surface_Data *parent;
Ector_Renderer_Shape_Data *shape;
Ector_Renderer_Data *base;
cairo_path_t *path;
};
EOLIAN static void
_ector_renderer_cairo_shape_efl_gfx_path_commit(Eo *obj EINA_UNUSED,
Ector_Renderer_Cairo_Shape_Data *pd)
{
if (pd->path)
{
cairo_path_destroy(pd->path);
pd->path = NULL;
}
}
static Eina_Bool
_ector_renderer_cairo_shape_ector_renderer_prepare(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd)
{
const Efl_Gfx_Path_Command *cmds = NULL;
const double *pts = NULL;
ector_renderer_prepare(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS));
// shouldn't this be moved to the cairo base object?
if (!pd->parent)
{
Ector_Renderer_Data *base;
base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
pd->parent = efl_data_xref(base->surface, ECTOR_CAIRO_SURFACE_CLASS, obj);
}
efl_gfx_path_get(obj, &cmds, &pts);
if (!pd->path && cmds)
{
cairo_new_path(pd->parent->cairo);
for (; *cmds != EFL_GFX_PATH_COMMAND_TYPE_END; cmds++)
{
switch (*cmds)
{
case EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO:
cairo_move_to(pd->parent->cairo, pts[0], pts[1]);
pts += 2;
break;
case EFL_GFX_PATH_COMMAND_TYPE_LINE_TO:
cairo_line_to(pd->parent->cairo, pts[0], pts[1]);
pts += 2;
break;
case EFL_GFX_PATH_COMMAND_TYPE_CUBIC_TO:
cairo_curve_to(pd->parent->cairo,
pts[0], pts[1], pts[2], pts[3], // control points
pts[4], pts[5]); // destination point
pts += 6;
break;
case EFL_GFX_PATH_COMMAND_TYPE_CLOSE:
cairo_close_path(pd->parent->cairo);
break;
case EFL_GFX_PATH_COMMAND_TYPE_LAST:
case EFL_GFX_PATH_COMMAND_TYPE_END:
break;
}
}
pd->path = cairo_copy_path(pd->parent->cairo);
}
return EINA_TRUE;
}
static Eina_Bool
_ector_renderer_cairo_shape_ector_renderer_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Efl_Gfx_Render_Op op, Eina_Array *clips, unsigned int mul_col)
{
int r, g, b, a;
unsigned i;
Efl_Gfx_Fill_Rule fill_rule;
if (pd->path == NULL) return EINA_FALSE;
cairo_save(pd->parent->cairo);
ector_renderer_draw(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS), op, clips, mul_col);
cairo_new_path(pd->parent->cairo);
cairo_append_path(pd->parent->cairo, pd->path);
fill_rule = efl_gfx_shape_fill_rule_get(obj);
if (fill_rule == EFL_GFX_FILL_RULE_ODD_EVEN)
cairo_set_fill_rule(pd->parent->cairo, CAIRO_FILL_RULE_EVEN_ODD);
else
cairo_set_fill_rule(pd->parent->cairo, CAIRO_FILL_RULE_WINDING);
if (pd->shape->fill)
ector_renderer_cairo_op_fill(pd->shape->fill, mul_col);
if (pd->shape->stroke.fill || pd->public_shape->stroke.color.a > 0)
{
cairo_fill_preserve(pd->parent->cairo);
if (pd->shape->stroke.fill)
ector_renderer_cairo_op_fill(pd->shape->stroke.fill, mul_col);
else
{
r = (((pd->public_shape->stroke.color.r * R_VAL(&mul_col)) + 0xff) >> 8);
g = (((pd->public_shape->stroke.color.g * G_VAL(&mul_col)) + 0xff) >> 8);
b = (((pd->public_shape->stroke.color.b * B_VAL(&mul_col)) + 0xff) >> 8);
a = (((pd->public_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->public_shape->stroke.dash)
{
double *dashinfo;
dashinfo = (double *) malloc(2 * pd->public_shape->stroke.dash_length * sizeof(double));
for (i = 0; i < pd->public_shape->stroke.dash_length; i++)
{
dashinfo[i*2] = pd->public_shape->stroke.dash[i].length;
dashinfo[i*2 + 1] = pd->public_shape->stroke.dash[i].gap;
}
cairo_set_dash(pd->parent->cairo, dashinfo, pd->public_shape->stroke.dash_length * 2, 0);
free(dashinfo);
}
}
// Set dash, cap and join
cairo_set_line_width(pd->parent->cairo, (pd->public_shape->stroke.width * pd->public_shape->stroke.scale));
cairo_set_line_cap(pd->parent->cairo, (cairo_line_cap_t) pd->public_shape->stroke.cap);
cairo_set_line_join(pd->parent->cairo, (cairo_line_join_t) pd->public_shape->stroke.join);
cairo_stroke(pd->parent->cairo);
}
else
{
cairo_fill(pd->parent->cairo);
}
cairo_restore(pd->parent->cairo);
return EINA_TRUE;
}
static Eina_Bool
_ector_renderer_cairo_shape_ector_renderer_cairo_op_fill(Eo *obj EINA_UNUSED,
Ector_Renderer_Cairo_Shape_Data *pd EINA_UNUSED,
unsigned int mul_col EINA_UNUSED)
{
// FIXME: let's find out how to fill a shape with a shape later.
// I need to read SVG specification and see how to map that with cairo.
ERR("fill with shape not implemented\n");
return EINA_FALSE;
}
static void
_ector_renderer_cairo_shape_efl_gfx_path_bounds_get(const Eo *obj,
Ector_Renderer_Cairo_Shape_Data *pd EINA_UNUSED,
Eina_Rect *r)
{
Ector_Renderer_Cairo_Data *bd;
// FIXME: It should be possible to ask cairo about this
efl_gfx_path_bounds_get(obj, r);
bd = efl_data_scope_get(obj, ECTOR_RENDERER_CAIRO_CLASS);
r->x += bd->generic->origin.x;
r->y += bd->generic->origin.y;
}
Eo *
_ector_renderer_cairo_shape_efl_object_constructor(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd)
{
obj = efl_constructor(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS));
if (!obj) return NULL;
pd->public_shape = efl_data_xref(obj, EFL_GFX_SHAPE_MIXIN, obj);
pd->shape = efl_data_xref(obj, ECTOR_RENDERER_SHAPE_MIXIN, obj);
pd->base = efl_data_xref(obj, ECTOR_RENDERER_CLASS, obj);
return obj;
}
static Efl_Object *
_ector_renderer_cairo_shape_efl_object_finalize(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd)
{
obj = efl_finalize(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS));
if (!obj) return NULL;
USE(pd->base, cairo_path_destroy, NULL);
USE(pd->base, cairo_restore, NULL);
USE(pd->base, cairo_fill, NULL);
USE(pd->base, cairo_set_dash, NULL);
USE(pd->base, cairo_fill_preserve, NULL);
USE(pd->base, cairo_set_source_rgba, NULL);
USE(pd->base, cairo_stroke, NULL);
USE(pd->base, cairo_set_line_width, NULL);
USE(pd->base, cairo_set_line_cap, NULL);
USE(pd->base, cairo_set_line_join, NULL);
USE(pd->base, cairo_new_path, NULL);
USE(pd->base, cairo_append_path, NULL);
USE(pd->base, cairo_save, NULL);
USE(pd->base, cairo_copy_path, NULL);
USE(pd->base, cairo_close_path, NULL);
USE(pd->base, cairo_curve_to, NULL);
USE(pd->base, cairo_line_to, NULL);
USE(pd->base, cairo_move_to, NULL);
USE(pd->base, cairo_set_fill_rule, NULL);
return obj;
}
void
_ector_renderer_cairo_shape_efl_object_destructor(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd)
{
Ector_Renderer_Data *base;
// FIXME: As base class destructor can't call destructor of mixin class.
// Call explicit API to free shape data.
efl_gfx_path_reset(obj);
base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS);
efl_data_xunref(base->surface, pd->parent, obj);
efl_data_xunref(obj, pd->shape, obj);
efl_data_xunref(obj, pd->base, obj);
efl_destructor(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS));
if (pd->path) cairo_path_destroy(pd->path);
}
unsigned int
_ector_renderer_cairo_shape_ector_renderer_crc_get(const Eo *obj,
Ector_Renderer_Cairo_Shape_Data *pd)
{
unsigned int crc;
crc = ector_renderer_crc_get(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS));
crc = eina_crc((void*) &pd->shape->stroke.marker, sizeof (pd->shape->stroke.marker), crc, EINA_FALSE);
crc = eina_crc((void*) &pd->public_shape->stroke.scale, sizeof (pd->public_shape->stroke.scale) * 3, crc, EINA_FALSE); // scale, width, centered
crc = eina_crc((void*) &pd->public_shape->stroke.color, sizeof (pd->public_shape->stroke.color), crc, EINA_FALSE);
crc = eina_crc((void*) &pd->public_shape->stroke.cap, sizeof (pd->public_shape->stroke.cap), crc, EINA_FALSE);
crc = eina_crc((void*) &pd->public_shape->stroke.join, sizeof (pd->public_shape->stroke.join), crc, EINA_FALSE);
if (pd->shape->fill) crc = _renderer_crc_get(pd->shape->fill, crc);
if (pd->shape->stroke.fill) crc = _renderer_crc_get(pd->shape->stroke.fill, crc);
if (pd->shape->stroke.marker) crc = _renderer_crc_get(pd->shape->stroke.marker, crc);
if (pd->public_shape->stroke.dash_length)
{
crc = eina_crc((void*) pd->public_shape->stroke.dash, sizeof (Efl_Gfx_Dash) * pd->public_shape->stroke.dash_length, crc, EINA_FALSE);
}
return crc;
}
#include "ector_renderer_cairo_shape.eo.c"

View File

@ -1,16 +0,0 @@
class @beta Ector.Renderer.Cairo.Shape extends Ector.Renderer.Cairo implements Ector.Renderer.Shape, Efl.Gfx.Path
{
[[Ector cairo renderer shape class]]
c_prefix: ector_renderer_cairo_shape;
implements {
Ector.Renderer.prepare;
Ector.Renderer.draw;
Efl.Gfx.Path.bounds_get;
Efl.Gfx.Path.commit;
Ector.Renderer.crc { get; }
Ector.Renderer.Cairo.op_fill;
Efl.Object.constructor;
Efl.Object.finalize;
Efl.Object.destructor;
}
}

View File

@ -1,39 +0,0 @@
ector_src += files([
'ector_renderer_cairo_gradient_linear.c',
'ector_renderer_cairo_gradient_radial.c',
'ector_renderer_cairo_shape.c',
'ector_renderer_cairo.c',
'ector_cairo_software_surface.c',
'ector_cairo_surface.c'
])
pub_eo_files = [
'ector_cairo_surface.eo',
'ector_cairo_software_surface.eo',
'ector_renderer_cairo.eo',
'ector_renderer_cairo_shape.eo',
'ector_renderer_cairo_gradient_linear.eo',
'ector_renderer_cairo_gradient_radial.eo'
]
foreach eo_file : pub_eo_files
pub_eo_file_target += custom_target('eolian_gen_' + eo_file,
input : eo_file,
output : [eo_file + '.h'],
depfile : eo_file + '.d',
install : false,
install_dir : dir_package_include,
command : eolian_gen + [ '-I', meson.current_source_dir(), eolian_include_directories,
'-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'),
'-o', 'c:' + join_paths(meson.current_build_dir(), eo_file + '.c'),
'-o', 'd:' + join_paths(meson.current_build_dir(), eo_file + '.d'),
'-gchd', '@INPUT@'])
endforeach
if get_option('install-eo-files')
install_data(pub_eo_files,
install_dir: join_paths(eolian_include_dir, package_version_name)
)
endif

View File

@ -34,8 +34,6 @@
#ifndef _ECTOR_GL_SURFACE_EO_CLASS_TYPE
#define _ECTOR_GL_SURFACE_EO_CLASS_TYPE
typedef Eo Ector_Cairo_Surface;
#endif
typedef unsigned int GLuint;

View File

@ -50,7 +50,6 @@ endforeach
eolian_include_directories += ['-I', meson.current_source_dir()]
subdir('cairo')
subdir('gl')
pub_eo_types_files = [

View File

@ -45,7 +45,7 @@ _pixels_gry8_to_argb_convert(uint32_t *dst, const uint8_t *src, int len)
}
EOLIAN static void
_ector_software_buffer_base_pixels_clear(Eo *obj, Ector_Software_Buffer_Base_Data *pd)
_ector_software_buffer_base_pixels_clear(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd)
{
if (!pd->pixels.u8) return;

View File

@ -2,7 +2,6 @@
#include "evas_gl_core_private.h"
#include "software/Ector_Software.h"
#include "cairo/Ector_Cairo.h"
#include "gl/Ector_GL.h"
#include "evas_ector_gl.h"
#include "filters/gl_engine_filter.h"
@ -2534,7 +2533,6 @@ eng_texture_image_get(void *engine EINA_UNUSED, void *texture)
return e3d_texture_get((E3D_Texture *)texture);
}
static Eina_Bool use_cairo = EINA_FALSE;
static Eina_Bool use_gl = EINA_FALSE;
static Ector_Surface *
@ -2544,20 +2542,14 @@ eng_ector_create(void *engine EINA_UNUSED)
const char *ector_backend;
ector_backend = getenv("ECTOR_BACKEND");
efl_domain_current_push(EFL_ID_DOMAIN_SHARED);
if (ector_backend && !strcasecmp(ector_backend, "default"))
{
ector = efl_add_ref(ECTOR_SOFTWARE_SURFACE_CLASS, NULL);
}
else if (ector_backend && !strcasecmp(ector_backend, "experimental"))
if (ector_backend && !strcasecmp(ector_backend, "gl"))
{
ector = efl_add_ref(ECTOR_GL_SURFACE_CLASS, NULL);
use_gl = EINA_TRUE;
}
else
{
ector = efl_add_ref(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL);
use_cairo = EINA_TRUE;
}
ector = efl_add_ref(ECTOR_SOFTWARE_SURFACE_CLASS, NULL);
efl_domain_current_pop();
return ector;
}
@ -2639,7 +2631,11 @@ eng_ector_renderer_draw(void *engine EINA_UNUSED, void *surface,
void *context EINA_UNUSED, Ector_Renderer *renderer,
Eina_Array *clips EINA_UNUSED, Eina_Bool do_async EINA_UNUSED)
{
if (use_cairo || !use_gl)
if (use_gl)
{
//FIXME no implementation yet
}
else
{
int w, h;
Eina_Rectangle *r;
@ -2654,10 +2650,7 @@ eng_ector_renderer_draw(void *engine EINA_UNUSED, void *surface,
while ((r = eina_array_pop(c)))
eina_rectangle_free(r);
eina_array_free(c);
}
else
{
//FIXME no implementation yet
}
}
@ -2724,7 +2717,11 @@ eng_ector_begin(void *engine, void *surface,
void *context EINA_UNUSED, Ector_Surface *ector,
int x, int y, Eina_Bool clear, Eina_Bool do_async EINA_UNUSED)
{
if (use_cairo|| !use_gl)
if (use_gl)
{
//FIXME: No implementation yet
}
else
{
int w, h, stride;
Evas_GL_Image *glim = surface;
@ -2740,10 +2737,7 @@ eng_ector_begin(void *engine, void *surface,
// it just uses the software backend to draw for now
ector_buffer_pixels_set(ector, pixels, w, h, stride, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE);
ector_surface_reference_point_set(ector, x, y);
}
else
{
//FIXME: No implementation yet
}
}
@ -2754,7 +2748,11 @@ eng_ector_end(void *engine,
Ector_Surface *ector,
Eina_Bool do_async EINA_UNUSED)
{
if (use_cairo || !use_gl)
if (use_gl)
{
//FIXME: No implementation yet
}
else
{
Evas_GL_Image *glim = surface;
DATA32 *pixels;
@ -2766,10 +2764,7 @@ eng_ector_end(void *engine,
eng_image_data_put(engine, glim, pixels);
ector_buffer_pixels_set(ector, NULL, 0, 0, 0, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE);
evas_common_cpu_end_opt();
}
else if (use_gl)
{
//FIXME: No implementation yet
}
}

View File

@ -5,7 +5,6 @@
#include "region.h"
#include <software/Ector_Software.h>
#include "cairo/Ector_Cairo.h"
#include "evas_ector_software.h"
#include "draw.h"
#include "evas_filter_private.h"
@ -4193,26 +4192,13 @@ eng_output_idle_flush(void *engine EINA_UNUSED, void *data)
// Ector functions
static Eina_Bool use_cairo;
static Ector_Surface *
eng_ector_create(void *engine EINA_UNUSED)
{
Ector_Surface *ector;
const char *ector_backend;
ector_backend = getenv("ECTOR_BACKEND");
efl_domain_current_push(EFL_ID_DOMAIN_SHARED);
if (ector_backend && !strcasecmp(ector_backend, "default"))
{
ector = efl_add_ref(ECTOR_SOFTWARE_SURFACE_CLASS, NULL);
use_cairo = EINA_FALSE;
}
else
{
ector = efl_add_ref(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL);
use_cairo = EINA_TRUE;
}
ector = efl_add_ref(ECTOR_SOFTWARE_SURFACE_CLASS, NULL);
efl_domain_current_pop();
return ector;
}