summaryrefslogtreecommitdiff
path: root/src/lib/ector
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-12-01 15:22:20 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-12-03 18:42:50 +0900
commitbad7911cd0f9d7eaa51c0c7b67ff3ed8d7da5599 (patch)
treec1f3f9552f9101c90d904e85f6d8bf5cc43cda57 /src/lib/ector
parent0cf5719e526b17bb6ad03f05643a760edf389e98 (diff)
Ector: Use Ector Buffer inside SW and Cairo renderers
Ector Surface now inherits from Ector Buffer, and the current two renderers (SW and Cairo SW) use Ector.Software.Buffer implementations for pixel surfaces. Basic pixel handling is merged and will allow easy extension (color conversion, etc...). Buffer classes are Mixins to be fully implemented by the final class, such as: Ector.Software.Buffer, Ector.Software.Surface or Ector.Cairo.Surface. This is a large ugly commit. Sorry. The code is quite a mess right now.
Diffstat (limited to 'src/lib/ector')
-rw-r--r--src/lib/ector/cairo/ector_cairo_surface.eo2
-rw-r--r--src/lib/ector/ector_buffer.h27
-rw-r--r--src/lib/ector/ector_generic_buffer.c12
-rw-r--r--src/lib/ector/ector_generic_buffer.eo3
-rw-r--r--src/lib/ector/ector_generic_surface.eo16
-rw-r--r--src/lib/ector/ector_private.h14
-rw-r--r--src/lib/ector/ector_renderer_base.c21
-rw-r--r--src/lib/ector/ector_renderer_generic_base.eo1
-rw-r--r--src/lib/ector/ector_renderer_generic_buffer.eo6
-rw-r--r--src/lib/ector/ector_surface.c34
-rw-r--r--src/lib/ector/software/Ector_Software.h1
-rw-r--r--src/lib/ector/software/ector_renderer_software_buffer.c4
-rw-r--r--src/lib/ector/software/ector_software_buffer.c111
-rw-r--r--src/lib/ector/software/ector_software_buffer.eo16
-rw-r--r--src/lib/ector/software/ector_software_buffer_base.eo19
-rw-r--r--src/lib/ector/software/ector_software_private.h35
-rw-r--r--src/lib/ector/software/ector_software_rasterizer.c28
-rw-r--r--src/lib/ector/software/ector_software_surface.c52
-rw-r--r--src/lib/ector/software/ector_software_surface.eo26
19 files changed, 184 insertions, 244 deletions
diff --git a/src/lib/ector/cairo/ector_cairo_surface.eo b/src/lib/ector/cairo/ector_cairo_surface.eo
index 78dbe154b5..001d73acf8 100644
--- a/src/lib/ector/cairo/ector_cairo_surface.eo
+++ b/src/lib/ector/cairo/ector_cairo_surface.eo
@@ -1,4 +1,4 @@
1class Ector.Cairo.Surface (Ector.Generic.Surface) 1class Ector.Cairo.Surface (Eo.Base, Ector.Generic.Surface)
2{ 2{
3 eo_prefix: ector_cairo_surface; 3 eo_prefix: ector_cairo_surface;
4 legacy_prefix: null; 4 legacy_prefix: null;
diff --git a/src/lib/ector/ector_buffer.h b/src/lib/ector/ector_buffer.h
new file mode 100644
index 0000000000..41a75cb8ac
--- /dev/null
+++ b/src/lib/ector/ector_buffer.h
@@ -0,0 +1,27 @@
1#include <Ector.h>
2
3#include "ector_generic_buffer.eo.h"
4#include "software/ector_software_buffer_base.eo.h"
5
6typedef struct _Ector_Generic_Buffer_Data
7{
8 Eo *eo;
9 unsigned int w, h;
10 unsigned char l, r, t, b;
11 Efl_Gfx_Colorspace cspace;
12} Ector_Generic_Buffer_Data;
13
14typedef struct _Ector_Software_Buffer_Base_Data
15{
16 Ector_Generic_Buffer_Data *generic; /* ugly */
17 union {
18 unsigned int *u32;
19 unsigned char *u8;
20 } pixels;
21 unsigned int stride;
22 unsigned int pixel_size; // in bytes
23 unsigned int map_count;
24 Eina_Bool writable : 1;
25 Eina_Bool nofree : 1; // pixel data should not be free()'ed
26 Eina_Bool span_free : 1;
27} Ector_Software_Buffer_Base_Data;
diff --git a/src/lib/ector/ector_generic_buffer.c b/src/lib/ector/ector_generic_buffer.c
index ba5955bfd2..9c97ff8e91 100644
--- a/src/lib/ector/ector_generic_buffer.c
+++ b/src/lib/ector/ector_generic_buffer.c
@@ -8,8 +8,6 @@
8#include "ector_private.h" 8#include "ector_private.h"
9#include "ector_generic_buffer.eo.h" 9#include "ector_generic_buffer.eo.h"
10 10
11#define MY_CLASS ECTOR_GENERIC_BUFFER_CLASS
12
13EOLIAN static Efl_Gfx_Colorspace 11EOLIAN static Efl_Gfx_Colorspace
14_ector_generic_buffer_cspace_get(Eo *obj EINA_UNUSED, Ector_Generic_Buffer_Data *pd) 12_ector_generic_buffer_cspace_get(Eo *obj EINA_UNUSED, Ector_Generic_Buffer_Data *pd)
15{ 13{
@@ -38,13 +36,5 @@ _ector_generic_buffer_flags_get(Eo *obj EINA_UNUSED, Ector_Generic_Buffer_Data *
38 return ECTOR_BUFFER_FLAG_NONE; 36 return ECTOR_BUFFER_FLAG_NONE;
39} 37}
40 38
41EOLIAN static Eo_Base *
42_ector_generic_buffer_eo_base_constructor(Eo *obj, Ector_Generic_Buffer_Data *pd)
43{
44 eo_do_super(obj, MY_CLASS, obj = eo_constructor());
45 pd->eo = obj;
46
47 return obj;
48}
49
50#include "ector_generic_buffer.eo.c" 39#include "ector_generic_buffer.eo.c"
40#include "ector_generic_surface.eo.c"
diff --git a/src/lib/ector/ector_generic_buffer.eo b/src/lib/ector/ector_generic_buffer.eo
index f0f15662d4..7b8a3edae6 100644
--- a/src/lib/ector/ector_generic_buffer.eo
+++ b/src/lib/ector/ector_generic_buffer.eo
@@ -15,7 +15,7 @@ enum Ector.Buffer.Access_Flag {
15 write = 0x2, 15 write = 0x2,
16} 16}
17 17
18abstract Ector.Generic.Buffer (Eo.Base) 18mixin Ector.Generic.Buffer
19{ 19{
20 [[2D pixel buffer interface for Ector 20 [[2D pixel buffer interface for Ector
21 @since 1.17 21 @since 1.17
@@ -122,7 +122,6 @@ abstract Ector.Generic.Buffer (Eo.Base)
122 detached; [[Emitted whenever the previously attached pixels are detached during pixels_set]] 122 detached; [[Emitted whenever the previously attached pixels are detached during pixels_set]]
123 } 123 }
124 implements { 124 implements {
125 Eo.Base.constructor;
126 @virtual .pixels_set; 125 @virtual .pixels_set;
127 @virtual .span_get; 126 @virtual .span_get;
128 @virtual .span_free; 127 @virtual .span_free;
diff --git a/src/lib/ector/ector_generic_surface.eo b/src/lib/ector/ector_generic_surface.eo
index a391ea08a2..cb05c6d3d5 100644
--- a/src/lib/ector/ector_generic_surface.eo
+++ b/src/lib/ector/ector_generic_surface.eo
@@ -1,19 +1,9 @@
1abstract Ector.Generic.Surface (Eo.Base) 1mixin Ector.Generic.Surface (Ector.Generic.Buffer)
2{ 2{
3 eo_prefix: ector_surface; 3 eo_prefix: ector_surface;
4 legacy_prefix: null;
5 data: null;
4 methods { 6 methods {
5 @property size {
6 set {
7 [[Changes the size of the given Evas object.]]
8 }
9 get {
10 [[Retrieves the (rectangular) size of the given Evas object.]]
11 }
12 values {
13 w: int;
14 h: int;
15 }
16 }
17 @property reference_point { 7 @property reference_point {
18 set { 8 set {
19 [[This define where is (0,0) in pixels coordinate inside the surface]] 9 [[This define where is (0,0) in pixels coordinate inside the surface]]
diff --git a/src/lib/ector/ector_private.h b/src/lib/ector/ector_private.h
index 13cfc7eee0..3418c99e58 100644
--- a/src/lib/ector/ector_private.h
+++ b/src/lib/ector/ector_private.h
@@ -91,7 +91,6 @@ typedef struct _Ector_Renderer_Generic_Gradient_Linear_Data Ector_Renderer_Gener
91typedef struct _Ector_Renderer_Generic_Gradient_Radial_Data Ector_Renderer_Generic_Gradient_Radial_Data; 91typedef struct _Ector_Renderer_Generic_Gradient_Radial_Data Ector_Renderer_Generic_Gradient_Radial_Data;
92typedef struct _Ector_Renderer_Generic_Shape_Data Ector_Renderer_Generic_Shape_Data; 92typedef struct _Ector_Renderer_Generic_Shape_Data Ector_Renderer_Generic_Shape_Data;
93typedef struct _Ector_Renderer_Generic_Buffer_Data Ector_Renderer_Generic_Buffer_Data; 93typedef struct _Ector_Renderer_Generic_Buffer_Data Ector_Renderer_Generic_Buffer_Data;
94typedef struct _Ector_Generic_Buffer_Data Ector_Generic_Buffer_Data;
95 94
96struct _Ector_Renderer_Generic_Base_Data 95struct _Ector_Renderer_Generic_Base_Data
97{ 96{
@@ -110,7 +109,8 @@ struct _Ector_Renderer_Generic_Base_Data
110 Ector_Renderer *mask; 109 Ector_Renderer *mask;
111 110
112 Ector_Quality q; 111 Ector_Quality q;
113 Eina_Bool visibility; 112 Eina_Bool visibility : 1;
113 Eina_Bool finalized : 1;
114}; 114};
115 115
116struct _Ector_Renderer_Generic_Gradient_Data 116struct _Ector_Renderer_Generic_Gradient_Data
@@ -145,14 +145,6 @@ struct _Ector_Renderer_Generic_Shape_Data
145 } stroke; 145 } stroke;
146}; 146};
147 147
148struct _Ector_Generic_Buffer_Data
149{
150 Eo *eo;
151 unsigned int w, h;
152 unsigned char l, r, t, b;
153 Efl_Gfx_Colorspace cspace;
154};
155
156struct _Ector_Renderer_Generic_Buffer_Data 148struct _Ector_Renderer_Generic_Buffer_Data
157{ 149{
158 Ector_Generic_Buffer *eo_buffer; 150 Ector_Generic_Buffer *eo_buffer;
@@ -172,4 +164,6 @@ _renderer_crc_get(Eo *obj, unsigned int crc)
172 return crc; 164 return crc;
173} 165}
174 166
167#include "ector_buffer.h"
168
175#endif 169#endif
diff --git a/src/lib/ector/ector_renderer_base.c b/src/lib/ector/ector_renderer_base.c
index 2b9a594c3e..66423bff9a 100644
--- a/src/lib/ector/ector_renderer_base.c
+++ b/src/lib/ector/ector_renderer_base.c
@@ -7,13 +7,27 @@
7 7
8#include "ector_private.h" 8#include "ector_private.h"
9 9
10#define MY_CLASS ECTOR_RENDERER_GENERIC_BASE_CLASS
11
10static void 12static void
11_ector_renderer_generic_base_eo_base_destructor(Eo *obj, Ector_Renderer_Generic_Base_Data *pd) 13_ector_renderer_generic_base_eo_base_destructor(Eo *obj, Ector_Renderer_Generic_Base_Data *pd)
12{ 14{
13 if (pd->m) free(pd->m); 15 if (pd->m) free(pd->m);
14 eo_unref(pd->surface); 16 eo_unref(pd->surface);
15 17
16 eo_do_super(obj, ECTOR_RENDERER_GENERIC_BASE_CLASS, eo_destructor()); 18 eo_do_super(obj, MY_CLASS, eo_destructor());
19}
20
21static Eo_Base *
22_ector_renderer_generic_base_eo_base_finalize(Eo *obj, Ector_Renderer_Generic_Base_Data *pd)
23{
24 if (!pd->surface)
25 {
26 CRI("surface is not set yet, go fix your code!");
27 return NULL;
28 }
29 pd->finalized = EINA_TRUE;
30 return eo_do_super_ret(obj, MY_CLASS, obj, eo_finalize());
17} 31}
18 32
19static Ector_Generic_Surface * 33static Ector_Generic_Surface *
@@ -25,6 +39,11 @@ _ector_renderer_generic_base_surface_get(Eo *obj EINA_UNUSED, Ector_Renderer_Gen
25static void 39static void
26_ector_renderer_generic_base_surface_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, Ector_Generic_Surface *s) 40_ector_renderer_generic_base_surface_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, Ector_Generic_Surface *s)
27{ 41{
42 if (pd->finalized)
43 {
44 CRI("surface_set can be called during object creation only!");
45 return;
46 }
28 pd->surface = eo_xref(s, obj); 47 pd->surface = eo_xref(s, obj);
29} 48}
30 49
diff --git a/src/lib/ector/ector_renderer_generic_base.eo b/src/lib/ector/ector_renderer_generic_base.eo
index 8c6ce6e78e..ea9c3abd1b 100644
--- a/src/lib/ector/ector_renderer_generic_base.eo
+++ b/src/lib/ector/ector_renderer_generic_base.eo
@@ -121,6 +121,7 @@ abstract Ector.Renderer.Generic.Base (Eo.Base)
121 } 121 }
122 implements { 122 implements {
123 Eo.Base.destructor; 123 Eo.Base.destructor;
124 Eo.Base.finalize;
124 @virtual .draw; 125 @virtual .draw;
125 @virtual .bounds_get; 126 @virtual .bounds_get;
126 @virtual .done; 127 @virtual .done;
diff --git a/src/lib/ector/ector_renderer_generic_buffer.eo b/src/lib/ector/ector_renderer_generic_buffer.eo
index 94e1ef295e..4d881052ad 100644
--- a/src/lib/ector/ector_renderer_generic_buffer.eo
+++ b/src/lib/ector/ector_renderer_generic_buffer.eo
@@ -1,12 +1,12 @@
1mixin Ector.Renderer.Generic.Buffer (Eo.Base, Efl.Gfx.Fill) 1mixin Ector.Renderer.Generic.Buffer (Ector.Renderer.Generic.Base, Efl.Gfx.Fill)
2{ 2{
3 [[Ector buffers have a default fill set to repeat]] 3 [[Ector buffers have a default fill set to repeat]]
4 eo_prefix: ector_renderer_buffer; 4 eo_prefix: ector_renderer_buffer;
5 legacy_prefix: null; 5 legacy_prefix: null;
6 methods { 6 methods {
7 @property buffer { 7 @property buffer {
8 set {} 8 set { [[Sets the source buffer for this renderer, adds a ref]] }
9 get {} 9 get { [[Return the current source, no ref change]] }
10 values { 10 values {
11 buf: Ector.Generic.Buffer*; 11 buf: Ector.Generic.Buffer*;
12 } 12 }
diff --git a/src/lib/ector/ector_surface.c b/src/lib/ector/ector_surface.c
deleted file mode 100644
index 23ad7eb2fd..0000000000
--- a/src/lib/ector/ector_surface.c
+++ /dev/null
@@ -1,34 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <Eina.h>
6#include <Ector.h>
7
8#include "ector_private.h"
9
10typedef struct _Ector_Generic_Surface_Data Ector_Generic_Surface_Data;
11struct _Ector_Generic_Surface_Data
12{
13 int w, h;
14};
15
16void
17_ector_generic_surface_size_set(Eo *obj EINA_UNUSED,
18 Ector_Generic_Surface_Data *pd,
19 int w, int h)
20{
21 pd->w = w;
22 pd->h = h;
23}
24
25void
26_ector_generic_surface_size_get(Eo *obj EINA_UNUSED,
27 Ector_Generic_Surface_Data *pd,
28 int *w, int *h)
29{
30 if (w) *w = pd->w;
31 if (h) *h = pd->h;
32}
33
34#include "ector_generic_surface.eo.c"
diff --git a/src/lib/ector/software/Ector_Software.h b/src/lib/ector/software/Ector_Software.h
index 8e2a92195a..430315a57e 100644
--- a/src/lib/ector/software/Ector_Software.h
+++ b/src/lib/ector/software/Ector_Software.h
@@ -14,6 +14,7 @@ typedef struct _Software_Rasterizer Software_Rasterizer;
14 14
15#include "software/ector_software_surface.eo.h" 15#include "software/ector_software_surface.eo.h"
16#include "software/ector_software_buffer.eo.h" 16#include "software/ector_software_buffer.eo.h"
17#include "software/ector_software_buffer_base.eo.h"
17#include "software/ector_renderer_software_base.eo.h" 18#include "software/ector_renderer_software_base.eo.h"
18#include "software/ector_renderer_software_shape.eo.h" 19#include "software/ector_renderer_software_shape.eo.h"
19#include "software/ector_renderer_software_buffer.eo.h" 20#include "software/ector_renderer_software_buffer.eo.h"
diff --git a/src/lib/ector/software/ector_renderer_software_buffer.c b/src/lib/ector/software/ector_renderer_software_buffer.c
index 2cda7128c2..0eb6fa90aa 100644
--- a/src/lib/ector/software/ector_renderer_software_buffer.c
+++ b/src/lib/ector/software/ector_renderer_software_buffer.c
@@ -34,7 +34,7 @@ _ector_renderer_software_buffer_buffer_get(Eo *obj EINA_UNUSED, Ector_Renderer_S
34EOLIAN static Eina_Bool 34EOLIAN static Eina_Bool
35_ector_renderer_software_buffer_ector_renderer_software_base_fill(Eo *obj, Ector_Renderer_Software_Buffer_Data *pd) 35_ector_renderer_software_buffer_ector_renderer_software_base_fill(Eo *obj, Ector_Renderer_Software_Buffer_Data *pd)
36{ 36{
37 Ector_Software_Buffer *buffer = eo_data_scope_get(obj, ECTOR_SOFTWARE_BUFFER_CLASS); 37 Ector_Software_Buffer *buffer = eo_data_scope_get(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN);
38 ector_software_rasterizer_buffer_set(pd->surface, buffer); 38 ector_software_rasterizer_buffer_set(pd->surface, buffer);
39 return EINA_TRUE; 39 return EINA_TRUE;
40} 40}
@@ -51,7 +51,7 @@ _ector_renderer_software_buffer_ector_renderer_generic_base_prepare(Eo *obj, Ect
51EOLIAN static unsigned int 51EOLIAN static unsigned int
52_ector_renderer_software_buffer_ector_renderer_generic_base_crc_get(Eo *obj, Ector_Renderer_Software_Buffer_Data *pd) 52_ector_renderer_software_buffer_ector_renderer_generic_base_crc_get(Eo *obj, Ector_Renderer_Software_Buffer_Data *pd)
53{ 53{
54 Ector_Software_Buffer_Data *buffer = eo_data_scope_get(pd->eo_buffer, ECTOR_SOFTWARE_BUFFER_CLASS); 54 Ector_Software_Buffer_Base_Data *buffer = eo_data_scope_get(pd->eo_buffer, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN);
55 unsigned int crc; 55 unsigned int crc;
56 56
57 eo_do_super(obj, MY_CLASS, crc = ector_renderer_crc_get()); 57 eo_do_super(obj, MY_CLASS, crc = ector_renderer_crc_get());
diff --git a/src/lib/ector/software/ector_software_buffer.c b/src/lib/ector/software/ector_software_buffer.c
index 4fdbcde947..541417f558 100644
--- a/src/lib/ector/software/ector_software_buffer.c
+++ b/src/lib/ector/software/ector_software_buffer.c
@@ -9,6 +9,9 @@
9#include "ector_private.h" 9#include "ector_private.h"
10#include "ector_software_private.h" 10#include "ector_software_private.h"
11#include "ector_generic_buffer.eo.h" 11#include "ector_generic_buffer.eo.h"
12#include "ector_software_buffer_base.eo.h"
13
14#define MY_CLASS ECTOR_SOFTWARE_BUFFER_CLASS
12 15
13#define fail(fmt, ...) do { ERR(fmt, ##__VA_ARGS__); goto on_fail; } while (0) 16#define fail(fmt, ...) do { ERR(fmt, ##__VA_ARGS__); goto on_fail; } while (0)
14 17
@@ -47,7 +50,7 @@ _pixels_gry8_to_argb_convert(uint32_t *dst, const uint8_t *src, int len)
47} 50}
48 51
49EOLIAN static void 52EOLIAN static void
50_ector_software_buffer_pixels_clear(Eo *obj, Ector_Software_Buffer_Data *pd) 53_ector_software_buffer_base_pixels_clear(Eo *obj, Ector_Software_Buffer_Base_Data *pd)
51{ 54{
52 if (!pd->pixels.u8) 55 if (!pd->pixels.u8)
53 return; 56 return;
@@ -62,11 +65,11 @@ _ector_software_buffer_pixels_clear(Eo *obj, Ector_Software_Buffer_Data *pd)
62} 65}
63 66
64EOLIAN static Eina_Bool 67EOLIAN static Eina_Bool
65_ector_software_buffer_ector_generic_buffer_pixels_set(Eo *obj, Ector_Software_Buffer_Data *pd, 68_ector_software_buffer_base_ector_generic_buffer_pixels_set(Eo *obj, Ector_Software_Buffer_Base_Data *pd,
66 void *pixels, int width, int height, int stride, 69 void *pixels, int width, int height, int stride,
67 Efl_Gfx_Colorspace cspace, Eina_Bool writable, 70 Efl_Gfx_Colorspace cspace, Eina_Bool writable,
68 unsigned char l, unsigned char r, 71 unsigned char l, unsigned char r,
69 unsigned char t, unsigned char b) 72 unsigned char t, unsigned char b)
70{ 73{
71 // safety check 74 // safety check
72 unsigned px = _min_stride_calc(1, cspace); 75 unsigned px = _min_stride_calc(1, cspace);
@@ -86,12 +89,15 @@ _ector_software_buffer_ector_generic_buffer_pixels_set(Eo *obj, Ector_Software_B
86 { 89 {
87 ERR("Invalid stride %u for width %u (+%u+%u) cspace %u. pixels_set failed.", 90 ERR("Invalid stride %u for width %u (+%u+%u) cspace %u. pixels_set failed.",
88 stride, width, l, r, cspace); 91 stride, width, l, r, cspace);
89 _ector_software_buffer_pixels_clear(obj, pd); 92 _ector_software_buffer_base_pixels_clear(obj, pd);
90 return EINA_FALSE; 93 return EINA_FALSE;
91 } 94 }
92 95
96 if ((px > 1) && (stride & (px - 1)))
97 ERR("Stride (%d) is not aligned to the pixel size (%d)", stride, px);
98
93 if (pd->pixels.u8 && (pd->pixels.u8 != pixels)) 99 if (pd->pixels.u8 && (pd->pixels.u8 != pixels))
94 _ector_software_buffer_pixels_clear(obj, pd); 100 _ector_software_buffer_base_pixels_clear(obj, pd);
95 101
96 if (pixels) 102 if (pixels)
97 { 103 {
@@ -105,38 +111,39 @@ _ector_software_buffer_ector_generic_buffer_pixels_set(Eo *obj, Ector_Software_B
105 pd->nofree = EINA_FALSE; 111 pd->nofree = EINA_FALSE;
106 pd->writable = EINA_TRUE; 112 pd->writable = EINA_TRUE;
107 } 113 }
108 pd->generic.w = width; 114 pd->generic->w = width;
109 pd->generic.h = height; 115 pd->generic->h = height;
110 pd->generic.l = l; 116 pd->generic->l = l;
111 pd->generic.r = r; 117 pd->generic->r = r;
112 pd->generic.t = t; 118 pd->generic->t = t;
113 pd->generic.b = b; 119 pd->generic->b = b;
114 pd->generic.cspace = cspace; 120 pd->generic->cspace = cspace;
115 pd->stride = stride; 121 pd->stride = stride;
122 pd->pixel_size = px;
116 return EINA_TRUE; 123 return EINA_TRUE;
117} 124}
118 125
119EOLIAN static uint8_t * 126EOLIAN static uint8_t *
120_ector_software_buffer_ector_generic_buffer_map(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Data *pd, 127_ector_software_buffer_base_ector_generic_buffer_map(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd,
121 int *offset, unsigned int *length, 128 int *offset, unsigned int *length,
122 Ector_Buffer_Access_Flag mode EINA_UNUSED, 129 Ector_Buffer_Access_Flag mode EINA_UNUSED,
123 unsigned int x, unsigned int y, unsigned int w, unsigned int h, 130 unsigned int x, unsigned int y, unsigned int w, unsigned int h,
124 Efl_Gfx_Colorspace cspace EINA_UNUSED, unsigned int *stride) 131 Efl_Gfx_Colorspace cspace EINA_UNUSED, unsigned int *stride)
125{ 132{
126 int off; 133 int off;
127 134
128 if (!pd->pixels.u8 || !pd->stride) 135 if (!pd->pixels.u8 || !pd->stride)
129 fail("Buffer has no pixel data yet"); 136 fail("Buffer has no pixel data yet");
130 if (cspace != pd->generic.cspace) 137 if (cspace != pd->generic->cspace)
131 fail("Invalid colorspace"); 138 fail("Invalid colorspace");
132 if (!w || !h || ((x + w) > pd->generic.w) || (y + h > pd->generic.h)) 139 if (!w || !h || ((x + w) > pd->generic->w) || (y + h > pd->generic->h))
133 fail("Invalid region requested: wanted %u,%u %ux%u but image is %ux%u", 140 fail("Invalid region requested: wanted %u,%u %ux%u but image is %ux%u",
134 x, y, w, h, pd->generic.w, pd->generic.h); 141 x, y, w, h, pd->generic->w, pd->generic->h);
135 142
136 pd->map_count++; 143 pd->map_count++;
137 off = _min_stride_calc(x + pd->generic.l, pd->generic.cspace) + (pd->stride * (y + pd->generic.t)); 144 off = _min_stride_calc(x + pd->generic->l, pd->generic->cspace) + (pd->stride * (y + pd->generic->t));
138 if (offset) *offset = off; 145 if (offset) *offset = off;
139 if (length) *length = (pd->stride * pd->generic.h) - off; 146 if (length) *length = (pd->stride * pd->generic->h) - off;
140 if (stride) *stride = pd->stride; 147 if (stride) *stride = pd->stride;
141 return pd->pixels.u8; 148 return pd->pixels.u8;
142 149
@@ -148,7 +155,7 @@ on_fail:
148} 155}
149 156
150EOLIAN static void 157EOLIAN static void
151_ector_software_buffer_ector_generic_buffer_unmap(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Data *pd, void *data, int offset EINA_UNUSED, unsigned int length EINA_UNUSED) 158_ector_software_buffer_base_ector_generic_buffer_unmap(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd, void *data, int offset EINA_UNUSED, unsigned int length EINA_UNUSED)
152{ 159{
153 if (!data) return; 160 if (!data) return;
154 if (data != pd->pixels.u8) 161 if (data != pd->pixels.u8)
@@ -164,35 +171,35 @@ _ector_software_buffer_ector_generic_buffer_unmap(Eo *obj EINA_UNUSED, Ector_Sof
164 pd->map_count--; 171 pd->map_count--;
165} 172}
166 173
167EOLIAN uint8_t * 174EOLIAN static uint8_t *
168_ector_software_buffer_ector_generic_buffer_span_get(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Data *pd, 175_ector_software_buffer_base_ector_generic_buffer_span_get(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd,
169 int x, int y, unsigned int w, Efl_Gfx_Colorspace cspace, 176 int x, int y, unsigned int w, Efl_Gfx_Colorspace cspace,
170 unsigned int *length) 177 unsigned int *length)
171{ 178{
172 uint8_t *src; 179 uint8_t *src;
173 int len, px; 180 int len, px;
174 181
175 if (!pd->pixels.u8) 182 if (!pd->pixels.u8)
176 fail("No pixel data"); 183 fail("No pixel data");
177 if ((x < -pd->generic.l) || (y < -pd->generic.t) || 184 if ((x < -pd->generic->l) || (y < -pd->generic->t) ||
178 ((unsigned) x > pd->generic.w) || ((unsigned) y > pd->generic.h)) 185 ((unsigned) x > pd->generic->w) || ((unsigned) y > pd->generic->h))
179 fail("Out of bounds"); 186 fail("Out of bounds");
180 if (((unsigned) x + w) > (pd->generic.w + pd->generic.l + pd->generic.r)) 187 if (((unsigned) x + w) > (pd->generic->w + pd->generic->l + pd->generic->r))
181 fail("Requested span too large"); 188 fail("Requested span too large");
182 189
183 px = _min_stride_calc(1, pd->generic.cspace); 190 px = _min_stride_calc(1, pd->generic->cspace);
184 len = _min_stride_calc(w, cspace); 191 len = _min_stride_calc(w, cspace);
185 if (length) *length = len; 192 if (length) *length = len;
186 193
187 src = pd->pixels.u8 + ((pd->generic.t + y) * pd->stride) + (px * (pd->generic.l + x)); 194 src = pd->pixels.u8 + ((pd->generic->t + y) * pd->stride) + (px * (pd->generic->l + x));
188 195
189 if (cspace == pd->generic.cspace) 196 if (cspace == pd->generic->cspace)
190 { 197 {
191 pd->span_free = EINA_FALSE; 198 pd->span_free = EINA_FALSE;
192 return src; 199 return src;
193 } 200 }
194 else if ((cspace == EFL_GFX_COLORSPACE_ARGB8888) && 201 else if ((cspace == EFL_GFX_COLORSPACE_ARGB8888) &&
195 (pd->generic.cspace == EFL_GFX_COLORSPACE_GRY8)) 202 (pd->generic->cspace == EFL_GFX_COLORSPACE_GRY8))
196 { 203 {
197 uint32_t *buf = malloc(len); 204 uint32_t *buf = malloc(len);
198 _pixels_gry8_to_argb_convert(buf, src, w); 205 _pixels_gry8_to_argb_convert(buf, src, w);
@@ -200,7 +207,7 @@ _ector_software_buffer_ector_generic_buffer_span_get(Eo *obj EINA_UNUSED, Ector_
200 return (uint8_t *) buf; 207 return (uint8_t *) buf;
201 } 208 }
202 else if ((cspace == EFL_GFX_COLORSPACE_GRY8) && 209 else if ((cspace == EFL_GFX_COLORSPACE_GRY8) &&
203 (pd->generic.cspace == EFL_GFX_COLORSPACE_ARGB8888)) 210 (pd->generic->cspace == EFL_GFX_COLORSPACE_ARGB8888))
204 { 211 {
205 uint8_t *buf = malloc(len); 212 uint8_t *buf = malloc(len);
206 _pixels_argb_to_gry8_convert(buf, (uint32_t *) src, w); 213 _pixels_argb_to_gry8_convert(buf, (uint32_t *) src, w);
@@ -215,16 +222,16 @@ on_fail:
215 return NULL; 222 return NULL;
216} 223}
217 224
218EOLIAN void 225EOLIAN static void
219_ector_software_buffer_ector_generic_buffer_span_free(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Data *pd, 226_ector_software_buffer_base_ector_generic_buffer_span_free(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd,
220 uint8_t *data) 227 uint8_t *data)
221{ 228{
222 if (pd->span_free) free(data); 229 if (pd->span_free) free(data);
223 pd->span_free = EINA_FALSE; 230 pd->span_free = EINA_FALSE;
224} 231}
225 232
226EOLIAN static Ector_Buffer_Flag 233EOLIAN static Ector_Buffer_Flag
227_ector_software_buffer_ector_generic_buffer_flags_get(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Data *pd) 234_ector_software_buffer_base_ector_generic_buffer_flags_get(Eo *obj EINA_UNUSED, Ector_Software_Buffer_Base_Data *pd)
228{ 235{
229 return ECTOR_BUFFER_FLAG_CPU_READABLE | 236 return ECTOR_BUFFER_FLAG_CPU_READABLE |
230 ECTOR_BUFFER_FLAG_CPU_READABLE_FAST | 237 ECTOR_BUFFER_FLAG_CPU_READABLE_FAST |
@@ -234,11 +241,24 @@ _ector_software_buffer_ector_generic_buffer_flags_get(Eo *obj EINA_UNUSED, Ector
234 : 0); 241 : 0);
235} 242}
236 243
244EOLIAN static Eo_Base *
245_ector_software_buffer_eo_base_constructor(Eo *obj, void *data EINA_UNUSED)
246{
247 Ector_Software_Buffer_Base_Data *pd;
248 eo_do_super(obj, MY_CLASS, obj = eo_constructor());
249 pd = eo_data_scope_get(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN);
250 pd->generic = eo_data_ref(obj, ECTOR_GENERIC_BUFFER_MIXIN);
251 pd->generic->eo = obj;
252 return obj;
253}
254
237EOLIAN static void 255EOLIAN static void
238_ector_software_buffer_eo_base_destructor(Eo *obj, Ector_Software_Buffer_Data *pd) 256_ector_software_buffer_eo_base_destructor(Eo *obj, void *data EINA_UNUSED)
239{ 257{
240 _ector_software_buffer_pixels_clear(obj, pd); 258 Ector_Software_Buffer_Base_Data *pd = eo_data_scope_get(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN);
241 eo_do_super(obj, ECTOR_SOFTWARE_BUFFER_CLASS, eo_destructor()); 259 _ector_software_buffer_base_pixels_clear(obj, pd);
260 eo_data_unref(obj, pd->generic);
261 eo_do_super(obj, MY_CLASS, eo_destructor());
242 if (pd->map_count) 262 if (pd->map_count)
243 { 263 {
244 ERR("Pixel data is still mapped during destroy! Check your code!"); 264 ERR("Pixel data is still mapped during destroy! Check your code!");
@@ -246,3 +266,4 @@ _ector_software_buffer_eo_base_destructor(Eo *obj, Ector_Software_Buffer_Data *p
246} 266}
247 267
248#include "ector_software_buffer.eo.c" 268#include "ector_software_buffer.eo.c"
269#include "ector_software_buffer_base.eo.c"
diff --git a/src/lib/ector/software/ector_software_buffer.eo b/src/lib/ector/software/ector_software_buffer.eo
index a2e365a72d..1190dce81a 100644
--- a/src/lib/ector/software/ector_software_buffer.eo
+++ b/src/lib/ector/software/ector_software_buffer.eo
@@ -1,19 +1,9 @@
1class Ector.Software.Buffer (Ector.Generic.Buffer) 1class Ector.Software.Buffer (Eo.Base, Ector.Software.Buffer.Base)
2{ 2{
3 [[A buffer in Ector Software is a readable & optionally writable image]]
4 legacy_prefix: null; 3 legacy_prefix: null;
5 methods { 4 data: null;
6 pixels_clear @protected {
7 [[Clear internal pixel buffer]]
8 }
9 }
10 implements { 5 implements {
6 Eo.Base.constructor;
11 Eo.Base.destructor; 7 Eo.Base.destructor;
12 Ector.Generic.Buffer.flags.get;
13 Ector.Generic.Buffer.pixels_set;
14 Ector.Generic.Buffer.span_get;
15 Ector.Generic.Buffer.span_free;
16 Ector.Generic.Buffer.map;
17 Ector.Generic.Buffer.unmap;
18 } 8 }
19} 9}
diff --git a/src/lib/ector/software/ector_software_buffer_base.eo b/src/lib/ector/software/ector_software_buffer_base.eo
new file mode 100644
index 0000000000..d10df04f1d
--- /dev/null
+++ b/src/lib/ector/software/ector_software_buffer_base.eo
@@ -0,0 +1,19 @@
1mixin Ector.Software.Buffer.Base (Ector.Generic.Buffer)
2{
3 [[A buffer in Ector Software is a readable & optionally writable image]]
4 eo_prefix: ector_software_buffer;
5 legacy_prefix: null;
6 methods {
7 pixels_clear @protected {
8 [[Clear internal pixel buffer]]
9 }
10 }
11 implements {
12 Ector.Generic.Buffer.flags.get;
13 Ector.Generic.Buffer.pixels_set;
14 Ector.Generic.Buffer.span_get;
15 Ector.Generic.Buffer.span_free;
16 Ector.Generic.Buffer.map;
17 Ector.Generic.Buffer.unmap;
18 }
19}
diff --git a/src/lib/ector/software/ector_software_private.h b/src/lib/ector/software/ector_software_private.h
index d0ec1323c6..51b856dabc 100644
--- a/src/lib/ector/software/ector_software_private.h
+++ b/src/lib/ector/software/ector_software_private.h
@@ -1,6 +1,7 @@
1#ifndef ECTOR_SOFTWARE_PRIVATE_H_ 1#ifndef ECTOR_SOFTWARE_PRIVATE_H_
2# define ECTOR_SOFTWARE_PRIVATE_H_ 2# define ECTOR_SOFTWARE_PRIVATE_H_
3 3
4#include "Ector_Software.h"
4#include "sw_ft_raster.h" 5#include "sw_ft_raster.h"
5#include "sw_ft_stroker.h" 6#include "sw_ft_stroker.h"
6#include "../ector_private.h" 7#include "../ector_private.h"
@@ -14,9 +15,14 @@ typedef unsigned int uint;
14#endif 15#endif
15 16
16typedef struct _Ector_Software_Surface_Data Ector_Software_Surface_Data; 17typedef struct _Ector_Software_Surface_Data Ector_Software_Surface_Data;
18typedef struct _Ector_Renderer_Software_Base_Data Ector_Renderer_Software_Base_Data;
17 19
18#define CHECK_SOFTWARE(Parent) (!(Parent && Parent->software)) 20#define CHECK_SOFTWARE(Parent) (!(Parent && Parent->software))
19 21
22struct _Ector_Renderer_Software_Base_Data
23{
24};
25
20// Gradient related structure 26// Gradient related structure
21typedef struct _Software_Gradient_Linear_Data 27typedef struct _Software_Gradient_Linear_Data
22{ 28{
@@ -47,30 +53,6 @@ typedef struct _Ector_Renderer_Software_Gradient_Data
47 uint* color_table; 53 uint* color_table;
48} Ector_Renderer_Software_Gradient_Data; 54} Ector_Renderer_Software_Gradient_Data;
49 55
50
51// Rasterizer related structure
52// FIXME: Merge with Ector_Software_Buffer
53typedef struct _Raster_Buffer
54{
55 int width;
56 int height;
57 DATA32 *buffer;
58} Raster_Buffer;
59
60typedef struct _Ector_Software_Buffer_Data
61{
62 Ector_Generic_Buffer_Data generic;
63 union {
64 unsigned int *u32;
65 unsigned char *u8;
66 } pixels;
67 unsigned int stride;
68 unsigned int map_count;
69 Eina_Bool writable : 1;
70 Eina_Bool nofree : 1; // pixel data should not be free()'ed
71 Eina_Bool span_free : 1;
72} Ector_Software_Buffer_Data;
73
74typedef struct _Shape_Rle_Data 56typedef struct _Shape_Rle_Data
75{ 57{
76 Eina_Rectangle bbox; 58 Eina_Rectangle bbox;
@@ -99,8 +81,7 @@ typedef enum _Span_Data_Type {
99 81
100typedef struct _Span_Data 82typedef struct _Span_Data
101{ 83{
102 Raster_Buffer raster_buffer; 84 Ector_Software_Buffer_Base_Data *raster_buffer;
103
104 SW_FT_SpanFunc blend; 85 SW_FT_SpanFunc blend;
105 SW_FT_SpanFunc unclipped_blend; 86 SW_FT_SpanFunc unclipped_blend;
106 87
@@ -114,7 +95,7 @@ typedef struct _Span_Data
114 union { 95 union {
115 DATA32 color; 96 DATA32 color;
116 Ector_Renderer_Software_Gradient_Data *gradient; 97 Ector_Renderer_Software_Gradient_Data *gradient;
117 Ector_Software_Buffer_Data *buffer; 98 Ector_Software_Buffer_Base_Data *buffer;
118 }; 99 };
119} Span_Data; 100} Span_Data;
120 101
diff --git a/src/lib/ector/software/ector_software_rasterizer.c b/src/lib/ector/software/ector_software_rasterizer.c
index e58d611f40..21bcb94683 100644
--- a/src/lib/ector/software/ector_software_rasterizer.c
+++ b/src/lib/ector/software/ector_software_rasterizer.c
@@ -17,17 +17,18 @@ _blend_color_argb(int count, const SW_FT_Span *spans, void *user_data)
17 RGBA_Comp_Func_Solid comp_func; 17 RGBA_Comp_Func_Solid comp_func;
18 Span_Data *data = (Span_Data *)(user_data); 18 Span_Data *data = (Span_Data *)(user_data);
19 uint color, *buffer, *target; 19 uint color, *buffer, *target;
20 const int pix_stride = data->raster_buffer->stride / 4;
20 21
21 // multiply the color with mul_col if any 22 // multiply the color with mul_col if any
22 color = ECTOR_MUL4_SYM(data->color, data->mul_col); 23 color = ECTOR_MUL4_SYM(data->color, data->mul_col);
23 comp_func = ector_comp_func_solid_span_get(data->op, color); 24 comp_func = ector_comp_func_solid_span_get(data->op, color);
24 25
25 // move to the offset location 26 // move to the offset location
26 buffer = data->raster_buffer.buffer + ((data->raster_buffer.width * data->offy) + data->offx); 27 buffer = data->raster_buffer->pixels.u32 + ((pix_stride * data->offy) + data->offx);
27 28
28 while (count--) 29 while (count--)
29 { 30 {
30 target = buffer + ((data->raster_buffer.width * spans->y) + spans->x); 31 target = buffer + ((pix_stride * spans->y) + spans->x);
31 comp_func(target, spans->len, color, spans->coverage); 32 comp_func(target, spans->len, color, spans->coverage);
32 ++spans; 33 ++spans;
33 } 34 }
@@ -45,6 +46,7 @@ _blend_gradient(int count, const SW_FT_Span *spans, void *user_data)
45 src_fetch fetchfunc = NULL; 46 src_fetch fetchfunc = NULL;
46 unsigned int buffer[BLEND_GRADIENT_BUFFER_SIZE], *target, *destbuffer; 47 unsigned int buffer[BLEND_GRADIENT_BUFFER_SIZE], *target, *destbuffer;
47 int length, l; 48 int length, l;
49 const int pix_stride = data->raster_buffer->stride / 4;
48 50
49 //@TODO, Get the proper composition function using ,color, ECTOR_OP etc. 51 //@TODO, Get the proper composition function using ,color, ECTOR_OP etc.
50 if (data->type == LinearGradient) fetchfunc = &fetch_linear_gradient; 52 if (data->type == LinearGradient) fetchfunc = &fetch_linear_gradient;
@@ -56,11 +58,11 @@ _blend_gradient(int count, const SW_FT_Span *spans, void *user_data)
56 comp_func = ector_comp_func_span_get(data->op, data->mul_col, data->gradient->alpha); 58 comp_func = ector_comp_func_span_get(data->op, data->mul_col, data->gradient->alpha);
57 59
58 // move to the offset location 60 // move to the offset location
59 destbuffer = data->raster_buffer.buffer + ((data->raster_buffer.width * data->offy) + data->offx); 61 destbuffer = data->raster_buffer->pixels.u32 + ((pix_stride * data->offy) + data->offx);
60 62
61 while (count--) 63 while (count--)
62 { 64 {
63 target = destbuffer + ((data->raster_buffer.width * spans->y) + spans->x); 65 target = destbuffer + ((pix_stride * spans->y) + spans->x);
64 length = spans->len; 66 length = spans->len;
65 while (length) 67 while (length)
66 { 68 {
@@ -95,30 +97,31 @@ _blend_image_argb(int count, const SW_FT_Span *spans, void *user_data)
95 DATA32 *buffer, *target; 97 DATA32 *buffer, *target;
96 DATA8 *src8; 98 DATA8 *src8;
97 unsigned int l, length, sy = 0; 99 unsigned int l, length, sy = 0;
100 const int pix_stride = data->raster_buffer->stride / 4;
98 101
99#warning FIXME: Image scaling, anyone? 102#warning FIXME: Image scaling, anyone?
100#warning FIXME: Optimize eo call with early call resolution 103#warning FIXME: Optimize eo call with early call resolution
101 104
102 comp_func = ector_comp_func_span_get(data->op, data->mul_col, EINA_TRUE); 105 comp_func = ector_comp_func_span_get(data->op, data->mul_col, EINA_TRUE);
103 106
104 buffer = data->raster_buffer.buffer + ((data->raster_buffer.width * data->offy) + data->offx); 107 buffer = data->raster_buffer->pixels.u32 + ((pix_stride * data->offy) + data->offx);
105 108
106 while (count--) 109 while (count--)
107 { 110 {
108 target = buffer + ((data->raster_buffer.width * spans->y) + spans->x); 111 target = buffer + ((pix_stride * spans->y) + spans->x);
109 length = spans->len; 112 length = spans->len;
110 while (length) 113 while (length)
111 { 114 {
112 l = MIN(length, data->buffer->generic.w); 115 l = MIN(length, data->buffer->generic->w);
113 eo_do(data->buffer->generic.eo, src8 = ector_buffer_span_get(0, sy, l, EFL_GFX_COLORSPACE_ARGB8888, NULL)); 116 eo_do(data->buffer->generic->eo, src8 = ector_buffer_span_get(0, sy, l, EFL_GFX_COLORSPACE_ARGB8888, NULL));
114 comp_func(target, (DATA32 *) src8, l, data->mul_col, spans->coverage); 117 comp_func(target, (DATA32 *) src8, l, data->mul_col, spans->coverage);
115 eo_do(data->buffer->generic.eo, ector_buffer_span_free(src8)); 118 eo_do(data->buffer->generic->eo, ector_buffer_span_free(src8));
116 target += l; 119 target += l;
117 length -= l; 120 length -= l;
118 } 121 }
119 ++spans; 122 ++spans;
120 ++sy; 123 ++sy;
121 if (sy >= data->buffer->generic.h) 124 if (sy >= data->buffer->generic->h)
122 sy = 0; 125 sy = 0;
123 } 126 }
124} 127}
@@ -327,7 +330,7 @@ _adjust_span_fill_methods(Span_Data *spdata)
327 spdata->unclipped_blend = &_blend_gradient; 330 spdata->unclipped_blend = &_blend_gradient;
328 break; 331 break;
329 case Image: 332 case Image:
330 if (spdata->buffer->generic.cspace == EFL_GFX_COLORSPACE_GRY8) 333 if (spdata->buffer->generic->cspace == EFL_GFX_COLORSPACE_GRY8)
331 spdata->unclipped_blend = &_blend_image_gry8; 334 spdata->unclipped_blend = &_blend_image_gry8;
332 else 335 else
333 spdata->unclipped_blend = &_blend_image_argb; 336 spdata->unclipped_blend = &_blend_image_argb;
@@ -362,7 +365,6 @@ void ector_software_rasterizer_init(Software_Rasterizer *rasterizer)
362 SW_FT_Stroker_Set(rasterizer->stroker, 1<<6,SW_FT_STROKER_LINECAP_BUTT,SW_FT_STROKER_LINEJOIN_MITER,0); 365 SW_FT_Stroker_Set(rasterizer->stroker, 1<<6,SW_FT_STROKER_LINECAP_BUTT,SW_FT_STROKER_LINEJOIN_MITER,0);
363 366
364 //initialize the span data. 367 //initialize the span data.
365 rasterizer->fill_data.raster_buffer.buffer = NULL;
366 rasterizer->fill_data.clip.enabled = EINA_FALSE; 368 rasterizer->fill_data.clip.enabled = EINA_FALSE;
367 rasterizer->fill_data.unclipped_blend = 0; 369 rasterizer->fill_data.unclipped_blend = 0;
368 rasterizer->fill_data.blend = 0; 370 rasterizer->fill_data.blend = 0;
@@ -570,7 +572,7 @@ void ector_software_rasterizer_radial_gradient_set(Software_Rasterizer *rasteriz
570void ector_software_rasterizer_buffer_set(Software_Rasterizer *rasterizer, 572void ector_software_rasterizer_buffer_set(Software_Rasterizer *rasterizer,
571 Ector_Software_Buffer *buffer) 573 Ector_Software_Buffer *buffer)
572{ 574{
573 rasterizer->fill_data.buffer = eo_data_scope_get(buffer, ECTOR_SOFTWARE_BUFFER_CLASS); 575 rasterizer->fill_data.buffer = eo_data_scope_get(buffer, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN);
574 rasterizer->fill_data.type = Image; 576 rasterizer->fill_data.type = Image;
575} 577}
576 578
diff --git a/src/lib/ector/software/ector_software_surface.c b/src/lib/ector/software/ector_software_surface.c
index 4767e4e654..bdd0599610 100644
--- a/src/lib/ector/software/ector_software_surface.c
+++ b/src/lib/ector/software/ector_software_surface.c
@@ -8,10 +8,7 @@
8#include "ector_private.h" 8#include "ector_private.h"
9#include "ector_software_private.h" 9#include "ector_software_private.h"
10 10
11typedef struct _Ector_Renderer_Software_Base_Data Ector_Renderer_Software_Base_Data; 11#define MY_CLASS ECTOR_SOFTWARE_SURFACE_CLASS
12struct _Ector_Renderer_Software_Base_Data
13{
14};
15 12
16static Ector_Renderer * 13static Ector_Renderer *
17_ector_software_surface_ector_generic_surface_renderer_factory_new(Eo *obj, 14_ector_software_surface_ector_generic_surface_renderer_factory_new(Eo *obj,
@@ -34,56 +31,21 @@ _ector_software_surface_ector_generic_surface_renderer_factory_new(Eo *obj,
34 return NULL; 31 return NULL;
35} 32}
36 33
37static void
38_ector_software_surface_context_set(Eo *obj EINA_UNUSED,
39 Ector_Software_Surface_Data *pd,
40 Software_Rasterizer *ctx)
41{
42 pd->software = ctx;
43}
44
45static Software_Rasterizer *
46_ector_software_surface_context_get(Eo *obj EINA_UNUSED,
47 Ector_Software_Surface_Data *pd)
48{
49 return pd->software;
50}
51
52void
53_ector_software_surface_surface_set(Eo *obj EINA_UNUSED,
54 Ector_Software_Surface_Data *pd,
55 void *pixels, unsigned int width, unsigned int height)
56{
57 pd->software->fill_data.raster_buffer.buffer = pixels;
58 pd->software->fill_data.raster_buffer.width = width;
59 pd->software->fill_data.raster_buffer.height = height;
60}
61
62void
63_ector_software_surface_surface_get(Eo *obj EINA_UNUSED,
64 Ector_Software_Surface_Data *pd,
65 void **pixels, unsigned int *width, unsigned int *height)
66{
67 *pixels = pd->software->fill_data.raster_buffer.buffer;
68 *width = pd->software->fill_data.raster_buffer.width;
69 *height = pd->software->fill_data.raster_buffer.height;
70}
71
72static Eo * 34static Eo *
73_ector_software_surface_eo_base_constructor(Eo *obj, 35_ector_software_surface_eo_base_constructor(Eo *obj, Ector_Software_Surface_Data *pd)
74 Ector_Software_Surface_Data *pd EINA_UNUSED)
75{ 36{
76 obj = eo_do_super_ret(obj, ECTOR_SOFTWARE_SURFACE_CLASS, obj, eo_constructor()); 37 obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
77 pd->software = (Software_Rasterizer *) calloc(1, sizeof(Software_Rasterizer)); 38 pd->software = (Software_Rasterizer *) calloc(1, sizeof(Software_Rasterizer));
78 ector_software_rasterizer_init(pd->software); 39 ector_software_rasterizer_init(pd->software);
79 return obj; 40 pd->software->fill_data.raster_buffer = eo_data_ref(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN);
41 return obj;
80} 42}
81 43
82static void 44static void
83_ector_software_surface_eo_base_destructor(Eo *obj EINA_UNUSED, 45_ector_software_surface_eo_base_destructor(Eo *obj, Ector_Software_Surface_Data *pd)
84 Ector_Software_Surface_Data *pd EINA_UNUSED)
85{ 46{
86 ector_software_rasterizer_done(pd->software); 47 ector_software_rasterizer_done(pd->software);
48 eo_data_unref(obj, pd->software->fill_data.raster_buffer);
87 free(pd->software); 49 free(pd->software);
88 pd->software = NULL; 50 pd->software = NULL;
89 eo_do_super(obj, ECTOR_SOFTWARE_SURFACE_CLASS, eo_destructor()); 51 eo_do_super(obj, ECTOR_SOFTWARE_SURFACE_CLASS, eo_destructor());
diff --git a/src/lib/ector/software/ector_software_surface.eo b/src/lib/ector/software/ector_software_surface.eo
index bea11cd9cf..34507e6549 100644
--- a/src/lib/ector/software/ector_software_surface.eo
+++ b/src/lib/ector/software/ector_software_surface.eo
@@ -1,30 +1,8 @@
1class Ector.Software.Surface (Ector.Generic.Surface) 1class Ector.Software.Surface (Ector.Software.Buffer, Ector.Generic.Surface)
2{ 2{
3 eo_prefix: ector_software_surface; 3 eo_prefix: ector_software_surface;
4 legacy_prefix: null; 4 legacy_prefix: null;
5 methods { 5 methods {}
6 @property context {
7 set {
8 }
9 get {
10 }
11 values {
12 ctx: Software_Rasterizer *;
13 }
14 }
15 @property surface {
16 set {
17 }
18 get {
19 }
20 values {
21 pixels: void *;
22 width: uint;
23 height: uint;
24 }
25 }
26 }
27
28 implements { 6 implements {
29 Ector.Generic.Surface.renderer_factory_new; 7 Ector.Generic.Surface.renderer_factory_new;
30 Ector.Generic.Surface.reference_point.set; 8 Ector.Generic.Surface.reference_point.set;