summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-01-04 18:00:30 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-01-05 15:43:44 +0900
commit0d5b42e6bbff30ead404460a0538d80282a9d6c9 (patch)
tree3c42489655e4ac2e2ad97aaae75068a88fc3d72c
parent66961126916f6ab61ba6549f7ad96399bdf773af (diff)
Evas filters: Move evas image creation to the engine
Evas filters is now more and more unaware of evas images (RGBA_Image) and the engine + ector take care of everything. Still left to do: - map / unmap an FBO buffer into RO or RW memory
-rw-r--r--src/lib/evas/filters/evas_filter.c61
-rw-r--r--src/lib/evas/filters/evas_filter_blend.c9
-rw-r--r--src/lib/evas/filters/evas_filter_private.h1
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.c3
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c71
5 files changed, 83 insertions, 62 deletions
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index 801c5a6d05..d632d9bb93 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -200,39 +200,21 @@ static Ector_Buffer *
200_ector_buffer_create(Evas_Filter_Buffer const *fb, void *data) 200_ector_buffer_create(Evas_Filter_Buffer const *fb, void *data)
201{ 201{
202 Evas_Colorspace cspace; 202 Evas_Colorspace cspace;
203 Image_Entry *ie; 203 Ector_Buffer_Flag flags;
204 204
205 // FIXME: We still rely on evas image structs (scaling and target render) 205 // FIXME: We still rely on evas image structs (scaling and target render)
206 // This should be fixed by implementing full support in ector 206 // This should be fixed by implementing full support in ector
207 // Note: dropped support for cserve2, that was not needed anyway 207 // Note: dropped support for cserve2, that was not needed anyway
208 208
209 flags = ECTOR_BUFFER_FLAG_CPU_READABLE | ECTOR_BUFFER_FLAG_CPU_WRITABLE;
210 if (fb->id == EVAS_FILTER_BUFFER_INPUT_ID)
211 flags |= ECTOR_BUFFER_FLAG_RENDERABLE;
212
209 cspace = fb->alpha_only ? EVAS_COLORSPACE_GRY8 : EVAS_COLORSPACE_ARGB8888; 213 cspace = fb->alpha_only ? EVAS_COLORSPACE_GRY8 : EVAS_COLORSPACE_ARGB8888;
210#if 0
211 // ideal code
212 return fb->ENFN->ector_buffer_new(fb->ENDT, fb->ctx->evas->evas, 214 return fb->ENFN->ector_buffer_new(fb->ENDT, fb->ctx->evas->evas,
213 data, fb->w, fb->h, 0, 215 data, fb->w, fb->h, 0,
214 cspace, EINA_TRUE, 0, 0, 0, 0, 216 (Efl_Gfx_Colorspace )cspace, EINA_TRUE,
215 ECTOR_BUFFER_FLAG_CPU_READABLE | 217 0, 0, 0, 0, flags);
216 ECTOR_BUFFER_FLAG_CPU_WRITABLE);
217#endif
218
219 if (data)
220 {
221 // no copy
222 ie = evas_cache_image_data(evas_common_image_cache_get(), fb->w, fb->h,
223 data, EINA_TRUE, cspace);
224 if (!ie) return NULL;
225 }
226 else
227 {
228 // alloc buffer
229 ie = evas_cache_image_copied_data(evas_common_image_cache_get(), fb->w, fb->h,
230 NULL, EINA_TRUE, cspace);
231 if (!ie) return NULL;
232 data = ((RGBA_Image *) ie)->image.data;
233 memset(data, 0, fb->w * fb->h * (fb->alpha_only ? 1 : 4));
234 }
235 return fb->ENFN->ector_buffer_wrap(fb->ENDT, fb->ctx->evas->evas, ie, EINA_TRUE);
236} 218}
237 219
238Eina_Bool 220Eina_Bool
@@ -323,7 +305,7 @@ evas_filter_context_buffers_allocate_all(Evas_Filter_Context *ctx)
323 305
324 EINA_LIST_FOREACH(ctx->buffers, li, fb) 306 EINA_LIST_FOREACH(ctx->buffers, li, fb)
325 { 307 {
326 if (fb->buffer || fb->source || fb->glimage) 308 if (fb->buffer || fb->source)
327 continue; 309 continue;
328 310
329 if (!fb->w && !fb->h) 311 if (!fb->w && !fb->h)
@@ -1439,27 +1421,14 @@ evas_filter_font_draw(Evas_Filter_Context *ctx, void *draw_context, int bufid,
1439 surface = _evas_image_get(fb->buffer); 1421 surface = _evas_image_get(fb->buffer);
1440 if (!surface) return EINA_FALSE; 1422 if (!surface) return EINA_FALSE;
1441 1423
1442 if (!ctx->gl_engine) 1424 // Copied from evas_font_draw_async_check
1443 { 1425 async_unref = ENFN->font_draw(ENDT, draw_context, surface,
1444 // Copied from evas_font_draw_async_check 1426 font, x, y, fb->w, fb->h, fb->w, fb->h,
1445 async_unref = ENFN->font_draw(ENDT, draw_context, surface, 1427 text_props, do_async);
1446 font, x, y, fb->w, fb->h, fb->w, fb->h, 1428 if (do_async && async_unref)
1447 text_props, do_async);
1448 if (do_async && async_unref)
1449 {
1450 evas_common_font_glyphs_ref(text_props->glyphs);
1451 evas_unref_queue_glyph_put(ctx->evas, text_props->glyphs);
1452 }
1453 }
1454 else
1455 { 1429 {
1456 // FIXME/GL: Render in software only. 1430 evas_common_font_glyphs_ref(text_props->glyphs);
1457 // Copied from eng_font_draw in the software engine. 1431 evas_unref_queue_glyph_put(ctx->evas, text_props->glyphs);
1458
1459 if (do_async) WRN("Async flag is ignored here!");
1460 evas_common_font_draw_prepare(text_props);
1461 evas_common_font_draw(surface, draw_context, x, y, text_props->glyphs);
1462 evas_common_cpu_end_opt();
1463 } 1432 }
1464 1433
1465 return EINA_TRUE; 1434 return EINA_TRUE;
diff --git a/src/lib/evas/filters/evas_filter_blend.c b/src/lib/evas/filters/evas_filter_blend.c
index 344a7c0bdd..9030e80e58 100644
--- a/src/lib/evas/filters/evas_filter_blend.c
+++ b/src/lib/evas/filters/evas_filter_blend.c
@@ -47,7 +47,7 @@ _image_draw_cpu_alpha_alpha(void *data EINA_UNUSED, void *context,
47 dstdata += dst_y * dw; 47 dstdata += dst_y * dw;
48 for (y = src_h; y; y--) 48 for (y = src_h; y; y--)
49 { 49 {
50 func(srcdata + src_x, dstdata + dst_x, src_w); 50 func((uint8_t *) srcdata + src_x, dstdata + dst_x, src_w);
51 srcdata += sw; 51 srcdata += sw;
52 dstdata += dw; 52 dstdata += dw;
53 } 53 }
@@ -181,7 +181,7 @@ _filter_blend_cpu_generic_do(Evas_Filter_Command *cmd, draw_func image_draw)
181 struct Filter_Blend_Draw_Context dc; 181 struct Filter_Blend_Draw_Context dc;
182 Eina_Bool ret = EINA_FALSE; 182 Eina_Bool ret = EINA_FALSE;
183 Evas_Filter_Buffer *src_fb; 183 Evas_Filter_Buffer *src_fb;
184 void *src, *dst; 184 void *src = NULL, *dst = NULL;
185 185
186 sx = 0; 186 sx = 0;
187 sy = 0; 187 sy = 0;
@@ -220,6 +220,7 @@ _filter_blend_cpu_generic_do(Evas_Filter_Command *cmd, draw_func image_draw)
220 220
221 src = _buffer_map_all(src_fb->buffer, &src_len, E_READ, src_fb->alpha_only ? E_ALPHA : E_ARGB, &src_stride); 221 src = _buffer_map_all(src_fb->buffer, &src_len, E_READ, src_fb->alpha_only ? E_ALPHA : E_ARGB, &src_stride);
222 dst = _buffer_map_all(cmd->output->buffer, &dst_len, E_WRITE, cmd->output->alpha_only ? E_ALPHA : E_ARGB, &dst_stride); 222 dst = _buffer_map_all(cmd->output->buffer, &dst_len, E_WRITE, cmd->output->alpha_only ? E_ALPHA : E_ARGB, &dst_stride);
223 EINA_SAFETY_ON_FALSE_GOTO(src && dst, end);
223 224
224 dc.rop = cmd->draw.rop; 225 dc.rop = cmd->draw.rop;
225 dc.color = ARGB_JOIN(cmd->draw.A, cmd->draw.R, cmd->draw.G, cmd->draw.B); 226 dc.color = ARGB_JOIN(cmd->draw.A, cmd->draw.R, cmd->draw.G, cmd->draw.B);
@@ -228,8 +229,8 @@ _filter_blend_cpu_generic_do(Evas_Filter_Command *cmd, draw_func image_draw)
228 sx, sy, sw, sh, dx, dy, dw, dh, image_draw); 229 sx, sy, sw, sh, dx, dy, dw, dh, image_draw);
229 230
230end: 231end:
231 eo_do(src_fb->buffer, ector_buffer_unmap(src, src_len)); 232 if (src) eo_do(src_fb->buffer, ector_buffer_unmap(src, src_len));
232 eo_do(cmd->output->buffer, ector_buffer_unmap(dst, dst_len)); 233 if (dst) eo_do(cmd->output->buffer, ector_buffer_unmap(dst, dst_len));
233 return ret; 234 return ret;
234} 235}
235 236
diff --git a/src/lib/evas/filters/evas_filter_private.h b/src/lib/evas/filters/evas_filter_private.h
index e5fbc3b3d3..bc13de964e 100644
--- a/src/lib/evas/filters/evas_filter_private.h
+++ b/src/lib/evas/filters/evas_filter_private.h
@@ -231,7 +231,6 @@ struct _Evas_Filter_Buffer
231 Evas_Object *source; 231 Evas_Object *source;
232 Eina_Stringshare *source_name; 232 Eina_Stringshare *source_name;
233 Ector_Generic_Buffer *buffer; 233 Ector_Generic_Buffer *buffer;
234 void *glimage;
235 int w, h; 234 int w, h;
236 235
237 Eina_Bool alpha_only : 1; // 1 channel (A) instead of 4 (RGBA) 236 Eina_Bool alpha_only : 1; // 1 channel (A) instead of 4 (RGBA)
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
index 03d957ac81..6b2e127ddc 100644
--- 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
@@ -64,15 +64,14 @@ _evas_ector_gl_rgbaimage_buffer_evas_ector_buffer_engine_image_get(Eo *obj EINA_
64{ 64{
65 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS); 65 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
66 Render_Engine_GL_Generic *re = e->engine.data.output; 66 Render_Engine_GL_Generic *re = e->engine.data.output;
67 Evas_Engine_GL_Context *gc = NULL;
68 int err = EVAS_LOAD_ERROR_NONE; 67 int err = EVAS_LOAD_ERROR_NONE;
68 Evas_Engine_GL_Context *gc;
69 69
70 if (evas) *evas = pd->evas; 70 if (evas) *evas = pd->evas;
71 if (image) *image = NULL; 71 if (image) *image = NULL;
72 if (pd->glim) 72 if (pd->glim)
73 goto end; 73 goto end;
74 74
75 EINA_SAFETY_ON_NULL_RETURN(re);
76 gc = re->window_gl_context_get(re->software.ob); 75 gc = re->window_gl_context_get(re->software.ob);
77 pd->glim = evas_gl_common_image_new_from_rgbaimage(gc, pd->image, NULL, &err); 76 pd->glim = evas_gl_common_image_new_from_rgbaimage(gc, pd->image, NULL, &err);
78 if ((err != EVAS_LOAD_ERROR_NONE) || !pd->glim) 77 if ((err != EVAS_LOAD_ERROR_NONE) || !pd->glim)
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index fc9caf04fc..6cc4b90bef 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -2469,7 +2469,7 @@ eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector)
2469} 2469}
2470 2470
2471static Ector_Buffer * 2471static Ector_Buffer *
2472eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image, Eina_Bool is_rgba_image) 2472eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *evas, void *engine_image, Eina_Bool is_rgba_image)
2473{ 2473{
2474 Ector_Buffer *buf = NULL; 2474 Ector_Buffer *buf = NULL;
2475 EINA_SAFETY_ON_NULL_RETURN_VAL(engine_image, NULL); 2475 EINA_SAFETY_ON_NULL_RETURN_VAL(engine_image, NULL);
@@ -2477,27 +2477,80 @@ eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image, Eina_
2477 { 2477 {
2478 RGBA_Image *im = engine_image; 2478 RGBA_Image *im = engine_image;
2479 2479
2480 buf = eo_add(EVAS_ECTOR_GL_RGBAIMAGE_BUFFER_CLASS, e, 2480 buf = eo_add(EVAS_ECTOR_GL_RGBAIMAGE_BUFFER_CLASS, evas,
2481 evas_ector_buffer_engine_image_set(e, im)); 2481 evas_ector_buffer_engine_image_set(evas, im));
2482 } 2482 }
2483 else 2483 else
2484 { 2484 {
2485 Evas_GL_Image *im = engine_image; 2485 Evas_GL_Image *im = engine_image;
2486 2486
2487 buf = eo_add(EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS, e, 2487 buf = eo_add(EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS, evas,
2488 evas_ector_buffer_engine_image_set(e, im)); 2488 evas_ector_buffer_engine_image_set(evas, im));
2489 } 2489 }
2490 return buf; 2490 return buf;
2491} 2491}
2492 2492
2493static Ector_Buffer * 2493static Ector_Buffer *
2494eng_ector_buffer_new(void *data EINA_UNUSED, Evas *e, void *pixels, 2494eng_ector_buffer_new(void *data, Evas *evas, void *pixels,
2495 int width, int height, int stride, 2495 int width, int height, int stride,
2496 Efl_Gfx_Colorspace cspace, Eina_Bool writeable, 2496 Efl_Gfx_Colorspace cspace, Eina_Bool writeable EINA_UNUSED,
2497 int l, int r, int t, int b, Ector_Buffer_Flag flags) 2497 int l, int r, int t, int b, Ector_Buffer_Flag flags)
2498{ 2498{
2499 CRI("Not implemented."); 2499 Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS);
2500 return NULL; 2500 Render_Engine_GL_Generic *re = e->engine.data.output;
2501 Evas_Engine_GL_Context *gc = NULL;
2502 Ector_Buffer *buf = NULL;
2503 int iw = width + l + r;
2504 int ih = height + t + b;
2505 int pxs = (cspace = EFL_GFX_COLORSPACE_ARGB8888) ? 4 : 1;
2506
2507 if (stride && (stride != iw * pxs))
2508 WRN("stride support is not implemented for ector gl buffers at this point!");
2509
2510 if ((flags & ECTOR_BUFFER_FLAG_RENDERABLE) == 0)
2511 {
2512 // Create an RGBA Image as backing
2513 Image_Entry *ie;
2514
2515 if (pixels)
2516 {
2517 // no copy
2518 ie = evas_cache_image_data(evas_common_image_cache_get(), iw, ih,
2519 pixels, EINA_TRUE, (Evas_Colorspace) cspace);
2520 if (!ie) return NULL;
2521 }
2522 else
2523 {
2524 // alloc buffer
2525 ie = evas_cache_image_copied_data(evas_common_image_cache_get(), iw, ih,
2526 NULL, EINA_TRUE, (Evas_Colorspace) cspace);
2527 if (!ie) return NULL;
2528 pixels = ((RGBA_Image *) ie)->image.data;
2529 memset(pixels, 0, iw * ih * pxs);
2530 }
2531 ie->borders.l = l;
2532 ie->borders.r = r;
2533 ie->borders.t = t;
2534 ie->borders.b = b;
2535
2536 buf = eng_ector_buffer_wrap(data, evas, ie, EINA_TRUE);
2537 evas_cache_image_drop(ie);
2538 }
2539 else
2540 {
2541 // Create only an Evas_GL_Image as backing
2542 Evas_GL_Image *im;
2543
2544 if (l || r || t || b)
2545 WRN("Borders are not supported by Evas surfaces!");
2546
2547 gc = re->window_gl_context_get(re->software.ob);
2548 im = evas_gl_common_image_surface_new(gc, iw, ih, EINA_TRUE);
2549 buf = eo_add(EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS, evas,
2550 evas_ector_buffer_engine_image_set(evas, im));
2551 im->references--;
2552 }
2553 return buf;
2501} 2554}
2502 2555
2503static Efl_Gfx_Render_Op 2556static Efl_Gfx_Render_Op