summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-01-04 17:48:48 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-01-05 15:43:44 +0900
commit66961126916f6ab61ba6549f7ad96399bdf773af (patch)
treefc4ca23f0250e51927cd7b0f7b721761c28f3131
parenta02c81005905486ebefc4dbab566807f2759d33b (diff)
Evas filters: Add GL buffer backed by RGBA_Image
Dumb implementation of a "smart" buffer capable of wrapping an RGBA_Image but that can still be rendered on screen (ie, an Evas_GL_Image is attached to it).
-rw-r--r--src/Makefile_Evas.am4
-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.c14
-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.eo12
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c8
6 files changed, 144 insertions, 12 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 6b4f239904..24e99299e5 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -755,12 +755,14 @@ GL_GENERIC_SOURCES = \
755modules/evas/engines/gl_generic/evas_engine.c \ 755modules/evas/engines/gl_generic/evas_engine.c \
756modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h \ 756modules/evas/engines/gl_generic/Evas_Engine_GL_Generic.h \
757modules/evas/engines/gl_generic/evas_ector_gl_buffer.c \ 757modules/evas/engines/gl_generic/evas_ector_gl_buffer.c \
758modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c 758modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c \
759modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.c \
759$(NULL) 760$(NULL)
760 761
761evas_gl_generic_eolian_files = \ 762evas_gl_generic_eolian_files = \
762modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo \ 763modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo \
763modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.eo \ 764modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.eo \
765modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.eo \
764$(NULL) 766$(NULL)
765 767
766evas_gl_generic_eolian_c = $(evas_gl_generic_eolian_files:%.eo=%.eo.c) 768evas_gl_generic_eolian_c = $(evas_gl_generic_eolian_files:%.eo=%.eo.c)
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 09b4cb54fd..93e30f43c9 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -660,6 +660,7 @@ Evas_GL_Image *evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const ch
660Evas_GL_Image *evas_gl_common_image_mmap(Evas_Engine_GL_Context *gc, Eina_File *f, const char *key, Evas_Image_Load_Opts *lo, int *error); 660Evas_GL_Image *evas_gl_common_image_mmap(Evas_Engine_GL_Context *gc, Eina_File *f, const char *key, Evas_Image_Load_Opts *lo, int *error);
661Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, DATA32 *data, int alpha, Evas_Colorspace cspace); 661Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, DATA32 *data, int alpha, Evas_Colorspace cspace);
662Evas_GL_Image *evas_gl_common_image_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, Evas_Colorspace cspace); 662Evas_GL_Image *evas_gl_common_image_new(Evas_Engine_GL_Context *gc, unsigned int w, unsigned int h, int alpha, Evas_Colorspace cspace);
663Evas_GL_Image *evas_gl_common_image_new_from_rgbaimage(Evas_Engine_GL_Context *gc, RGBA_Image *im, Evas_Image_Load_Opts *lo, int *error);
663Evas_GL_Image *evas_gl_common_image_alpha_set(Evas_GL_Image *im, int alpha); 664Evas_GL_Image *evas_gl_common_image_alpha_set(Evas_GL_Image *im, int alpha);
664void evas_gl_common_image_scale_hint_set(Evas_GL_Image *im, int hint); 665void evas_gl_common_image_scale_hint_set(Evas_GL_Image *im, int hint);
665void evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint); 666void evas_gl_common_image_content_hint_set(Evas_GL_Image *im, int hint);
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 664b4e4764..e62cfdc88a 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_image.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_image.c
@@ -150,9 +150,9 @@ _evas_gl_cspace_list_fill(Evas_Engine_GL_Context *gc)
150 CS_APPEND(EVAS_COLORSPACE_ARGB8888); 150 CS_APPEND(EVAS_COLORSPACE_ARGB8888);
151} 151}
152 152
153static Evas_GL_Image * 153Evas_GL_Image *
154_evas_gl_common_image(Evas_Engine_GL_Context *gc, RGBA_Image *im_im, 154evas_gl_common_image_new_from_rgbaimage(Evas_Engine_GL_Context *gc, RGBA_Image *im_im,
155 Evas_Image_Load_Opts *lo, int *error) 155 Evas_Image_Load_Opts *lo, int *error)
156{ 156{
157 Evas_GL_Image *im; 157 Evas_GL_Image *im;
158 Eina_List *l; 158 Eina_List *l;
@@ -260,7 +260,7 @@ evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const char *file, const ch
260 im_im = NULL; 260 im_im = NULL;
261 } 261 }
262 else 262 else
263 return _evas_gl_common_image(gc, im_im, lo, error); 263 return evas_gl_common_image_new_from_rgbaimage(gc, im_im, lo, error);
264 } 264 }
265 } 265 }
266#endif 266#endif
@@ -268,7 +268,7 @@ evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const char *file, const ch
268 im_im = evas_common_load_image_from_file(file, key, lo, error); 268 im_im = evas_common_load_image_from_file(file, key, lo, error);
269 if (!im_im) return NULL; 269 if (!im_im) return NULL;
270 270
271 return _evas_gl_common_image(gc, im_im, lo, error); 271 return evas_gl_common_image_new_from_rgbaimage(gc, im_im, lo, error);
272} 272}
273 273
274Evas_GL_Image * 274Evas_GL_Image *
@@ -291,7 +291,7 @@ evas_gl_common_image_mmap(Evas_Engine_GL_Context *gc, Eina_File *f, const char *
291 im_im = NULL; 291 im_im = NULL;
292 } 292 }
293 else 293 else
294 return _evas_gl_common_image(gc, im_im, lo, error); 294 return evas_gl_common_image_new_from_rgbaimage(gc, im_im, lo, error);
295 } 295 }
296 } 296 }
297#endif 297#endif
@@ -299,7 +299,7 @@ evas_gl_common_image_mmap(Evas_Engine_GL_Context *gc, Eina_File *f, const char *
299 im_im = evas_common_load_image_from_mmap(f, key, lo, error); 299 im_im = evas_common_load_image_from_mmap(f, key, lo, error);
300 if (!im_im) return NULL; 300 if (!im_im) return NULL;
301 301
302 return _evas_gl_common_image(gc, im_im, lo, error); 302 return evas_gl_common_image_new_from_rgbaimage(gc, im_im, lo, error);
303} 303}
304 304
305EAPI Evas_GL_Image * 305EAPI Evas_GL_Image *
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
new file mode 100644
index 0000000000..03d957ac81
--- /dev/null
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.c
@@ -0,0 +1,117 @@
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 Eina_Bool b;
35
36 EINA_SAFETY_ON_NULL_RETURN(image);
37 if (eo_do_ret(obj, b, eo_finalized_get()))
38 {
39 CRI("engine_image must be set at construction time only");
40 return;
41 }
42
43 if (!im->image.data)
44 {
45 CRI("image has no pixels yet");
46 return;
47 }
48
49 pd->evas = eo_xref(evas, obj);
50 evas_cache_image_ref(&im->cache_entry);
51 pd->image = im;
52 if (!pd->image) return;
53
54 eo_do(obj, ector_buffer_pixels_set(im->image.data,
55 im->cache_entry.w, im->cache_entry.h, 0,
56 (Efl_Gfx_Colorspace) im->cache_entry.space,
57 EINA_TRUE, 0, 0, 0, 0));
58}
59
60EOLIAN static void
61_evas_ector_gl_rgbaimage_buffer_evas_ector_buffer_engine_image_get(Eo *obj EINA_UNUSED,
62 Evas_Ector_GL_RGBAImage_Buffer_Data *pd,
63 Evas **evas, void **image)
64{
65 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
66 Render_Engine_GL_Generic *re = e->engine.data.output;
67 Evas_Engine_GL_Context *gc = NULL;
68 int err = EVAS_LOAD_ERROR_NONE;
69
70 if (evas) *evas = pd->evas;
71 if (image) *image = NULL;
72 if (pd->glim)
73 goto end;
74
75 EINA_SAFETY_ON_NULL_RETURN(re);
76 gc = re->window_gl_context_get(re->software.ob);
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_eo_base_constructor(Eo *obj, Evas_Ector_GL_RGBAImage_Buffer_Data *pd)
90{
91 eo_do_super(obj, MY_CLASS, obj = eo_constructor());
92 pd->base = eo_data_xref(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN, obj);
93 return obj;
94}
95
96EOLIAN static Eo *
97_evas_ector_gl_rgbaimage_buffer_eo_base_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 eo_do_super_ret(obj, MY_CLASS, obj, eo_finalize());
103}
104
105EOLIAN static void
106_evas_ector_gl_rgbaimage_buffer_eo_base_destructor(Eo *obj, Evas_Ector_GL_RGBAImage_Buffer_Data *pd)
107{
108 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
109
110 eo_data_xunref(obj, pd->base, obj);
111 ENFN->image_free(ENDT, pd->glim);
112 evas_cache_image_drop(&pd->image->cache_entry);
113 eo_xunref(pd->evas, obj);
114 eo_do_super(obj, MY_CLASS, eo_destructor());
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
new file mode 100644
index 0000000000..3c8f38397b
--- /dev/null
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_rgbaimage_buffer.eo
@@ -0,0 +1,12 @@
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 legacy_prefix: null;
5 implements {
6 Eo.Base.constructor;
7 Eo.Base.finalize;
8 Eo.Base.destructor;
9 Evas.Ector.Buffer.engine_image.get;
10 Evas.Ector.Buffer.engine_image.set;
11 }
12}
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index 27aae7fe1b..fc9caf04fc 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -7,7 +7,7 @@
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 "../software_generic/evas_ector_software_buffer.eo.h" 10#include "evas_ector_gl_rgbaimage_buffer.eo.h"
11 11
12#if defined HAVE_DLSYM && ! defined _WIN32 12#if defined HAVE_DLSYM && ! defined _WIN32
13# include <dlfcn.h> /* dlopen,dlclose,etc */ 13# include <dlfcn.h> /* dlopen,dlclose,etc */
@@ -2475,10 +2475,10 @@ eng_ector_buffer_wrap(void *data EINA_UNUSED, Evas *e, void *engine_image, Eina_
2475 EINA_SAFETY_ON_NULL_RETURN_VAL(engine_image, NULL); 2475 EINA_SAFETY_ON_NULL_RETURN_VAL(engine_image, NULL);
2476 if (is_rgba_image) 2476 if (is_rgba_image)
2477 { 2477 {
2478 Image_Entry *ie = engine_image; 2478 RGBA_Image *im = engine_image;
2479 2479
2480 buf = eo_add(EVAS_ECTOR_SOFTWARE_BUFFER_CLASS, e, 2480 buf = eo_add(EVAS_ECTOR_GL_RGBAIMAGE_BUFFER_CLASS, e,
2481 evas_ector_buffer_engine_image_set(e, ie)); 2481 evas_ector_buffer_engine_image_set(e, im));
2482 } 2482 }
2483 else 2483 else
2484 { 2484 {