summaryrefslogtreecommitdiff
path: root/src/modules/evas
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 /src/modules/evas
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
Diffstat (limited to 'src/modules/evas')
-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
5 files changed, 51 insertions, 24 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 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;