summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-01-18 11:47:25 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-04-14 11:26:43 +0900
commit2ef8d6f39af839c23551239216cea100254f80df (patch)
tree415581d3cb5245012225777926638827051bc3c2 /src/modules
parentfb52c15e8513cc1458341da13e570d231a886551 (diff)
evas filters: Refactor ector and gfx filters A LOT
Alright, so this is a massive patch that is the result of trying to get rid of unused or poorly implemented classes in ector. Originally ector was meant to support VG but extend to things like filters as well. At the moment, ector's design makes it quite hard to plug in the filters. For now I think it's easier to implement the GL support for the filters directly in the engine, where I hope to interfere as little as possible. This massive patch keeps only the required minimum to support a versatile gl buffer that can be mapped, drawn or rendered to (FBO). It's extremely inefficient as it relies on glReadPixels and lots of texture uploads, as well as conversions between ARGB and Alpha. Another type of GL buffer is a wrap around an existing GL image, but that one is read-only (map or draw: no write map, no FBO). No, all the filters run fine, and the high-level implementation (evas_filters.c) does not need to know whether the underlying engine is SW or GL. One problem though appears with the blending or blurring of some Alpha buffers, the colors are wrong. This patch removes more lines than it adds so it must be good ;)
Diffstat (limited to '')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h1
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_image.c61
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_texture.c1
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c344
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo36
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c279
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.eo11
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.c117
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.eo10
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c90
-rw-r--r--src/modules/evas/engines/gl_generic/filters/gl_filter_blend.c37
-rw-r--r--src/modules/evas/engines/software_generic/evas_ector_software_buffer.c60
-rw-r--r--src/modules/evas/engines/software_generic/evas_ector_software_buffer.eo5
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c73
-rw-r--r--src/modules/evas/engines/software_generic/filters/evas_filter_displace.c4
-rw-r--r--src/modules/evas/engines/software_generic/filters/evas_filter_fill.c10
-rw-r--r--src/modules/evas/engines/software_generic/filters/evas_filter_mask.c6
17 files changed, 697 insertions, 448 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h
index ef91f7b9d6..38474bbe35 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -688,6 +688,7 @@ void evas_gl_common_image_dirty(Evas_GL_Image *im, unsigned int x,
688void evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im); 688void evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im);
689void evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int npoints, RGBA_Map_Point *p, int smooth, int level); 689void evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int npoints, RGBA_Map_Point *p, int smooth, int level);
690void evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth); 690void evas_gl_common_image_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth);
691Evas_GL_Image *evas_gl_common_image_surface_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im);
691 692
692void *evas_gl_font_texture_new(void *gc, RGBA_Font_Glyph *fg); 693void *evas_gl_font_texture_new(void *gc, RGBA_Font_Glyph *fg);
693void evas_gl_font_texture_free(void *); 694void evas_gl_font_texture_free(void *);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_image.c b/src/modules/evas/engines/gl_common/evas_gl_image.c
index 3b02db1406..de907be540 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_image.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_image.c
@@ -248,6 +248,8 @@ evas_gl_common_image_new_from_rgbaimage(Evas_Engine_GL_Context *gc, RGBA_Image *
248 } 248 }
249 */ 249 */
250 250
251 if (error) *error = EVAS_LOAD_ERROR_NONE;
252
251 // FIXME: keep unreffed shared images around 253 // FIXME: keep unreffed shared images around
252 EINA_LIST_FOREACH(gc->shared->images, l, im) 254 EINA_LIST_FOREACH(gc->shared->images, l, im)
253 { 255 {
@@ -1039,6 +1041,65 @@ evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im)
1039 } 1041 }
1040} 1042}
1041 1043
1044Evas_GL_Image *
1045evas_gl_common_image_surface_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im)
1046{
1047 Evas_GL_Image *glim = NULL;
1048 Eina_Bool alpha;
1049 int w, h;
1050
1051 if (!gc || !im || !im->im || !im->im->image.data)
1052 goto fail;
1053
1054 if (im->im->cache_entry.space == EFL_GFX_COLORSPACE_ARGB8888)
1055 alpha = EINA_FALSE;
1056 else if (im->im->cache_entry.space == EFL_GFX_COLORSPACE_GRY8)
1057 alpha = EINA_TRUE;
1058 else goto fail;
1059
1060 w = im->im->cache_entry.w;
1061 h = im->im->cache_entry.h;
1062 glim = evas_gl_common_image_surface_new(gc, w, h, EINA_TRUE, EINA_FALSE);
1063 if (!glim) goto fail;
1064
1065 if (alpha)
1066 {
1067 RGBA_Image *image;
1068 uint32_t *rgba;
1069 uint8_t *gry8;
1070 int k;
1071
1072 image = evas_common_image_new(w, h, EINA_TRUE);
1073 if (!image) goto fail;
1074
1075 rgba = image->image.data;
1076 gry8 = im->im->image.data8;
1077 for (k = 0; k < (w * h); k++)
1078 {
1079 const int c = *gry8++;
1080 *rgba++ = ARGB_JOIN(c, c, c, c);
1081 }
1082
1083 glim->im = image;
1084 }
1085 else
1086 {
1087 evas_cache_image_ref(&im->im->cache_entry);
1088 glim->im = im->im;
1089 }
1090
1091 glim->dirty = EINA_TRUE;
1092 evas_gl_common_image_update(gc, glim);
1093 evas_gl_common_image_free(im);
1094
1095 return glim;
1096
1097fail:
1098 ERR("Failed to update surface pixels!");
1099 if (glim) evas_gl_common_image_free(glim);
1100 return NULL;
1101}
1102
1042void 1103void
1043evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im, 1104evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
1044 int npoints, RGBA_Map_Point *p, int smooth, int level EINA_UNUSED) 1105 int npoints, RGBA_Map_Point *p, int smooth, int level EINA_UNUSED)
diff --git a/src/modules/evas/engines/gl_common/evas_gl_texture.c b/src/modules/evas/engines/gl_common/evas_gl_texture.c
index f4d747e331..77c55f593b 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_texture.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_texture.c
@@ -82,6 +82,7 @@ static const struct {
82 { MATCH_FALSE, MATCH_FALSE, EVAS_COLORSPACE_ARGB8888, &rgb_ifmt, &rgb_fmt }, 82 { MATCH_FALSE, MATCH_FALSE, EVAS_COLORSPACE_ARGB8888, &rgb_ifmt, &rgb_fmt },
83#endif 83#endif
84 { MATCH_FALSE, MATCH_ANY, EVAS_COLORSPACE_GRY8, &lum_fmt, &lum_ifmt }, 84 { MATCH_FALSE, MATCH_ANY, EVAS_COLORSPACE_GRY8, &lum_fmt, &lum_ifmt },
85 { MATCH_TRUE, MATCH_ANY, EVAS_COLORSPACE_GRY8, &alpha_fmt, &alpha_ifmt },
85 { MATCH_TRUE, MATCH_ANY, EVAS_COLORSPACE_AGRY88, &lum_alpha_fmt, &lum_alpha_ifmt }, 86 { MATCH_TRUE, MATCH_ANY, EVAS_COLORSPACE_AGRY88, &lum_alpha_fmt, &lum_alpha_ifmt },
86 // ETC1/2 support 87 // ETC1/2 support
87 { MATCH_FALSE, MATCH_ANY, EVAS_COLORSPACE_ETC1, &etc1_fmt, &etc1_fmt }, 88 { MATCH_FALSE, MATCH_ANY, EVAS_COLORSPACE_ETC1, &etc1_fmt, &etc1_fmt },
diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c
index 4736e6592c..ef8999e160 100644
--- a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c
@@ -2,13 +2,357 @@
2# include "config.h" 2# include "config.h"
3#endif 3#endif
4 4
5#define ECTOR_GL_BUFFER_BASE_PROTECTED
6
7#include "evas_common_private.h"
8#include "evas_gl_private.h"
9
5#include <gl/Ector_GL.h> 10#include <gl/Ector_GL.h>
6#include "gl/ector_gl_private.h" 11#include "gl/ector_gl_private.h"
7#include "evas_common_private.h" 12#include "evas_common_private.h"
13#include "../gl_common/evas_gl_common.h"
14#include "evas_private.h"
8#include "ector_buffer.h" 15#include "ector_buffer.h"
16#include "Evas_Engine_GL_Generic.h"
17
9#include "evas_ector_buffer.eo.h" 18#include "evas_ector_buffer.eo.h"
10#include "evas_ector_gl_buffer.eo.h" 19#include "evas_ector_gl_buffer.eo.h"
11 20
12#define MY_CLASS EVAS_ECTOR_GL_BUFFER_CLASS 21#define MY_CLASS EVAS_ECTOR_GL_BUFFER_CLASS
13 22
23typedef struct _Ector_GL_Buffer_Map Ector_GL_Buffer_Map;
24typedef struct _Evas_Ector_GL_Buffer_Data Evas_Ector_GL_Buffer_Data;
25
26struct _Ector_GL_Buffer_Map
27{
28 EINA_INLIST;
29 void *ptr;
30 unsigned int base_size; // in bytes
31 unsigned int x, y, w, h;
32 void *image_data, *base_data;
33 size_t length;
34 Efl_Gfx_Colorspace cspace;
35 Evas_GL_Image *im;
36 Eina_Bool allocated;
37 Ector_Buffer_Access_Flag mode;
38};
39
40struct _Evas_Ector_GL_Buffer_Data
41{
42 Evas_Public_Data *evas;
43 Evas_GL_Image *glim;
44 Eina_Bool alpha_only;
45 Ector_GL_Buffer_Map *maps;
46};
47
48#define ENFN pd->evas->engine.func
49#define ENDT pd->evas->engine.data.output
50
51// testing out some macros to maybe add to eina
52#define EINA_INLIST_REMOVE(l,i) do { l = (__typeof__(l)) eina_inlist_remove(EINA_INLIST_GET(l), EINA_INLIST_GET(i)); } while (0)
53#define EINA_INLIST_APPEND(l,i) do { l = (__typeof__(l)) eina_inlist_append(EINA_INLIST_GET(l), EINA_INLIST_GET(i)); } while (0)
54#define EINA_INLIST_PREPEND(l,i) do { l = (__typeof__(l)) eina_inlist_prepend(EINA_INLIST_GET(l), EINA_INLIST_GET(i)); } while (0)
55
56#define fail(fmt, ...) do { ERR(fmt, ##__VA_ARGS__); goto on_fail; } while (0)
57
58/* FIXME: Conversion routines don't belong here */
59static inline void
60_pixels_argb_to_gry8_convert(uint8_t *dst, const uint32_t *src, int len)
61{
62 int k;
63 for (k = 0; k < len; k++)
64 {
65 const uint32_t *s = src++;
66 *dst++ = A_VAL(s);
67 }
68}
69
70static inline void
71_pixels_gry8_to_argb_convert(uint32_t *dst, const uint8_t *src, int len)
72{
73 int k;
74 for (k = 0; k < len; k++)
75 {
76 const uint8_t s = *src++;
77 *dst++ = ARGB_JOIN(s, s, s, s);
78 }
79}
80
81static inline Eina_Bool
82_evas_gl_image_is_fbo(Evas_GL_Image *glim)
83{
84 return glim && glim->tex && glim->tex->pt && glim->tex->pt->fb;
85}
86
87EOLIAN static void
88_evas_ector_gl_buffer_gl_buffer_prepare(Eo *obj, Evas_Ector_GL_Buffer_Data *pd,
89 Evas_Canvas *eo_evas,
90 int w, int h, Efl_Gfx_Colorspace cspace,
91 Ector_Buffer_Flag flags EINA_UNUSED)
92{
93 Render_Engine_GL_Generic *re;
94 Evas_Engine_GL_Context *gc;
95 Evas_GL_Image *im;
96
97 // this is meant to be called only once
98 EINA_SAFETY_ON_FALSE_GOTO(!pd->evas, on_fail);
99 EINA_SAFETY_ON_FALSE_GOTO(!efl_finalized_get(obj), on_fail);
100
101 if (cspace == EFL_GFX_COLORSPACE_ARGB8888)
102 pd->alpha_only = EINA_FALSE;
103 else if (cspace == EFL_GFX_COLORSPACE_GRY8)
104 pd->alpha_only = EINA_TRUE;
105 else
106 fail("Unsupported colorspace: %u", cspace);
107
108 pd->evas = efl_data_xref(eo_evas, EVAS_CANVAS_CLASS, obj);
109 re = pd->evas->engine.data.output;
110 gc = re->window_gl_context_get(re->software.ob);
111
112 im = evas_gl_common_image_surface_new(gc, w, h, EINA_TRUE, EINA_FALSE);
113 if (!im) fail("Failed to create GL surface!");
114
115 pd->glim = im;
116 return;
117
118on_fail:
119 if (pd->glim) evas_gl_common_image_free(pd->glim);
120 pd->glim = NULL;
121}
122
123EOLIAN static void *
124_evas_ector_gl_buffer_evas_ector_buffer_drawable_image_get(Eo *obj EINA_UNUSED,
125 Evas_Ector_GL_Buffer_Data *pd,
126 Eina_Bool update)
127{
128 Render_Engine_GL_Generic *re = pd->evas->engine.data.output;
129 Evas_Engine_GL_Context *gc;
130
131 if (pd->maps != NULL)
132 fail("Image is currently mapped!");
133
134 evas_gl_common_image_ref(pd->glim);
135 if (!update) return pd->glim;
136
137 gc = re->window_gl_context_get(re->software.ob);
138 evas_gl_common_image_update(gc, pd->glim);
139
140 return pd->glim;
141
142on_fail:
143 return NULL;
144}
145
146EOLIAN static void *
147_evas_ector_gl_buffer_evas_ector_buffer_render_image_get(Eo *obj EINA_UNUSED,
148 Evas_Ector_GL_Buffer_Data *pd,
149 Eina_Bool update)
150{
151 Render_Engine_GL_Generic *re = pd->evas->engine.data.output;
152 Evas_Engine_GL_Context *gc;
153
154 if (pd->maps != NULL)
155 fail("Image is currently mapped!");
156
157 evas_gl_common_image_ref(pd->glim);
158 if (!update) return pd->glim;
159
160 gc = re->window_gl_context_get(re->software.ob);
161 evas_gl_common_image_update(gc, pd->glim);
162
163 return pd->glim;
164
165on_fail:
166 return NULL;
167}
168
169EOLIAN static Eina_Bool
170_evas_ector_gl_buffer_evas_ector_buffer_engine_image_release(Eo *obj EINA_UNUSED,
171 Evas_Ector_GL_Buffer_Data *pd,
172 void *image)
173{
174 EINA_SAFETY_ON_NULL_RETURN_VAL(image, EINA_FALSE);
175 EINA_SAFETY_ON_FALSE_RETURN_VAL(pd->glim == image, EINA_FALSE);
176
177 evas_gl_common_image_free(pd->glim);
178
179 return EINA_TRUE;
180}
181
182EOLIAN static void
183_evas_ector_gl_buffer_ector_buffer_size_get(Eo *obj EINA_UNUSED,
184 Evas_Ector_GL_Buffer_Data *pd,
185 int *w, int *h)
186{
187 if (w) *w = pd->glim->w;
188 if (h) *h = pd->glim->h;
189}
190
191EOLIAN static Efl_Gfx_Colorspace
192_evas_ector_gl_buffer_ector_buffer_cspace_get(Eo *obj EINA_UNUSED,
193 Evas_Ector_GL_Buffer_Data *pd)
194{
195 if (pd->alpha_only)
196 return EFL_GFX_COLORSPACE_GRY8;
197 else
198 return EFL_GFX_COLORSPACE_ARGB8888;
199}
200
201EOLIAN static Ector_Buffer_Flag
202_evas_ector_gl_buffer_ector_buffer_flags_get(Eo *obj EINA_UNUSED,
203 Evas_Ector_GL_Buffer_Data *pd EINA_UNUSED)
204{
205 return ECTOR_BUFFER_FLAG_CPU_READABLE | ECTOR_BUFFER_FLAG_DRAWABLE |
206 ECTOR_BUFFER_FLAG_CPU_WRITABLE | ECTOR_BUFFER_FLAG_RENDERABLE;
207}
208
209EOLIAN static void *
210_evas_ector_gl_buffer_ector_buffer_map(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buffer_Data *pd,
211 unsigned int *length,
212 Ector_Buffer_Access_Flag mode,
213 unsigned int x, unsigned int y, unsigned int w, unsigned int h,
214 Efl_Gfx_Colorspace cspace, unsigned int *stride)
215{
216 Eina_Bool write = !!(mode & ECTOR_BUFFER_ACCESS_FLAG_WRITE);
217 Ector_GL_Buffer_Map *map = NULL;
218 Eina_Bool tofree = EINA_FALSE;
219 Evas_GL_Image *im = NULL;
220 unsigned int W, H;
221 int len, err;
222 uint32_t *data;
223 int pxs;
224
225 W = pd->glim->w;
226 H = pd->glim->h;
227 if (!w) w = W - x;
228 if (!h) h = H - y;
229 if ((x + w > W) || (y + h > H)) return NULL;
230
231 if (write && _evas_gl_image_is_fbo(pd->glim))
232 {
233 // Can not open FBO data to write!
234 im = ENFN->image_data_get(ENDT, pd->glim, EINA_FALSE, &data, &err, &tofree);
235 if (!im) return NULL;
236 }
237 else
238 {
239 im = ENFN->image_data_get(ENDT, pd->glim, write, &data, &err, &tofree);
240 if (!im) return NULL;
241 }
242
243 map = calloc(1, sizeof(*map));
244 map->mode = mode;
245 map->cspace = cspace;
246 map->x = x;
247 map->y = y;
248 map->w = w;
249 map->h = h;
250 map->image_data = data;
251 map->im = tofree ? im : NULL;
252
253 len = W * H;
254 if (cspace == EFL_GFX_COLORSPACE_GRY8)
255 {
256 uint8_t *data8 = malloc(len);
257
258 if (!data8) goto on_fail;
259 _pixels_argb_to_gry8_convert(data8, data, len);
260 map->allocated = EINA_TRUE;
261 map->base_data = data8;
262 map->ptr = data8 + x + (y * W);
263 pxs = 1;
264 }
265 else
266 {
267 map->allocated = EINA_FALSE;
268 map->base_data = data;
269 map->ptr = data + x + (y * W);
270 pxs = 4;
271 }
272
273 map->base_size = len * pxs;
274 map->length = (W * h + w - W) * pxs;
275 if (stride) *stride = W * pxs;
276 if (length) *length = map->length;
277
278 EINA_INLIST_PREPEND(pd->maps, map);;
279 return map->ptr;
280
281on_fail:
282 free(map);
283 return NULL;
284}
285
286EOLIAN static void
287_evas_ector_gl_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Buffer_Data *pd,
288 void *data, unsigned int length)
289{
290 Ector_GL_Buffer_Map *map;
291 if (!data) return;
292
293 EINA_INLIST_FOREACH(pd->maps, map)
294 {
295 if ((map->ptr == data) && (map->length == length))
296 {
297 EINA_INLIST_REMOVE(pd->maps, map);
298 if (map->mode & ECTOR_BUFFER_ACCESS_FLAG_WRITE)
299 {
300 Render_Engine_GL_Generic *re = pd->evas->engine.data.output;
301 Evas_GL_Image *old_glim = pd->glim;
302 Evas_Engine_GL_Context *gc;
303 int W, H;
304
305 W = pd->glim->w;
306 H = pd->glim->h;
307 gc = re->window_gl_context_get(re->software.ob);
308
309 if (map->cspace == EFL_GFX_COLORSPACE_GRY8)
310 _pixels_gry8_to_argb_convert(map->image_data, map->base_data, W * H);
311
312 if (map->im)
313 {
314 pd->glim = evas_gl_common_image_surface_update(gc, map->im);
315 evas_gl_common_image_free(old_glim);
316 }
317 else
318 {
319 pd->glim = evas_gl_common_image_surface_update(gc, old_glim);
320 }
321 }
322 else
323 {
324 if (map->im)
325 ENFN->image_free(ENDT, map->im);
326 else
327 ENFN->image_data_put(ENDT, pd->glim, map->image_data);
328 }
329 if (map->allocated)
330 free(map->base_data);
331 free(map);
332 return;
333 }
334 }
335
336 ERR("Tried to unmap a non-mapped region!");
337}
338
339EOLIAN static Efl_Object *
340_evas_ector_gl_buffer_efl_object_finalize(Eo *obj, Evas_Ector_GL_Buffer_Data *pd)
341{
342 if (!pd->glim)
343 {
344 ERR("Buffer was not initialized properly!");
345 return NULL;
346 }
347 return efl_finalize(efl_super(obj, MY_CLASS));
348}
349
350EOLIAN static void
351_evas_ector_gl_buffer_efl_object_destructor(Eo *obj, Evas_Ector_GL_Buffer_Data *pd)
352{
353 evas_gl_common_image_free(pd->glim);
354 efl_data_xunref(pd->evas->evas, pd->evas, obj);
355 efl_destructor(efl_super(obj, MY_CLASS));
356}
357
14#include "evas_ector_gl_buffer.eo.c" 358#include "evas_ector_gl_buffer.eo.c"
diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo
index 417ee53136..6c6bdc03b9 100644
--- a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo
@@ -1,5 +1,35 @@
1class Evas.Ector.GL.Buffer (Efl.Object, Evas.Ector.Buffer, Ector.GL.Buffer.Base) 1class Evas.Ector.GL.Buffer (Efl.Object, Evas.Ector.Buffer, Ector.GL.Buffer)
2{ 2{
3 [[Evas ector GL buffer class]] 3 [[An Ector GL buffer capable of being mapped, drawn and rendered to.
4 data: null; 4
5 Potentially very inefficient (may rely on glReadPixels).
6 ]]
7 methods {
8 gl_buffer_prepare {
9 [[Set the main properties to create a gl buffer.]]
10 params {
11 evas: Evas.Canvas; [[The current canvas]]
12 w: int; [[Width]]
13 h: int; [[Height]]
14 cspace: Efl.Gfx.Colorspace; [[Alpha or RGBA]]
15 flags: Ector.Buffer.Flag; [[Required buffer capabilities
16 (map/draw/render, etc...)]]
17 }
18 }
19 }
20 constructors {
21 .gl_buffer_prepare;
22 }
23 implements {
24 Efl.Object.finalize;
25 Efl.Object.destructor;
26 Evas.Ector.Buffer.drawable_image_get;
27 Evas.Ector.Buffer.render_image_get;
28 Evas.Ector.Buffer.engine_image_release;
29 Ector.Buffer.size { get; }
30 Ector.Buffer.cspace { get; }
31 Ector.Buffer.flags { get; }
32 Ector.Buffer.map;
33 Ector.Buffer.unmap;
34 }
5} 35}
diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c b/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c
index 4625071d8c..647f7cc7df 100644
--- a/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c
@@ -2,14 +2,20 @@
2# include "config.h" 2# include "config.h"
3#endif 3#endif
4 4
5/* this one is read-only buffer wrapping an existing evas_gl_image */
6
5#define ECTOR_GL_BUFFER_BASE_PROTECTED 7#define ECTOR_GL_BUFFER_BASE_PROTECTED
6 8
9#include "evas_common_private.h"
10#include "evas_gl_private.h"
11
7#include <gl/Ector_GL.h> 12#include <gl/Ector_GL.h>
8#include "gl/ector_gl_private.h" 13#include "gl/ector_gl_private.h"
9#include "evas_common_private.h" 14#include "evas_common_private.h"
10#include "../gl_common/evas_gl_common.h" 15#include "../gl_common/evas_gl_common.h"
11#include "evas_private.h" 16#include "evas_private.h"
12#include "ector_buffer.h" 17#include "ector_buffer.h"
18#include "Evas_Engine_GL_Generic.h"
13 19
14#include "evas_ector_buffer.eo.h" 20#include "evas_ector_buffer.eo.h"
15#include "evas_ector_gl_buffer.eo.h" 21#include "evas_ector_gl_buffer.eo.h"
@@ -17,30 +23,36 @@
17 23
18#define MY_CLASS EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS 24#define MY_CLASS EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS
19 25
20typedef struct _Ector_GL_Buffer_Map 26typedef struct _Ector_GL_Buffer_Map Ector_GL_Buffer_Map;
27typedef struct _Evas_Ector_GL_Image_Buffer_Data Evas_Ector_GL_Image_Buffer_Data;
28
29struct _Ector_GL_Buffer_Map
21{ 30{
22 EINA_INLIST; 31 EINA_INLIST;
23 void *ptr; 32 void *ptr;
24 unsigned int size; // in bytes 33 unsigned int base_size; // in bytes
25 unsigned int x, y, w, h; 34 unsigned int x, y, w, h;
35 void *image_data, *base_data;
36 size_t length;
26 Efl_Gfx_Colorspace cspace; 37 Efl_Gfx_Colorspace cspace;
27 Evas_GL_Image *im; 38 Evas_GL_Image *im;
28 Eina_Bool allocated; 39 Eina_Bool allocated, free_image;
29 Ector_Buffer_Access_Flag mode; 40 Ector_Buffer_Access_Flag mode;
30} Ector_GL_Buffer_Map; 41};
31 42
32typedef struct 43struct _Evas_Ector_GL_Image_Buffer_Data
33{ 44{
34 Ector_GL_Buffer_Base_Data *base; 45 Evas_Public_Data *evas;
35 Evas *evas; 46 Evas_GL_Image *glim;
36 Evas_GL_Image *image; 47 Ector_GL_Buffer_Map *maps;
37 struct { 48};
38 Eina_Inlist *maps; // Ector_GL_Buffer_Map
39 } internal;
40} Evas_Ector_GL_Image_Buffer_Data;
41 49
42#define ENFN e->engine.func 50#define ENFN pd->evas->engine.func
43#define ENDT e->engine.data.output 51#define ENDT pd->evas->engine.data.output
52
53// testing out some macros to maybe add to eina
54#define EINA_INLIST_REMOVE(l,i) do { l = (__typeof__(l)) eina_inlist_remove(EINA_INLIST_GET(l), EINA_INLIST_GET(i)); } while (0)
55#define EINA_INLIST_APPEND(l,i) do { l = (__typeof__(l)) eina_inlist_append(EINA_INLIST_GET(l), EINA_INLIST_GET(i)); } while (0)
44 56
45/* FIXME: Conversion routines don't belong here */ 57/* FIXME: Conversion routines don't belong here */
46static inline void 58static inline void
@@ -58,92 +70,99 @@ EOLIAN static void
58_evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd, 70_evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd,
59 Evas *evas, void *image) 71 Evas *evas, void *image)
60{ 72{
61 Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
62 Evas_GL_Image *im = image; 73 Evas_GL_Image *im = image;
63 int l = 0, r = 0, t = 0, b = 0;
64
65 if (pd->base->generic->immutable)
66 {
67 CRI("Can't set image after finalize");
68 return;
69 }
70 74
71 pd->evas = efl_xref(evas, obj); 75 EINA_SAFETY_ON_FALSE_RETURN(!pd->glim);
72 EINA_SAFETY_ON_NULL_RETURN(im); 76 EINA_SAFETY_ON_NULL_RETURN(im);
73 77
74 if (im->tex && im->tex->pt) 78 pd->evas = efl_data_xref(evas, EVAS_CANVAS_CLASS, obj);
75 { 79 evas_gl_common_image_ref(im);
76 if (im->im) 80 pd->glim = im;
77 { 81}
78 l = im->im->cache_entry.borders.l;
79 r = im->im->cache_entry.borders.r;
80 t = im->im->cache_entry.borders.t;
81 b = im->im->cache_entry.borders.b;
82 }
83 else
84 {
85 // always 1 pixel border, except FBO
86 if (!im->tex->pt->fb)
87 l = r = t = b = 1;
88 }
89 82
90 pd->image = ENFN->image_ref(ENDT, im); 83EOLIAN static void *
91 ector_gl_buffer_base_attach(obj, im->tex->pt->texture, im->tex->pt->fb, (Efl_Gfx_Colorspace) evas_gl_common_gl_format_to_colorspace(im->tex->pt->format), im->tex->w, im->tex->h, im->tex->x, im->tex->y, im->tex->pt->w, im->tex->pt->h, l, r, t, b); 84_evas_ector_gl_image_buffer_evas_ector_buffer_drawable_image_get(Eo *obj EINA_UNUSED,
92 } 85 Evas_Ector_GL_Image_Buffer_Data *pd,
93 else 86 Eina_Bool update EINA_UNUSED)
94 { 87{
95 // FIXME: This might be required to support texture upload here 88 evas_gl_common_image_ref(pd->glim);
96 ERR("Image has no attached texture! Unsupported!"); 89 return pd->glim;
97 pd->image = NULL;
98 }
99} 90}
100 91
101EOLIAN static void 92EOLIAN static Eina_Bool
102_evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_get(Eo *obj EINA_UNUSED, 93_evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_release(Eo *obj EINA_UNUSED,
103 Evas_Ector_GL_Image_Buffer_Data *pd, 94 Evas_Ector_GL_Image_Buffer_Data *pd,
104 Evas **evas, void **image) 95 void *image)
105{ 96{
106 if (evas) *evas = pd->evas; 97 EINA_SAFETY_ON_NULL_RETURN_VAL(image, EINA_FALSE);
107 if (image) *image = pd->image; 98 EINA_SAFETY_ON_FALSE_RETURN_VAL(pd->glim == image, EINA_FALSE);
99
100 evas_gl_common_image_free(pd->glim);
101 return EINA_TRUE;
108} 102}
109 103
110EOLIAN static Ector_Buffer_Flag 104EOLIAN static Ector_Buffer_Flag
111_evas_ector_gl_image_buffer_ector_buffer_flags_get(Eo *obj EINA_UNUSED, 105_evas_ector_gl_image_buffer_ector_buffer_flags_get(Eo *obj EINA_UNUSED,
112 Evas_Ector_GL_Image_Buffer_Data *pd) 106 Evas_Ector_GL_Image_Buffer_Data *pd EINA_UNUSED)
113{ 107{
114 Ector_Buffer_Flag flags; 108 return ECTOR_BUFFER_FLAG_CPU_READABLE | ECTOR_BUFFER_FLAG_DRAWABLE;
115 109}
116 if (!pd->image) return 0;
117 110
118 flags = ECTOR_BUFFER_FLAG_CPU_READABLE; 111EOLIAN static void
119 if (pd->image->tex) 112_evas_ector_gl_image_buffer_ector_buffer_size_get(Eo *obj EINA_UNUSED,
120 { 113 Evas_Ector_GL_Image_Buffer_Data *pd,
121 flags |= ECTOR_BUFFER_FLAG_DRAWABLE; 114 int *w, int *h)
122 if (pd->image->tex->pt->fb) 115{
123 flags |= ECTOR_BUFFER_FLAG_RENDERABLE; 116 if (w) *w = pd->glim->w;
124 } 117 if (h) *h = pd->glim->h;
125 if (pd->image->im) 118}
126 flags |= ECTOR_BUFFER_FLAG_CPU_WRITABLE;
127 119
128 return flags; 120EOLIAN static Efl_Gfx_Colorspace
121_evas_ector_gl_image_buffer_ector_buffer_cspace_get(Eo *obj EINA_UNUSED,
122 Evas_Ector_GL_Image_Buffer_Data *pd EINA_UNUSED)
123{
124 return EFL_GFX_COLORSPACE_ARGB8888;
129} 125}
130 126
131EOLIAN static void * 127EOLIAN static void *
132_evas_ector_gl_image_buffer_ector_buffer_map(Eo *obj EINA_UNUSED, Evas_Ector_GL_Image_Buffer_Data *pd, unsigned int *length, 128_evas_ector_gl_image_buffer_ector_buffer_map(Eo *obj EINA_UNUSED, Evas_Ector_GL_Image_Buffer_Data *pd, unsigned int *length,
133 Ector_Buffer_Access_Flag mode, 129 Ector_Buffer_Access_Flag mode,
134 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,
135 Efl_Gfx_Colorspace cspace, unsigned int *stride) 131 Efl_Gfx_Colorspace cspace, unsigned int *stride)
136{ 132{
137 Evas_Public_Data *e = efl_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
138 Ector_GL_Buffer_Map *map = NULL; 133 Ector_GL_Buffer_Map *map = NULL;
139 Eina_Bool tofree = EINA_FALSE; 134 Eina_Bool tofree = EINA_FALSE;
140 Evas_GL_Image *im; 135 Evas_GL_Image *im = NULL;
141 uint32_t *data; 136 unsigned int W, H;
142 int len, err; 137 int len, err;
138 uint32_t *data;
139 int pxs;
140
141 if ((cspace != EFL_GFX_COLORSPACE_GRY8) && (cspace != EFL_GFX_COLORSPACE_ARGB8888))
142 {
143 ERR("Unsupported colorspace for map: %d", (int) cspace);
144 return NULL;
145 }
146
147 if (mode == EFL_GFX_BUFFER_ACCESS_MODE_NONE)
148 {
149 ERR("Invalid access mode for map (none)");
150 return NULL;
151 }
152
153 if (mode & EFL_GFX_BUFFER_ACCESS_MODE_WRITE)
154 {
155 ERR("%s does not support write access for map", efl_class_name_get(MY_CLASS));
156 return NULL;
157 }
143 158
144 im = ENFN->image_data_get(ENDT, pd->image, 159 W = pd->glim->w;
145 mode & ECTOR_BUFFER_ACCESS_FLAG_WRITE, 160 H = pd->glim->h;
146 &data, &err, &tofree); 161 if (!w) w = W - x;
162 if (!h) h = H - y;
163 if ((x + w > W) || (y + h > H)) return NULL;
164
165 im = ENFN->image_data_get(ENDT, pd->glim, EINA_FALSE, &data, &err, &tofree);
147 if (!im) return NULL; 166 if (!im) return NULL;
148 167
149 map = calloc(1, sizeof(*map)); 168 map = calloc(1, sizeof(*map));
@@ -153,111 +172,89 @@ _evas_ector_gl_image_buffer_ector_buffer_map(Eo *obj EINA_UNUSED, Evas_Ector_GL_
153 map->y = y; 172 map->y = y;
154 map->w = w; 173 map->w = w;
155 map->h = h; 174 map->h = h;
156 map->ptr = data; 175 map->image_data = data;
157 176 map->im = im;
158 if (tofree) 177 map->free_image = tofree;
159 map->im = im;
160 else
161 map->im = NULL;
162 178
163 len = w * h; 179 len = W * H;
164 if (cspace == EFL_GFX_COLORSPACE_GRY8) 180 if (cspace == EFL_GFX_COLORSPACE_GRY8)
165 { 181 {
166 uint8_t *data8 = malloc(len); 182 uint8_t *data8 = malloc(len);
183
184 if (!data8) goto fail;
167 _pixels_argb_to_gry8_convert(data8, data, len); 185 _pixels_argb_to_gry8_convert(data8, data, len);
168 map->allocated = EINA_TRUE; 186 map->allocated = EINA_TRUE;
169 map->ptr = data8; 187 map->base_data = data8;
170 map->size = len; 188 map->ptr = data8 + x + (y * W);
171 if (stride) *stride = w; 189 pxs = 1;
172 } 190 }
173 else 191 else
174 { 192 {
175 map->allocated = EINA_FALSE; 193 map->allocated = EINA_FALSE;
176 map->ptr = data; 194 map->base_data = data;
177 map->size = len * 4; 195 map->ptr = data + x + (y * W);
178 if (stride) *stride = w * 4; 196 pxs = 4;
179 } 197 }
180 198
181 if (length) *length = map->size; 199 map->base_size = len * pxs;
200 map->length = (W * h + w - W) * pxs;
201 if (stride) *stride = W * pxs;
202 if (length) *length = map->length;
182 203
183 pd->internal.maps = eina_inlist_prepend(pd->internal.maps, EINA_INLIST_GET(map)); 204 if (!tofree)
205 pd->glim = im;
206
207 EINA_INLIST_APPEND(pd->maps, map);
184 return map->ptr; 208 return map->ptr;
209
210fail:
211 free(map);
212 return NULL;
185} 213}
186 214
187EOLIAN static void 215EOLIAN static void
188_evas_ector_gl_image_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Image_Buffer_Data *pd, 216_evas_ector_gl_image_buffer_ector_buffer_unmap(Eo *obj EINA_UNUSED,
189 void *data, unsigned int length) 217 Evas_Ector_GL_Image_Buffer_Data *pd,
218 void *data, unsigned int length)
190{ 219{
191 Evas_Public_Data *e = efl_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
192 Ector_GL_Buffer_Map *map; 220 Ector_GL_Buffer_Map *map;
193 if (!data) return; 221 if (!data) return;
194 222
195 EINA_INLIST_FOREACH(pd->internal.maps, map) 223 EINA_INLIST_FOREACH(pd->maps, map)
196 { 224 {
197 if ((map->ptr == data) && ((map->size == length) || (length == (unsigned int) -1))) 225 if ((map->base_data == data) && (map->length == length))
198 { 226 {
199 pd->internal.maps = eina_inlist_remove(pd->internal.maps, EINA_INLIST_GET(map)); 227 EINA_INLIST_REMOVE(pd->maps, map);
200 if (map->mode & ECTOR_BUFFER_ACCESS_FLAG_WRITE) 228 if (map->free_image)
201 {
202 CRI("Not implemented yet. Dropping pixel changes.");
203 }
204 if (map->im)
205 ENFN->image_free(ENDT, map->im); 229 ENFN->image_free(ENDT, map->im);
230 else
231 ENFN->image_data_put(ENDT, map->im, map->image_data);
206 if (map->allocated) 232 if (map->allocated)
207 free(map->ptr); 233 free(map->base_data);
234 free(map);
208 return; 235 return;
209 } 236 }
210 } 237 }
211 238
212 CRI("Tried to unmap a non-mapped region!"); 239 ERR("Tried to unmap a non-mapped region: %p +%u", data, length);
213}
214
215EOLIAN static uint8_t *
216_evas_ector_gl_image_buffer_ector_buffer_span_get(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd, int x, int y, unsigned int w,
217 Efl_Gfx_Colorspace cspace, unsigned int *length)
218{
219 // ector_buffer_map
220 return _evas_ector_gl_image_buffer_ector_buffer_map
221 (obj, pd, length, ECTOR_BUFFER_ACCESS_FLAG_READ, x, y, w, 1, cspace, NULL);
222}
223
224EOLIAN static void
225_evas_ector_gl_image_buffer_ector_buffer_span_free(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd, uint8_t *data)
226{
227 // ector_buffer_unmap
228 return _evas_ector_gl_image_buffer_ector_buffer_unmap
229 (obj, pd, data, (unsigned int) -1);
230}
231
232
233EOLIAN static Efl_Object *
234_evas_ector_gl_image_buffer_efl_object_constructor(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd)
235{
236 obj = efl_constructor(efl_super(obj, MY_CLASS));
237 pd->base = efl_data_ref(obj, ECTOR_GL_BUFFER_BASE_MIXIN);
238 pd->base->generic = efl_data_ref(obj, ECTOR_BUFFER_MIXIN);
239 pd->base->generic->eo = obj;
240 return obj;
241} 240}
242 241
243EOLIAN static Efl_Object * 242EOLIAN static Efl_Object *
244_evas_ector_gl_image_buffer_efl_object_finalize(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd) 243_evas_ector_gl_image_buffer_efl_object_finalize(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd)
245{ 244{
246 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->base, NULL); 245 if (!pd->glim)
247 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->image, NULL); 246 {
248 pd->base->generic->immutable = EINA_TRUE; 247 ERR("Buffer was not initialized properly!");
248 return NULL;
249 }
249 return efl_finalize(efl_super(obj, MY_CLASS)); 250 return efl_finalize(efl_super(obj, MY_CLASS));
250} 251}
251 252
252EOLIAN static void 253EOLIAN static void
253_evas_ector_gl_image_buffer_efl_object_destructor(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd) 254_evas_ector_gl_image_buffer_efl_object_destructor(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd)
254{ 255{
255 Evas_Public_Data *e = efl_data_scope_get(pd->evas, EVAS_CANVAS_CLASS); 256 evas_gl_common_image_free(pd->glim);
256 257 efl_data_xunref(pd->evas->evas, pd->evas, obj);
257 efl_data_unref(obj, pd->base->generic);
258 efl_data_unref(obj, pd->base);
259 ENFN->image_free(ENDT, pd->image);
260 efl_xunref(pd->evas, obj);
261 efl_destructor(efl_super(obj, MY_CLASS)); 258 efl_destructor(efl_super(obj, MY_CLASS));
262} 259}
263 260
diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.eo b/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.eo
index eff9d82984..ccf1534549 100644
--- a/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.eo
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.eo
@@ -1,14 +1,15 @@
1class Evas.Ector.GL.Image.Buffer (Evas.Ector.GL.Buffer, Evas.Ector.Buffer) 1class Evas.Ector.GL.Image.Buffer (Efl.Object, Evas.Ector.Buffer, Ector.GL.Buffer)
2{ 2{
3 [[An Ector GL buffer wrapping an existing Evas_GL_Image.]] 3 [[An Ector GL buffer wrapping an existing Evas_GL_Image.]]
4 implements { 4 implements {
5 Efl.Object.constructor;
6 Efl.Object.finalize; 5 Efl.Object.finalize;
7 Efl.Object.destructor; 6 Efl.Object.destructor;
8 Evas.Ector.Buffer.engine_image { get; set; } 7 Evas.Ector.Buffer.engine_image_set;
8 Evas.Ector.Buffer.drawable_image_get;
9 Evas.Ector.Buffer.engine_image_release;
10 Ector.Buffer.size { get; }
11 Ector.Buffer.cspace { get; }
9 Ector.Buffer.flags { get; } 12 Ector.Buffer.flags { get; }
10 Ector.Buffer.span_get;
11 Ector.Buffer.span_free;
12 Ector.Buffer.map; 13 Ector.Buffer.map;
13 Ector.Buffer.unmap; 14 Ector.Buffer.unmap;
14 } 15 }
diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.c b/src/modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.c
deleted file mode 100644
index 91bb22220d..0000000000
--- a/src/modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.c
+++ /dev/null
@@ -1,117 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include "evas_common_private.h"
6#include "evas_gl_private.h"
7
8#include <software/Ector_Software.h>
9#include <gl/Ector_GL.h>
10#include "Evas_Engine_GL_Generic.h"
11
12#include "evas_ector_buffer.eo.h"
13#include "evas_ector_gl_rgbaimage_buffer.eo.h"
14#include "../software_generic/evas_ector_software_buffer.eo.h"
15
16#define MY_CLASS EVAS_ECTOR_GL_RGBAIMAGE_BUFFER_CLASS
17
18typedef struct {
19 Ector_Software_Buffer_Base_Data *base;
20 Evas *evas;
21 RGBA_Image *image;
22 Evas_GL_Image *glim;
23} Evas_Ector_GL_RGBAImage_Buffer_Data;
24
25// GL engine stuff, do not use with RGBA_Image / Image_Entry
26#define ENFN e->engine.func
27#define ENDT e->engine.data.output
28
29EOLIAN static void
30_evas_ector_gl_rgbaimage_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ector_GL_RGBAImage_Buffer_Data *pd,
31 Evas *evas, void *image)
32{
33 RGBA_Image *im = image;
34
35 EINA_SAFETY_ON_NULL_RETURN(image);
36 if (efl_finalized_get(obj))
37 {
38 CRI("engine_image must be set at construction time only");
39 return;
40 }
41
42 if (!im->image.data)
43 {
44 CRI("image has no pixels yet");
45 return;
46 }
47
48 pd->evas = efl_xref(evas, obj);
49 evas_cache_image_ref(&im->cache_entry);
50 pd->image = im;
51
52 ector_buffer_pixels_set(obj, im->image.data, im->cache_entry.w, im->cache_entry.h, 0, (Efl_Gfx_Colorspace) im->cache_entry.space, EINA_TRUE, 0, 0, 0, 0);
53}
54
55EOLIAN static void
56_evas_ector_gl_rgbaimage_buffer_evas_ector_buffer_engine_image_get(Eo *obj EINA_UNUSED,
57 Evas_Ector_GL_RGBAImage_Buffer_Data *pd,
58 Evas **evas, void **image)
59{
60 Evas_Public_Data *e = efl_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
61 Render_Engine_GL_Generic *re = e->engine.data.output;
62 int err = EVAS_LOAD_ERROR_NONE;
63 Evas_Engine_GL_Context *gc;
64
65 if (evas) *evas = pd->evas;
66 if (image) *image = NULL;
67 if (pd->glim)
68 goto end;
69
70 gc = re->window_gl_context_get(re->software.ob);
71#ifdef EVAS_CSERVE2
72 if (evas_cache2_image_cached(&pd->image->cache_entry))
73 evas_cache2_image_ref(&pd->image->cache_entry);
74 else
75#endif
76 evas_cache_image_ref(&pd->image->cache_entry);
77 pd->glim = evas_gl_common_image_new_from_rgbaimage(gc, pd->image, NULL, &err);
78 if ((err != EVAS_LOAD_ERROR_NONE) || !pd->glim)
79 {
80 ERR("Failed to create GL image! error %d", err);
81 return;
82 }
83
84end:
85 if (image) *image = pd->glim;
86}
87
88EOLIAN static Eo *
89_evas_ector_gl_rgbaimage_buffer_efl_object_constructor(Eo *obj, Evas_Ector_GL_RGBAImage_Buffer_Data *pd)
90{
91 obj = efl_constructor(efl_super(obj, MY_CLASS));
92 pd->base = efl_data_xref(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN, obj);
93 return obj;
94}
95
96EOLIAN static Eo *
97_evas_ector_gl_rgbaimage_buffer_efl_object_finalize(Eo *obj, Evas_Ector_GL_RGBAImage_Buffer_Data *pd)
98{
99 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->base, NULL);
100 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->image, NULL);
101 pd->base->generic->immutable = EINA_TRUE;
102 return efl_finalize(efl_super(obj, MY_CLASS));
103}
104
105EOLIAN static void
106_evas_ector_gl_rgbaimage_buffer_efl_object_destructor(Eo *obj, Evas_Ector_GL_RGBAImage_Buffer_Data *pd)
107{
108 Evas_Public_Data *e = efl_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
109
110 efl_data_xunref(obj, pd->base, obj);
111 ENFN->image_free(ENDT, pd->glim);
112 evas_cache_image_drop(&pd->image->cache_entry);
113 efl_xunref(pd->evas, obj);
114 efl_destructor(efl_super(obj, MY_CLASS));
115}
116
117#include "evas_ector_gl_rgbaimage_buffer.eo.c"
diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.eo b/src/modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.eo
deleted file mode 100644
index 1bb15e8a5b..0000000000
--- a/src/modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.eo
+++ /dev/null
@@ -1,10 +0,0 @@
1class Evas.Ector.GL.RGBAImage.Buffer (Ector.Software.Buffer, Evas.Ector.Buffer)
2{
3 [[A buffer object wrapping an existing Evas RGBA_Image for the GL Engine.]]
4 implements {
5 Efl.Object.constructor;
6 Efl.Object.finalize;
7 Efl.Object.destructor;
8 Evas.Ector.Buffer.engine_image { get; set; }
9 }
10}
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index 00fcc1d555..fe127d4936 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -7,7 +7,6 @@
7#include "evas_ector_buffer.eo.h" 7#include "evas_ector_buffer.eo.h"
8#include "evas_ector_gl_buffer.eo.h" 8#include "evas_ector_gl_buffer.eo.h"
9#include "evas_ector_gl_image_buffer.eo.h" 9#include "evas_ector_gl_image_buffer.eo.h"
10#include "evas_ector_gl_rgbaimage_buffer.eo.h"
11#include "filters/gl_engine_filter.h" 10#include "filters/gl_engine_filter.h"
12 11
13#if defined HAVE_DLSYM && ! defined _WIN32 12#if defined HAVE_DLSYM && ! defined _WIN32
@@ -844,11 +843,11 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
844 if (!ok) 843 if (!ok)
845 { 844 {
846 if (err) *err = EVAS_LOAD_ERROR_GENERIC; 845 if (err) *err = EVAS_LOAD_ERROR_GENERIC;
847 ERR("Unlock failed."); 846 ERR("ReadPixels failed.");
848 return NULL; 847 return NULL;
849 } 848 }
850 *image_data = im_new->im->image.data; 849 *image_data = im_new->im->image.data;
851 if (tofree) *tofree = EINA_TRUE; 850 *tofree = EINA_TRUE;
852 return im_new; 851 return im_new;
853 } 852 }
854 853
@@ -2539,85 +2538,22 @@ eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector)
2539} 2538}
2540 2539
2541static Ector_Buffer * 2540static Ector_Buffer *
2542eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *evas, void *engine_image, Eina_Bool is_rgba_image) 2541eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *evas, void *engine_image)
2543{ 2542{
2544 Ector_Buffer *buf = NULL; 2543 Evas_GL_Image *im = engine_image;
2545 EINA_SAFETY_ON_NULL_RETURN_VAL(engine_image, NULL);
2546 if (is_rgba_image)
2547 {
2548 RGBA_Image *im = engine_image;
2549 2544
2550 buf = efl_add(EVAS_ECTOR_GL_RGBAIMAGE_BUFFER_CLASS, evas, evas_ector_buffer_engine_image_set(efl_added, evas, im)); 2545 EINA_SAFETY_ON_NULL_RETURN_VAL(engine_image, NULL);
2551 }
2552 else
2553 {
2554 Evas_GL_Image *im = engine_image;
2555 2546
2556 buf = efl_add(EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS, evas, evas_ector_buffer_engine_image_set(efl_added, evas, im)); 2547 return efl_add(EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS, evas,
2557 } 2548 evas_ector_buffer_engine_image_set(efl_added, evas, im));
2558 return buf;
2559} 2549}
2560 2550
2561static Ector_Buffer * 2551static Ector_Buffer *
2562eng_ector_buffer_new(void *data, Evas *evas, void *pixels, 2552eng_ector_buffer_new(void *data EINA_UNUSED, Evas *evas, int w, int h,
2563 int width, int height, int stride, 2553 Efl_Gfx_Colorspace cspace, Ector_Buffer_Flag flags)
2564 Efl_Gfx_Colorspace cspace, Eina_Bool writeable EINA_UNUSED,
2565 int l, int r, int t, int b, Ector_Buffer_Flag flags)
2566{ 2554{
2567 Evas_Public_Data *e = efl_data_scope_get(evas, EVAS_CANVAS_CLASS); 2555 return efl_add(EVAS_ECTOR_GL_BUFFER_CLASS, evas,
2568 Render_Engine_GL_Generic *re = e->engine.data.output; 2556 evas_ector_gl_buffer_prepare(efl_added, evas, w, h, cspace, flags));
2569 Evas_Engine_GL_Context *gc = NULL;
2570 Ector_Buffer *buf = NULL;
2571 int iw = width + l + r;
2572 int ih = height + t + b;
2573 int pxs = (cspace == EFL_GFX_COLORSPACE_ARGB8888) ? 4 : 1;
2574
2575 if (stride && (stride != iw * pxs))
2576 WRN("stride support is not implemented for ector gl buffers at this point!");
2577
2578 if ((flags & ECTOR_BUFFER_FLAG_RENDERABLE) == 0)
2579 {
2580 // Create an RGBA Image as backing
2581 Image_Entry *ie;
2582
2583 if (pixels)
2584 {
2585 // no copy
2586 ie = evas_cache_image_data(evas_common_image_cache_get(), iw, ih,
2587 pixels, EINA_TRUE, (Evas_Colorspace) cspace);
2588 if (!ie) return NULL;
2589 }
2590 else
2591 {
2592 // alloc buffer
2593 ie = evas_cache_image_copied_data(evas_common_image_cache_get(), iw, ih,
2594 NULL, EINA_TRUE, (Evas_Colorspace) cspace);
2595 if (!ie) return NULL;
2596 pixels = ((RGBA_Image *) ie)->image.data;
2597 memset(pixels, 0, iw * ih * pxs);
2598 }
2599 ie->borders.l = l;
2600 ie->borders.r = r;
2601 ie->borders.t = t;
2602 ie->borders.b = b;
2603
2604 buf = eng_ector_buffer_wrap(data, evas, ie, EINA_TRUE);
2605 evas_cache_image_drop(ie);
2606 }
2607 else
2608 {
2609 // Create only an Evas_GL_Image as backing
2610 Evas_GL_Image *im;
2611
2612 if (l || r || t || b)
2613 WRN("Borders are not supported by Evas surfaces!");
2614
2615 gc = re->window_gl_context_get(re->software.ob);
2616 im = evas_gl_common_image_surface_new(gc, iw, ih, EINA_TRUE, EINA_FALSE);
2617 buf = efl_add(EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS, evas, evas_ector_buffer_engine_image_set(efl_added, evas, im));
2618 im->references--;
2619 }
2620 return buf;
2621} 2557}
2622 2558
2623static Efl_Gfx_Render_Op 2559static Efl_Gfx_Render_Op
@@ -2768,7 +2704,7 @@ eng_ector_begin(void *data, void *context EINA_UNUSED, Ector_Surface *ector,
2768 } 2704 }
2769 } 2705 }
2770 memset(buffer->software, 0, sizeof (unsigned int) * w * h); 2706 memset(buffer->software, 0, sizeof (unsigned int) * w * h);
2771 ector_buffer_pixels_set(ector, buffer->software, w, h, 0, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE, 0, 0, 0, 0); 2707 ector_buffer_pixels_set(ector, buffer->software, w, h, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE);
2772 ector_surface_reference_point_set(ector, x, y); 2708 ector_surface_reference_point_set(ector, x, y);
2773 } 2709 }
2774 else 2710 else
@@ -2796,7 +2732,7 @@ eng_ector_end(void *data, void *context EINA_UNUSED, Ector_Surface *ector,
2796 w = gl_context->w; h = gl_context->h; 2732 w = gl_context->w; h = gl_context->h;
2797 mul_use = gl_context->dc->mul.use; 2733 mul_use = gl_context->dc->mul.use;
2798 2734
2799 ector_buffer_pixels_set(ector, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0); 2735 ector_buffer_pixels_set(ector, NULL, 0, 0, 0, 0);
2800 buffer->gl = eng_image_data_put(data, buffer->gl, buffer->software); 2736 buffer->gl = eng_image_data_put(data, buffer->gl, buffer->software);
2801 2737
2802 if (!mul_use) 2738 if (!mul_use)
diff --git a/src/modules/evas/engines/gl_generic/filters/gl_filter_blend.c b/src/modules/evas/engines/gl_generic/filters/gl_filter_blend.c
index 9ed93897cf..5e48883ba3 100644
--- a/src/modules/evas/engines/gl_generic/filters/gl_filter_blend.c
+++ b/src/modules/evas/engines/gl_generic/filters/gl_filter_blend.c
@@ -4,17 +4,40 @@ static Eina_Bool
4_gl_filter_blend(Render_Engine_GL_Generic *re, Evas_Filter_Command *cmd) 4_gl_filter_blend(Render_Engine_GL_Generic *re, Evas_Filter_Command *cmd)
5{ 5{
6 Evas_Engine_GL_Context *gc; 6 Evas_Engine_GL_Context *gc;
7 Evas_GL_Image *image; 7 Evas_GL_Image *image, *surface;
8 Evas_Canvas *eo_evas; 8 RGBA_Draw_Context *dc_save;
9 void *im = NULL;
10 9
11 re->window_use(re->software.ob); 10 re->window_use(re->software.ob);
12 gc = re->window_gl_context_get(re->software.ob); 11 gc = re->window_gl_context_get(re->software.ob);
13 12
14 evas_ector_buffer_engine_image_get(cmd->input->buffer, &eo_evas, &im); 13 image = evas_ector_buffer_drawable_image_get(cmd->input->buffer, EINA_TRUE);
15 image = im;
16 14
17 evas_gl_common_image_draw(gc, image, 0, 0, image->w, image->h, 0, 0, image->w, image->h, EINA_TRUE); 15 EINA_SAFETY_ON_NULL_RETURN_VAL(image, EINA_FALSE);
16 EINA_SAFETY_ON_NULL_RETURN_VAL(image->tex, EINA_FALSE);
17
18 surface = evas_ector_buffer_render_image_get(cmd->output->buffer, EINA_FALSE);
19
20 EINA_SAFETY_ON_NULL_RETURN_VAL(surface, EINA_FALSE);
21 EINA_SAFETY_ON_NULL_RETURN_VAL(surface->tex, EINA_FALSE);
22 EINA_SAFETY_ON_NULL_RETURN_VAL(surface->tex->pt, EINA_FALSE);
23 EINA_SAFETY_ON_FALSE_RETURN_VAL(surface->tex->pt->fb != 0, EINA_FALSE);
24 evas_gl_common_context_target_surface_set(gc, surface);
25
26 // TODO: mapped render iteration
27
28 dc_save = gc->dc;
29 gc->dc = evas_common_draw_context_new();
30 evas_common_draw_context_set_multiplier(gc->dc, cmd->draw.R, cmd->draw.G, cmd->draw.B, cmd->draw.A);
31
32 evas_gl_common_image_draw(gc, image, 0, 0, image->w, image->h,
33 cmd->draw.ox, cmd->draw.oy, image->w, image->h,
34 EINA_TRUE);
35
36 evas_common_draw_context_free(gc->dc);
37 gc->dc = dc_save;
38
39 evas_ector_buffer_engine_image_release(cmd->input->buffer, image);
40 evas_ector_buffer_engine_image_release(cmd->output->buffer, surface);
18 41
19 return EINA_TRUE; 42 return EINA_TRUE;
20} 43}
@@ -26,5 +49,5 @@ gl_filter_blend_func_get(Evas_Filter_Command *cmd)
26 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->output, NULL); 49 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->output, NULL);
27 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->input, NULL); 50 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->input, NULL);
28 51
29 return NULL; // _gl_filter_blend; 52 return _gl_filter_blend;
30} 53}
diff --git a/src/modules/evas/engines/software_generic/evas_ector_software_buffer.c b/src/modules/evas/engines/software_generic/evas_ector_software_buffer.c
index 061d5fbd89..d3129744cd 100644
--- a/src/modules/evas/engines/software_generic/evas_ector_software_buffer.c
+++ b/src/modules/evas/engines/software_generic/evas_ector_software_buffer.c
@@ -27,46 +27,44 @@ _evas_ector_software_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ect
27 RGBA_Image *im = image; 27 RGBA_Image *im = image;
28 28
29 EINA_SAFETY_ON_NULL_RETURN(image); 29 EINA_SAFETY_ON_NULL_RETURN(image);
30 if (efl_finalized_get(obj)) 30 EINA_SAFETY_ON_FALSE_RETURN(!efl_finalized_get(obj));
31 { 31 EINA_SAFETY_ON_NULL_RETURN(im->image.data);
32 CRI("engine_image must be set at construction time only");
33 return;
34 }
35
36 if (!im->image.data)
37 {
38 CRI("image has no pixels yet");
39 return;
40 }
41 32
42 pd->evas = efl_data_xref(evas, EVAS_CANVAS_CLASS, obj); 33 pd->evas = efl_data_xref(evas, EVAS_CANVAS_CLASS, obj);
43 evas_cache_image_ref(&im->cache_entry); 34 evas_cache_image_ref(&im->cache_entry);
44 pd->image = im; 35 pd->image = im;
45 36
46 ector_buffer_pixels_set(obj, im->image.data, im->cache_entry.w, im->cache_entry.h, 0, (Efl_Gfx_Colorspace) im->cache_entry.space, EINA_TRUE, 0, 0, 0, 0); 37 ector_buffer_pixels_set(obj, im->image.data, im->cache_entry.w, im->cache_entry.h, im->cache_entry.space, EINA_TRUE);
47} 38}
48 39
49EOLIAN static void 40EOLIAN static void *
50_evas_ector_software_buffer_evas_ector_buffer_engine_image_get(Eo *obj EINA_UNUSED, 41_evas_ector_software_buffer_evas_ector_buffer_drawable_image_get(Eo *obj EINA_UNUSED,
42 Evas_Ector_Software_Buffer_Data *pd,
43 Eina_Bool update EINA_UNUSED)
44{
45 evas_cache_image_ref(&pd->image->cache_entry);
46 return pd->image;
47}
48
49EOLIAN static void *
50_evas_ector_software_buffer_evas_ector_buffer_render_image_get(Eo *obj EINA_UNUSED,
51 Evas_Ector_Software_Buffer_Data *pd, 51 Evas_Ector_Software_Buffer_Data *pd,
52 Evas **evas, void **image) 52 Eina_Bool update EINA_UNUSED)
53{ 53{
54 if (!pd->evas) 54 evas_cache_image_ref(&pd->image->cache_entry);
55 { 55 return pd->image;
56 INF("evas_ector_buffer_engine_image_set was not called on this image"); 56}
57 if (evas) *evas = NULL; 57
58 if (image) *image = NULL; 58EOLIAN static Eina_Bool
59 return; 59_evas_ector_software_buffer_evas_ector_buffer_engine_image_release(Eo *obj EINA_UNUSED,
60 } 60 Evas_Ector_Software_Buffer_Data *pd,
61 if (evas) *evas = pd->evas->evas; 61 void *image)
62 if (pd->evas->engine.func->gl_surface_read_pixels) 62{
63 { 63 EINA_SAFETY_ON_NULL_RETURN_VAL(image, EINA_FALSE);
64 ERR("Invalid: requesting engine_image from a GL image from a simple SW buffer!"); 64 EINA_SAFETY_ON_FALSE_RETURN_VAL(pd->image == image, EINA_FALSE);
65 if (image) *image = NULL; 65
66 return; 66 evas_cache_image_drop(&pd->image->cache_entry);
67 } 67 return EINA_TRUE;
68
69 if (image) *image = pd->image;
70} 68}
71 69
72EOLIAN static Eo * 70EOLIAN static Eo *
diff --git a/src/modules/evas/engines/software_generic/evas_ector_software_buffer.eo b/src/modules/evas/engines/software_generic/evas_ector_software_buffer.eo
index f2c98bb17a..938cd3a4e8 100644
--- a/src/modules/evas/engines/software_generic/evas_ector_software_buffer.eo
+++ b/src/modules/evas/engines/software_generic/evas_ector_software_buffer.eo
@@ -5,6 +5,9 @@ class Evas.Ector.Software.Buffer (Ector.Software.Buffer, Evas.Ector.Buffer)
5 Efl.Object.constructor; 5 Efl.Object.constructor;
6 Efl.Object.finalize; 6 Efl.Object.finalize;
7 Efl.Object.destructor; 7 Efl.Object.destructor;
8 Evas.Ector.Buffer.engine_image { get; set; } 8 Evas.Ector.Buffer.engine_image_set;
9 Evas.Ector.Buffer.drawable_image_get;
10 Evas.Ector.Buffer.render_image_get;
11 Evas.Ector.Buffer.engine_image_release;
9 } 12 }
10} 13}
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index 4ccec9bc8f..3947af63ad 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -4333,7 +4333,7 @@ eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector)
4333} 4333}
4334 4334
4335static Ector_Buffer * 4335static Ector_Buffer *
4336eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image, Eina_Bool is_rgba_image EINA_UNUSED) 4336eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image)
4337{ 4337{
4338 Image_Entry *ie = engine_image; 4338 Image_Entry *ie = engine_image;
4339 Ector_Buffer *buf = NULL; 4339 Ector_Buffer *buf = NULL;
@@ -4342,60 +4342,41 @@ eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image, Eina_
4342 4342
4343 if (!efl_domain_current_push(EFL_ID_DOMAIN_SHARED)) 4343 if (!efl_domain_current_push(EFL_ID_DOMAIN_SHARED))
4344 return NULL; 4344 return NULL;
4345 buf = efl_add(EVAS_ECTOR_SOFTWARE_BUFFER_CLASS, NULL, evas_ector_buffer_engine_image_set(efl_added, e, ie)); 4345 buf = efl_add(EVAS_ECTOR_SOFTWARE_BUFFER_CLASS, NULL,
4346 evas_ector_buffer_engine_image_set(efl_added, e, ie));
4346 efl_domain_current_pop(); 4347 efl_domain_current_pop();
4347 4348
4348 return buf; 4349 return buf;
4349} 4350}
4350 4351
4351static Ector_Buffer * 4352static Ector_Buffer *
4352eng_ector_buffer_new(void *data EINA_UNUSED, Evas *evas, void *pixels, 4353eng_ector_buffer_new(void *data EINA_UNUSED, Evas *evas, int width, int height,
4353 int width, int height, int stride, 4354 Efl_Gfx_Colorspace cspace, Ector_Buffer_Flag flags EINA_UNUSED)
4354 Efl_Gfx_Colorspace cspace, Eina_Bool writeable,
4355 int l, int r, int t, int b,
4356 Ector_Buffer_Flag flags EINA_UNUSED)
4357{ 4355{
4358 Ector_Buffer *buf = NULL; 4356 Ector_Buffer *buf;
4359 int pxs = (cspace == EFL_GFX_COLORSPACE_ARGB8888) ? 4 : 1; 4357 Image_Entry *ie;
4360 int iw = width + l + r; 4358 void *pixels;
4361 int ih = height + t + b; 4359 int pxs;
4362 4360
4363 if ((flags & (ECTOR_BUFFER_FLAG_RENDERABLE | ECTOR_BUFFER_FLAG_DRAWABLE)) == 0) 4361 if (cspace == EFL_GFX_COLORSPACE_ARGB8888)
4364 { 4362 pxs = 4;
4365 if (!efl_domain_current_push(EFL_ID_DOMAIN_SHARED)) 4363 else if (cspace == EFL_GFX_COLORSPACE_GRY8)
4366 return NULL; 4364 pxs = 1;
4367 buf = efl_add(ECTOR_SOFTWARE_BUFFER_CLASS, NULL, ector_buffer_pixels_set(efl_added, pixels, width, height, stride, cspace, writeable, l, r, t, b));
4368 efl_domain_current_pop();
4369 }
4370 else 4365 else
4371 { 4366 {
4372 // Create an RGBA Image as backing 4367 ERR("Unsupported colorspace: %d", (int) cspace);
4373 Image_Entry *ie; 4368 return NULL;
4369 }
4374 4370
4375 if (pixels) 4371 // alloc buffer
4376 { 4372 ie = evas_cache_image_copied_data(evas_common_image_cache_get(), width, height,
4377 // no copy 4373 NULL, EINA_TRUE, cspace);
4378 ie = evas_cache_image_data(evas_common_image_cache_get(), iw, ih, 4374 if (!ie) return NULL;
4379 pixels, EINA_TRUE, (Evas_Colorspace) cspace); 4375 pixels = ((RGBA_Image *) ie)->image.data;
4380 if (!ie) return NULL; 4376 memset(pixels, 0, width * height * pxs);
4381 }
4382 else
4383 {
4384 // alloc buffer
4385 ie = evas_cache_image_copied_data(evas_common_image_cache_get(), iw, ih,
4386 NULL, EINA_TRUE, (Evas_Colorspace) cspace);
4387 if (!ie) return NULL;
4388 pixels = ((RGBA_Image *) ie)->image.data;
4389 memset(pixels, 0, iw * ih * pxs);
4390 }
4391 ie->borders.l = l;
4392 ie->borders.r = r;
4393 ie->borders.t = t;
4394 ie->borders.b = b;
4395 4377
4396 buf = eng_ector_buffer_wrap(data, evas, ie, EINA_TRUE); 4378 buf = eng_ector_buffer_wrap(data, evas, ie);
4397 evas_cache_image_drop(ie); 4379 evas_cache_image_drop(ie);
4398 }
4399 4380
4400 return buf; 4381 return buf;
4401} 4382}
@@ -4546,7 +4527,7 @@ _draw_thread_ector_surface_set(void *data)
4546 y = ector_surface->y; 4527 y = ector_surface->y;
4547 } 4528 }
4548 4529
4549 ector_buffer_pixels_set(ector_surface->ector, pixels, w, h, 0, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE, 0, 0, 0, 0); 4530 ector_buffer_pixels_set(ector_surface->ector, pixels, w, h, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE);
4550 ector_surface_reference_point_set(ector_surface->ector, x, y); 4531 ector_surface_reference_point_set(ector_surface->ector, x, y);
4551 4532
4552 eina_mempool_free(_mp_command_ector_surface, ector_surface); 4533 eina_mempool_free(_mp_command_ector_surface, ector_surface);
@@ -4591,7 +4572,7 @@ eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, Ector_Surface
4591 w = sf->cache_entry.w; 4572 w = sf->cache_entry.w;
4592 h = sf->cache_entry.h; 4573 h = sf->cache_entry.h;
4593 4574
4594 ector_buffer_pixels_set(ector, pixels, w, h, 0, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE, 0, 0, 0, 0); 4575 ector_buffer_pixels_set(ector, pixels, w, h, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE);
4595 ector_surface_reference_point_set(ector, x, y); 4576 ector_surface_reference_point_set(ector, x, y);
4596 } 4577 }
4597} 4578}
@@ -4613,7 +4594,7 @@ eng_ector_end(void *data EINA_UNUSED, void *context EINA_UNUSED, Ector_Surface *
4613 } 4594 }
4614 else 4595 else
4615 { 4596 {
4616 ector_buffer_pixels_set(ector, NULL, 0, 0, 0, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE, 0, 0, 0, 0); 4597 ector_buffer_pixels_set(ector, NULL, 0, 0, EFL_GFX_COLORSPACE_ARGB8888, EINA_TRUE);
4617 evas_common_cpu_end_opt(); 4598 evas_common_cpu_end_opt();
4618 } 4599 }
4619} 4600}
diff --git a/src/modules/evas/engines/software_generic/filters/evas_filter_displace.c b/src/modules/evas/engines/software_generic/filters/evas_filter_displace.c
index aeea412c79..cc459a0592 100644
--- a/src/modules/evas/engines/software_generic/filters/evas_filter_displace.c
+++ b/src/modules/evas/engines/software_generic/filters/evas_filter_displace.c
@@ -269,7 +269,7 @@ _filter_displace_cpu_rgba(Evas_Filter_Command *cmd)
269 EINA_SAFETY_ON_FALSE_RETURN_VAL(h == cmd->output->h, EINA_FALSE); 269 EINA_SAFETY_ON_FALSE_RETURN_VAL(h == cmd->output->h, EINA_FALSE);
270 270
271 src = _buffer_map_all(cmd->input->buffer, &src_len, E_READ, E_ARGB, &src_stride); 271 src = _buffer_map_all(cmd->input->buffer, &src_len, E_READ, E_ARGB, &src_stride);
272 dst = _buffer_map_all(cmd->output->buffer, &dst_len, E_READ, E_ARGB, &dst_stride); 272 dst = _buffer_map_all(cmd->output->buffer, &dst_len, E_READ | E_WRITE, E_ARGB, &dst_stride);
273 stretch = cmd->displacement.flags & EVAS_FILTER_DISPLACE_STRETCH; 273 stretch = cmd->displacement.flags & EVAS_FILTER_DISPLACE_STRETCH;
274 smooth = cmd->displacement.flags & EVAS_FILTER_DISPLACE_LINEAR; 274 smooth = cmd->displacement.flags & EVAS_FILTER_DISPLACE_LINEAR;
275 map_w = cmd->mask->w; 275 map_w = cmd->mask->w;
@@ -294,7 +294,7 @@ _filter_displace_cpu_rgba(Evas_Filter_Command *cmd)
294 } 294 }
295 else map_fb = cmd->mask; 295 else map_fb = cmd->mask;
296 296
297 map_start = (uint32_t *) _buffer_map_all(map_fb->buffer, &map_len, E_READ, E_ARGB, &map_stride); 297 map_start = _buffer_map_all(map_fb->buffer, &map_len, E_READ, E_ARGB, &map_stride);
298 EINA_SAFETY_ON_FALSE_GOTO(src && dst && map_start, end); 298 EINA_SAFETY_ON_FALSE_GOTO(src && dst && map_start, end);
299 299
300 _filter_displace_cpu_rgba_do(w, h, map_w, map_h, intensity, 300 _filter_displace_cpu_rgba_do(w, h, map_w, map_h, intensity,
diff --git a/src/modules/evas/engines/software_generic/filters/evas_filter_fill.c b/src/modules/evas/engines/software_generic/filters/evas_filter_fill.c
index 87a0075c35..6460b861e1 100644
--- a/src/modules/evas/engines/software_generic/filters/evas_filter_fill.c
+++ b/src/modules/evas/engines/software_generic/filters/evas_filter_fill.c
@@ -10,7 +10,7 @@ _fill_cpu(Evas_Filter_Command *cmd)
10 uint32_t color = ARGB_JOIN(cmd->draw.A, cmd->draw.R, cmd->draw.G, cmd->draw.B); 10 uint32_t color = ARGB_JOIN(cmd->draw.A, cmd->draw.R, cmd->draw.G, cmd->draw.B);
11 unsigned int stride, len; 11 unsigned int stride, len;
12 int w, h, k; 12 int w, h, k;
13 uint8_t *ptr; 13 uint8_t *map, *ptr;
14 14
15 if (!cmd->draw.clip_mode_lrtb) 15 if (!cmd->draw.clip_mode_lrtb)
16 { 16 {
@@ -31,10 +31,10 @@ _fill_cpu(Evas_Filter_Command *cmd)
31 h = CLAMP(0, fb->h - y - cmd->draw.clip.b, fb->h - y); 31 h = CLAMP(0, fb->h - y - cmd->draw.clip.b, fb->h - y);
32 } 32 }
33 33
34 ptr = _buffer_map_all(fb->buffer, &len, E_WRITE, fb->alpha_only ? E_ALPHA : E_ARGB, &stride); 34 map = _buffer_map_all(fb->buffer, &len, E_WRITE, fb->alpha_only ? E_ALPHA : E_ARGB, &stride);
35 if (!ptr) return EINA_FALSE; 35 if (!map) return EINA_FALSE;
36 36
37 ptr += y * stride; 37 ptr = map + y * stride;
38 if (fb->alpha_only) 38 if (fb->alpha_only)
39 { 39 {
40 for (k = 0; k < h; k++) 40 for (k = 0; k < h; k++)
@@ -52,7 +52,7 @@ _fill_cpu(Evas_Filter_Command *cmd)
52 } 52 }
53 } 53 }
54 54
55 ector_buffer_unmap(fb->buffer, ptr, len); 55 ector_buffer_unmap(fb->buffer, map, len);
56 return EINA_TRUE; 56 return EINA_TRUE;
57} 57}
58 58
diff --git a/src/modules/evas/engines/software_generic/filters/evas_filter_mask.c b/src/modules/evas/engines/software_generic/filters/evas_filter_mask.c
index 9243811a52..a138b43af1 100644
--- a/src/modules/evas/engines/software_generic/filters/evas_filter_mask.c
+++ b/src/modules/evas/engines/software_generic/filters/evas_filter_mask.c
@@ -16,9 +16,9 @@ eng_filter_mask_func_get(Evas_Filter_Command *cmd)
16 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->input, NULL); 16 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->input, NULL);
17 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->output, NULL); 17 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->output, NULL);
18 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->mask, NULL); 18 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->mask, NULL);
19 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->input->buffer, NULL); 19 //EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->input->buffer, NULL);
20 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->output->buffer, NULL); 20 //EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->output->buffer, NULL);
21 EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->mask->buffer, NULL); 21 //EINA_SAFETY_ON_NULL_RETURN_VAL(cmd->mask->buffer, NULL);
22 EINA_SAFETY_ON_FALSE_RETURN_VAL((cmd->input->w > 0) && (cmd->input->h > 0), NULL); 22 EINA_SAFETY_ON_FALSE_RETURN_VAL((cmd->input->w > 0) && (cmd->input->h > 0), NULL);
23 EINA_SAFETY_ON_FALSE_RETURN_VAL((cmd->mask->w > 0) && (cmd->mask->h > 0), NULL); 23 EINA_SAFETY_ON_FALSE_RETURN_VAL((cmd->mask->w > 0) && (cmd->mask->h > 0), NULL);
24 EINA_SAFETY_ON_FALSE_RETURN_VAL(cmd->input->w == cmd->output->w, NULL); 24 EINA_SAFETY_ON_FALSE_RETURN_VAL(cmd->input->w == cmd->output->w, NULL);