summaryrefslogtreecommitdiff
path: root/src/modules/evas
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-01-04 20:33:37 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-01-05 15:43:44 +0900
commit13f66f8887b3f7f63be26c6ec55cebd6ca7bd1bd (patch)
tree463e7a4b636e66db64043963099c8c095ff6490c /src/modules/evas
parent0d5b42e6bbff30ead404460a0538d80282a9d6c9 (diff)
Evas filters: Complete basic repairs for GL engine
Now the filters should work with the GL engine, again, but with a potentially crazy performance. Indeed, the input buffer is now backed by an FBO, that needs to be glReadPixel'ed everytime it is accessed by the filters (mapped).
Diffstat (limited to 'src/modules/evas')
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c160
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.eo5
2 files changed, 165 insertions, 0 deletions
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 c8de1d8aad..2b5b644d44 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
@@ -17,16 +17,54 @@
17 17
18#define MY_CLASS EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS 18#define MY_CLASS EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS
19 19
20typedef struct _Ector_GL_Buffer_Map
21{
22 EINA_INLIST;
23 void *ptr;
24 unsigned int size; // in bytes
25 unsigned int x, y, w, h;
26 Efl_Gfx_Colorspace cspace;
27 Evas_GL_Image *im;
28 Eina_Bool allocated;
29 Ector_Buffer_Access_Flag mode;
30} Ector_GL_Buffer_Map;
31
20typedef struct 32typedef struct
21{ 33{
22 Ector_GL_Buffer_Base_Data *base; 34 Ector_GL_Buffer_Base_Data *base;
23 Evas *evas; 35 Evas *evas;
24 Evas_GL_Image *image; 36 Evas_GL_Image *image;
37 struct {
38 Eina_Inlist *maps; // Ector_GL_Buffer_Map
39 } internal;
25} Evas_Ector_GL_Image_Buffer_Data; 40} Evas_Ector_GL_Image_Buffer_Data;
26 41
27#define ENFN e->engine.func 42#define ENFN e->engine.func
28#define ENDT e->engine.data.output 43#define ENDT e->engine.data.output
29 44
45/* FIXME: Conversion routines don't belong here */
46static inline void
47_pixels_argb_to_gry8_convert(uint8_t *dst, const uint32_t *src, int len)
48{
49 int k;
50 for (k = 0; k < len; k++)
51 {
52 const uint32_t *s = src++;
53 *dst++ = A_VAL(s);
54 }
55}
56
57static inline void
58_pixels_gry8_to_argb_convert(uint32_t *dst, const uint8_t *src, int len)
59{
60 int k;
61 for (k = 0; k < len; k++)
62 {
63 uint8_t s = *src++;
64 *dst++ = ARGB_JOIN(s, s, s, s);
65 }
66}
67
30EOLIAN static void 68EOLIAN static void
31_evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd, 69_evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd,
32 Evas *evas, void *image) 70 Evas *evas, void *image)
@@ -86,6 +124,128 @@ _evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_get(Eo *obj EINA_UNUS
86 if (image) *image = pd->image; 124 if (image) *image = pd->image;
87} 125}
88 126
127EOLIAN static Ector_Buffer_Flag
128_evas_ector_gl_image_buffer_ector_generic_buffer_flags_get(Eo *obj EINA_UNUSED,
129 Evas_Ector_GL_Image_Buffer_Data *pd)
130{
131 Ector_Buffer_Flag flags;
132
133 if (!pd->image) return 0;
134
135 flags = ECTOR_BUFFER_FLAG_CPU_READABLE;
136 if (pd->image->tex)
137 {
138 flags |= ECTOR_BUFFER_FLAG_DRAWABLE;
139 if (pd->image->tex->pt->fb)
140 flags |= ECTOR_BUFFER_FLAG_RENDERABLE;
141 }
142 if (pd->image->im)
143 flags |= ECTOR_BUFFER_FLAG_CPU_WRITABLE;
144
145 return flags;
146}
147
148EOLIAN static void *
149_evas_ector_gl_image_buffer_ector_generic_buffer_map(Eo *obj EINA_UNUSED, Evas_Ector_GL_Image_Buffer_Data *pd, unsigned int *length,
150 Ector_Buffer_Access_Flag mode,
151 unsigned int x, unsigned int y, unsigned int w, unsigned int h,
152 Efl_Gfx_Colorspace cspace, unsigned int *stride)
153{
154 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
155 Ector_GL_Buffer_Map *map = NULL;
156 Eina_Bool tofree = EINA_FALSE;
157 Evas_GL_Image *im;
158 uint32_t *data;
159 int len, err;
160
161 im = ENFN->image_data_get(ENDT, pd->image,
162 mode & ECTOR_BUFFER_ACCESS_FLAG_WRITE,
163 &data, &err, &tofree);
164 if (!im) return NULL;
165
166 map = calloc(1, sizeof(*map));
167 map->mode = mode;
168 map->cspace = cspace;
169 map->x = x;
170 map->y = y;
171 map->w = w;
172 map->h = h;
173 map->ptr = data;
174
175 if (tofree)
176 map->im = im;
177 else
178 map->im = ENFN->image_ref(ENDT, im);
179
180 len = w * h;
181 if (cspace == EFL_GFX_COLORSPACE_GRY8)
182 {
183 uint8_t *data8 = malloc(len);
184 _pixels_argb_to_gry8_convert(data8, data, len);
185 map->allocated = EINA_TRUE;
186 map->ptr = data8;
187 map->size = len;
188 if (stride) *stride = w;
189 }
190 else
191 {
192 map->allocated = EINA_FALSE;
193 map->ptr = data;
194 map->size = len * 4;
195 if (stride) *stride = w * 4;
196 }
197
198 if (length) *length = map->size;
199
200 pd->internal.maps = eina_inlist_prepend(pd->internal.maps, EINA_INLIST_GET(map));
201 return map->ptr;
202}
203
204EOLIAN static void
205_evas_ector_gl_image_buffer_ector_generic_buffer_unmap(Eo *obj EINA_UNUSED, Evas_Ector_GL_Image_Buffer_Data *pd,
206 void *data, unsigned int length)
207{
208 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
209 Ector_GL_Buffer_Map *map;
210 if (!data) return;
211
212 EINA_INLIST_FOREACH(pd->internal.maps, map)
213 {
214 if ((map->ptr == data) && ((map->size == length) || (length == (unsigned int) -1)))
215 {
216 pd->internal.maps = eina_inlist_remove(pd->internal.maps, EINA_INLIST_GET(map));
217 if (map->mode & ECTOR_BUFFER_ACCESS_FLAG_WRITE)
218 {
219 CRI("Not implemented yet. Dropping pixel changes.");
220 }
221 ENFN->image_free(ENDT, map->im);
222 if (map->allocated)
223 free(map->ptr);
224 return;
225 }
226 }
227
228 CRI("Tried to unmap a non-mapped region!");
229}
230
231EOLIAN static uint8_t *
232_evas_ector_gl_image_buffer_ector_generic_buffer_span_get(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd, int x, int y, unsigned int w,
233 Efl_Gfx_Colorspace cspace, unsigned int *length)
234{
235 // ector_buffer_map
236 return _evas_ector_gl_image_buffer_ector_generic_buffer_map
237 (obj, pd, length, ECTOR_BUFFER_ACCESS_FLAG_READ, x, y, w, 1, cspace, NULL);
238}
239
240EOLIAN static void
241_evas_ector_gl_image_buffer_ector_generic_buffer_span_free(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd, uint8_t *data)
242{
243 // ector_buffer_unmap
244 return _evas_ector_gl_image_buffer_ector_generic_buffer_unmap
245 (obj, pd, data, (unsigned int) -1);
246}
247
248
89EOLIAN static Eo_Base * 249EOLIAN static Eo_Base *
90_evas_ector_gl_image_buffer_eo_base_constructor(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd) 250_evas_ector_gl_image_buffer_eo_base_constructor(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd)
91{ 251{
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 82cebb4e3d..2eede45d15 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
@@ -8,5 +8,10 @@ class Evas.Ector.GL.Image.Buffer (Evas.Ector.GL.Buffer, Evas.Ector.Buffer)
8 Eo.Base.destructor; 8 Eo.Base.destructor;
9 Evas.Ector.Buffer.engine_image.set; 9 Evas.Ector.Buffer.engine_image.set;
10 Evas.Ector.Buffer.engine_image.get; 10 Evas.Ector.Buffer.engine_image.get;
11 Ector.Generic.Buffer.flags.get;
12 Ector.Generic.Buffer.span_get;
13 Ector.Generic.Buffer.span_free;
14 Ector.Generic.Buffer.map;
15 Ector.Generic.Buffer.unmap;
11 } 16 }
12} 17}