diff options
Diffstat (limited to '')
19 files changed, 2 insertions, 1553 deletions
diff --git a/src/lib/ector/Ector.h b/src/lib/ector/Ector.h index 01a71d6e6e..961a42c150 100644 --- a/src/lib/ector/Ector.h +++ b/src/lib/ector/Ector.h | |||
@@ -52,7 +52,7 @@ extern "C" { | |||
52 | * | 52 | * |
53 | * Ector is a retained mode drawing library designed to work | 53 | * Ector is a retained mode drawing library designed to work |
54 | * for and with a scenegraph such as Evas, which supports several | 54 | * for and with a scenegraph such as Evas, which supports several |
55 | * types of rendering surface including software, cairo, and gl. | 55 | * types of rendering surface including software and gl. |
56 | * | 56 | * |
57 | * @section ector_main_compiling How to compile the library | 57 | * @section ector_main_compiling How to compile the library |
58 | * | 58 | * |
diff --git a/src/lib/ector/cairo/Ector_Cairo.h b/src/lib/ector/cairo/Ector_Cairo.h deleted file mode 100644 index 99eeafac9a..0000000000 --- a/src/lib/ector/cairo/Ector_Cairo.h +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | #ifndef ECTOR_CAIRO_H_ | ||
2 | # define ECTOR_CAIRO_H_ | ||
3 | |||
4 | #include <Ector.h> | ||
5 | |||
6 | #ifdef EAPI | ||
7 | # undef EAPI | ||
8 | #endif | ||
9 | |||
10 | #ifdef _WIN32 | ||
11 | # ifdef EFL_BUILD | ||
12 | # ifdef DLL_EXPORT | ||
13 | # define EAPI __declspec(dllexport) | ||
14 | # else | ||
15 | # define EAPI | ||
16 | # endif | ||
17 | # else | ||
18 | # define EAPI __declspec(dllimport) | ||
19 | # endif | ||
20 | #else | ||
21 | # ifdef __GNUC__ | ||
22 | # if __GNUC__ >= 4 | ||
23 | # define EAPI __attribute__ ((visibility("default"))) | ||
24 | # else | ||
25 | # define EAPI | ||
26 | # endif | ||
27 | # else | ||
28 | # define EAPI | ||
29 | # endif | ||
30 | #endif | ||
31 | |||
32 | #ifdef EFL_BETA_API_SUPPORT | ||
33 | |||
34 | #ifndef _ECTOR_CAIRO_SURFACE_EO_CLASS_TYPE | ||
35 | #define _ECTOR_CAIRO_SURFACE_EO_CLASS_TYPE | ||
36 | |||
37 | typedef Eo Ector_Cairo_Surface; | ||
38 | |||
39 | #endif | ||
40 | |||
41 | typedef struct _cairo_t cairo_t; | ||
42 | |||
43 | #include "cairo/ector_cairo_surface.eo.h" | ||
44 | #include "cairo/ector_cairo_software_surface.eo.h" | ||
45 | #include "cairo/ector_renderer_cairo.eo.h" | ||
46 | #include "cairo/ector_renderer_cairo_shape.eo.h" | ||
47 | #include "cairo/ector_renderer_cairo_gradient_linear.eo.h" | ||
48 | #include "cairo/ector_renderer_cairo_gradient_radial.eo.h" | ||
49 | |||
50 | #endif | ||
51 | |||
52 | #undef EAPI | ||
53 | #define EAPI | ||
54 | |||
55 | #endif | ||
diff --git a/src/lib/ector/cairo/ector_cairo_private.h b/src/lib/ector/cairo/ector_cairo_private.h deleted file mode 100644 index a7a6d7661f..0000000000 --- a/src/lib/ector/cairo/ector_cairo_private.h +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
1 | #ifndef ECTOR_CAIRO_PRIVATE_H_ | ||
2 | # define ECTOR_CAIRO_PRIVATE_H_ | ||
3 | |||
4 | #include "draw.h" | ||
5 | |||
6 | typedef void cairo_pattern_t; | ||
7 | |||
8 | typedef struct { | ||
9 | double xx; double yx; | ||
10 | double xy; double yy; | ||
11 | double x0; double y0; | ||
12 | } cairo_matrix_t; | ||
13 | |||
14 | typedef struct _Ector_Cairo_Surface_Data Ector_Cairo_Surface_Data; | ||
15 | typedef struct _Ector_Renderer_Cairo_Data Ector_Renderer_Cairo_Data; | ||
16 | |||
17 | struct _Ector_Cairo_Surface_Data | ||
18 | { | ||
19 | cairo_t *cairo; | ||
20 | struct { | ||
21 | double x, y; | ||
22 | } current; | ||
23 | }; | ||
24 | |||
25 | struct _Ector_Renderer_Cairo_Data | ||
26 | { | ||
27 | Ector_Cairo_Surface_Data *parent; | ||
28 | Ector_Renderer_Data *generic; | ||
29 | |||
30 | cairo_matrix_t *m; | ||
31 | }; | ||
32 | |||
33 | typedef enum _cairo_extend { | ||
34 | CAIRO_EXTEND_NONE, | ||
35 | CAIRO_EXTEND_REPEAT, | ||
36 | CAIRO_EXTEND_REFLECT, | ||
37 | CAIRO_EXTEND_PAD | ||
38 | } cairo_extend_t; | ||
39 | |||
40 | static inline cairo_extend_t | ||
41 | _ector_cairo_extent_get(Efl_Gfx_Gradient_Spread s) | ||
42 | { | ||
43 | switch (s) | ||
44 | { | ||
45 | case EFL_GFX_GRADIENT_SPREAD_PAD: | ||
46 | return CAIRO_EXTEND_PAD; | ||
47 | case EFL_GFX_GRADIENT_SPREAD_REFLECT: | ||
48 | return CAIRO_EXTEND_REFLECT; | ||
49 | case EFL_GFX_GRADIENT_SPREAD_REPEAT: | ||
50 | return CAIRO_EXTEND_REPEAT; | ||
51 | default: | ||
52 | return CAIRO_EXTEND_NONE; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | #define CHECK_CAIRO(Parent) (!(Parent && Parent->cairo)) | ||
57 | |||
58 | #define USE(Obj, Sym, Error) \ | ||
59 | if (!Sym) Sym = _ector_cairo_symbol_get(Obj, #Sym); \ | ||
60 | if (!Sym) return Error; | ||
61 | |||
62 | static inline void * | ||
63 | _ector_cairo_symbol_get(Ector_Renderer_Data *base, | ||
64 | const char *name) | ||
65 | { | ||
66 | void *sym; | ||
67 | |||
68 | sym = ector_cairo_surface_symbol_get(base->surface, name); | ||
69 | return sym; | ||
70 | } | ||
71 | |||
72 | extern void (*cairo_pattern_add_color_stop_rgba)(cairo_pattern_t *pattern, double offset, | ||
73 | double red, double green, double blue, double alpha); | ||
74 | |||
75 | static inline void | ||
76 | _ector_renderer_cairo_gradient_prepare(cairo_pattern_t *pat, | ||
77 | Ector_Renderer_Gradient_Data *src, | ||
78 | unsigned int mul_col) | ||
79 | { | ||
80 | unsigned int i; | ||
81 | |||
82 | for (i = 0; i < src->colors_count; i++) | ||
83 | { | ||
84 | int r,g,b,a; | ||
85 | |||
86 | r = ((src->colors[i].r * R_VAL(&mul_col)) >> 8); | ||
87 | g = ((src->colors[i].g * G_VAL(&mul_col)) >> 8); | ||
88 | b = ((src->colors[i].b * B_VAL(&mul_col)) >> 8); | ||
89 | a = ((src->colors[i].a * A_VAL(&mul_col)) >> 8); | ||
90 | ector_color_argb_unpremul(a, &r, &g, &b); | ||
91 | cairo_pattern_add_color_stop_rgba(pat, src->colors[i].offset, r/255.0, g/255.0, b/255.0, a/255.0); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | #endif | ||
diff --git a/src/lib/ector/cairo/ector_cairo_software_surface.c b/src/lib/ector/cairo/ector_cairo_software_surface.c deleted file mode 100644 index 96bf1c1081..0000000000 --- a/src/lib/ector/cairo/ector_cairo_software_surface.c +++ /dev/null | |||
@@ -1,120 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | #include "config.h" /* so that EAPI in Evas.h is correctly defined */ | ||
3 | #endif | ||
4 | |||
5 | #include "Ector_Cairo.h" | ||
6 | #include "ector_private.h" | ||
7 | #include <software/Ector_Software.h> | ||
8 | #include "ector_cairo_software_surface.eo.h" | ||
9 | |||
10 | #define MY_CLASS ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS | ||
11 | |||
12 | #define USE(Obj, Sym, Error) \ | ||
13 | if (!Sym) Sym = _ector_cairo_symbol_get(Obj, #Sym); \ | ||
14 | if (!Sym) return Error; | ||
15 | |||
16 | static inline void * | ||
17 | _ector_cairo_symbol_get(Eo *ector_surface, const char *name) | ||
18 | { | ||
19 | void *sym; | ||
20 | |||
21 | sym = ector_cairo_surface_symbol_get(ector_surface, name); | ||
22 | return sym; | ||
23 | } | ||
24 | |||
25 | typedef struct _cairo_surface_t cairo_surface_t; | ||
26 | typedef enum { | ||
27 | CAIRO_FORMAT_INVALID = -1, | ||
28 | CAIRO_FORMAT_ARGB32 = 0, | ||
29 | CAIRO_FORMAT_RGB24 = 1, | ||
30 | CAIRO_FORMAT_A8 = 2, | ||
31 | CAIRO_FORMAT_A1 = 3, | ||
32 | CAIRO_FORMAT_RGB16_565 = 4, | ||
33 | CAIRO_FORMAT_RGB30 = 5 | ||
34 | } cairo_format_t; | ||
35 | |||
36 | static cairo_surface_t *(*cairo_image_surface_create_for_data)(unsigned char *data, | ||
37 | cairo_format_t format, | ||
38 | int width, | ||
39 | int height, | ||
40 | int stride) = NULL; | ||
41 | static void (*cairo_surface_destroy)(cairo_surface_t *surface) = NULL; | ||
42 | static cairo_t *(*cairo_create)(cairo_surface_t *target) = NULL; | ||
43 | static void (*cairo_destroy)(cairo_t *cr) = NULL; | ||
44 | |||
45 | typedef struct _Ector_Cairo_Software_Surface_Data Ector_Cairo_Software_Surface_Data; | ||
46 | struct _Ector_Cairo_Software_Surface_Data | ||
47 | { | ||
48 | cairo_surface_t *surface; | ||
49 | Ector_Software_Buffer_Base_Data *base; | ||
50 | }; | ||
51 | |||
52 | EOLIAN static Eina_Bool | ||
53 | _ector_cairo_software_surface_ector_buffer_pixels_set(Eo *obj, Ector_Cairo_Software_Surface_Data *pd, | ||
54 | void *pixels, int width, int height, int stride, | ||
55 | Efl_Gfx_Colorspace cspace, Eina_Bool writable) | ||
56 | { | ||
57 | cairo_t *ctx = NULL; | ||
58 | Eina_Bool ok = EINA_FALSE; | ||
59 | |||
60 | if ((cspace != EFL_GFX_COLORSPACE_ARGB8888) || !writable) | ||
61 | { | ||
62 | ERR("Unsupported surface type!"); | ||
63 | return EINA_FALSE; | ||
64 | } | ||
65 | |||
66 | USE(obj, cairo_image_surface_create_for_data, EINA_FALSE); | ||
67 | USE(obj, cairo_surface_destroy, EINA_FALSE); | ||
68 | USE(obj, cairo_create, EINA_FALSE); | ||
69 | USE(obj, cairo_destroy, EINA_FALSE); | ||
70 | |||
71 | if (pd->surface) | ||
72 | cairo_surface_destroy(pd->surface); | ||
73 | pd->surface = NULL; | ||
74 | |||
75 | ok = ector_buffer_pixels_set(efl_super(obj, MY_CLASS), pixels, width, height, stride, cspace, writable); | ||
76 | |||
77 | if (ok && pixels) | ||
78 | { | ||
79 | pd->surface = cairo_image_surface_create_for_data(pixels, | ||
80 | CAIRO_FORMAT_ARGB32, | ||
81 | width, height, pd->base->stride); | ||
82 | if (!pd->surface) goto end; | ||
83 | |||
84 | ctx = cairo_create(pd->surface); | ||
85 | } | ||
86 | |||
87 | end: | ||
88 | /* evas_common_cpu_end_opt(); // do we need this? */ | ||
89 | ector_cairo_surface_context_set(obj, ctx); | ||
90 | return ok; | ||
91 | } | ||
92 | |||
93 | void | ||
94 | _ector_cairo_software_surface_surface_get(Eo *obj EINA_UNUSED, Ector_Cairo_Software_Surface_Data *pd, void **pixels, unsigned int *width, unsigned int *height) | ||
95 | { | ||
96 | if (pixels) *pixels = pd->base->pixels.u8; | ||
97 | if (width) *width = pd->base->generic->w; | ||
98 | if (height) *height = pd->base->generic->h; | ||
99 | } | ||
100 | |||
101 | static Efl_Object * | ||
102 | _ector_cairo_software_surface_efl_object_constructor(Eo *obj, Ector_Cairo_Software_Surface_Data *pd) | ||
103 | { | ||
104 | obj = efl_constructor(efl_super(obj, MY_CLASS)); | ||
105 | |||
106 | if (!obj) return NULL; | ||
107 | pd->base = efl_data_ref(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN); | ||
108 | pd->base->generic = efl_data_ref(obj, ECTOR_BUFFER_MIXIN); | ||
109 | pd->base->generic->eo = obj; | ||
110 | return obj; | ||
111 | } | ||
112 | |||
113 | EOLIAN static void | ||
114 | _ector_cairo_software_surface_efl_object_destructor(Eo *obj, Ector_Cairo_Software_Surface_Data *pd) | ||
115 | { | ||
116 | efl_data_unref(obj, pd->base); | ||
117 | efl_destructor(efl_super(obj, MY_CLASS)); | ||
118 | } | ||
119 | |||
120 | #include "ector_cairo_software_surface.eo.c" | ||
diff --git a/src/lib/ector/cairo/ector_cairo_software_surface.eo b/src/lib/ector/cairo/ector_cairo_software_surface.eo deleted file mode 100644 index 9cd23e5cf5..0000000000 --- a/src/lib/ector/cairo/ector_cairo_software_surface.eo +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | class @beta Ector.Cairo.Software.Surface extends Ector.Cairo.Surface implements Ector.Software.Buffer.Base | ||
2 | { | ||
3 | [[Ector surface on a cairo software backend | ||
4 | |||
5 | Used to render ector content into a cairo software backend. | ||
6 | ]] | ||
7 | c_prefix: ector_cairo_software_surface; | ||
8 | methods {} | ||
9 | implements { | ||
10 | Ector.Buffer.pixels_set; | ||
11 | Efl.Object.constructor; | ||
12 | Efl.Object.destructor; | ||
13 | } | ||
14 | } | ||
diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c deleted file mode 100644 index 28d904499e..0000000000 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ /dev/null | |||
@@ -1,146 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "config.h" | ||
3 | #endif | ||
4 | |||
5 | #include <Eina.h> | ||
6 | #include <Ector.h> | ||
7 | #include <cairo/Ector_Cairo.h> | ||
8 | |||
9 | #include "ector_private.h" | ||
10 | #include "ector_cairo_private.h" | ||
11 | |||
12 | static unsigned int _cairo_count = 0; | ||
13 | static Eina_Module *_cairo_so = NULL; | ||
14 | |||
15 | static void * | ||
16 | _ector_cairo_surface_symbol_get(Eo *obj EINA_UNUSED, | ||
17 | Ector_Cairo_Surface_Data *pd EINA_UNUSED, | ||
18 | const char *name) | ||
19 | { | ||
20 | if (!_cairo_so) | ||
21 | { | ||
22 | #define LOAD(x) \ | ||
23 | if (!_cairo_so) \ | ||
24 | { \ | ||
25 | _cairo_so = eina_module_new(x); \ | ||
26 | if (_cairo_so && \ | ||
27 | !eina_module_load(_cairo_so)) \ | ||
28 | { \ | ||
29 | eina_module_free(_cairo_so); \ | ||
30 | _cairo_so = NULL; \ | ||
31 | } \ | ||
32 | } | ||
33 | #if defined(_WIN32) || defined(__CYGWIN__) | ||
34 | LOAD("libcairo-2.dll"); | ||
35 | LOAD("libcairo.dll"); | ||
36 | #elif defined(__APPLE__) && defined(__MACH__) | ||
37 | LOAD("libcairo.dylib"); | ||
38 | LOAD("libcairo.so"); | ||
39 | #else | ||
40 | LOAD("libcairo.so"); | ||
41 | #endif | ||
42 | |||
43 | #undef LOAD | ||
44 | } | ||
45 | |||
46 | if (!_cairo_so) | ||
47 | { | ||
48 | ERR("Couldn't find cairo library. Please make sure that your system can locate it."); | ||
49 | return NULL; | ||
50 | } | ||
51 | |||
52 | return eina_module_symbol_get(_cairo_so, name); | ||
53 | } | ||
54 | |||
55 | #undef USE | ||
56 | #define USE(Obj, Sym, Error) \ | ||
57 | if (!Sym) Sym = _ector_cairo_surface_symbol_get(Obj, NULL, #Sym); \ | ||
58 | if (!Sym) return Error; | ||
59 | |||
60 | static Ector_Renderer * | ||
61 | _ector_cairo_surface_ector_surface_renderer_factory_new(Eo *obj, | ||
62 | Ector_Cairo_Surface_Data *pd EINA_UNUSED, | ||
63 | const Efl_Class *type) | ||
64 | { | ||
65 | if (type == ECTOR_RENDERER_SHAPE_MIXIN) | ||
66 | return efl_add_ref(ECTOR_RENDERER_CAIRO_SHAPE_CLASS, NULL, ector_renderer_surface_set(efl_added, obj)); | ||
67 | else if (type == ECTOR_RENDERER_GRADIENT_LINEAR_MIXIN) | ||
68 | return efl_add_ref(ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, NULL, ector_renderer_surface_set(efl_added, obj)); | ||
69 | else if (type == ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN) | ||
70 | return efl_add_ref(ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, NULL, ector_renderer_surface_set(efl_added, obj)); | ||
71 | |||
72 | ERR("Couldn't find class for type: %s\n", efl_class_name_get(type)); | ||
73 | return NULL; | ||
74 | } | ||
75 | |||
76 | typedef struct _cairo_surface_t cairo_surface_t; | ||
77 | |||
78 | static void (*cairo_destroy)(cairo_t *cr) = NULL; | ||
79 | static cairo_surface_t *(*cairo_image_surface_create)(int format, | ||
80 | int width, | ||
81 | int height) = NULL; | ||
82 | static cairo_t *(*cairo_create)(cairo_surface_t *target) = NULL; | ||
83 | |||
84 | static cairo_surface_t *internal = NULL; | ||
85 | |||
86 | static void | ||
87 | _ector_cairo_surface_context_set(Eo *obj EINA_UNUSED, | ||
88 | Ector_Cairo_Surface_Data *pd, | ||
89 | cairo_t *ctx) | ||
90 | { | ||
91 | if (pd->cairo) cairo_destroy(pd->cairo); | ||
92 | if (!ctx) | ||
93 | { | ||
94 | if (!internal) internal = cairo_image_surface_create(0, 1, 1); | ||
95 | ctx = cairo_create(internal); | ||
96 | } | ||
97 | pd->current.x = pd->current.y = 0; | ||
98 | pd->cairo = ctx; | ||
99 | } | ||
100 | |||
101 | static cairo_t * | ||
102 | _ector_cairo_surface_context_get(const Eo *obj EINA_UNUSED, | ||
103 | Ector_Cairo_Surface_Data *pd) | ||
104 | { | ||
105 | return pd->cairo; | ||
106 | } | ||
107 | |||
108 | static void | ||
109 | _ector_cairo_surface_ector_surface_reference_point_set(Eo *obj EINA_UNUSED, | ||
110 | Ector_Cairo_Surface_Data *pd, | ||
111 | int x, int y) | ||
112 | { | ||
113 | pd->current.x = x; | ||
114 | pd->current.y = y; | ||
115 | } | ||
116 | |||
117 | static Eo * | ||
118 | _ector_cairo_surface_efl_object_constructor(Eo *obj, | ||
119 | Ector_Cairo_Surface_Data *pd) | ||
120 | { | ||
121 | USE(obj, cairo_destroy, NULL); | ||
122 | USE(obj, cairo_image_surface_create, NULL); | ||
123 | USE(obj, cairo_create, NULL); | ||
124 | |||
125 | obj = efl_constructor(efl_super(obj, ECTOR_CAIRO_SURFACE_CLASS)); | ||
126 | if (!obj) return NULL; | ||
127 | |||
128 | _cairo_count++; | ||
129 | |||
130 | _ector_cairo_surface_context_set(obj, pd, NULL); | ||
131 | |||
132 | return obj; | ||
133 | } | ||
134 | |||
135 | static void | ||
136 | _ector_cairo_surface_efl_object_destructor(Eo *obj EINA_UNUSED, | ||
137 | Ector_Cairo_Surface_Data *pd EINA_UNUSED) | ||
138 | { | ||
139 | efl_destructor(efl_super(obj, ECTOR_CAIRO_SURFACE_CLASS)); | ||
140 | |||
141 | if (--_cairo_count) return ; | ||
142 | if (_cairo_so) eina_module_free(_cairo_so); | ||
143 | _cairo_so = NULL; | ||
144 | } | ||
145 | |||
146 | #include "ector_cairo_surface.eo.c" | ||
diff --git a/src/lib/ector/cairo/ector_cairo_surface.eo b/src/lib/ector/cairo/ector_cairo_surface.eo deleted file mode 100644 index dabd214147..0000000000 --- a/src/lib/ector/cairo/ector_cairo_surface.eo +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | struct @extern cairo_t; [[cairo_t type]] | ||
2 | |||
3 | class @beta Ector.Cairo.Surface extends Efl.Object implements Ector.Surface | ||
4 | { | ||
5 | [[Ector surface on a cairo backend | ||
6 | |||
7 | Used to render ector content into a cairo backend. | ||
8 | ]] | ||
9 | c_prefix: ector_cairo_surface; | ||
10 | methods { | ||
11 | @property context { | ||
12 | [[Cairo context]] | ||
13 | set { | ||
14 | } | ||
15 | get { | ||
16 | } | ||
17 | values { | ||
18 | ctx: ptr(cairo_t); [[Cairo context]] | ||
19 | } | ||
20 | } | ||
21 | symbol_get { | ||
22 | [[Lookup symbal name in cairo lib]] | ||
23 | return: void_ptr @no_unused; [[Pointer to cairo lib with this symbol]] | ||
24 | params { | ||
25 | @in name: string; [[Symbol name]] | ||
26 | } | ||
27 | } | ||
28 | } | ||
29 | implements { | ||
30 | Ector.Surface.renderer_factory_new; | ||
31 | Ector.Surface.reference_point { set; } | ||
32 | Efl.Object.destructor; | ||
33 | Efl.Object.constructor; | ||
34 | } | ||
35 | } | ||
diff --git a/src/lib/ector/cairo/ector_renderer_cairo.c b/src/lib/ector/cairo/ector_renderer_cairo.c deleted file mode 100644 index ddcca419d8..0000000000 --- a/src/lib/ector/cairo/ector_renderer_cairo.c +++ /dev/null | |||
@@ -1,229 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "config.h" | ||
3 | #endif | ||
4 | |||
5 | #include <math.h> | ||
6 | #include <float.h> | ||
7 | |||
8 | #include <Eina.h> | ||
9 | #include <Ector.h> | ||
10 | #include <cairo/Ector_Cairo.h> | ||
11 | |||
12 | #include "ector_private.h" | ||
13 | #include "ector_cairo_private.h" | ||
14 | |||
15 | typedef enum { | ||
16 | CAIRO_OPERATOR_CLEAR, | ||
17 | |||
18 | CAIRO_OPERATOR_SOURCE, | ||
19 | CAIRO_OPERATOR_OVER, | ||
20 | CAIRO_OPERATOR_IN, | ||
21 | CAIRO_OPERATOR_OUT, | ||
22 | CAIRO_OPERATOR_ATOP, | ||
23 | |||
24 | CAIRO_OPERATOR_DEST, | ||
25 | CAIRO_OPERATOR_DEST_OVER, | ||
26 | CAIRO_OPERATOR_DEST_IN, | ||
27 | CAIRO_OPERATOR_DEST_OUT, | ||
28 | CAIRO_OPERATOR_DEST_ATOP, | ||
29 | |||
30 | CAIRO_OPERATOR_XOR, | ||
31 | CAIRO_OPERATOR_ADD, | ||
32 | CAIRO_OPERATOR_SATURATE, | ||
33 | |||
34 | CAIRO_OPERATOR_MULTIPLY, | ||
35 | CAIRO_OPERATOR_SCREEN, | ||
36 | CAIRO_OPERATOR_OVERLAY, | ||
37 | CAIRO_OPERATOR_DARKEN, | ||
38 | CAIRO_OPERATOR_LIGHTEN, | ||
39 | CAIRO_OPERATOR_COLOR_DODGE, | ||
40 | CAIRO_OPERATOR_COLOR_BURN, | ||
41 | CAIRO_OPERATOR_HARD_LIGHT, | ||
42 | CAIRO_OPERATOR_SOFT_LIGHT, | ||
43 | CAIRO_OPERATOR_DIFFERENCE, | ||
44 | CAIRO_OPERATOR_EXCLUSION, | ||
45 | CAIRO_OPERATOR_HSL_HUE, | ||
46 | CAIRO_OPERATOR_HSL_SATURATION, | ||
47 | CAIRO_OPERATOR_HSL_COLOR, | ||
48 | CAIRO_OPERATOR_HSL_LUMINOSITY | ||
49 | } cairo_operator_t; | ||
50 | |||
51 | static void (*cairo_translate)(cairo_t *cr, double tx, double ty) = NULL; | ||
52 | static void (*cairo_matrix_init)(cairo_matrix_t *matrix, | ||
53 | double xx, double yx, | ||
54 | double xy, double yy, | ||
55 | double x0, double y0) = NULL; | ||
56 | static void (*cairo_transform)(cairo_t *cr, const cairo_matrix_t *matrix) = NULL; | ||
57 | static void (*cairo_set_source_rgba)(cairo_t *cr, | ||
58 | double red, double green, double blue, | ||
59 | double alpha) = NULL; | ||
60 | static void (*cairo_set_operator)(cairo_t *cr, cairo_operator_t op) = NULL; | ||
61 | static void (*cairo_matrix_init_identity)(cairo_matrix_t *matrix) = NULL; | ||
62 | |||
63 | static void (*cairo_new_path)(cairo_t *cr) = NULL; | ||
64 | static void (*cairo_rectangle)(cairo_t *cr, double x, double y, double width, double height) = NULL; | ||
65 | static void (*cairo_clip)(cairo_t *cr) = NULL; | ||
66 | static void (*cairo_device_to_user)(cairo_t *cr, double *x, double *y) = NULL; | ||
67 | |||
68 | // This routine is shared for all gradient types to use | ||
69 | void (*cairo_pattern_add_color_stop_rgba)(cairo_pattern_t *pattern, double offset, | ||
70 | double red, double green, double blue, double alpha) = NULL; | ||
71 | |||
72 | static cairo_matrix_t identity; | ||
73 | |||
74 | // Cairo needs unpremultiplied color, so force unpremul here | ||
75 | void | ||
76 | _ector_renderer_cairo_ector_renderer_color_set(Eo *obj EINA_UNUSED, | ||
77 | Ector_Renderer_Cairo_Data *pd, | ||
78 | int r, int g, int b, int a) | ||
79 | { | ||
80 | pd->generic->color.r = r; | ||
81 | pd->generic->color.g = g; | ||
82 | pd->generic->color.b = b; | ||
83 | pd->generic->color.a = a; | ||
84 | } | ||
85 | |||
86 | void | ||
87 | _ector_renderer_cairo_ector_renderer_color_get(const Eo *obj EINA_UNUSED, | ||
88 | Ector_Renderer_Cairo_Data *pd, | ||
89 | int *r, int *g, int *b, int *a) | ||
90 | { | ||
91 | if (r) *r = pd->generic->color.r; | ||
92 | if (g) *g = pd->generic->color.g; | ||
93 | if (b) *b = pd->generic->color.b; | ||
94 | if (a) *a = pd->generic->color.a; | ||
95 | } | ||
96 | |||
97 | static Eina_Bool | ||
98 | _ector_renderer_cairo_ector_renderer_prepare(Eo *obj, Ector_Renderer_Cairo_Data *pd) | ||
99 | { | ||
100 | if (!pd->parent) | ||
101 | { | ||
102 | pd->parent = efl_data_xref(pd->generic->surface, ECTOR_CAIRO_SURFACE_CLASS, obj); | ||
103 | } | ||
104 | if (pd->generic->m) | ||
105 | { | ||
106 | if (!pd->m) pd->m = malloc(sizeof (cairo_matrix_t)); | ||
107 | cairo_matrix_init(pd->m, | ||
108 | pd->generic->m->xx, pd->generic->m->yx, | ||
109 | pd->generic->m->xy, pd->generic->m->yy, | ||
110 | pd->generic->m->xz, pd->generic->m->yz); | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | free(pd->m); | ||
115 | pd->m = NULL; | ||
116 | } | ||
117 | |||
118 | return EINA_TRUE; | ||
119 | } | ||
120 | |||
121 | static Eina_Bool | ||
122 | _ector_renderer_cairo_ector_renderer_draw(Eo *obj EINA_UNUSED, | ||
123 | Ector_Renderer_Cairo_Data *pd, | ||
124 | Efl_Gfx_Render_Op op, | ||
125 | Eina_Array *clips EINA_UNUSED, | ||
126 | unsigned int mul_col) | ||
127 | { | ||
128 | int r, g, b, a; | ||
129 | cairo_operator_t cop; | ||
130 | double cx, cy; | ||
131 | |||
132 | switch (op) | ||
133 | { | ||
134 | case EFL_GFX_RENDER_OP_BLEND: | ||
135 | cop = CAIRO_OPERATOR_OVER; | ||
136 | break; | ||
137 | case EFL_GFX_RENDER_OP_COPY: | ||
138 | default: | ||
139 | cop = CAIRO_OPERATOR_SOURCE; | ||
140 | break; | ||
141 | } | ||
142 | |||
143 | r = ((pd->generic->color.r * R_VAL(&mul_col)) >> 8); | ||
144 | g = ((pd->generic->color.g * G_VAL(&mul_col)) >> 8); | ||
145 | b = ((pd->generic->color.b * B_VAL(&mul_col)) >> 8); | ||
146 | a = ((pd->generic->color.a * A_VAL(&mul_col)) >> 8); | ||
147 | ector_color_argb_unpremul(a, &r, &g, &b); | ||
148 | |||
149 | cairo_set_operator(pd->parent->cairo, cop); | ||
150 | |||
151 | if (clips) | ||
152 | { | ||
153 | int clip_count = eina_array_count(clips); | ||
154 | int i=0; | ||
155 | for (; i < clip_count ; i++) | ||
156 | { | ||
157 | Eina_Rectangle *clip = (Eina_Rectangle *)eina_array_data_get(clips, i); | ||
158 | double x = (double)clip->x; | ||
159 | double y = (double)clip->y; | ||
160 | |||
161 | cairo_new_path(pd->parent->cairo); | ||
162 | cairo_device_to_user(pd->parent->cairo, &x, &y); | ||
163 | cairo_rectangle(pd->parent->cairo, x, y, clip->w, clip->h); | ||
164 | } | ||
165 | cairo_clip(pd->parent->cairo); | ||
166 | } | ||
167 | |||
168 | cairo_transform(pd->parent->cairo, &identity); | ||
169 | cx = pd->generic->origin.x + pd->parent->current.x; | ||
170 | cy = pd->generic->origin.y + pd->parent->current.y; | ||
171 | |||
172 | cairo_translate(pd->parent->cairo, cx, cy); | ||
173 | |||
174 | if (pd->m) cairo_transform(pd->parent->cairo, pd->m); | ||
175 | else cairo_transform(pd->parent->cairo, &identity); | ||
176 | |||
177 | cairo_set_source_rgba(pd->parent->cairo, r/255.0, g/255.0, b/255.0, a/255.0); | ||
178 | |||
179 | return EINA_TRUE; | ||
180 | } | ||
181 | |||
182 | static Eo * | ||
183 | _ector_renderer_cairo_efl_object_constructor(Eo *obj, Ector_Renderer_Cairo_Data *pd EINA_UNUSED) | ||
184 | { | ||
185 | obj = efl_constructor(efl_super(obj, ECTOR_RENDERER_CAIRO_CLASS)); | ||
186 | if (!obj) return NULL; | ||
187 | |||
188 | pd->generic = efl_data_xref(obj, ECTOR_RENDERER_CLASS, obj); | ||
189 | |||
190 | return obj; | ||
191 | } | ||
192 | |||
193 | static Efl_Object * | ||
194 | _ector_renderer_cairo_efl_object_finalize(Eo *obj, Ector_Renderer_Cairo_Data *pd) | ||
195 | { | ||
196 | obj = efl_finalize(efl_super(obj, ECTOR_RENDERER_CAIRO_CLASS)); | ||
197 | if (!obj) return NULL; | ||
198 | |||
199 | USE(pd->generic, cairo_matrix_init, NULL); | ||
200 | USE(pd->generic, cairo_translate, NULL); | ||
201 | USE(pd->generic, cairo_set_source_rgba, NULL); | ||
202 | USE(pd->generic, cairo_transform, NULL); | ||
203 | USE(pd->generic, cairo_set_operator, NULL); | ||
204 | USE(pd->generic, cairo_new_path, NULL); | ||
205 | USE(pd->generic, cairo_rectangle, NULL); | ||
206 | USE(pd->generic, cairo_clip, NULL); | ||
207 | USE(pd->generic, cairo_device_to_user, NULL); | ||
208 | USE(pd->generic, cairo_matrix_init_identity, NULL); | ||
209 | |||
210 | cairo_matrix_init_identity(&identity); | ||
211 | |||
212 | return obj; | ||
213 | } | ||
214 | |||
215 | static void | ||
216 | _ector_renderer_cairo_efl_object_destructor(Eo *obj, Ector_Renderer_Cairo_Data *pd) | ||
217 | { | ||
218 | Ector_Renderer_Data *base; | ||
219 | |||
220 | base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS); | ||
221 | efl_data_xunref(base->surface, pd->parent, obj); | ||
222 | efl_data_xunref(obj, pd->generic, obj); | ||
223 | |||
224 | free(pd->m); | ||
225 | |||
226 | efl_destructor(efl_super(obj, ECTOR_RENDERER_CAIRO_CLASS)); | ||
227 | } | ||
228 | |||
229 | #include "ector_renderer_cairo.eo.c" | ||
diff --git a/src/lib/ector/cairo/ector_renderer_cairo.eo b/src/lib/ector/cairo/ector_renderer_cairo.eo deleted file mode 100644 index 3f100b1ef1..0000000000 --- a/src/lib/ector/cairo/ector_renderer_cairo.eo +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | abstract @beta Ector.Renderer.Cairo extends Ector.Renderer | ||
2 | { | ||
3 | [[Ector cairo renderer abstract class]] | ||
4 | methods { | ||
5 | op_fill @pure_virtual { | ||
6 | [[Fill operation]] | ||
7 | return: bool; [[$true on success, $false otherwise]] | ||
8 | params { | ||
9 | @in mul_col: uint; [[Premultiplied color]] | ||
10 | } | ||
11 | } | ||
12 | } | ||
13 | implements { | ||
14 | Ector.Renderer.prepare; | ||
15 | Ector.Renderer.draw; | ||
16 | Ector.Renderer.color { get; set; } | ||
17 | Efl.Object.constructor; | ||
18 | Efl.Object.finalize; | ||
19 | Efl.Object.destructor; | ||
20 | } | ||
21 | } | ||
diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c deleted file mode 100644 index 598e625a8c..0000000000 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ /dev/null | |||
@@ -1,197 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "config.h" | ||
3 | #endif | ||
4 | |||
5 | #include <Eina.h> | ||
6 | #include <Ector.h> | ||
7 | #include <cairo/Ector_Cairo.h> | ||
8 | |||
9 | #include "ector_private.h" | ||
10 | #include "ector_cairo_private.h" | ||
11 | |||
12 | static cairo_pattern_t *(*cairo_pattern_create_linear)(double x0, double y0, | ||
13 | double x1, double y1) = NULL; | ||
14 | static void (*cairo_set_source)(cairo_t *cr, cairo_pattern_t *source) = NULL; | ||
15 | static void (*cairo_fill)(cairo_t *cr) = NULL; | ||
16 | static void (*cairo_rectangle)(cairo_t *cr, | ||
17 | double x, double y, | ||
18 | double width, double height) = NULL; | ||
19 | static void (*cairo_pattern_destroy)(cairo_pattern_t *pattern) = NULL; | ||
20 | |||
21 | static void (*cairo_pattern_set_extend)(cairo_pattern_t *pattern, cairo_extend_t extend) = NULL; | ||
22 | |||
23 | typedef struct _Ector_Renderer_Cairo_Gradient_Linear_Data Ector_Renderer_Cairo_Gradient_Linear_Data; | ||
24 | struct _Ector_Renderer_Cairo_Gradient_Linear_Data | ||
25 | { | ||
26 | Ector_Cairo_Surface_Data *parent; | ||
27 | }; | ||
28 | |||
29 | static cairo_pattern_t * | ||
30 | _ector_renderer_cairo_gradient_linear_prepare(Eo *obj EINA_UNUSED, | ||
31 | Ector_Renderer_Gradient_Linear_Data *gld, | ||
32 | Ector_Renderer_Gradient_Data *gd, | ||
33 | unsigned int mul_col) | ||
34 | { | ||
35 | cairo_pattern_t *pat; | ||
36 | |||
37 | pat = cairo_pattern_create_linear(gld->start.x, gld->start.y, | ||
38 | gld->end.x, gld->end.y); | ||
39 | if (!pat) return NULL; | ||
40 | _ector_renderer_cairo_gradient_prepare(pat, gd, mul_col); | ||
41 | |||
42 | cairo_pattern_set_extend(pat, _ector_cairo_extent_get(gd->s)); | ||
43 | |||
44 | return pat; | ||
45 | } | ||
46 | |||
47 | static Eina_Bool | ||
48 | _ector_renderer_cairo_gradient_linear_ector_renderer_prepare(Eo *obj, | ||
49 | Ector_Renderer_Cairo_Gradient_Linear_Data *pd) | ||
50 | { | ||
51 | ector_renderer_prepare(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS)); | ||
52 | |||
53 | if (!pd->parent) | ||
54 | { | ||
55 | Ector_Renderer_Data *base; | ||
56 | |||
57 | base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS); | ||
58 | pd->parent = efl_data_xref(base->surface, ECTOR_CAIRO_SURFACE_CLASS, obj); | ||
59 | } | ||
60 | |||
61 | return EINA_FALSE; | ||
62 | } | ||
63 | |||
64 | static Eina_Bool | ||
65 | _ector_renderer_cairo_gradient_linear_ector_renderer_draw(Eo *obj, | ||
66 | Ector_Renderer_Cairo_Gradient_Linear_Data *pd, | ||
67 | Efl_Gfx_Render_Op op, Eina_Array *clips, unsigned int mul_col) | ||
68 | { | ||
69 | Ector_Renderer_Gradient_Linear_Data *gld; | ||
70 | Ector_Renderer_Gradient_Data *gd; | ||
71 | cairo_pattern_t *pat; | ||
72 | |||
73 | // FIXME: don't ignore clipping ! | ||
74 | gld = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_LINEAR_MIXIN); | ||
75 | gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN); | ||
76 | if (!gd || !gld) return EINA_FALSE; | ||
77 | |||
78 | pat = _ector_renderer_cairo_gradient_linear_prepare(obj, gld, gd, mul_col); | ||
79 | if (!pat) return EINA_FALSE; | ||
80 | |||
81 | ector_renderer_draw(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS), op, clips, mul_col); | ||
82 | |||
83 | cairo_rectangle(pd->parent->cairo, gld->start.x, gld->start.y, | ||
84 | gld->end.x - gld->start.x, | ||
85 | gld->end.y - gld->start.y); | ||
86 | cairo_set_source(pd->parent->cairo, pat); | ||
87 | cairo_fill(pd->parent->cairo); | ||
88 | cairo_pattern_destroy(pat); | ||
89 | |||
90 | return EINA_TRUE; | ||
91 | } | ||
92 | |||
93 | static Eina_Bool | ||
94 | _ector_renderer_cairo_gradient_linear_ector_renderer_cairo_op_fill(Eo *obj, | ||
95 | Ector_Renderer_Cairo_Gradient_Linear_Data *pd, | ||
96 | unsigned int mul_col) | ||
97 | { | ||
98 | Ector_Renderer_Gradient_Linear_Data *gld; | ||
99 | Ector_Renderer_Gradient_Data *gd; | ||
100 | cairo_pattern_t *pat; | ||
101 | |||
102 | gld = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_LINEAR_MIXIN); | ||
103 | gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN); | ||
104 | if (!gd || !gld) return EINA_FALSE; | ||
105 | |||
106 | pat = _ector_renderer_cairo_gradient_linear_prepare(obj, gld, gd, mul_col); | ||
107 | if (!pat) return EINA_FALSE; | ||
108 | |||
109 | cairo_set_source(pd->parent->cairo, pat); | ||
110 | cairo_pattern_destroy(pat); | ||
111 | |||
112 | return EINA_TRUE; | ||
113 | } | ||
114 | |||
115 | static void | ||
116 | _ector_renderer_cairo_gradient_linear_efl_gfx_path_bounds_get(const Eo *obj, | ||
117 | Ector_Renderer_Cairo_Gradient_Linear_Data *pd EINA_UNUSED, | ||
118 | Eina_Rect *r) | ||
119 | { | ||
120 | Ector_Renderer_Gradient_Linear_Data *gld; | ||
121 | Ector_Renderer_Cairo_Data *bd; | ||
122 | |||
123 | gld = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN); | ||
124 | bd = efl_data_scope_get(obj, ECTOR_RENDERER_CAIRO_CLASS); | ||
125 | EINA_RECTANGLE_SET(r, | ||
126 | bd->generic->origin.x + gld->start.x, | ||
127 | bd->generic->origin.y + gld->start.y, | ||
128 | gld->end.x - gld->start.x, | ||
129 | gld->end.y - gld->start.y); | ||
130 | } | ||
131 | |||
132 | static Efl_Object * | ||
133 | _ector_renderer_cairo_gradient_linear_efl_object_finalize(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd EINA_UNUSED) | ||
134 | { | ||
135 | Ector_Renderer_Data *base; | ||
136 | |||
137 | obj = efl_finalize(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS)); | ||
138 | if (!obj) return NULL; | ||
139 | |||
140 | base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS); | ||
141 | |||
142 | USE(base, cairo_set_source, NULL); | ||
143 | USE(base, cairo_pattern_destroy, NULL); | ||
144 | USE(base, cairo_rectangle, NULL); | ||
145 | USE(base, cairo_fill, NULL); | ||
146 | USE(base, cairo_pattern_destroy, NULL); | ||
147 | USE(base, cairo_set_source, NULL); | ||
148 | USE(base, cairo_pattern_set_extend, NULL); | ||
149 | USE(base, cairo_pattern_create_linear, NULL); | ||
150 | USE(base, cairo_pattern_add_color_stop_rgba, NULL); | ||
151 | |||
152 | return obj; | ||
153 | } | ||
154 | |||
155 | static void | ||
156 | _ector_renderer_cairo_gradient_linear_efl_object_destructor(Eo *obj, | ||
157 | Ector_Renderer_Cairo_Gradient_Linear_Data *pd) | ||
158 | { | ||
159 | Ector_Renderer_Data *base; | ||
160 | |||
161 | base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS); | ||
162 | efl_data_xunref(base->surface, pd->parent, obj); | ||
163 | |||
164 | efl_destructor(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS)); | ||
165 | } | ||
166 | |||
167 | static void | ||
168 | _ector_renderer_cairo_gradient_linear_efl_gfx_gradient_stop_set(Eo *obj, | ||
169 | Ector_Renderer_Cairo_Gradient_Linear_Data *pd EINA_UNUSED, | ||
170 | const Efl_Gfx_Gradient_Stop *colors, | ||
171 | unsigned int length) | ||
172 | { | ||
173 | efl_gfx_gradient_stop_set(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS), colors, length); | ||
174 | } | ||
175 | |||
176 | static unsigned int | ||
177 | _ector_renderer_cairo_gradient_linear_ector_renderer_crc_get(const Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd EINA_UNUSED) | ||
178 | { | ||
179 | Ector_Renderer_Gradient_Linear_Data *gld; | ||
180 | Ector_Renderer_Gradient_Data *gd; | ||
181 | unsigned int crc; | ||
182 | |||
183 | crc = ector_renderer_crc_get(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS)); | ||
184 | |||
185 | gld = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_LINEAR_MIXIN); | ||
186 | gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN); | ||
187 | if (!gd || !gld) return crc; | ||
188 | |||
189 | crc = eina_crc((void*) gd->s, sizeof (Efl_Gfx_Gradient_Spread), crc, EINA_FALSE); | ||
190 | if (gd->colors_count) | ||
191 | crc = eina_crc((void*) gd->colors, sizeof (Efl_Gfx_Gradient_Stop) * gd->colors_count, crc, EINA_FALSE); | ||
192 | crc = eina_crc((void*) gld, sizeof (Ector_Renderer_Gradient_Linear_Data), crc, EINA_FALSE); | ||
193 | |||
194 | return crc; | ||
195 | } | ||
196 | |||
197 | #include "ector_renderer_cairo_gradient_linear.eo.c" | ||
diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo deleted file mode 100644 index c6f2c4fe8d..0000000000 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | class @beta Ector.Renderer.Cairo.Gradient.Linear extends Ector.Renderer.Cairo implements Ector.Renderer.Gradient, Ector.Renderer.Gradient.Linear, Efl.Gfx.Path | ||
2 | { | ||
3 | [[Ector cairo renderer gradient linear]] | ||
4 | c_prefix: ector_renderer_cairo_gradient_linear; | ||
5 | implements { | ||
6 | Ector.Renderer.prepare; | ||
7 | Ector.Renderer.draw; | ||
8 | Efl.Gfx.Path.bounds_get; | ||
9 | Ector.Renderer.crc { get; } | ||
10 | Ector.Renderer.Cairo.op_fill; | ||
11 | Efl.Object.finalize; | ||
12 | Efl.Object.destructor; | ||
13 | Efl.Gfx.Gradient.stop { set; } | ||
14 | } | ||
15 | } | ||
diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c deleted file mode 100644 index bb5add0373..0000000000 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ /dev/null | |||
@@ -1,220 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "config.h" | ||
3 | #endif | ||
4 | |||
5 | #include <Eina.h> | ||
6 | #include <Ector.h> | ||
7 | #include <cairo/Ector_Cairo.h> | ||
8 | |||
9 | #include "ector_private.h" | ||
10 | #include "ector_cairo_private.h" | ||
11 | |||
12 | static cairo_pattern_t *(*cairo_pattern_create_radial)(double cx0, double cy0, | ||
13 | double radius0, | ||
14 | double cx1, double cy1, | ||
15 | double radius1) = NULL; | ||
16 | static void (*cairo_set_source)(cairo_t *cr, cairo_pattern_t *source) = NULL; | ||
17 | static void (*cairo_fill)(cairo_t *cr) = NULL; | ||
18 | static void (*cairo_arc)(cairo_t *cr, | ||
19 | double xc, double yc, | ||
20 | double radius, | ||
21 | double angle1, double angle2) = NULL; | ||
22 | static void (*cairo_pattern_destroy)(cairo_pattern_t *pattern) = NULL; | ||
23 | |||
24 | static void (*cairo_pattern_set_extend)(cairo_pattern_t *pattern, cairo_extend_t extend) = NULL; | ||
25 | static void (*cairo_pattern_set_matrix)(cairo_t *cr, cairo_matrix_t *matrix) = NULL; | ||
26 | static void (*cairo_matrix_init)(cairo_matrix_t *matrix, | ||
27 | double xx, double yx, | ||
28 | double xy, double yy, | ||
29 | double x0, double y0) = NULL; | ||
30 | |||
31 | // FIXME: as long as it is not possible to directly access the parent structure | ||
32 | // this will be duplicated from the linear gradient renderer | ||
33 | typedef struct _Ector_Renderer_Cairo_Gradient_Radial_Data Ector_Renderer_Cairo_Gradient_Radial_Data; | ||
34 | struct _Ector_Renderer_Cairo_Gradient_Radial_Data | ||
35 | { | ||
36 | Ector_Cairo_Surface_Data *parent; | ||
37 | }; | ||
38 | |||
39 | static Eina_Bool | ||
40 | _ector_renderer_cairo_gradient_radial_ector_renderer_prepare(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd) | ||
41 | { | ||
42 | ector_renderer_prepare(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS)); | ||
43 | |||
44 | if (!pd->parent) | ||
45 | { | ||
46 | Ector_Renderer_Data *base; | ||
47 | |||
48 | base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS); | ||
49 | pd->parent = efl_data_xref(base->surface, ECTOR_CAIRO_SURFACE_CLASS, obj); | ||
50 | } | ||
51 | |||
52 | return EINA_FALSE; | ||
53 | } | ||
54 | |||
55 | static cairo_pattern_t * | ||
56 | _ector_renderer_cairo_gradient_radial_prepare(Eo *obj, | ||
57 | Ector_Renderer_Gradient_Radial_Data *grd, | ||
58 | Ector_Renderer_Gradient_Data *gd, | ||
59 | unsigned int mul_col) | ||
60 | { | ||
61 | Ector_Renderer_Data *pd = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS); | ||
62 | cairo_pattern_t *pat; | ||
63 | cairo_matrix_t pd_m; | ||
64 | |||
65 | pat = cairo_pattern_create_radial(grd->focal.x, grd->focal.y, 0, | ||
66 | grd->radial.x, grd->radial.y, grd->radius); | ||
67 | if (!pat) return NULL; | ||
68 | |||
69 | _ector_renderer_cairo_gradient_prepare(pat, gd, mul_col); | ||
70 | |||
71 | cairo_pattern_set_extend(pat, _ector_cairo_extent_get(gd->s)); | ||
72 | |||
73 | if (pd->m) | ||
74 | { | ||
75 | cairo_matrix_init(&pd_m, | ||
76 | pd->m->xx, pd->m->yx, | ||
77 | pd->m->xy, pd->m->yy, | ||
78 | pd->m->xz, pd->m->yz); | ||
79 | cairo_pattern_set_matrix(pat, &pd_m); | ||
80 | } | ||
81 | |||
82 | return pat; | ||
83 | } | ||
84 | |||
85 | // Clearly duplicated and should be in a common place... | ||
86 | static Eina_Bool | ||
87 | _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) | ||
88 | { | ||
89 | Ector_Renderer_Gradient_Radial_Data *grd; | ||
90 | Ector_Renderer_Gradient_Data *gd; | ||
91 | cairo_pattern_t *pat; | ||
92 | |||
93 | // FIXME: Handle clipping and generally make it work :-) | ||
94 | grd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN); | ||
95 | gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN); | ||
96 | if (!grd || !gd) return EINA_FALSE; | ||
97 | |||
98 | pat = _ector_renderer_cairo_gradient_radial_prepare(obj, grd, gd, mul_col); | ||
99 | if (!pat) return EINA_FALSE; | ||
100 | |||
101 | ector_renderer_draw(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS), op, clips, mul_col); | ||
102 | |||
103 | cairo_arc(pd->parent->cairo, | ||
104 | grd->radial.x, grd->radial.y, | ||
105 | grd->radius, | ||
106 | 0, 2 * M_PI); | ||
107 | cairo_set_source(pd->parent->cairo, pat); | ||
108 | cairo_fill(pd->parent->cairo); | ||
109 | cairo_pattern_destroy(pat); | ||
110 | |||
111 | return EINA_TRUE; | ||
112 | } | ||
113 | |||
114 | // Clearly duplicated and should be in a common place... | ||
115 | static Eina_Bool | ||
116 | _ector_renderer_cairo_gradient_radial_ector_renderer_cairo_op_fill(Eo *obj, | ||
117 | Ector_Renderer_Cairo_Gradient_Radial_Data *pd, | ||
118 | unsigned int mul_col) | ||
119 | { | ||
120 | Ector_Renderer_Gradient_Radial_Data *grd; | ||
121 | Ector_Renderer_Gradient_Data *gd; | ||
122 | cairo_pattern_t *pat; | ||
123 | |||
124 | grd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN); | ||
125 | gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN); | ||
126 | if (!grd || !gd) return EINA_FALSE; | ||
127 | |||
128 | pat = _ector_renderer_cairo_gradient_radial_prepare(obj, grd, gd, mul_col); | ||
129 | if (!pat) return EINA_FALSE; | ||
130 | |||
131 | cairo_set_source(pd->parent->cairo, pat); | ||
132 | cairo_pattern_destroy(pat); | ||
133 | |||
134 | return EINA_TRUE; | ||
135 | } | ||
136 | |||
137 | static void | ||
138 | _ector_renderer_cairo_gradient_radial_efl_gfx_path_bounds_get(const Eo *obj EINA_UNUSED, | ||
139 | Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED, | ||
140 | Eina_Rect *r) | ||
141 | { | ||
142 | Ector_Renderer_Gradient_Radial_Data *gld; | ||
143 | Ector_Renderer_Cairo_Data *bd; | ||
144 | |||
145 | gld = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN); | ||
146 | bd = efl_data_scope_get(obj, ECTOR_RENDERER_CAIRO_CLASS); | ||
147 | EINA_RECTANGLE_SET(r, | ||
148 | bd->generic->origin.x + gld->radial.x - gld->radius, | ||
149 | bd->generic->origin.y + gld->radial.y - gld->radius, | ||
150 | gld->radius * 2, gld->radius * 2); | ||
151 | } | ||
152 | |||
153 | static Efl_Object * | ||
154 | _ector_renderer_cairo_gradient_radial_efl_object_finalize(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED) | ||
155 | { | ||
156 | Ector_Renderer_Data *base; | ||
157 | |||
158 | obj = efl_finalize(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS)); | ||
159 | if (!obj) return NULL; | ||
160 | |||
161 | base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS); | ||
162 | |||
163 | USE(base, cairo_set_source, NULL); | ||
164 | USE(base, cairo_pattern_destroy, NULL); | ||
165 | USE(base, cairo_arc, NULL); | ||
166 | USE(base, cairo_fill, NULL); | ||
167 | USE(base, cairo_matrix_init, NULL); | ||
168 | USE(base, cairo_set_source, NULL); | ||
169 | USE(base, cairo_pattern_destroy, NULL); | ||
170 | USE(base, cairo_pattern_set_extend, NULL); | ||
171 | USE(base, cairo_pattern_set_matrix, NULL); | ||
172 | USE(base, cairo_pattern_create_radial, NULL); | ||
173 | USE(base, cairo_pattern_add_color_stop_rgba, NULL); | ||
174 | |||
175 | return obj; | ||
176 | } | ||
177 | |||
178 | static void | ||
179 | _ector_renderer_cairo_gradient_radial_efl_object_destructor(Eo *obj, | ||
180 | Ector_Renderer_Cairo_Gradient_Radial_Data *pd) | ||
181 | { | ||
182 | Ector_Renderer_Data *base; | ||
183 | |||
184 | base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS); | ||
185 | efl_data_xunref(base->surface, pd->parent, obj); | ||
186 | |||
187 | efl_destructor(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS)); | ||
188 | } | ||
189 | |||
190 | static void | ||
191 | _ector_renderer_cairo_gradient_radial_efl_gfx_gradient_stop_set(Eo *obj, | ||
192 | Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED, | ||
193 | const Efl_Gfx_Gradient_Stop *colors, | ||
194 | unsigned int length) | ||
195 | { | ||
196 | efl_gfx_gradient_stop_set(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS), colors, length); | ||
197 | } | ||
198 | |||
199 | static unsigned int | ||
200 | _ector_renderer_cairo_gradient_radial_ector_renderer_crc_get(const Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED) | ||
201 | { | ||
202 | Ector_Renderer_Gradient_Radial_Data *grd; | ||
203 | Ector_Renderer_Gradient_Data *gd; | ||
204 | unsigned int crc; | ||
205 | |||
206 | crc = ector_renderer_crc_get(efl_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS)); | ||
207 | |||
208 | grd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_RADIAL_MIXIN); | ||
209 | gd = efl_data_scope_get(obj, ECTOR_RENDERER_GRADIENT_MIXIN); | ||
210 | if (!grd || !gd) return crc; | ||
211 | |||
212 | crc = eina_crc((void*) gd->s, sizeof (Efl_Gfx_Gradient_Spread), crc, EINA_FALSE); | ||
213 | if (gd->colors_count) | ||
214 | crc = eina_crc((void*) gd->colors, sizeof (Efl_Gfx_Gradient_Stop) * gd->colors_count, crc, EINA_FALSE); | ||
215 | crc = eina_crc((void*) grd, sizeof (Ector_Renderer_Gradient_Radial_Data), crc, EINA_FALSE); | ||
216 | |||
217 | return crc; | ||
218 | } | ||
219 | |||
220 | #include "ector_renderer_cairo_gradient_radial.eo.c" | ||
diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo deleted file mode 100644 index bdf0059b3c..0000000000 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | class @beta Ector.Renderer.Cairo.Gradient.Radial extends Ector.Renderer.Cairo implements Ector.Renderer.Gradient, Ector.Renderer.Gradient.Radial, Efl.Gfx.Path | ||
2 | { | ||
3 | [[Ector cairo renderer gradient radial]] | ||
4 | c_prefix: ector_renderer_cairo_gradient_radial; | ||
5 | implements { | ||
6 | Ector.Renderer.prepare; | ||
7 | Ector.Renderer.draw; | ||
8 | Efl.Gfx.Path.bounds_get; | ||
9 | Ector.Renderer.crc { get; } | ||
10 | Ector.Renderer.Cairo.op_fill; | ||
11 | Efl.Object.destructor; | ||
12 | Efl.Object.finalize; | ||
13 | Efl.Gfx.Gradient.stop { set; } | ||
14 | } | ||
15 | } | ||
diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c deleted file mode 100644 index 87fe2a0778..0000000000 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ /dev/null | |||
@@ -1,331 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "config.h" | ||
3 | #endif | ||
4 | |||
5 | #include <math.h> | ||
6 | #include <float.h> | ||
7 | |||
8 | #include <Eina.h> | ||
9 | #include <Ector.h> | ||
10 | #include <cairo/Ector_Cairo.h> | ||
11 | |||
12 | #include "ector_private.h" | ||
13 | #include "ector_cairo_private.h" | ||
14 | |||
15 | typedef struct _cairo_path_t cairo_path_t; | ||
16 | |||
17 | typedef enum _cairo_line_cap { | ||
18 | CAIRO_LINE_CAP_BUTT, | ||
19 | CAIRO_LINE_CAP_ROUND, | ||
20 | CAIRO_LINE_CAP_SQUARE | ||
21 | } cairo_line_cap_t; | ||
22 | |||
23 | typedef enum _cairo_line_join { | ||
24 | CAIRO_LINE_JOIN_MITER, | ||
25 | CAIRO_LINE_JOIN_ROUND, | ||
26 | CAIRO_LINE_JOIN_BEVEL | ||
27 | } cairo_line_join_t; | ||
28 | |||
29 | typedef enum _cairo_fill_rule { | ||
30 | CAIRO_FILL_RULE_WINDING, | ||
31 | CAIRO_FILL_RULE_EVEN_ODD | ||
32 | } cairo_fill_rule_t; | ||
33 | |||
34 | static void (*cairo_move_to)(cairo_t *cr, double x, double y) = NULL; | ||
35 | static void (*cairo_line_to)(cairo_t *cr, double x, double y) = NULL; | ||
36 | static void (*cairo_curve_to)(cairo_t *cr, | ||
37 | double x1, double y1, | ||
38 | double x2, double y2, | ||
39 | double x3, double y3) = NULL; | ||
40 | static void (*cairo_close_path)(cairo_t *cr) = NULL; | ||
41 | |||
42 | static void (*cairo_fill)(cairo_t *cr) = NULL; | ||
43 | static void (*cairo_fill_preserve)(cairo_t *cr) = NULL; | ||
44 | static void (*cairo_stroke)(cairo_t *cr) = NULL; | ||
45 | |||
46 | static void (*cairo_set_source_rgba)(cairo_t *cr, | ||
47 | double red, double green, | ||
48 | double blue, double alpha) = NULL; | ||
49 | |||
50 | |||
51 | static cairo_path_t *(*cairo_copy_path)(cairo_t *cr) = NULL; | ||
52 | static void (*cairo_path_destroy)(cairo_path_t *path) = NULL; | ||
53 | static void (*cairo_new_path)(cairo_t *cr) = NULL; | ||
54 | static void (*cairo_append_path)(cairo_t *cr, const cairo_path_t *path) = NULL; | ||
55 | |||
56 | static void (*cairo_set_line_width)(cairo_t *cr, double width) = NULL; | ||
57 | static void (*cairo_set_line_cap)(cairo_t *cr, cairo_line_cap_t line_cap) = NULL; | ||
58 | static void (*cairo_set_line_join)(cairo_t *cr, cairo_line_join_t line_join) = NULL; | ||
59 | |||
60 | static void (*cairo_save)(cairo_t *cr) = NULL; | ||
61 | static void (*cairo_restore)(cairo_t *cr) = NULL; | ||
62 | |||
63 | static void (*cairo_set_dash) (cairo_t *cr, const double *dashes, int num_dashes, double offset) = NULL; | ||
64 | static void (*cairo_set_fill_rule) (cairo_t *cr, cairo_fill_rule_t fill_rule); | ||
65 | |||
66 | typedef struct _Ector_Renderer_Cairo_Shape_Data Ector_Renderer_Cairo_Shape_Data; | ||
67 | struct _Ector_Renderer_Cairo_Shape_Data | ||
68 | { | ||
69 | Efl_Gfx_Shape_Public *public_shape; | ||
70 | |||
71 | Ector_Cairo_Surface_Data *parent; | ||
72 | Ector_Renderer_Shape_Data *shape; | ||
73 | Ector_Renderer_Data *base; | ||
74 | |||
75 | cairo_path_t *path; | ||
76 | }; | ||
77 | |||
78 | EOLIAN static void | ||
79 | _ector_renderer_cairo_shape_efl_gfx_path_commit(Eo *obj EINA_UNUSED, | ||
80 | Ector_Renderer_Cairo_Shape_Data *pd) | ||
81 | { | ||
82 | if (pd->path) | ||
83 | { | ||
84 | cairo_path_destroy(pd->path); | ||
85 | pd->path = NULL; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | static Eina_Bool | ||
90 | _ector_renderer_cairo_shape_ector_renderer_prepare(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) | ||
91 | { | ||
92 | const Efl_Gfx_Path_Command *cmds = NULL; | ||
93 | const double *pts = NULL; | ||
94 | |||
95 | ector_renderer_prepare(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS)); | ||
96 | |||
97 | // shouldn't this be moved to the cairo base object? | ||
98 | if (!pd->parent) | ||
99 | { | ||
100 | Ector_Renderer_Data *base; | ||
101 | |||
102 | base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS); | ||
103 | pd->parent = efl_data_xref(base->surface, ECTOR_CAIRO_SURFACE_CLASS, obj); | ||
104 | } | ||
105 | |||
106 | efl_gfx_path_get(obj, &cmds, &pts); | ||
107 | if (!pd->path && cmds) | ||
108 | { | ||
109 | cairo_new_path(pd->parent->cairo); | ||
110 | |||
111 | for (; *cmds != EFL_GFX_PATH_COMMAND_TYPE_END; cmds++) | ||
112 | { | ||
113 | switch (*cmds) | ||
114 | { | ||
115 | case EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO: | ||
116 | cairo_move_to(pd->parent->cairo, pts[0], pts[1]); | ||
117 | |||
118 | pts += 2; | ||
119 | break; | ||
120 | case EFL_GFX_PATH_COMMAND_TYPE_LINE_TO: | ||
121 | cairo_line_to(pd->parent->cairo, pts[0], pts[1]); | ||
122 | |||
123 | pts += 2; | ||
124 | break; | ||
125 | case EFL_GFX_PATH_COMMAND_TYPE_CUBIC_TO: | ||
126 | |||
127 | cairo_curve_to(pd->parent->cairo, | ||
128 | pts[0], pts[1], pts[2], pts[3], // control points | ||
129 | pts[4], pts[5]); // destination point | ||
130 | |||
131 | pts += 6; | ||
132 | break; | ||
133 | case EFL_GFX_PATH_COMMAND_TYPE_CLOSE: | ||
134 | cairo_close_path(pd->parent->cairo); | ||
135 | break; | ||
136 | case EFL_GFX_PATH_COMMAND_TYPE_LAST: | ||
137 | case EFL_GFX_PATH_COMMAND_TYPE_END: | ||
138 | break; | ||
139 | } | ||
140 | } | ||
141 | |||
142 | pd->path = cairo_copy_path(pd->parent->cairo); | ||
143 | } | ||
144 | |||
145 | return EINA_TRUE; | ||
146 | } | ||
147 | |||
148 | static Eina_Bool | ||
149 | _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) | ||
150 | { | ||
151 | int r, g, b, a; | ||
152 | unsigned i; | ||
153 | Efl_Gfx_Fill_Rule fill_rule; | ||
154 | |||
155 | if (pd->path == NULL) return EINA_FALSE; | ||
156 | |||
157 | cairo_save(pd->parent->cairo); | ||
158 | |||
159 | ector_renderer_draw(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS), op, clips, mul_col); | ||
160 | |||
161 | cairo_new_path(pd->parent->cairo); | ||
162 | cairo_append_path(pd->parent->cairo, pd->path); | ||
163 | |||
164 | fill_rule = efl_gfx_shape_fill_rule_get(obj); | ||
165 | if (fill_rule == EFL_GFX_FILL_RULE_ODD_EVEN) | ||
166 | cairo_set_fill_rule(pd->parent->cairo, CAIRO_FILL_RULE_EVEN_ODD); | ||
167 | else | ||
168 | cairo_set_fill_rule(pd->parent->cairo, CAIRO_FILL_RULE_WINDING); | ||
169 | |||
170 | if (pd->shape->fill) | ||
171 | ector_renderer_cairo_op_fill(pd->shape->fill, mul_col); | ||
172 | |||
173 | if (pd->shape->stroke.fill || pd->public_shape->stroke.color.a > 0) | ||
174 | { | ||
175 | cairo_fill_preserve(pd->parent->cairo); | ||
176 | |||
177 | if (pd->shape->stroke.fill) | ||
178 | ector_renderer_cairo_op_fill(pd->shape->stroke.fill, mul_col); | ||
179 | else | ||
180 | { | ||
181 | r = (((pd->public_shape->stroke.color.r * R_VAL(&mul_col)) + 0xff) >> 8); | ||
182 | g = (((pd->public_shape->stroke.color.g * G_VAL(&mul_col)) + 0xff) >> 8); | ||
183 | b = (((pd->public_shape->stroke.color.b * B_VAL(&mul_col)) + 0xff) >> 8); | ||
184 | a = (((pd->public_shape->stroke.color.a * A_VAL(&mul_col)) + 0xff) >> 8); | ||
185 | ector_color_argb_unpremul(a, &r, &g, &b); | ||
186 | cairo_set_source_rgba(pd->parent->cairo, r/255.0, g/255.0, b/255.0, a/255.0); | ||
187 | if (pd->public_shape->stroke.dash) | ||
188 | { | ||
189 | double *dashinfo; | ||
190 | |||
191 | dashinfo = (double *) malloc(2 * pd->public_shape->stroke.dash_length * sizeof(double)); | ||
192 | for (i = 0; i < pd->public_shape->stroke.dash_length; i++) | ||
193 | { | ||
194 | dashinfo[i*2] = pd->public_shape->stroke.dash[i].length; | ||
195 | dashinfo[i*2 + 1] = pd->public_shape->stroke.dash[i].gap; | ||
196 | } | ||
197 | cairo_set_dash(pd->parent->cairo, dashinfo, pd->public_shape->stroke.dash_length * 2, 0); | ||
198 | free(dashinfo); | ||
199 | } | ||
200 | } | ||
201 | |||
202 | // Set dash, cap and join | ||
203 | cairo_set_line_width(pd->parent->cairo, (pd->public_shape->stroke.width * pd->public_shape->stroke.scale)); | ||
204 | cairo_set_line_cap(pd->parent->cairo, (cairo_line_cap_t) pd->public_shape->stroke.cap); | ||
205 | cairo_set_line_join(pd->parent->cairo, (cairo_line_join_t) pd->public_shape->stroke.join); | ||
206 | cairo_stroke(pd->parent->cairo); | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | cairo_fill(pd->parent->cairo); | ||
211 | } | ||
212 | |||
213 | cairo_restore(pd->parent->cairo); | ||
214 | return EINA_TRUE; | ||
215 | } | ||
216 | |||
217 | static Eina_Bool | ||
218 | _ector_renderer_cairo_shape_ector_renderer_cairo_op_fill(Eo *obj EINA_UNUSED, | ||
219 | Ector_Renderer_Cairo_Shape_Data *pd EINA_UNUSED, | ||
220 | unsigned int mul_col EINA_UNUSED) | ||
221 | { | ||
222 | // FIXME: let's find out how to fill a shape with a shape later. | ||
223 | // I need to read SVG specification and see how to map that with cairo. | ||
224 | ERR("fill with shape not implemented\n"); | ||
225 | return EINA_FALSE; | ||
226 | } | ||
227 | |||
228 | static void | ||
229 | _ector_renderer_cairo_shape_efl_gfx_path_bounds_get(const Eo *obj, | ||
230 | Ector_Renderer_Cairo_Shape_Data *pd EINA_UNUSED, | ||
231 | Eina_Rect *r) | ||
232 | { | ||
233 | Ector_Renderer_Cairo_Data *bd; | ||
234 | |||
235 | // FIXME: It should be possible to ask cairo about this | ||
236 | efl_gfx_path_bounds_get(obj, r); | ||
237 | |||
238 | bd = efl_data_scope_get(obj, ECTOR_RENDERER_CAIRO_CLASS); | ||
239 | r->x += bd->generic->origin.x; | ||
240 | r->y += bd->generic->origin.y; | ||
241 | } | ||
242 | |||
243 | Eo * | ||
244 | _ector_renderer_cairo_shape_efl_object_constructor(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) | ||
245 | { | ||
246 | obj = efl_constructor(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS)); | ||
247 | |||
248 | if (!obj) return NULL; | ||
249 | |||
250 | pd->public_shape = efl_data_xref(obj, EFL_GFX_SHAPE_MIXIN, obj); | ||
251 | pd->shape = efl_data_xref(obj, ECTOR_RENDERER_SHAPE_MIXIN, obj); | ||
252 | pd->base = efl_data_xref(obj, ECTOR_RENDERER_CLASS, obj); | ||
253 | |||
254 | return obj; | ||
255 | } | ||
256 | |||
257 | static Efl_Object * | ||
258 | _ector_renderer_cairo_shape_efl_object_finalize(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) | ||
259 | { | ||
260 | obj = efl_finalize(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS)); | ||
261 | if (!obj) return NULL; | ||
262 | |||
263 | USE(pd->base, cairo_path_destroy, NULL); | ||
264 | USE(pd->base, cairo_restore, NULL); | ||
265 | USE(pd->base, cairo_fill, NULL); | ||
266 | USE(pd->base, cairo_set_dash, NULL); | ||
267 | USE(pd->base, cairo_fill_preserve, NULL); | ||
268 | USE(pd->base, cairo_set_source_rgba, NULL); | ||
269 | USE(pd->base, cairo_stroke, NULL); | ||
270 | USE(pd->base, cairo_set_line_width, NULL); | ||
271 | USE(pd->base, cairo_set_line_cap, NULL); | ||
272 | USE(pd->base, cairo_set_line_join, NULL); | ||
273 | USE(pd->base, cairo_new_path, NULL); | ||
274 | USE(pd->base, cairo_append_path, NULL); | ||
275 | USE(pd->base, cairo_save, NULL); | ||
276 | USE(pd->base, cairo_copy_path, NULL); | ||
277 | USE(pd->base, cairo_close_path, NULL); | ||
278 | USE(pd->base, cairo_curve_to, NULL); | ||
279 | USE(pd->base, cairo_line_to, NULL); | ||
280 | USE(pd->base, cairo_move_to, NULL); | ||
281 | USE(pd->base, cairo_set_fill_rule, NULL); | ||
282 | |||
283 | return obj; | ||
284 | } | ||
285 | |||
286 | void | ||
287 | _ector_renderer_cairo_shape_efl_object_destructor(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) | ||
288 | { | ||
289 | Ector_Renderer_Data *base; | ||
290 | |||
291 | // FIXME: As base class destructor can't call destructor of mixin class. | ||
292 | // Call explicit API to free shape data. | ||
293 | efl_gfx_path_reset(obj); | ||
294 | |||
295 | base = efl_data_scope_get(obj, ECTOR_RENDERER_CLASS); | ||
296 | efl_data_xunref(base->surface, pd->parent, obj); | ||
297 | |||
298 | efl_data_xunref(obj, pd->shape, obj); | ||
299 | efl_data_xunref(obj, pd->base, obj); | ||
300 | |||
301 | efl_destructor(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS)); | ||
302 | |||
303 | if (pd->path) cairo_path_destroy(pd->path); | ||
304 | } | ||
305 | |||
306 | unsigned int | ||
307 | _ector_renderer_cairo_shape_ector_renderer_crc_get(const Eo *obj, | ||
308 | Ector_Renderer_Cairo_Shape_Data *pd) | ||
309 | { | ||
310 | unsigned int crc; | ||
311 | |||
312 | crc = ector_renderer_crc_get(efl_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS)); | ||
313 | |||
314 | crc = eina_crc((void*) &pd->shape->stroke.marker, sizeof (pd->shape->stroke.marker), crc, EINA_FALSE); | ||
315 | crc = eina_crc((void*) &pd->public_shape->stroke.scale, sizeof (pd->public_shape->stroke.scale) * 3, crc, EINA_FALSE); // scale, width, centered | ||
316 | crc = eina_crc((void*) &pd->public_shape->stroke.color, sizeof (pd->public_shape->stroke.color), crc, EINA_FALSE); | ||
317 | crc = eina_crc((void*) &pd->public_shape->stroke.cap, sizeof (pd->public_shape->stroke.cap), crc, EINA_FALSE); | ||
318 | crc = eina_crc((void*) &pd->public_shape->stroke.join, sizeof (pd->public_shape->stroke.join), crc, EINA_FALSE); | ||
319 | |||
320 | if (pd->shape->fill) crc = _renderer_crc_get(pd->shape->fill, crc); | ||
321 | if (pd->shape->stroke.fill) crc = _renderer_crc_get(pd->shape->stroke.fill, crc); | ||
322 | if (pd->shape->stroke.marker) crc = _renderer_crc_get(pd->shape->stroke.marker, crc); | ||
323 | if (pd->public_shape->stroke.dash_length) | ||
324 | { | ||
325 | crc = eina_crc((void*) pd->public_shape->stroke.dash, sizeof (Efl_Gfx_Dash) * pd->public_shape->stroke.dash_length, crc, EINA_FALSE); | ||
326 | } | ||
327 | |||
328 | return crc; | ||
329 | } | ||
330 | |||
331 | #include "ector_renderer_cairo_shape.eo.c" | ||
diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo deleted file mode 100644 index b2d41c6842..0000000000 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | class @beta Ector.Renderer.Cairo.Shape extends Ector.Renderer.Cairo implements Ector.Renderer.Shape, Efl.Gfx.Path | ||
2 | { | ||
3 | [[Ector cairo renderer shape class]] | ||
4 | c_prefix: ector_renderer_cairo_shape; | ||
5 | implements { | ||
6 | Ector.Renderer.prepare; | ||
7 | Ector.Renderer.draw; | ||
8 | Efl.Gfx.Path.bounds_get; | ||
9 | Efl.Gfx.Path.commit; | ||
10 | Ector.Renderer.crc { get; } | ||
11 | Ector.Renderer.Cairo.op_fill; | ||
12 | Efl.Object.constructor; | ||
13 | Efl.Object.finalize; | ||
14 | Efl.Object.destructor; | ||
15 | } | ||
16 | } | ||
diff --git a/src/lib/ector/cairo/meson.build b/src/lib/ector/cairo/meson.build deleted file mode 100644 index 094aedb3e6..0000000000 --- a/src/lib/ector/cairo/meson.build +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | |||
2 | ector_src += files([ | ||
3 | 'ector_renderer_cairo_gradient_linear.c', | ||
4 | 'ector_renderer_cairo_gradient_radial.c', | ||
5 | 'ector_renderer_cairo_shape.c', | ||
6 | 'ector_renderer_cairo.c', | ||
7 | 'ector_cairo_software_surface.c', | ||
8 | 'ector_cairo_surface.c' | ||
9 | ]) | ||
10 | |||
11 | pub_eo_files = [ | ||
12 | 'ector_cairo_surface.eo', | ||
13 | 'ector_cairo_software_surface.eo', | ||
14 | 'ector_renderer_cairo.eo', | ||
15 | 'ector_renderer_cairo_shape.eo', | ||
16 | 'ector_renderer_cairo_gradient_linear.eo', | ||
17 | 'ector_renderer_cairo_gradient_radial.eo' | ||
18 | ] | ||
19 | |||
20 | foreach eo_file : pub_eo_files | ||
21 | pub_eo_file_target += custom_target('eolian_gen_' + eo_file, | ||
22 | input : eo_file, | ||
23 | output : [eo_file + '.h'], | ||
24 | depfile : eo_file + '.d', | ||
25 | install : false, | ||
26 | install_dir : dir_package_include, | ||
27 | command : eolian_gen + [ '-I', meson.current_source_dir(), eolian_include_directories, | ||
28 | '-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'), | ||
29 | '-o', 'c:' + join_paths(meson.current_build_dir(), eo_file + '.c'), | ||
30 | '-o', 'd:' + join_paths(meson.current_build_dir(), eo_file + '.d'), | ||
31 | '-gchd', '@INPUT@']) | ||
32 | endforeach | ||
33 | |||
34 | |||
35 | if get_option('install-eo-files') | ||
36 | install_data(pub_eo_files, | ||
37 | install_dir: join_paths(eolian_include_dir, package_version_name) | ||
38 | ) | ||
39 | endif | ||
diff --git a/src/lib/ector/gl/Ector_GL.h b/src/lib/ector/gl/Ector_GL.h index 131288a180..88b6c6bae1 100644 --- a/src/lib/ector/gl/Ector_GL.h +++ b/src/lib/ector/gl/Ector_GL.h | |||
@@ -34,8 +34,6 @@ | |||
34 | #ifndef _ECTOR_GL_SURFACE_EO_CLASS_TYPE | 34 | #ifndef _ECTOR_GL_SURFACE_EO_CLASS_TYPE |
35 | #define _ECTOR_GL_SURFACE_EO_CLASS_TYPE | 35 | #define _ECTOR_GL_SURFACE_EO_CLASS_TYPE |
36 | 36 | ||
37 | typedef Eo Ector_Cairo_Surface; | ||
38 | |||
39 | #endif | 37 | #endif |
40 | 38 | ||
41 | typedef unsigned int GLuint; | 39 | typedef unsigned int GLuint; |
diff --git a/src/lib/ector/meson.build b/src/lib/ector/meson.build index 5bedb7e82b..b0d33a1d42 100644 --- a/src/lib/ector/meson.build +++ b/src/lib/ector/meson.build | |||
@@ -50,7 +50,6 @@ endforeach | |||
50 | 50 | ||
51 | eolian_include_directories += ['-I', meson.current_source_dir()] | 51 | eolian_include_directories += ['-I', meson.current_source_dir()] |
52 | 52 | ||
53 | subdir('cairo') | ||
54 | subdir('gl') | 53 | subdir('gl') |
55 | 54 | ||
56 | pub_eo_types_files = [ | 55 | pub_eo_types_files = [ |
diff --git a/src/lib/ector/software/ector_software_buffer.c b/src/lib/ector/software/ector_software_buffer.c index 5a5c940f7f..df7fc27d1f 100644 --- a/src/lib/ector/software/ector_software_buffer.c +++ b/src/lib/ector/software/ector_software_buffer.c | |||
@@ -45,7 +45,7 @@ _pixels_gry8_to_argb_convert(uint32_t *dst, const uint8_t *src, int len) | |||
45 | } | 45 | } |
46 | 46 | ||
47 | EOLIAN static void | 47 | EOLIAN static void |
48 | _ector_software_buffer_base_pixels_clear(Eo *obj, Ector_Software_Buffer_Base_Data *pd) | 48 | _ector_software_buffer_base_pixels_clear(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd) |
49 | { | 49 | { |
50 | if (!pd->pixels.u8) return; | 50 | if (!pd->pixels.u8) return; |
51 | 51 | ||