summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-12-31 14:33:03 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-01-05 15:43:44 +0900
commit9e0670a7051cb7cee928078b362ae8642908902f (patch)
treedbc8acd7b41bef96e400b668e00760f9f27cd4dc
parentdc4790e08ba8bd239e499227881ba8b7c95c127e (diff)
Evas filters & Ector GL: Prepare ground work for GL buffers
This fixes crashes, adds safety, and notes a couple of things that are not yet implemented: - Make an Evas_GL_Image from an RGBA_Image so we can draw it on the canvas. This means Evas.Ector.GL.RGBA_Image.Buffer - Readable Evas_GL_Image objects with gl_read_pixels --> Implement proper map() & unmap() for GL buffers
-rw-r--r--src/lib/evas/filters/evas_filter.c12
-rw-r--r--src/lib/evas/include/evas_private.h2
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c13
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.eo2
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c27
-rw-r--r--src/modules/evas/engines/software_generic/evas_ector_software_buffer.c31
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c2
7 files changed, 59 insertions, 30 deletions
diff --git a/src/lib/evas/filters/evas_filter.c b/src/lib/evas/filters/evas_filter.c
index b3068d7466..801c5a6d05 100644
--- a/src/lib/evas/filters/evas_filter.c
+++ b/src/lib/evas/filters/evas_filter.c
@@ -40,6 +40,8 @@ _evas_image_get(Ector_Buffer *buf)
40{ 40{
41 void *image = NULL; 41 void *image = NULL;
42 if (!buf) return NULL; 42 if (!buf) return NULL;
43 /* FIXME: This MAY return RGBA_Image because engine_image_set MAY pass an
44 * RGBA_Image... Baaaaah */
43 eo_do(buf, evas_ector_buffer_engine_image_get(NULL, &image)); 45 eo_do(buf, evas_ector_buffer_engine_image_get(NULL, &image));
44 return image; 46 return image;
45} 47}
@@ -73,7 +75,7 @@ evas_filter_context_new(Evas_Public_Data *evas, Eina_Bool async)
73 if (ctx->gl_engine) 75 if (ctx->gl_engine)
74 { 76 {
75 // FIXME!!! 77 // FIXME!!!
76 CRI("gl support not implemented"); 78 ERR("GL support not fully implemented! Repair work is in progress!");
77 } 79 }
78 return ctx; 80 return ctx;
79} 81}
@@ -142,7 +144,7 @@ evas_filter_context_proxy_render_all(Evas_Filter_Context *ctx, Eo *eo_obj,
142 } 144 }
143 _filter_buffer_backing_free(fb); 145 _filter_buffer_backing_free(fb);
144 XDBG("Source #%d '%s' has dimensions %dx%d", fb->id, fb->source_name, fb->w, fb->h); 146 XDBG("Source #%d '%s' has dimensions %dx%d", fb->id, fb->source_name, fb->w, fb->h);
145 fb->buffer = ENFN->ector_buffer_wrap(ENDT, obj->layer->evas->evas, source->proxy->surface); 147 fb->buffer = ENFN->ector_buffer_wrap(ENDT, obj->layer->evas->evas, source->proxy->surface, EINA_FALSE);
146 fb->alpha_only = EINA_FALSE; 148 fb->alpha_only = EINA_FALSE;
147 } 149 }
148} 150}
@@ -204,7 +206,7 @@ _ector_buffer_create(Evas_Filter_Buffer const *fb, void *data)
204 // This should be fixed by implementing full support in ector 206 // This should be fixed by implementing full support in ector
205 // Note: dropped support for cserve2, that was not needed anyway 207 // Note: dropped support for cserve2, that was not needed anyway
206 208
207 cspace = fb->alpha_only ? E_ALPHA : E_ARGB; 209 cspace = fb->alpha_only ? EVAS_COLORSPACE_GRY8 : EVAS_COLORSPACE_ARGB8888;
208#if 0 210#if 0
209 // ideal code 211 // ideal code
210 return fb->ENFN->ector_buffer_new(fb->ENDT, fb->ctx->evas->evas, 212 return fb->ENFN->ector_buffer_new(fb->ENDT, fb->ctx->evas->evas,
@@ -230,7 +232,7 @@ _ector_buffer_create(Evas_Filter_Buffer const *fb, void *data)
230 data = ((RGBA_Image *) ie)->image.data; 232 data = ((RGBA_Image *) ie)->image.data;
231 memset(data, 0, fb->w * fb->h * (fb->alpha_only ? 1 : 4)); 233 memset(data, 0, fb->w * fb->h * (fb->alpha_only ? 1 : 4));
232 } 234 }
233 return fb->ENFN->ector_buffer_wrap(fb->ENDT, fb->ctx->evas->evas, ie); 235 return fb->ENFN->ector_buffer_wrap(fb->ENDT, fb->ctx->evas->evas, ie, EINA_TRUE);
234} 236}
235 237
236Eina_Bool 238Eina_Bool
@@ -396,7 +398,7 @@ _filter_buffer_new_from_evas_surface(Evas_Filter_Context *ctx, void *image)
396 398
397 fb->id = ++(ctx->last_buffer_id); 399 fb->id = ++(ctx->last_buffer_id);
398 fb->ctx = ctx; 400 fb->ctx = ctx;
399 fb->buffer = ENFN->ector_buffer_wrap(ENDT, ctx->evas->evas, image); 401 fb->buffer = ENFN->ector_buffer_wrap(ENDT, ctx->evas->evas, image, EINA_FALSE);
400 ENFN->image_size_get(ENDT, image, &fb->w, &fb->h); 402 ENFN->image_size_get(ENDT, image, &fb->w, &fb->h);
401 fb->alpha_only = (ENFN->image_colorspace_get(ENDT, image) 403 fb->alpha_only = (ENFN->image_colorspace_get(ENDT, image)
402 == EVAS_COLORSPACE_GRY8); 404 == EVAS_COLORSPACE_GRY8);
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 8ca3c2b7f1..b9f8a33733 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1450,7 +1450,7 @@ struct _Evas_Func
1450 1450
1451 Ector_Surface *(*ector_create) (void *data); 1451 Ector_Surface *(*ector_create) (void *data);
1452 void (*ector_destroy) (void *data, Ector_Surface *surface); 1452 void (*ector_destroy) (void *data, Ector_Surface *surface);
1453 Ector_Buffer *(*ector_buffer_wrap) (void *data, Evas *e, void *engine_image); 1453 Ector_Buffer *(*ector_buffer_wrap) (void *data, Evas *e, void *engine_image, Eina_Bool is_rgba_image);
1454 Ector_Buffer *(*ector_buffer_new) (void *data, Evas *e, void *pixels, int width, int height, int stride, Efl_Gfx_Colorspace cspace, Eina_Bool writeable, int l, int r, int t, int b, Ector_Buffer_Flag flags); 1454 Ector_Buffer *(*ector_buffer_new) (void *data, Evas *e, void *pixels, int width, int height, int stride, Efl_Gfx_Colorspace cspace, Eina_Bool writeable, int l, int r, int t, int b, Ector_Buffer_Flag flags);
1455 void (*ector_begin) (void *data, void *context, Ector_Surface *ector, void *surface, void *engine_data, int x, int y, Eina_Bool do_async); 1455 void (*ector_begin) (void *data, void *context, Ector_Surface *ector, void *surface, void *engine_data, int x, int y, Eina_Bool do_async);
1456 void (*ector_renderer_draw) (void *data, void *context, void *surface, void *engine_data, Ector_Renderer *r, Eina_Array *clips, Eina_Bool do_async); 1456 void (*ector_renderer_draw) (void *data, void *context, void *surface, void *engine_data, Ector_Renderer *r, Eina_Array *clips, Eina_Bool do_async);
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 101f0d9b99..c8de1d8aad 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
@@ -42,8 +42,7 @@ _evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ect
42 } 42 }
43 43
44 pd->evas = eo_xref(evas, obj); 44 pd->evas = eo_xref(evas, obj);
45 pd->image = ENFN->image_ref(ENDT, im); 45 EINA_SAFETY_ON_NULL_RETURN(im);
46 if (!pd->image) return;
47 46
48 if (im->tex && im->tex->pt) 47 if (im->tex && im->tex->pt)
49 { 48 {
@@ -60,9 +59,11 @@ _evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ect
60 if (!im->tex->pt->fb) 59 if (!im->tex->pt->fb)
61 l = r = t = b = 1; 60 l = r = t = b = 1;
62 } 61 }
62
63 pd->image = ENFN->image_ref(ENDT, im);
63 eo_do(obj, ector_gl_buffer_base_attach(im->tex->pt->texture, 64 eo_do(obj, ector_gl_buffer_base_attach(im->tex->pt->texture,
64 im->tex->pt->fb, 65 im->tex->pt->fb,
65 evas_gl_common_gl_format_to_colorspace(im->tex->pt->format), 66 (Efl_Gfx_Colorspace) evas_gl_common_gl_format_to_colorspace(im->tex->pt->format),
66 im->tex->w, im->tex->h, 67 im->tex->w, im->tex->h,
67 im->tex->x, im->tex->y, 68 im->tex->x, im->tex->y,
68 im->tex->pt->w, im->tex->pt->h, 69 im->tex->pt->w, im->tex->pt->h,
@@ -70,7 +71,9 @@ _evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ect
70 } 71 }
71 else 72 else
72 { 73 {
73 ERR("What do we do now?"); 74 // FIXME: This might be required to support texture upload here
75 ERR("Image has no attached texture! Unsupported!");
76 pd->image = NULL;
74 } 77 }
75} 78}
76 79
@@ -87,7 +90,7 @@ EOLIAN static Eo_Base *
87_evas_ector_gl_image_buffer_eo_base_constructor(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd) 90_evas_ector_gl_image_buffer_eo_base_constructor(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd)
88{ 91{
89 eo_do_super(obj, MY_CLASS, obj = eo_constructor()); 92 eo_do_super(obj, MY_CLASS, obj = eo_constructor());
90 pd->base = eo_data_ref(obj, ECTOR_GL_BUFFER_CLASS); 93 pd->base = eo_data_ref(obj, ECTOR_GL_BUFFER_BASE_MIXIN);
91 pd->base->generic = eo_data_ref(obj, ECTOR_GENERIC_BUFFER_MIXIN); 94 pd->base->generic = eo_data_ref(obj, ECTOR_GENERIC_BUFFER_MIXIN);
92 pd->base->generic->eo = obj; 95 pd->base->generic->eo = obj;
93 return obj; 96 return obj;
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 0b72cda8a9..82cebb4e3d 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,4 +1,4 @@
1class Evas.Ector.GL.Image.Buffer (Evas.Ector.GL.Buffer) 1class Evas.Ector.GL.Image.Buffer (Evas.Ector.GL.Buffer, Evas.Ector.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 legacy_prefix: null; 4 legacy_prefix: null;
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index 78a73f41d1..27aae7fe1b 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -4,6 +4,10 @@
4#include "software/Ector_Software.h" 4#include "software/Ector_Software.h"
5#include "cairo/Ector_Cairo.h" 5#include "cairo/Ector_Cairo.h"
6#include "gl/Ector_GL.h" 6#include "gl/Ector_GL.h"
7#include "evas_ector_buffer.eo.h"
8#include "evas_ector_gl_buffer.eo.h"
9#include "evas_ector_gl_image_buffer.eo.h"
10#include "../software_generic/evas_ector_software_buffer.eo.h"
7 11
8#if defined HAVE_DLSYM && ! defined _WIN32 12#if defined HAVE_DLSYM && ! defined _WIN32
9# include <dlfcn.h> /* dlopen,dlclose,etc */ 13# include <dlfcn.h> /* dlopen,dlclose,etc */
@@ -2465,10 +2469,25 @@ eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector)
2465} 2469}
2466 2470
2467static Ector_Buffer * 2471static Ector_Buffer *
2468eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image) 2472eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image, Eina_Bool is_rgba_image)
2469{ 2473{
2470#warning FIXME: implement me 2474 Ector_Buffer *buf = NULL;
2471 return NULL; 2475 EINA_SAFETY_ON_NULL_RETURN_VAL(engine_image, NULL);
2476 if (is_rgba_image)
2477 {
2478 Image_Entry *ie = engine_image;
2479
2480 buf = eo_add(EVAS_ECTOR_SOFTWARE_BUFFER_CLASS, e,
2481 evas_ector_buffer_engine_image_set(e, ie));
2482 }
2483 else
2484 {
2485 Evas_GL_Image *im = engine_image;
2486
2487 buf = eo_add(EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS, e,
2488 evas_ector_buffer_engine_image_set(e, im));
2489 }
2490 return buf;
2472} 2491}
2473 2492
2474static Ector_Buffer * 2493static Ector_Buffer *
@@ -2477,7 +2496,7 @@ eng_ector_buffer_new(void *data EINA_UNUSED, Evas *e, void *pixels,
2477 Efl_Gfx_Colorspace cspace, Eina_Bool writeable, 2496 Efl_Gfx_Colorspace cspace, Eina_Bool writeable,
2478 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)
2479{ 2498{
2480#warning FIXME: implement me 2499 CRI("Not implemented.");
2481 return NULL; 2500 return NULL;
2482} 2501}
2483 2502
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 22efa05329..d46b2c1119 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
@@ -5,7 +5,6 @@
5#include <software/Ector_Software.h> 5#include <software/Ector_Software.h>
6#include "evas_common_private.h" 6#include "evas_common_private.h"
7#include "evas_private.h" 7#include "evas_private.h"
8#include "draw.h"
9 8
10#include "evas_ector_buffer.eo.h" 9#include "evas_ector_buffer.eo.h"
11#include "evas_ector_software_buffer.eo.h" 10#include "evas_ector_software_buffer.eo.h"
@@ -15,28 +14,26 @@
15typedef struct { 14typedef struct {
16 Ector_Software_Buffer_Base_Data *base; 15 Ector_Software_Buffer_Base_Data *base;
17 Evas *evas; 16 Evas *evas;
18 Image_Entry *image; 17 RGBA_Image *image;
19} Evas_Ector_Software_Buffer_Data; 18} Evas_Ector_Software_Buffer_Data;
20 19
21#define ENFN e->engine.func 20// Note: Don't use ENFN, ENDT here because the GL engine may also use SW buffers
22#define ENDT e->engine.data.output 21// eg. in the filters.
23 22
24EOLIAN static void 23EOLIAN static void
25_evas_ector_software_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ector_Software_Buffer_Data *pd, 24_evas_ector_software_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ector_Software_Buffer_Data *pd,
26 Evas *evas, void *image) 25 Evas *evas, void *image)
27{ 26{
28 Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS); 27 RGBA_Image *im = image;
29 Image_Entry *ie = image;
30 RGBA_Image *im;
31 Eina_Bool b; 28 Eina_Bool b;
32 29
30 EINA_SAFETY_ON_NULL_RETURN(image);
33 if (eo_do_ret(obj, b, eo_finalized_get())) 31 if (eo_do_ret(obj, b, eo_finalized_get()))
34 { 32 {
35 CRI("engine_image must be set at construction time only"); 33 CRI("engine_image must be set at construction time only");
36 return; 34 return;
37 } 35 }
38 36
39 im = (RGBA_Image *) ie;
40 if (!im->image.data) 37 if (!im->image.data)
41 { 38 {
42 CRI("image has no pixels yet"); 39 CRI("image has no pixels yet");
@@ -44,12 +41,13 @@ _evas_ector_software_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ect
44 } 41 }
45 42
46 pd->evas = eo_xref(evas, obj); 43 pd->evas = eo_xref(evas, obj);
47 pd->image = ENFN->image_ref(ENDT, ie); 44 evas_cache_image_ref(&im->cache_entry);
45 pd->image = im;
48 if (!pd->image) return; 46 if (!pd->image) return;
49 47
50 eo_do(obj, ector_buffer_pixels_set(im->image.data, 48 eo_do(obj, ector_buffer_pixels_set(im->image.data,
51 im->cache_entry.w, im->cache_entry.h, 0, 49 im->cache_entry.w, im->cache_entry.h, 0,
52 im->cache_entry.space, 50 (Efl_Gfx_Colorspace) im->cache_entry.space,
53 EINA_TRUE, 0, 0, 0, 0)); 51 EINA_TRUE, 0, 0, 0, 0));
54} 52}
55 53
@@ -58,7 +56,16 @@ _evas_ector_software_buffer_evas_ector_buffer_engine_image_get(Eo *obj EINA_UNUS
58 Evas_Ector_Software_Buffer_Data *pd, 56 Evas_Ector_Software_Buffer_Data *pd,
59 Evas **evas, void **image) 57 Evas **evas, void **image)
60{ 58{
59 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
60
61 if (evas) *evas = pd->evas; 61 if (evas) *evas = pd->evas;
62 if (e->engine.func->gl_surface_read_pixels)
63 {
64 ERR("Invalid: requesting engine_image from a GL image from a simple SW buffer!");
65 if (image) *image = NULL;
66 return;
67 }
68
62 if (image) *image = pd->image; 69 if (image) *image = pd->image;
63} 70}
64 71
@@ -82,10 +89,8 @@ _evas_ector_software_buffer_eo_base_finalize(Eo *obj, Evas_Ector_Software_Buffer
82EOLIAN static void 89EOLIAN static void
83_evas_ector_software_buffer_eo_base_destructor(Eo *obj, Evas_Ector_Software_Buffer_Data *pd) 90_evas_ector_software_buffer_eo_base_destructor(Eo *obj, Evas_Ector_Software_Buffer_Data *pd)
84{ 91{
85 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
86
87 eo_data_xunref(obj, pd->base, obj); 92 eo_data_xunref(obj, pd->base, obj);
88 ENFN->image_free(ENDT, pd->image); 93 evas_cache_image_drop(&pd->image->cache_entry);
89 eo_xunref(pd->evas, obj); 94 eo_xunref(pd->evas, obj);
90 eo_do_super(obj, MY_CLASS, eo_destructor()); 95 eo_do_super(obj, MY_CLASS, eo_destructor());
91} 96}
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index a32c7e60c6..06d2a5d4ca 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -3758,7 +3758,7 @@ eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector)
3758} 3758}
3759 3759
3760static Ector_Buffer * 3760static Ector_Buffer *
3761eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image) 3761eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image, Eina_Bool is_rgba_image EINA_UNUSED)
3762{ 3762{
3763 Image_Entry *ie = engine_image; 3763 Image_Entry *ie = engine_image;
3764 Ector_Buffer *buf = NULL; 3764 Ector_Buffer *buf = NULL;