summaryrefslogtreecommitdiff
path: root/src/modules/evas
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-12-17 18:04:06 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-01-05 15:43:44 +0900
commitdc4790e08ba8bd239e499227881ba8b7c95c127e (patch)
tree31ddc62791570ebffb26c686188378dff5f0947c /src/modules/evas
parenteda13b729851605615032a4af400de9b820e2d63 (diff)
Ector GL: Add skeletton for Evas.Ector.GL.Image.Buffer
This is an ector buffer backed by an existing Evas_GL_Image
Diffstat (limited to '')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h9
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_texture.c15
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c14
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo5
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c117
-rw-r--r--src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.eo12
-rw-r--r--src/modules/evas/engines/software_generic/evas_ector_software_buffer.c17
7 files changed, 179 insertions, 10 deletions
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 24a5c3a122..09b4cb54fd 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -18,6 +18,8 @@
18# define MESA_EGL_NO_X11_HEADERS 18# define MESA_EGL_NO_X11_HEADERS
19#endif 19#endif
20 20
21#ifndef EVAS_GL_NO_HEADERS
22
21#ifdef BUILD_ENGINE_GL_COCOA 23#ifdef BUILD_ENGINE_GL_COCOA
22# include <OpenGL/gl.h> 24# include <OpenGL/gl.h>
23# include <OpenGL/glext.h> 25# include <OpenGL/glext.h>
@@ -41,6 +43,8 @@
41# endif 43# endif
42#endif 44#endif
43 45
46#endif
47
44#include "evas_gl_define.h" 48#include "evas_gl_define.h"
45 49
46#define EVAS_GL_TILE_SIZE 16 50#define EVAS_GL_TILE_SIZE 16
@@ -649,6 +653,7 @@ Evas_GL_Texture *evas_gl_common_texture_nv12tiled_new(Evas_Engine_GL_Context *g
649void evas_gl_common_texture_nv12tiled_update(Evas_GL_Texture *tex, DATA8 **row, unsigned int w, unsigned int h); 653void evas_gl_common_texture_nv12tiled_update(Evas_GL_Texture *tex, DATA8 **row, unsigned int w, unsigned int h);
650Evas_GL_Texture *evas_gl_common_texture_rgb_a_pair_new(Evas_Engine_GL_Context *gc, RGBA_Image *im); 654Evas_GL_Texture *evas_gl_common_texture_rgb_a_pair_new(Evas_Engine_GL_Context *gc, RGBA_Image *im);
651void evas_gl_common_texture_rgb_a_pair_update(Evas_GL_Texture *tex, RGBA_Image *im); 655void evas_gl_common_texture_rgb_a_pair_update(Evas_GL_Texture *tex, RGBA_Image *im);
656Evas_Colorspace evas_gl_common_gl_format_to_colorspace(GLuint f);
652 657
653void evas_gl_common_image_alloc_ensure(Evas_GL_Image *im); 658void evas_gl_common_image_alloc_ensure(Evas_GL_Image *im);
654Evas_GL_Image *evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const char *file, const char *key, Evas_Image_Load_Opts *lo, int *error); 659Evas_GL_Image *evas_gl_common_image_load(Evas_Engine_GL_Context *gc, const char *file, const char *key, Evas_Image_Load_Opts *lo, int *error);
@@ -864,6 +869,8 @@ __evas_gl_errdyn(int err, const char *file, const char *func, int line, const ch
864Eina_Bool evas_gl_common_module_open(void); 869Eina_Bool evas_gl_common_module_open(void);
865void evas_gl_common_module_close(void); 870void evas_gl_common_module_close(void);
866 871
872#ifndef EVAS_GL_NO_HEADERS
873
867static inline void 874static inline void
868_tex_sub_2d(Evas_Engine_GL_Context *gc, int x, int y, int w, int h, int fmt, int type, const void *pix) 875_tex_sub_2d(Evas_Engine_GL_Context *gc, int x, int y, int w, int h, int fmt, int type, const void *pix)
869{ 876{
@@ -880,6 +887,8 @@ _comp_tex_sub_2d(Evas_Engine_GL_Context *gc, int x, int y, int w, int h, int fmt
880 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, fmt, imgsize, pix); 887 glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, fmt, imgsize, pix);
881} 888}
882 889
890#endif
891
883#include "evas_gl_3d_common.h" 892#include "evas_gl_3d_common.h"
884 893
885#undef EAPI 894#undef EAPI
diff --git a/src/modules/evas/engines/gl_common/evas_gl_texture.c b/src/modules/evas/engines/gl_common/evas_gl_texture.c
index 9c31dda89a..f72a3e8cf9 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_texture.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_texture.c
@@ -161,6 +161,21 @@ _evas_gl_texture_search_format(Eina_Bool alpha, Eina_Bool bgra, Evas_Colorspace
161 return -1; 161 return -1;
162} 162}
163 163
164Evas_Colorspace
165evas_gl_common_gl_format_to_colorspace(GLuint f)
166{
167 unsigned i;
168
169 for (i = 0; i < sizeof(matching_format) / sizeof(matching_format[0]); i++)
170 {
171 if (*matching_format[i].format == f)
172 return matching_format[i].cspace;
173 }
174
175 ERR("Unknown texture format!");
176 return EVAS_COLORSPACE_ARGB8888;
177}
178
164static void 179static void
165_print_tex_count(void) 180_print_tex_count(void)
166{ 181{
diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c
new file mode 100644
index 0000000000..4736e6592c
--- /dev/null
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.c
@@ -0,0 +1,14 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <gl/Ector_GL.h>
6#include "gl/ector_gl_private.h"
7#include "evas_common_private.h"
8#include "ector_buffer.h"
9#include "evas_ector_buffer.eo.h"
10#include "evas_ector_gl_buffer.eo.h"
11
12#define MY_CLASS EVAS_ECTOR_GL_BUFFER_CLASS
13
14#include "evas_ector_gl_buffer.eo.c"
diff --git a/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo
new file mode 100644
index 0000000000..6912657250
--- /dev/null
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_buffer.eo
@@ -0,0 +1,5 @@
1class Evas.Ector.GL.Buffer (Eo.Base, Evas.Ector.Buffer, Ector.GL.Buffer.Base)
2{
3 legacy_prefix: null;
4 data: null;
5}
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
new file mode 100644
index 0000000000..101f0d9b99
--- /dev/null
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.c
@@ -0,0 +1,117 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#define ECTOR_GL_BUFFER_BASE_PROTECTED
6
7#include <gl/Ector_GL.h>
8#include "gl/ector_gl_private.h"
9#include "evas_common_private.h"
10#include "../gl_common/evas_gl_common.h"
11#include "evas_private.h"
12#include "ector_buffer.h"
13
14#include "evas_ector_buffer.eo.h"
15#include "evas_ector_gl_buffer.eo.h"
16#include "evas_ector_gl_image_buffer.eo.h"
17
18#define MY_CLASS EVAS_ECTOR_GL_IMAGE_BUFFER_CLASS
19
20typedef struct
21{
22 Ector_GL_Buffer_Base_Data *base;
23 Evas *evas;
24 Evas_GL_Image *image;
25} Evas_Ector_GL_Image_Buffer_Data;
26
27#define ENFN e->engine.func
28#define ENDT e->engine.data.output
29
30EOLIAN static void
31_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)
33{
34 Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS);
35 Evas_GL_Image *im = image;
36 int l = 0, r = 0, t = 0, b = 0;
37
38 if (pd->base->generic->immutable)
39 {
40 CRI("Can't set image after finalize");
41 return;
42 }
43
44 pd->evas = eo_xref(evas, obj);
45 pd->image = ENFN->image_ref(ENDT, im);
46 if (!pd->image) return;
47
48 if (im->tex && im->tex->pt)
49 {
50 if (im->im)
51 {
52 l = im->im->cache_entry.borders.l;
53 r = im->im->cache_entry.borders.r;
54 t = im->im->cache_entry.borders.t;
55 b = im->im->cache_entry.borders.b;
56 }
57 else
58 {
59 // always 1 pixel border, except FBO
60 if (!im->tex->pt->fb)
61 l = r = t = b = 1;
62 }
63 eo_do(obj, ector_gl_buffer_base_attach(im->tex->pt->texture,
64 im->tex->pt->fb,
65 evas_gl_common_gl_format_to_colorspace(im->tex->pt->format),
66 im->tex->w, im->tex->h,
67 im->tex->x, im->tex->y,
68 im->tex->pt->w, im->tex->pt->h,
69 l, r, t, b));
70 }
71 else
72 {
73 ERR("What do we do now?");
74 }
75}
76
77EOLIAN static void
78_evas_ector_gl_image_buffer_evas_ector_buffer_engine_image_get(Eo *obj EINA_UNUSED,
79 Evas_Ector_GL_Image_Buffer_Data *pd,
80 Evas **evas, void **image)
81{
82 if (evas) *evas = pd->evas;
83 if (image) *image = pd->image;
84}
85
86EOLIAN static Eo_Base *
87_evas_ector_gl_image_buffer_eo_base_constructor(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd)
88{
89 eo_do_super(obj, MY_CLASS, obj = eo_constructor());
90 pd->base = eo_data_ref(obj, ECTOR_GL_BUFFER_CLASS);
91 pd->base->generic = eo_data_ref(obj, ECTOR_GENERIC_BUFFER_MIXIN);
92 pd->base->generic->eo = obj;
93 return obj;
94}
95
96EOLIAN static Eo_Base *
97_evas_ector_gl_image_buffer_eo_base_finalize(Eo *obj, Evas_Ector_GL_Image_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_image_buffer_eo_base_destructor(Eo *obj, Evas_Ector_GL_Image_Buffer_Data *pd)
107{
108 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
109
110 eo_data_unref(obj, pd->base->generic);
111 eo_data_unref(obj, pd->base);
112 ENFN->image_free(ENDT, pd->image);
113 eo_xunref(pd->evas, obj);
114 eo_do_super(obj, MY_CLASS, eo_destructor());
115}
116
117#include "evas_ector_gl_image_buffer.eo.c"
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
new file mode 100644
index 0000000000..0b72cda8a9
--- /dev/null
+++ b/src/modules/evas/engines/gl_generic/evas_ector_gl_image_buffer.eo
@@ -0,0 +1,12 @@
1class Evas.Ector.GL.Image.Buffer (Evas.Ector.GL.Buffer)
2{
3 [[An Ector GL buffer wrapping an existing Evas_GL_Image.]]
4 legacy_prefix: null;
5 implements {
6 Eo.Base.constructor;
7 Eo.Base.finalize;
8 Eo.Base.destructor;
9 Evas.Ector.Buffer.engine_image.set;
10 Evas.Ector.Buffer.engine_image.get;
11 }
12}
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 44ebf8fbd3..22efa05329 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
@@ -15,7 +15,7 @@
15typedef struct { 15typedef struct {
16 Ector_Software_Buffer_Base_Data *base; 16 Ector_Software_Buffer_Base_Data *base;
17 Evas *evas; 17 Evas *evas;
18 Image_Entry *ie; 18 Image_Entry *image;
19} Evas_Ector_Software_Buffer_Data; 19} Evas_Ector_Software_Buffer_Data;
20 20
21#define ENFN e->engine.func 21#define ENFN e->engine.func
@@ -44,8 +44,8 @@ _evas_ector_software_buffer_evas_ector_buffer_engine_image_set(Eo *obj, Evas_Ect
44 } 44 }
45 45
46 pd->evas = eo_xref(evas, obj); 46 pd->evas = eo_xref(evas, obj);
47 pd->ie = ENFN->image_ref(ENDT, ie); 47 pd->image = ENFN->image_ref(ENDT, ie);
48 if (!pd->ie) return; 48 if (!pd->image) return;
49 49
50 eo_do(obj, ector_buffer_pixels_set(im->image.data, 50 eo_do(obj, ector_buffer_pixels_set(im->image.data,
51 im->cache_entry.w, im->cache_entry.h, 0, 51 im->cache_entry.w, im->cache_entry.h, 0,
@@ -59,7 +59,7 @@ _evas_ector_software_buffer_evas_ector_buffer_engine_image_get(Eo *obj EINA_UNUS
59 Evas **evas, void **image) 59 Evas **evas, void **image)
60{ 60{
61 if (evas) *evas = pd->evas; 61 if (evas) *evas = pd->evas;
62 if (image) *image = pd->ie; 62 if (image) *image = pd->image;
63} 63}
64 64
65EOLIAN static Eo * 65EOLIAN static Eo *
@@ -73,11 +73,8 @@ _evas_ector_software_buffer_eo_base_constructor(Eo *obj, Evas_Ector_Software_Buf
73EOLIAN static Eo * 73EOLIAN static Eo *
74_evas_ector_software_buffer_eo_base_finalize(Eo *obj, Evas_Ector_Software_Buffer_Data *pd) 74_evas_ector_software_buffer_eo_base_finalize(Eo *obj, Evas_Ector_Software_Buffer_Data *pd)
75{ 75{
76 if (!pd->ie) 76 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->base, NULL);
77 { 77 EINA_SAFETY_ON_NULL_RETURN_VAL(pd->image, NULL);
78 CRI("engine_image must be set at construction time only");
79 return NULL;
80 }
81 pd->base->generic->immutable = EINA_TRUE; 78 pd->base->generic->immutable = EINA_TRUE;
82 return eo_do_super_ret(obj, MY_CLASS, obj, eo_finalize()); 79 return eo_do_super_ret(obj, MY_CLASS, obj, eo_finalize());
83} 80}
@@ -88,7 +85,7 @@ _evas_ector_software_buffer_eo_base_destructor(Eo *obj, Evas_Ector_Software_Buff
88 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS); 85 Evas_Public_Data *e = eo_data_scope_get(pd->evas, EVAS_CANVAS_CLASS);
89 86
90 eo_data_xunref(obj, pd->base, obj); 87 eo_data_xunref(obj, pd->base, obj);
91 ENFN->image_free(ENDT, pd->ie); 88 ENFN->image_free(ENDT, pd->image);
92 eo_xunref(pd->evas, obj); 89 eo_xunref(pd->evas, obj);
93 eo_do_super(obj, MY_CLASS, eo_destructor()); 90 eo_do_super(obj, MY_CLASS, eo_destructor());
94} 91}