summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Michael <cp.michael@samsung.com>2013-02-27 12:33:50 +0000
committerChristopher Michael <cp.michael@samsung.com>2013-02-27 12:33:50 +0000
commit12a6ef11bb0a70e6206cf7ebccd901438606267f (patch)
tree948b7f6f064124e745c620f90873e67286da86eb
parentba863894480ad1a8f14c6992e154b1aaa85dc7e5 (diff)
Remove old wayland_egl code.
Signed-off-by: Christopher Michael <cp.michael@samsung.com>
-rw-r--r--src/modules/evas/engines/wayland_egl/Evas_Engine_Wayland_Egl.h49
-rw-r--r--src/modules/evas/engines/wayland_egl/evas_engine.c3804
-rw-r--r--src/modules/evas/engines/wayland_egl/evas_engine.h87
-rw-r--r--src/modules/evas/engines/wayland_egl/evas_wl_main.c295
4 files changed, 0 insertions, 4235 deletions
diff --git a/src/modules/evas/engines/wayland_egl/Evas_Engine_Wayland_Egl.h b/src/modules/evas/engines/wayland_egl/Evas_Engine_Wayland_Egl.h
deleted file mode 100644
index ff5fcd83bb..0000000000
--- a/src/modules/evas/engines/wayland_egl/Evas_Engine_Wayland_Egl.h
+++ /dev/null
@@ -1,49 +0,0 @@
1#ifndef _EVAS_ENGINE_WAYLAND_EGL_H
2#define _EVAS_ENGINE_WAYLAND_EGL_H
3
4/*
5 * Wayland supoprt is considered experimental as wayland itself is still
6 * unstable and liable to change core protocol. If you use this api, it is
7 * possible it will break in future, until this notice is removed.
8 */
9
10#include <wayland-client.h>
11
12typedef struct _Evas_Engine_Info_Wayland_Egl Evas_Engine_Info_Wayland_Egl;
13
14struct _Evas_Engine_Info_Wayland_Egl
15{
16 /* PRIVATE - don't mess with this baby or evas will poke its tongue out */
17 /* at you and make nasty noises */
18 Evas_Engine_Info magic;
19
20 /* engine specific data & parameters it needs to set up */
21 struct {
22 struct wl_display *display;
23 struct wl_surface *surface;
24 int depth;
25 int screen;
26 int rotation;
27 int edges;
28 unsigned int destination_alpha : 1;
29 } info;
30 /* engine specific function calls to query stuff about the destination */
31 /* engine (what visual & colormap & depth to use, performance info etc. */
32 struct {
33 int (*best_depth_get) (Evas_Engine_Info_Wayland_Egl *einfo);
34 } func;
35
36 struct {
37 void (*pre_swap) (void *data, Evas *e);
38 void (*post_swap) (void *data, Evas *e);
39
40 void *data; // data for callback calls
41 } callback;
42
43 /* non-blocking or blocking mode */
44 Evas_Engine_Render_Mode render_mode;
45
46 unsigned char vsync : 1; // does nothing right now
47 unsigned char indirect : 1; // use indirect rendering
48};
49#endif
diff --git a/src/modules/evas/engines/wayland_egl/evas_engine.c b/src/modules/evas/engines/wayland_egl/evas_engine.c
deleted file mode 100644
index 965030ec30..0000000000
--- a/src/modules/evas/engines/wayland_egl/evas_engine.c
+++ /dev/null
@@ -1,3804 +0,0 @@
1#include "evas_common.h" /* Also includes international specific stuff */
2#include "evas_private.h"
3#include "evas_engine.h"
4
5#ifdef HAVE_DLSYM
6# include <dlfcn.h> /* dlopen,dlclose,etc */
7#else
8# error gl_x11 should not get compiled if dlsym is not found on the system!
9#endif
10
11#define EVAS_GL_NO_GL_H_CHECK 1
12#include "Evas_GL.h"
13
14typedef struct _Render_Engine Render_Engine;
15typedef struct _Render_Engine_GL_Surface Render_Engine_GL_Surface;
16typedef struct _Render_Engine_GL_Context Render_Engine_GL_Context;
17typedef struct _Render_Engine_GL_Resource Render_Engine_GL_Resource;
18typedef struct _Extension_Entry Extension_Entry;
19
20struct _Render_Engine
21{
22 Evas_GL_Wl_Window *win;
23 Evas_Engine_Info_Wayland_Egl *info;
24 Evas *evas;
25 Tilebuf *tb;
26 int end;
27 int w, h;
28 int vsync;
29 struct
30 {
31 int max_rb_size;
32 int msaa_support;
33 int msaa_samples[4];
34
35 //---------//
36 int rgb_888[4];
37 int rgba_8888[4];
38
39 int depth_8[4];
40 int depth_16[4];
41 int depth_24[4];
42 int depth_32[4];
43
44 int stencil_1[4];
45 int stencil_2[4];
46 int stencil_4[4];
47 int stencil_8[4];
48 int stencil_16[4];
49
50 int depth_24_stencil_8[4];
51 } gl_cap;
52
53 int gl_cap_initted;
54};
55
56struct _Render_Engine_GL_Surface
57{
58 int initialized;
59 int fbo_attached;
60 int w, h;
61 int depth_bits;
62 int stencil_bits;
63
64 int direct_fb_opt;
65
66 GLint rt_msaa_samples;
67
68 // Render target texture/buffers
69 GLuint rt_tex;
70 GLint rt_internal_fmt;
71 GLenum rt_fmt;
72 GLuint rb_depth;
73 GLenum rb_depth_fmt;
74 GLuint rb_stencil;
75 GLenum rb_stencil_fmt;
76 GLuint rb_depth_stencil;
77 GLenum rb_depth_stencil_fmt;
78
79 EGLSurface direct_sfc;
80
81 Render_Engine_GL_Context *current_ctx;
82};
83
84struct _Render_Engine_GL_Context
85{
86 int initialized;
87 EGLContext context;
88 GLuint context_fbo;
89 GLuint current_fbo;
90
91 int scissor_enabled;
92 int scissor_updated;
93
94 Render_Engine_GL_Surface *current_sfc;
95};
96
97// Resources used per thread
98struct _Render_Engine_GL_Resource
99{
100 // Resource context/surface per Thread in TLS for evasgl use
101 EGLContext context;
102 EGLSurface surface;
103};
104
105// Extension Handling
106struct _Extension_Entry
107{
108 const char *name;
109 const char *real_name;
110 int supported;
111};
112
113static int initted = 0;
114static int gl_wins = 0;
115static int gl_direct_override = 0;
116static int gl_direct_enabled = 0;
117static Render_Engine_GL_Context *current_evgl_ctx;
118static Render_Engine *current_engine;
119static Evas_Object *gl_direct_img_obj = NULL; /* NEW */
120
121static int _ext_initted = 0; /* NEW */
122static char _gl_ext_string[1024];
123static char _evasgl_ext_string[1024];
124
125// Resource context/surface per Thread in TLS for evasgl use
126static Eina_TLS resource_key;
127static Eina_List *resource_list;
128LK(resource_lock);
129
130typedef void (*_eng_fn) (void);
131typedef _eng_fn (*glsym_func_eng_fn) ();
132typedef void (*glsym_func_void) ();
133typedef void *(*glsym_func_void_ptr) ();
134typedef int (*glsym_func_int) ();
135typedef unsigned int (*glsym_func_uint) ();
136typedef unsigned char (*glsym_func_uchar) ();
137typedef unsigned char *(*glsym_func_uchar_ptr) ();
138typedef const char *(*glsym_func_const_char_ptr) ();
139
140#ifndef EGL_NATIVE_PIXMAP_KHR
141# define EGL_NATIVE_PIXMAP_KHR 0x30b0
142#endif
143_eng_fn (*glsym_eglGetProcAddress) (const char *a) = NULL;
144void (*glsym_eglBindTexImage) (EGLDisplay a, EGLSurface b, int c) = NULL;
145void (*glsym_eglReleaseTexImage) (EGLDisplay a, EGLSurface b, int c) = NULL;
146void *(*glsym_eglCreateImage) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, const int *e) = NULL;
147void (*glsym_eglDestroyImage) (EGLDisplay a, void *b) = NULL;
148void (*glsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL;
149void (*glsym_glEGLImageTargetRenderbufferStorageOES) (int a, void *b) = NULL;
150void *(*glsym_eglMapImageSEC) (void *a, void *b) = NULL;
151unsigned int (*glsym_eglUnmapImageSEC) (void *a, void *b) = NULL;
152const char *(*glsym_eglQueryString) (EGLDisplay a, int name) = NULL;
153
154unsigned int (*glsym_eglLockSurface) (EGLDisplay a, EGLSurface b, const int *attrib_list) = NULL;
155unsigned int (*glsym_eglUnlockSurface) (EGLDisplay a, EGLSurface b) = NULL;
156
157// GLES2 Extensions
158void (*glsym_glGetProgramBinaryOES) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary) = NULL;
159void (*glsym_glProgramBinaryOES) (GLuint program, GLenum binaryFormat, const void *binary, GLint length) = NULL;
160void* (*glsym_glMapBufferOES) (GLenum target, GLenum access) = NULL;
161unsigned char (*glsym_glUnmapBufferOES) (GLenum target) = NULL;
162void (*glsym_glGetBufferPointervOES) (GLenum target, GLenum pname, void** params) = NULL;
163void (*glsym_glTexImage3DOES) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels) = NULL;
164void (*glsym_glTexSubImage3DOES) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels) = NULL;
165void (*glsym_glCopyTexSubImage3DOES) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
166void (*glsym_glCompressedTexImage3DOES) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data) = NULL;
167void (*glsym_glCompressedTexSubImage3DOES) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data) = NULL;
168void (*glsym_glFramebufferTexture3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) = NULL;
169void (*glsym_glGetPerfMonitorGroupsAMD) (GLint* numGroups, GLsizei groupsSize, GLuint* groups) = NULL;
170void (*glsym_glGetPerfMonitorCountersAMD) (GLuint group, GLint* numCounters, GLint* maxActiveCounters, GLsizei counterSize, GLuint* counters) = NULL;
171void (*glsym_glGetPerfMonitorGroupStringAMD) (GLuint group, GLsizei bufSize, GLsizei* length, char* groupString) = NULL;
172void (*glsym_glGetPerfMonitorCounterStringAMD) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, char* counterString) = NULL;
173void (*glsym_glGetPerfMonitorCounterInfoAMD) (GLuint group, GLuint counter, GLenum pname, void* data) = NULL;
174void (*glsym_glGenPerfMonitorsAMD) (GLsizei n, GLuint* monitors) = NULL;
175void (*glsym_glDeletePerfMonitorsAMD) (GLsizei n, GLuint* monitors) = NULL;
176void (*glsym_glSelectPerfMonitorCountersAMD) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* countersList) = NULL;
177void (*glsym_glBeginPerfMonitorAMD) (GLuint monitor) = NULL;
178void (*glsym_glEndPerfMonitorAMD) (GLuint monitor) = NULL;
179void (*glsym_glGetPerfMonitorCounterDataAMD) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint* bytesWritten) = NULL;
180void (*glsym_glDiscardFramebufferEXT) (GLenum target, GLsizei numAttachments, const GLenum* attachments) = NULL;
181void (*glsym_glMultiDrawArraysEXT) (GLenum mode, GLint* first, GLsizei* count, GLsizei primcount) = NULL;
182void (*glsym_glMultiDrawElementsEXT) (GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount) = NULL;
183void (*glsym_glDeleteFencesNV) (GLsizei n, const GLuint* fences) = NULL;
184void (*glsym_glGenFencesNV) (GLsizei n, GLuint* fences) = NULL;
185unsigned char (*glsym_glIsFenceNV) (GLuint fence) = NULL;
186unsigned char (*glsym_glTestFenceNV) (GLuint fence) = NULL;
187void (*glsym_glGetFenceivNV) (GLuint fence, GLenum pname, GLint* params) = NULL;
188void (*glsym_glFinishFenceNV) (GLuint fence) = NULL;
189void (*glsym_glSetFenceNV) (GLuint, GLenum) = NULL;
190void (*glsym_glRenderbufferStorageMultisample) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) = NULL;
191void (*glsym_glFramebufferTexture2DMultisample) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) = NULL;
192void (*glsym_glGetDriverControlsQCOM) (GLint* num, GLsizei size, GLuint* driverControls) = NULL;
193void (*glsym_glGetDriverControlStringQCOM) (GLuint driverControl, GLsizei bufSize, GLsizei* length, char* driverControlString) = NULL;
194void (*glsym_glEnableDriverControlQCOM) (GLuint driverControl) = NULL;
195void (*glsym_glDisableDriverControlQCOM) (GLuint driverControl) = NULL;
196void (*glsym_glExtGetTexturesQCOM) (GLuint* textures, GLint maxTextures, GLint* numTextures) = NULL;
197void (*glsym_glExtGetBuffersQCOM) (GLuint* buffers, GLint maxBuffers, GLint* numBuffers) = NULL;
198void (*glsym_glExtGetRenderbuffersQCOM) (GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers) = NULL;
199void (*glsym_glExtGetFramebuffersQCOM) (GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers) = NULL;
200void (*glsym_glExtGetTexLevelParameterivQCOM) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params) = NULL;
201void (*glsym_glExtTexObjectStateOverrideiQCOM) (GLenum target, GLenum pname, GLint param) = NULL;
202void (*glsym_glExtGetTexSubImageQCOM) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void* texels) = NULL;
203void (*glsym_glExtGetBufferPointervQCOM) (GLenum target, void** params) = NULL;
204void (*glsym_glExtGetShadersQCOM) (GLuint* shaders, GLint maxShaders, GLint* numShaders) = NULL;
205void (*glsym_glExtGetProgramsQCOM) (GLuint* programs, GLint maxPrograms, GLint* numPrograms) = NULL;
206unsigned char (*glsym_glExtIsProgramBinaryQCOM) (GLuint program) = NULL;
207void (*glsym_glExtGetProgramBinarySourceQCOM) (GLuint program, GLenum shadertype, char* source, GLint* length) = NULL;
208
209
210//------ GLES 2.0 Extensions supported in EvasGL -----//
211static Extension_Entry _gl_ext_entries[] = {
212 //--- Function Extensions ---//
213 { "GL_OES_get_program_binary", "get_program_binary", 0 },
214 { "GL_OES_mapbuffer", "mapbuffer", 0 },
215 { "GL_OES_texture_3D", "texture_3D", 0 },
216 { "AMD_performance_monitor", "AMD_performance_monitor", 0 },
217 { "GL_EXT_discard_framebuffer", "discard_framebuffer", 0 },
218 { "GL_EXT_multi_draw_arrays", "multi_draw_arrays", 0 },
219 { "GL_NV_fence", "NV_fence", 0 },
220 { "GL_QCOM_driver_control", "QCOM_driver_control", 0 },
221 { "GL_QCOM_extended_get", "QCOM_extended_get", 0 },
222 { "GL_QCOM_extended_get2", "QCOM_extended_get2", 0 },
223
224 //--- Define Extensions ---//
225 { "GL_OES_compressed_ETC1_RGB8_texture", "compressed_ETC1_RGB8_texture", 0 },
226 { "GL_OES_compressed_paletted_texture", "compressed_paletted_texture", 0 },
227 { "GL_OES_depth24", "depth24", 0 },
228 { "GL_OES_depth32", "depth32", 0 },
229 { "GL_OES_EvasGL_image", "EGL_image", 0 },
230 { "GL_OES_packed_depth_stencil", "packed_depth_stencil", 0 },
231 { "GL_OES_rgb8_rgba8", "rgb8_rgba8", 0 },
232 { "GL_OES_standard_derivatives", "standard_derivatives", 0 },
233 { "GL_OES_stencil1", "stencil1", 0 },
234 { "GL_OES_stencil4", "stencil4", 0 },
235 { "GL_OES_texture_float", "texture_float", 0 },
236 { "GL_OES_texture_half_float", "texture_half_float", 0 },
237 { "GL_OES_texture_half_float_linear", "texture_half_float_linear", 0 },
238 { "GL_OES_texture_npot", "texture_npot", 0 },
239 { "GL_OES_vertex_half_float", "vertex_half_float", 0 },
240 { "GL_OES_vertex_type_10_10_10_2", "vertex_type_10_10_10_2", 0 },
241 { "GL_AMD_compressed_3DC_texture", "compressed_3DC_texture", 0 },
242 { "GL_AMD_compressed_ATC_texture", "compressed_ATC_texture", 0 },
243 { "GL_AMD_program_binary_Z400", "program_binary_Z400", 0 },
244 { "GL_EXT_blend_minmax", "blend_minmax", 0 },
245 { "GL_EXT_read_format_bgra", "read_format_bgra", 0 },
246 { "GL_EXT_texture_filter_anisotropic", "texture_filter_anisotrophic", 0 },
247 { "GL_EXT_texture_format_BGRA8888", "texture_format_BGRA8888", 0 },
248 { "GL_EXT_texture_type_2_10_10_10_REV", "texture_type_2_10_10_10_rev", 0 },
249 { "GL_IMG_program_binary", "IMG_program_binary", 0 },
250 { "GL_IMG_read_format", "IMG_read_format", 0 },
251 { "GL_IMG_shader_binary", "IMG_shader_binary", 0 },
252 { "GL_IMG_texture_compression_pvrtc", "IMG_texture_compression_pvrtc", 0 },
253 { "GL_QCOM_perfmon_global_mode", "QCOM_perfmon_global_mode", 0 },
254 { "GL_QCOM_writeonly_rendering", "QCOM_writeonly_rendering", 0 },
255 { NULL, NULL, 0}
256};
257
258//------ Extensions supported in EvasGL -----//
259static Extension_Entry _evasgl_ext_entries[] = {
260 { "EvasGL_KHR_image", "EGL_KHR_image", 0 },
261 { "EvasGL_KHR_vg_parent_image", "EGL_KHR_vg_parent_image", 0 },
262 { "EvasGL_KHR_gl_texture_2D_image", "EGL_KHR_gl_texture_2D_image", 0 },
263 { "EvasGL_KHR_gl_texture_cubemap_image", "EGL_KHR_gl_texture_cubemap_image", 0 },
264 { "EvasGL_KHR_gl_texture_3D_image", "EGL_KHR_gl_texture_3D_image", 0 },
265 { "EvasGL_KHR_gl_renderbuffer_image", "EGL_KHR_gl_renderbuffer_image", 0 },
266 { NULL, NULL, 0 }
267};
268
269static void
270_sym_init(void)
271{
272 static int done = 0;
273
274 if (done) return;
275
276#define FINDSYM(dst, sym, typ) \
277 if ((!dst) && (glsym_eglGetProcAddress)) dst = (typ)glsym_eglGetProcAddress(sym); \
278 if (!dst) dst = (typ)dlsym(RTLD_DEFAULT, sym)
279
280 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddress", glsym_func_eng_fn);
281 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressEXT", glsym_func_eng_fn);
282 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressARB", glsym_func_eng_fn);
283 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressKHR", glsym_func_eng_fn);
284
285 FINDSYM(glsym_eglBindTexImage, "eglBindTexImage", glsym_func_void);
286 FINDSYM(glsym_eglBindTexImage, "eglBindTexImageEXT", glsym_func_void);
287 FINDSYM(glsym_eglBindTexImage, "eglBindTexImageARB", glsym_func_void);
288 FINDSYM(glsym_eglBindTexImage, "eglBindTexImageKHR", glsym_func_void);
289
290 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImage", glsym_func_void);
291 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageEXT", glsym_func_void);
292 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageARB", glsym_func_void);
293 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageKHR", glsym_func_void);
294
295 FINDSYM(glsym_eglCreateImage, "eglCreateImage", glsym_func_void_ptr);
296 FINDSYM(glsym_eglCreateImage, "eglCreateImageEXT", glsym_func_void_ptr);
297 FINDSYM(glsym_eglCreateImage, "eglCreateImageARB", glsym_func_void_ptr);
298 FINDSYM(glsym_eglCreateImage, "eglCreateImageKHR", glsym_func_void_ptr);
299
300 FINDSYM(glsym_eglDestroyImage, "eglDestroyImage", glsym_func_void);
301 FINDSYM(glsym_eglDestroyImage, "eglDestroyImageEXT", glsym_func_void);
302 FINDSYM(glsym_eglDestroyImage, "eglDestroyImageARB", glsym_func_void);
303 FINDSYM(glsym_eglDestroyImage, "eglDestroyImageKHR", glsym_func_void);
304
305 FINDSYM(glsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", glsym_func_void);
306
307 FINDSYM(glsym_glEGLImageTargetRenderbufferStorageOES, "glEGLImageTargetRenderbufferStorageOES", glsym_func_void);
308
309 FINDSYM(glsym_eglMapImageSEC, "eglMapImageSEC", glsym_func_void_ptr);
310 FINDSYM(glsym_eglUnmapImageSEC, "eglUnmapImageSEC", glsym_func_uint);
311
312 FINDSYM(glsym_eglQueryString, "eglQueryString", glsym_func_const_char_ptr);
313
314 FINDSYM(glsym_eglLockSurface, "eglLockSurface", glsym_func_uint);
315 FINDSYM(glsym_eglLockSurface, "eglLockSurfaceEXT", glsym_func_uint);
316 FINDSYM(glsym_eglLockSurface, "eglLockSurfaceARB", glsym_func_uint);
317 FINDSYM(glsym_eglLockSurface, "eglLockSurfaceKHR", glsym_func_uint);
318
319 FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurface", glsym_func_uint);
320 FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurfaceEXT", glsym_func_uint);
321 FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurfaceARB", glsym_func_uint);
322 FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurfaceKHR", glsym_func_uint);
323
324 //----------- GLES 2.0 Extensions ------------//
325 // If the symbol's not found, they get set to NULL
326 // If one of the functions in the extension exists, the extension in supported
327 /* GL_OES_get_program_binary */
328 FINDSYM(glsym_glGetProgramBinaryOES, "glGetProgramBinary", glsym_func_void);
329 FINDSYM(glsym_glGetProgramBinaryOES, "glGetProgramBinaryEXT", glsym_func_void);
330 FINDSYM(glsym_glGetProgramBinaryOES, "glGetProgramBinaryARB", glsym_func_void);
331 FINDSYM(glsym_glGetProgramBinaryOES, "glGetProgramBinaryOES", glsym_func_void);
332
333 FINDSYM(glsym_glProgramBinaryOES, "glProgramBinary", glsym_func_void);
334 FINDSYM(glsym_glProgramBinaryOES, "glProgramBinaryEXT", glsym_func_void);
335 FINDSYM(glsym_glProgramBinaryOES, "glProgramBinaryARB", glsym_func_void);
336 FINDSYM(glsym_glProgramBinaryOES, "glProgramBinaryOES", glsym_func_void);
337
338 // Check the first function to see if the extension is supported...
339 if (glsym_glGetProgramBinaryOES) _gl_ext_entries[0].supported = 1;
340
341 /* GL_OES_mapbuffer */
342 FINDSYM(glsym_glMapBufferOES, "glMapBuffer", glsym_func_void_ptr);
343 FINDSYM(glsym_glMapBufferOES, "glMapBufferEXT", glsym_func_void_ptr);
344 FINDSYM(glsym_glMapBufferOES, "glMapBufferARB", glsym_func_void_ptr);
345 FINDSYM(glsym_glMapBufferOES, "glMapBufferOES", glsym_func_void_ptr);
346
347 FINDSYM(glsym_glUnmapBufferOES, "glUnmapBuffer", glsym_func_uchar);
348 FINDSYM(glsym_glUnmapBufferOES, "glUnmapBufferEXT", glsym_func_uchar);
349 FINDSYM(glsym_glUnmapBufferOES, "glUnmapBufferARB", glsym_func_uchar);
350 FINDSYM(glsym_glUnmapBufferOES, "glUnmapBufferOES", glsym_func_uchar);
351
352 FINDSYM(glsym_glGetBufferPointervOES, "glGetBufferPointerv", glsym_func_void);
353 FINDSYM(glsym_glGetBufferPointervOES, "glGetBufferPointervEXT", glsym_func_void);
354 FINDSYM(glsym_glGetBufferPointervOES, "glGetBufferPointervARB", glsym_func_void);
355 FINDSYM(glsym_glGetBufferPointervOES, "glGetBufferPointervOES", glsym_func_void);
356
357 if (glsym_glMapBufferOES) _gl_ext_entries[1].supported = 1;
358
359 /* GL_OES_texture_3D */
360 FINDSYM(glsym_glTexImage3DOES, "glTexImage3D", glsym_func_void);
361 FINDSYM(glsym_glTexImage3DOES, "glTexImage3DEXT", glsym_func_void);
362 FINDSYM(glsym_glTexImage3DOES, "glTexImage3DARB", glsym_func_void);
363 FINDSYM(glsym_glTexImage3DOES, "glTexImage3DOES", glsym_func_void);
364
365 FINDSYM(glsym_glTexSubImage3DOES, "glTexSubImage3D", glsym_func_void);
366 FINDSYM(glsym_glTexSubImage3DOES, "glTexSubImage3DEXT", glsym_func_void);
367 FINDSYM(glsym_glTexSubImage3DOES, "glTexSubImage3DARB", glsym_func_void);
368 FINDSYM(glsym_glTexSubImage3DOES, "glTexSubImage3DOES", glsym_func_void);
369
370 FINDSYM(glsym_glCopyTexSubImage3DOES, "glCopyTexSubImage3D", glsym_func_void);
371 FINDSYM(glsym_glCopyTexSubImage3DOES, "glCopyTexSubImage3DARB", glsym_func_void);
372 FINDSYM(glsym_glCopyTexSubImage3DOES, "glCopyTexSubImage3DEXT", glsym_func_void);
373 FINDSYM(glsym_glCopyTexSubImage3DOES, "glCopyTexSubImage3DOES", glsym_func_void);
374
375 FINDSYM(glsym_glCompressedTexImage3DOES, "glCompressedTexImage3D", glsym_func_void);
376 FINDSYM(glsym_glCompressedTexImage3DOES, "glCompressedTexImage3DARB", glsym_func_void);
377 FINDSYM(glsym_glCompressedTexImage3DOES, "glCompressedTexImage3DEXT", glsym_func_void);
378 FINDSYM(glsym_glCompressedTexImage3DOES, "glCompressedTexImage3DOES", glsym_func_void);
379
380 FINDSYM(glsym_glCompressedTexSubImage3DOES, "glCompressedTexSubImage3D", glsym_func_void);
381 FINDSYM(glsym_glCompressedTexSubImage3DOES, "glCompressedTexSubImage3DARB", glsym_func_void);
382 FINDSYM(glsym_glCompressedTexSubImage3DOES, "glCompressedTexSubImage3DEXT", glsym_func_void);
383 FINDSYM(glsym_glCompressedTexSubImage3DOES, "glCompressedTexSubImage3DOES", glsym_func_void);
384
385 FINDSYM(glsym_glFramebufferTexture3DOES, "glFramebufferTexture3D", glsym_func_void);
386 FINDSYM(glsym_glFramebufferTexture3DOES, "glFramebufferTexture3DARB", glsym_func_void);
387 FINDSYM(glsym_glFramebufferTexture3DOES, "glFramebufferTexture3DEXT", glsym_func_void);
388 FINDSYM(glsym_glFramebufferTexture3DOES, "glFramebufferTexture3DOES", glsym_func_void);
389
390 if (glsym_glTexSubImage3DOES) _gl_ext_entries[2].supported = 1;
391
392 /* AMD_performance_monitor */
393 FINDSYM(glsym_glGetPerfMonitorGroupsAMD, "glGetPerfMonitorGroupsAMD", glsym_func_void);
394 FINDSYM(glsym_glGetPerfMonitorCountersAMD, "glGetPerfMonitorCountersAMD", glsym_func_void);
395 FINDSYM(glsym_glGetPerfMonitorGroupStringAMD, "glGetPerfMonitorGroupStringAMD", glsym_func_void);
396 FINDSYM(glsym_glGetPerfMonitorCounterStringAMD, "glGetPerfMonitorCounterStringAMD", glsym_func_void);
397 FINDSYM(glsym_glGetPerfMonitorCounterInfoAMD, "glGetPerfMonitorCounterInfoAMD", glsym_func_void);
398 FINDSYM(glsym_glGenPerfMonitorsAMD, "glGenPerfMonitorsAMD", glsym_func_void);
399 FINDSYM(glsym_glDeletePerfMonitorsAMD, "glDeletePerfMonitorsAMD", glsym_func_void);
400 FINDSYM(glsym_glSelectPerfMonitorCountersAMD, "glSelectPerfMonitorCountersAMD", glsym_func_void);
401 FINDSYM(glsym_glBeginPerfMonitorAMD, "glBeginPerfMonitorAMD", glsym_func_void);
402 FINDSYM(glsym_glEndPerfMonitorAMD, "glEndPerfMonitorAMD", glsym_func_void);
403 FINDSYM(glsym_glGetPerfMonitorCounterDataAMD, "glGetPerfMonitorCounterDataAMD", glsym_func_void);
404
405 if (glsym_glGetPerfMonitorGroupsAMD) _gl_ext_entries[3].supported = 1;
406
407 /* GL_EXT_discard_framebuffer */
408 FINDSYM(glsym_glDiscardFramebufferEXT, "glDiscardFramebuffer", glsym_func_void);
409 FINDSYM(glsym_glDiscardFramebufferEXT, "glDiscardFramebufferARB", glsym_func_void);
410 FINDSYM(glsym_glDiscardFramebufferEXT, "glDiscardFramebufferEXT", glsym_func_void);
411
412 if (glsym_glDiscardFramebufferEXT) _gl_ext_entries[4].supported = 1;
413
414 /* GL_EXT_multi_draw_arrays */
415 FINDSYM(glsym_glMultiDrawArraysEXT, "glMultiDrawArrays", glsym_func_void);
416 FINDSYM(glsym_glMultiDrawArraysEXT, "glMultiDrawArraysARB", glsym_func_void);
417 FINDSYM(glsym_glMultiDrawArraysEXT, "glMultiDrawArraysEXT", glsym_func_void);
418
419 FINDSYM(glsym_glMultiDrawElementsEXT, "glMultiDrawElements", glsym_func_void);
420 FINDSYM(glsym_glMultiDrawElementsEXT, "glMultiDrawElementsARB", glsym_func_void);
421 FINDSYM(glsym_glMultiDrawElementsEXT, "glMultiDrawElementsEXT", glsym_func_void);
422
423 if (glsym_glMultiDrawArraysEXT) _gl_ext_entries[5].supported = 1;
424
425 /* GL_NV_fence */
426 FINDSYM(glsym_glDeleteFencesNV, "glDeleteFencesNV", glsym_func_void);
427 FINDSYM(glsym_glGenFencesNV, "glGenFencesNV", glsym_func_void);
428 FINDSYM(glsym_glIsFenceNV, "glIsFenceNV", glsym_func_uchar);
429 FINDSYM(glsym_glTestFenceNV, "glTestFenceNV", glsym_func_uchar);
430 FINDSYM(glsym_glGetFenceivNV, "glGetFenceivNV", glsym_func_void);
431 FINDSYM(glsym_glFinishFenceNV, "glFinishFenceNV", glsym_func_void);
432 FINDSYM(glsym_glSetFenceNV, "glSetFenceNV", glsym_func_void);
433
434 if (glsym_glDeleteFencesNV) _gl_ext_entries[6].supported = 1;
435
436 /* GL_QCOM_driver_control */
437 FINDSYM(glsym_glGetDriverControlsQCOM, "glGetDriverControlsQCOM", glsym_func_void);
438 FINDSYM(glsym_glGetDriverControlStringQCOM, "glGetDriverControlStringQCOM", glsym_func_void);
439 FINDSYM(glsym_glEnableDriverControlQCOM, "glEnableDriverControlQCOM", glsym_func_void);
440 FINDSYM(glsym_glDisableDriverControlQCOM, "glDisableDriverControlQCOM", glsym_func_void);
441
442 if (glsym_glGetDriverControlsQCOM) _gl_ext_entries[7].supported = 1;
443
444 /* GL_QCOM_extended_get */
445 FINDSYM(glsym_glExtGetTexturesQCOM, "glExtGetTexturesQCOM", glsym_func_void);
446 FINDSYM(glsym_glExtGetBuffersQCOM, "glExtGetBuffersQCOM", glsym_func_void);
447 FINDSYM(glsym_glExtGetRenderbuffersQCOM, "glExtGetRenderbuffersQCOM", glsym_func_void);
448 FINDSYM(glsym_glExtGetFramebuffersQCOM, "glExtGetFramebuffersQCOM", glsym_func_void);
449 FINDSYM(glsym_glExtGetTexLevelParameterivQCOM, "glExtGetTexLevelParameterivQCOM", glsym_func_void);
450 FINDSYM(glsym_glExtTexObjectStateOverrideiQCOM, "glExtTexObjectStateOverrideiQCOM", glsym_func_void);
451 FINDSYM(glsym_glExtGetTexSubImageQCOM, "glExtGetTexSubImageQCOM", glsym_func_void);
452 FINDSYM(glsym_glExtGetBufferPointervQCOM, "glExtGetBufferPointervQCOM", glsym_func_void);
453
454 if (glsym_glExtGetTexturesQCOM) _gl_ext_entries[8].supported = 1;
455
456 /* GL_QCOM_extended_get2 */
457 FINDSYM(glsym_glExtGetShadersQCOM, "glExtGetShadersQCOM", glsym_func_void);
458 FINDSYM(glsym_glExtGetProgramsQCOM, "glExtGetProgramsQCOM", glsym_func_void);
459 FINDSYM(glsym_glExtIsProgramBinaryQCOM, "glExtIsProgramBinaryQCOM", glsym_func_uchar);
460 FINDSYM(glsym_glExtGetProgramBinarySourceQCOM, "glExtGetProgramBinarySourceQCOM", glsym_func_void);
461
462 if (glsym_glExtGetShadersQCOM) _gl_ext_entries[9].supported = 1;
463}
464
465static void
466_extensions_init(Render_Engine *re)
467{
468 int i;
469 const char *glexts, *evasglexts;
470
471 memset(_gl_ext_string, 0, 1024);
472 memset(_evasgl_ext_string, 0, 1024);
473
474 // GLES 2.0 Extensions
475 glexts = (const char*)glGetString(GL_EXTENSIONS);
476
477 DBG("--------GLES 2.0 Extensions--------");
478 for (i = 0; _gl_ext_entries[i].name != NULL; i++)
479 {
480 if ( (strstr(glexts, _gl_ext_entries[i].name) != NULL) ||
481 (strstr(glexts, _gl_ext_entries[i].real_name) != NULL) )
482 {
483 _gl_ext_entries[i].supported = 1;
484 strcat(_gl_ext_string, _gl_ext_entries[i].name);
485 strcat(_gl_ext_string, " ");
486 DBG("\t%s", _gl_ext_entries[i].name);
487 }
488
489 }
490 DBG(" ");
491
492 // EGL Extensions
493 evasglexts = glsym_eglQueryString(re->win->egl_disp, EGL_EXTENSIONS);
494
495 DBG("--------EvasGL Extensions----------");
496 for (i = 0; _evasgl_ext_entries[i].name != NULL; i++)
497 {
498 if ( (strstr(evasglexts, _evasgl_ext_entries[i].name) != NULL) ||
499 (strstr(evasglexts, _evasgl_ext_entries[i].real_name) != NULL) )
500 {
501 _evasgl_ext_entries[i].supported = 1;
502 strcat(_evasgl_ext_string, _evasgl_ext_entries[i].name);
503 strcat(_evasgl_ext_string, " ");
504 DBG("\t%s", _evasgl_ext_entries[i].name);
505 }
506 }
507 DBG(" ");
508}
509
510int _evas_engine_wl_egl_log_dom = -1;
511
512/* function tables - filled in later (func and parent func) */
513static Evas_Func func, pfunc;
514
515/* Function table for GL APIs */
516static Evas_GL_API gl_funcs;
517
518static void *
519eng_info(Evas *e EINA_UNUSED)
520{
521 Evas_Engine_Info_Wayland_Egl *info;
522
523 info = calloc(1, sizeof(Evas_Engine_Info_Wayland_Egl));
524 info->magic.magic = rand();
525 info->func.best_depth_get = eng_best_depth_get;
526 info->render_mode = EVAS_RENDER_MODE_BLOCKING;
527
528 return info;
529}
530
531static void
532eng_info_free(Evas *e EINA_UNUSED, void *info)
533{
534 Evas_Engine_Info_Wayland_Egl *in;
535// dont free! why bother? its not worth it
536// eina_log_domain_unregister(_evas_engine_GL_X11_log_dom);
537 in = (Evas_Engine_Info_Wayland_Egl *)info;
538 free(in);
539}
540
541static int
542_re_wincheck(Render_Engine *re)
543{
544 if (!re) return 0;
545 if (re->win->surf) return 1;
546 eng_window_resurf(re->win);
547 if (!re->win->surf)
548 {
549 ERR("GL engine can't re-create window surface!");
550 }
551 return 0;
552}
553
554static void
555_re_winfree(Render_Engine *re)
556{
557 if (!re->win->surf) return;
558 eng_window_unsurf(re->win);
559}
560
561static Render_Engine_GL_Resource *
562_create_internal_glue_resources(void *data)
563{
564 Render_Engine *re;
565 Render_Engine_GL_Resource *rsc;
566
567 if (!(re = (Render_Engine *)data)) return NULL;
568
569 rsc = calloc(1, sizeof(Render_Engine_GL_Resource));
570 if (!rsc) return NULL;
571
572 // EGL
573 int context_attrs[3];
574 context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
575 context_attrs[1] = 2;
576 context_attrs[2] = EGL_NONE;
577
578 // Create resource surface for EGL
579 if (re->win->egl_surface[0])
580 rsc->surface = re->win->egl_surface[0];
581 else
582 {
583 rsc->surface =
584 eglCreateWindowSurface(re->win->egl_disp, re->win->egl_config,
585 (EGLNativeWindowType)re->win->win, NULL);
586 }
587
588 if (!rsc->surface)
589 {
590 ERR("Creating internal resource surface failed.");
591 free(rsc);
592 return NULL;
593 }
594
595 // Create a resource context for EGL
596 rsc->context =
597 eglCreateContext(re->win->egl_disp, re->win->egl_config,
598 re->win->egl_context[0], context_attrs);
599 if (!rsc->context)
600 {
601 ERR("Internal Resource Context Creations Failed.");
602 free(rsc);
603 return NULL;
604 }
605
606 // Add to the resource resource list for cleanup
607 LKL(resource_lock);
608 resource_list = eina_list_prepend(resource_list, rsc);
609 LKU(resource_lock);
610
611 // Set the resource in TLS
612 if (eina_tls_set(resource_key, (void*)rsc) == EINA_FALSE)
613 {
614 ERR("Failed setting TLS Resource");
615 free(rsc);
616 return NULL;
617 }
618
619 return rsc;
620}
621
622static int
623_destroy_internal_glue_resources(void *data)
624{
625 Render_Engine *re = (Render_Engine *)data;
626 Eina_List *l;
627 Render_Engine_GL_Resource *rsc;
628
629 // EGL
630 // Delete the Resources
631 LKL(resource_lock);
632 EINA_LIST_FOREACH(resource_list, l, rsc)
633 {
634 if (rsc->surface) eglDestroySurface(re->win->egl_disp, rsc->surface);
635 if (rsc->context) eglDestroyContext(re->win->egl_disp, rsc->context);
636 free(rsc);
637 }
638 eina_list_free(resource_list);
639 resource_list = NULL;
640 LKU(resource_lock);
641
642 // Destroy TLS
643 eina_tls_free(resource_key);
644
645 return 1;
646}
647
648static int
649eng_setup(Evas *eo_e, void *in)
650{
651 Evas_Public_Data *e = eo_data_get(eo_e, EVAS_CLASS);
652 Render_Engine *re;
653 Evas_Engine_Info_Wayland_Egl *info;
654 Evas_GL_Wl_Window *new_win = NULL;
655
656 info = (Evas_Engine_Info_Wayland_Egl *)in;
657 if (!e->engine.data.output)
658 {
659 re = calloc(1, sizeof(Render_Engine));
660 if (!re) return 0;
661 re->info = info;
662 re->evas = eo_e;
663 e->engine.data.output = re;
664 re->w = e->output.w;
665 re->h = e->output.h;
666
667 re->win = eng_window_new(re->info->info.display,
668 re->info->info.surface,
669 re->info->info.screen,
670 re->info->info.depth, re->w, re->h,
671 re->info->indirect,
672 re->info->info.destination_alpha,
673 re->info->info.rotation);
674 if (!re->win)
675 {
676 free(re);
677 e->engine.data.output = NULL;
678 return 0;
679 }
680
681 gl_wins++;
682 if (!initted)
683 {
684 evas_common_cpu_init();
685 evas_common_blend_init();
686 evas_common_image_init();
687 evas_common_convert_init();
688 evas_common_scale_init();
689 evas_common_rectangle_init();
690 evas_common_polygon_init();
691 evas_common_line_init();
692 evas_common_font_init();
693 evas_common_draw_init();
694 evas_common_tilebuf_init();
695
696 // Initialize TLS
697 if (eina_tls_new(&resource_key) == EINA_FALSE)
698 ERR("Error creating tls key");
699
700 DBG("TLS KEY create... %d", resource_key);
701
702 initted = 1;
703 }
704 }
705 else
706 {
707 if (!(re = e->engine.data.output)) return 0;
708 if (_re_wincheck(re))
709 {
710 if ((re->info->info.display != re->win->disp) ||
711 (re->info->info.surface != re->win->surface) ||
712 (re->info->info.screen != re->win->screen) ||
713 (re->info->info.depth != re->win->depth) ||
714 (re->info->info.destination_alpha != re->win->alpha) ||
715 (re->info->info.rotation != re->win->rot))
716 {
717 int inc = 0;
718
719 /* if we already have a window surface, check for NULL input surface.
720 * this will mean we are hiding the window and should destroy
721 * things properly */
722 if ((re->win->surface) && (re->info->info.surface == NULL))
723 {
724 if (re->win)
725 {
726 eng_window_free(re->win);
727 gl_wins--;
728 re->win = NULL;
729 }
730 return 1;
731 }
732
733 new_win = eng_window_new(re->info->info.display,
734 re->info->info.surface,
735 re->info->info.screen,
736 re->info->info.depth,
737 e->output.w, e->output.h,
738 re->info->indirect,
739 re->info->info.destination_alpha,
740 re->info->info.rotation);
741
742 if (new_win)
743 {
744 // free old win
745 if (re->win)
746 {
747 re->win->gl_context->references++;
748 eng_window_free(re->win);
749 inc = 1;
750 gl_wins--;
751 }
752
753 re->win = new_win;
754 re->w = e->output.w;
755 re->h = e->output.h;
756
757 eng_window_use(re->win);
758 if (re->win) gl_wins++;
759 if ((re->win) && (inc))
760 re->win->gl_context->references--;
761 }
762 }
763 else if ((re->win->w != e->output.w) ||
764 (re->win->h != e->output.h))
765 {
766 re->w = e->output.w;
767 re->h = e->output.h;
768 re->win->w = e->output.w;
769 re->win->h = e->output.h;
770 eng_window_use(re->win);
771 evas_gl_common_context_resize(re->win->gl_context,
772 re->win->w, re->win->h,
773 re->win->rot);
774 }
775 }
776 }
777
778 if (!re->win)
779 {
780 free(re);
781 e->engine.data.output = NULL;
782 return 0;
783 }
784
785 if (!e->engine.data.output)
786 {
787 if (re->win)
788 {
789 eng_window_free(re->win);
790 gl_wins--;
791 }
792 free(re);
793 e->engine.data.output = NULL;
794 return 0;
795 }
796 re->tb = evas_common_tilebuf_new(re->win->w, re->win->h);
797 if (!re->tb)
798 {
799 if (re->win)
800 {
801 eng_window_free(re->win);
802 gl_wins--;
803 }
804 free(re);
805 e->engine.data.output = NULL;
806 return 0;
807 }
808 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
809
810 if (!e->engine.data.context)
811 {
812 e->engine.data.context =
813 e->engine.func->context_new(e->engine.data.output);
814 }
815
816 eng_window_use(re->win);
817
818 re->vsync = 0;
819 if (!_ext_initted)
820 {
821 _sym_init();
822 _extensions_init(re);
823 _ext_initted = 1;
824 }
825
826 // This is used in extensions. Not pretty but can't get display otherwise.
827 current_engine = re;
828
829 return 1;
830}
831
832static void
833eng_output_free(void *data)
834{
835 Render_Engine *re;
836
837 re = (Render_Engine *)data;
838
839 if (re)
840 {
841#if 0
842 // Destroy the resource surface
843 // Only required for EGL case
844 if (re->surface)
845 eglDestroySurface(re->win->egl_disp, re->surface);
846
847 // Destroy the resource context
848 _destroy_internal_context(re, context);
849#endif
850 if (re->win)
851 {
852 if ((initted == 1) && (gl_wins == 1))
853 _destroy_internal_glue_resources(re);
854 eng_window_free(re->win);
855 gl_wins--;
856 }
857 evas_common_tilebuf_free(re->tb);
858 free(re);
859 }
860 if ((initted == 1) && (gl_wins == 0))
861 {
862 evas_common_image_shutdown();
863 evas_common_font_shutdown();
864 initted = 0;
865 }
866}
867
868static void
869eng_output_resize(void *data, int w, int h)
870{
871 Render_Engine *re;
872
873 re = (Render_Engine *)data;
874 if ((!re) || (!re->win)) return;
875
876 re->win->w = w;
877 re->win->h = h;
878 eng_window_use(re->win);
879
880 if (re->win->win)
881 {
882 int aw, ah, dx, dy;
883
884 wl_egl_window_get_attached_size(re->win->win, &aw, &ah);
885
886 if (re->info->info.edges & 4) // resize from left
887 dx = aw - w;
888 else
889 dx = 0;
890 if (re->info->info.edges & 1) // resize from top
891 dy = ah - h;
892 else
893 dy = 0;
894
895 wl_egl_window_resize(re->win->win, w, h, dx, dy);
896 }
897
898 evas_gl_common_context_resize(re->win->gl_context, w, h, re->win->rot);
899 evas_common_tilebuf_free(re->tb);
900 re->tb = evas_common_tilebuf_new(w, h);
901 if (re->tb)
902 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
903}
904
905static void
906eng_output_tile_size_set(void *data, int w, int h)
907{
908 Render_Engine *re;
909
910 re = (Render_Engine *)data;
911 evas_common_tilebuf_set_tile_size(re->tb, w, h);
912}
913
914static void
915eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
916{
917 Render_Engine *re;
918
919 re = (Render_Engine *)data;
920 if ((!re) || (!re->win)) return;
921
922 eng_window_use(re->win);
923 evas_gl_common_context_resize(re->win->gl_context, re->win->w, re->win->h, re->win->rot);
924 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
925
926 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, re->win->w, re->win->h);
927 if ((w <= 0) || (h <= 0)) return;
928 if (!re->win->draw.redraw)
929 {
930#if 1
931 re->win->draw.x1 = x;
932 re->win->draw.y1 = y;
933 re->win->draw.x2 = x + w - 1;
934 re->win->draw.y2 = y + h - 1;
935#else
936 re->win->draw.x1 = 0;
937 re->win->draw.y1 = 0;
938 re->win->draw.x2 = re->win->w - 1;
939 re->win->draw.y2 = re->win->h - 1;
940#endif
941 }
942 else
943 {
944 if (x < re->win->draw.x1) re->win->draw.x1 = x;
945 if (y < re->win->draw.y1) re->win->draw.y1 = y;
946 if ((x + w - 1) > re->win->draw.x2) re->win->draw.x2 = x + w - 1;
947 if ((y + h - 1) > re->win->draw.y2) re->win->draw.y2 = y + h - 1;
948 }
949 re->win->draw.redraw = 1;
950}
951
952static void
953eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
954{
955 Render_Engine *re;
956
957 re = (Render_Engine *)data;
958 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
959}
960
961static void
962eng_output_redraws_clear(void *data)
963{
964 Render_Engine *re;
965
966 re = (Render_Engine *)data;
967 evas_common_tilebuf_clear(re->tb);
968/* re->win->draw.redraw = 0;*/
969// INF("GL: finish update cycle!");
970}
971
972/* vsync games - not for now though */
973#define VSYNC_TO_SCREEN 1
974
975static void *
976eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
977{
978 Render_Engine *re;
979 Tilebuf_Rect *rects;
980
981 re = (Render_Engine *)data;
982 /* get the upate rect surface - return engine data as dummy */
983 rects = evas_common_tilebuf_get_render_rects(re->tb);
984 if (rects)
985 {
986 evas_common_tilebuf_free_render_rects(rects);
987 evas_common_tilebuf_clear(re->tb);
988 eng_window_use(re->win);
989 if (!_re_wincheck(re)) return NULL;
990 evas_gl_common_context_flush(re->win->gl_context);
991 evas_gl_common_context_newframe(re->win->gl_context);
992 if (x) *x = 0;
993 if (y) *y = 0;
994 if (w) *w = re->win->w;
995 if (h) *h = re->win->h;
996 if (cx) *cx = 0;
997 if (cy) *cy = 0;
998 if (cw) *cw = re->win->w;
999 if (ch) *ch = re->win->h;
1000 return re->win->gl_context->def_surface;
1001 }
1002 return NULL;
1003}
1004
1005//#define FRAMECOUNT 1
1006
1007#ifdef FRAMECOUNT
1008static double
1009get_time(void)
1010{
1011 struct timeval timev;
1012
1013 gettimeofday(&timev, NULL);
1014 return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
1015}
1016#endif
1017
1018static int safe_native = -1;
1019
1020static void
1021eng_output_redraws_next_update_push(void *data, void *surface EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED, Evas_Render_Mode render_mode)
1022{
1023 Render_Engine *re;
1024#ifdef FRAMECOUNT
1025 static double pt = 0.0;
1026 double ta, tb;
1027#endif
1028
1029 if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return;
1030
1031 re = (Render_Engine *)data;
1032 /* put back update surface.. in this case just unflag redraw */
1033 if (!_re_wincheck(re)) return;
1034 re->win->draw.redraw = 0;
1035 re->win->draw.drew = 1;
1036 evas_gl_common_context_flush(re->win->gl_context);
1037 if (safe_native == -1)
1038 {
1039 const char *s;
1040
1041 s = getenv("EVAS_GL_SAFE_NATIVE");
1042 safe_native = 0;
1043 if (s)
1044 safe_native = atoi(s);
1045 else
1046 {
1047 s = (const char *)glGetString(GL_RENDERER);
1048 if (s)
1049 {
1050 if (strstr(s, "PowerVR SGX 540") || strstr(s, "Mali-400 MP"))
1051 safe_native = 1;
1052 }
1053 }
1054 }
1055 // this is needed to make sure all previous rendering is flushed to
1056 // buffers/surfaces
1057# ifdef FRAMECOUNT
1058 double t0 = get_time();
1059 ta = t0 - pt;
1060 pt = t0;
1061# endif
1062 // previous rendering should be done and swapped
1063 if (!safe_native) eglWaitNative(EGL_CORE_NATIVE_ENGINE);
1064# ifdef FRAMECOUNT
1065 double t1 = get_time();
1066 tb = t1 - t0;
1067 printf("... %1.5f -> %1.5f | ", ta, tb);
1068# endif
1069 if (eglGetError() != EGL_SUCCESS)
1070 {
1071 printf("Error: eglWaitNative(EGL_CORE_NATIVE_ENGINE) fail.\n");
1072 }
1073}
1074
1075static void
1076eng_output_flush(void *data, Evas_Render_Mode render_mode)
1077{
1078 Render_Engine *re;
1079
1080 if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) return;
1081
1082 re = (Render_Engine *)data;
1083 if (!_re_wincheck(re)) return;
1084 if (!re->win->draw.drew) return;
1085//x// printf("frame -> flush\n");
1086 re->win->draw.drew = 0;
1087 eng_window_use(re->win);
1088
1089# ifdef FRAMECOUNT
1090 double t0 = get_time();
1091# endif
1092
1093 if (!re->vsync)
1094 {
1095 if (re->info->vsync) eglSwapInterval(re->win->egl_disp, 1);
1096 else eglSwapInterval(re->win->egl_disp, 0);
1097 re->vsync = 1;
1098 }
1099
1100 if (re->info->callback.pre_swap)
1101 re->info->callback.pre_swap(re->info->callback.data, re->evas);
1102
1103 eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]);
1104 if (!safe_native) eglWaitGL();
1105
1106 if (re->info->callback.post_swap)
1107 re->info->callback.post_swap(re->info->callback.data, re->evas);
1108
1109 if (eglGetError() != EGL_SUCCESS)
1110 printf("Error: eglSwapBuffers() fail.\n");
1111
1112# ifdef FRAMECOUNT
1113 double t1 = get_time();
1114 printf("%1.5f\n", t1 - t0);
1115# endif
1116}
1117
1118static void
1119eng_output_idle_flush(void *data EINA_UNUSED)
1120{
1121 /* Render_Engine *re; */
1122
1123 /* re = (Render_Engine *)data; */
1124}
1125
1126static void
1127eng_output_dump(void *data)
1128{
1129 Render_Engine *re;
1130
1131 re = (Render_Engine *)data;
1132 evas_common_image_image_all_unload();
1133 evas_common_font_font_all_unload();
1134 evas_gl_common_image_all_unload(re->win->gl_context);
1135 _re_winfree(re);
1136}
1137
1138static void
1139eng_context_cutout_add(void *data EINA_UNUSED, void *context, int x, int y, int w, int h)
1140{
1141// Render_Engine *re;
1142//
1143// re = (Render_Engine *)data;
1144// re->win->gl_context->dc = context;
1145 evas_common_draw_context_add_cutout(context, x, y, w, h);
1146}
1147
1148static void
1149eng_context_cutout_clear(void *data EINA_UNUSED, void *context)
1150{
1151// Render_Engine *re;
1152//
1153// re = (Render_Engine *)data;
1154// re->win->gl_context->dc = context;
1155 evas_common_draw_context_clear_cutouts(context);
1156}
1157
1158static void
1159eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h, Eina_Bool do_async EINA_UNUSED)
1160{
1161 Render_Engine *re;
1162
1163 re = (Render_Engine *)data;
1164 eng_window_use(re->win);
1165 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
1166 re->win->gl_context->dc = context;
1167 evas_gl_common_rect_draw(re->win->gl_context, x, y, w, h);
1168}
1169
1170static void
1171eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2, Eina_Bool do_async EINA_UNUSED)
1172{
1173 Render_Engine *re;
1174
1175 re = (Render_Engine *)data;
1176 eng_window_use(re->win);
1177 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
1178 re->win->gl_context->dc = context;
1179 evas_gl_common_line_draw(re->win->gl_context, x1, y1, x2, y2);
1180}
1181
1182static void *
1183eng_polygon_point_add(void *data EINA_UNUSED, void *context EINA_UNUSED, void *polygon, int x, int y)
1184{
1185 /* Render_Engine *re; */
1186
1187 /* re = (Render_Engine *)data; */
1188 return evas_gl_common_poly_point_add(polygon, x, y);
1189}
1190
1191static void *
1192eng_polygon_points_clear(void *data EINA_UNUSED, void *context EINA_UNUSED, void *polygon)
1193{
1194 /* Render_Engine *re; */
1195
1196 /* re = (Render_Engine *)data; */
1197 return evas_gl_common_poly_points_clear(polygon);
1198}
1199
1200static void
1201eng_polygon_draw(void *data, void *context, void *surface EINA_UNUSED, void *polygon, int x, int y, Eina_Bool do_async EINA_UNUSED)
1202{
1203 Render_Engine *re;
1204
1205 re = (Render_Engine *)data;
1206 eng_window_use(re->win);
1207 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
1208 re->win->gl_context->dc = context;
1209 evas_gl_common_poly_draw(re->win->gl_context, polygon, x, y);
1210}
1211
1212static int
1213eng_image_alpha_get(void *data EINA_UNUSED, void *image)
1214{
1215// Render_Engine *re;
1216 Evas_GL_Image *im;
1217
1218// re = (Render_Engine *)data;
1219 if (!image) return 1;
1220 im = image;
1221 return im->alpha;
1222}
1223
1224static int
1225eng_image_colorspace_get(void *data EINA_UNUSED, void *image)
1226{
1227// Render_Engine *re;
1228 Evas_GL_Image *im;
1229
1230// re = (Render_Engine *)data;
1231 if (!image) return EVAS_COLORSPACE_ARGB8888;
1232 im = image;
1233 return im->cs.space;
1234}
1235
1236static void *
1237eng_image_alpha_set(void *data, void *image, int has_alpha)
1238{
1239 Render_Engine *re;
1240 Evas_GL_Image *im;
1241
1242 re = (Render_Engine *)data;
1243 if (!image) return NULL;
1244 im = image;
1245 if (im->alpha == has_alpha) return image;
1246 if (im->native.data)
1247 {
1248 im->alpha = has_alpha;
1249 return image;
1250 }
1251 eng_window_use(re->win);
1252 if ((im->tex) && (im->tex->pt->dyn.img))
1253 {
1254 im->alpha = has_alpha;
1255 im->tex->alpha = im->alpha;
1256 return image;
1257 }
1258 /* FIXME: can move to gl_common */
1259 if (im->cs.space != EVAS_COLORSPACE_ARGB8888) return im;
1260 if ((has_alpha) && (im->im->cache_entry.flags.alpha)) return image;
1261 else if ((!has_alpha) && (!im->im->cache_entry.flags.alpha)) return image;
1262 if (im->references > 1)
1263 {
1264 Evas_GL_Image *im_new;
1265
1266 if (!im->im->image.data)
1267 evas_cache_image_load_data(&im->im->cache_entry);
1268 im_new = evas_gl_common_image_new_from_copied_data
1269 (im->gc, im->im->cache_entry.w, im->im->cache_entry.h,
1270 im->im->image.data,
1271 eng_image_alpha_get(data, image),
1272 eng_image_colorspace_get(data, image));
1273 if (!im_new) return im;
1274 evas_gl_common_image_free(im);
1275 im = im_new;
1276 }
1277 else
1278 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
1279 return evas_gl_common_image_alpha_set(im, has_alpha ? 1 : 0);
1280// im->im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
1281// return image;
1282}
1283
1284static void *
1285eng_image_border_set(void *data EINA_UNUSED, void *image, int l EINA_UNUSED, int r EINA_UNUSED, int t EINA_UNUSED, int b EINA_UNUSED)
1286{
1287// Render_Engine *re;
1288//
1289// re = (Render_Engine *)data;
1290 return image;
1291}
1292
1293static void
1294eng_image_border_get(void *data EINA_UNUSED, void *image EINA_UNUSED, int *l EINA_UNUSED, int *r EINA_UNUSED, int *t EINA_UNUSED, int *b EINA_UNUSED)
1295{
1296// Render_Engine *re;
1297//
1298// re = (Render_Engine *)data;
1299}
1300
1301static char *
1302eng_image_comment_get(void *data EINA_UNUSED, void *image, char *key EINA_UNUSED)
1303{
1304// Render_Engine *re;
1305 Evas_GL_Image *im;
1306
1307// re = (Render_Engine *)data;
1308 if (!image) return NULL;
1309 im = image;
1310 if (!im->im) return NULL;
1311 return im->im->info.comment;
1312}
1313
1314static char *
1315eng_image_format_get(void *data EINA_UNUSED, void *image EINA_UNUSED)
1316{
1317// Render_Engine *re;
1318 /* Evas_GL_Image *im; */
1319
1320// re = (Render_Engine *)data;
1321 /* im = image; */
1322 return NULL;
1323}
1324
1325static void
1326eng_image_colorspace_set(void *data, void *image, int cspace)
1327{
1328 Render_Engine *re;
1329 Evas_GL_Image *im;
1330
1331 re = (Render_Engine *)data;
1332 if (!image) return;
1333 im = image;
1334 if (im->native.data) return;
1335 /* FIXME: can move to gl_common */
1336 if (im->cs.space == cspace) return;
1337 eng_window_use(re->win);
1338 evas_cache_image_colorspace(&im->im->cache_entry, cspace);
1339 switch (cspace)
1340 {
1341 case EVAS_COLORSPACE_ARGB8888:
1342 if (im->cs.data)
1343 {
1344 if (!im->cs.no_free) free(im->cs.data);
1345 im->cs.data = NULL;
1346 im->cs.no_free = 0;
1347 }
1348 break;
1349 case EVAS_COLORSPACE_YCBCR422P601_PL:
1350 case EVAS_COLORSPACE_YCBCR422P709_PL:
1351 case EVAS_COLORSPACE_YCBCR422601_PL:
1352 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
1353 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
1354 if (im->tex) evas_gl_common_texture_free(im->tex);
1355 im->tex = NULL;
1356 if (im->cs.data)
1357 {
1358 if (!im->cs.no_free) free(im->cs.data);
1359 }
1360 if (im->im->cache_entry.h > 0)
1361 im->cs.data =
1362 calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
1363 else
1364 im->cs.data = NULL;
1365 im->cs.no_free = 0;
1366 break;
1367 default:
1368 abort();
1369 break;
1370 }
1371 im->cs.space = cspace;
1372}
1373
1374/////////////////////////////////////////////////////////////////////////
1375//
1376//
1377typedef struct _Native Native;
1378
1379struct _Native
1380{
1381 Evas_Native_Surface ns;
1382 struct wl_egl_pixmap *pixmap;
1383
1384 void *egl_surface;
1385};
1386
1387// FIXME: this is enabled so updates happen - but its SLOOOOOOOOOOOOOOOW
1388// (i am sure this is the reason) not to mention seemingly superfluous. but
1389// i need to enable it for it to work on fglrx at least. havent tried nvidia.
1390//
1391// why is this the case? does anyone know? has anyone tried it on other gfx
1392// drivers?
1393//
1394//#define GLX_TEX_PIXMAP_RECREATE 1
1395
1396static void
1397_native_bind_cb(void *data EINA_UNUSED, void *image)
1398{
1399 Evas_GL_Image *im = image;
1400 Native *n = im->native.data;
1401
1402 if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
1403 {
1404 glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id);
1405 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1406 }
1407}
1408
1409static void
1410_native_unbind_cb(void *data EINA_UNUSED, void *image)
1411{
1412 Evas_GL_Image *im = image;
1413 Native *n = im->native.data;
1414
1415 if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
1416 {
1417 glBindTexture(GL_TEXTURE_2D, 0);
1418 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1419 }
1420}
1421
1422static void
1423_native_free_cb(void *data, void *image)
1424{
1425 Render_Engine *re = data;
1426 Evas_GL_Image *im = image;
1427 Native *n = im->native.data;
1428 uint32_t texid;
1429
1430 if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
1431 {
1432 texid = n->ns.data.opengl.texture_id;
1433 eina_hash_del(re->win->gl_context->shared->native_tex_hash, &texid, im);
1434 }
1435 im->native.data = NULL;
1436 im->native.func.data = NULL;
1437 im->native.func.bind = NULL;
1438 im->native.func.unbind = NULL;
1439 im->native.func.free = NULL;
1440 free(n);
1441}
1442
1443static void *
1444eng_image_native_set(void *data, void *image, void *native)
1445{
1446 Render_Engine *re = (Render_Engine *)data;
1447 Evas_Native_Surface *ns = native;
1448 Evas_GL_Image *im = image, *im2 = NULL;
1449 Native *n = NULL;
1450 uint32_t texid;
1451 unsigned int tex = 0;
1452 unsigned int fbo = 0;
1453
1454 if (ns && ns->type != EVAS_NATIVE_SURFACE_OPENGL) return NULL;
1455
1456 if (!im)
1457 {
1458 if ((ns) && (ns->type == EVAS_NATIVE_SURFACE_OPENGL))
1459 {
1460 im = evas_gl_common_image_new_from_data(re->win->gl_context,
1461 ns->data.opengl.w,
1462 ns->data.opengl.h,
1463 NULL, 1,
1464 EVAS_COLORSPACE_ARGB8888);
1465 }
1466 else
1467 return NULL;
1468 }
1469
1470 if (ns)
1471 {
1472 tex = ns->data.opengl.texture_id;
1473 fbo = ns->data.opengl.framebuffer_id;
1474 if (im->native.data)
1475 {
1476 Evas_Native_Surface *ens = im->native.data;
1477 if ((ens->data.opengl.texture_id == tex) &&
1478 (ens->data.opengl.framebuffer_id == fbo))
1479 return im;
1480 }
1481 }
1482 if ((!ns) && (!im->native.data)) return im;
1483
1484 eng_window_use(re->win);
1485
1486 if (im->native.data)
1487 {
1488 if (im->native.func.free)
1489 im->native.func.free(im->native.func.data, im);
1490 evas_gl_common_image_native_disable(im);
1491 }
1492
1493 if (!ns) return im;
1494
1495 texid = tex;
1496 im2 = eina_hash_find(re->win->gl_context->shared->native_tex_hash, &texid);
1497 if (im2 == im) return im;
1498 if (im2)
1499 {
1500 n = im2->native.data;
1501 if (n)
1502 {
1503 evas_gl_common_image_ref(im2);
1504 evas_gl_common_image_free(im);
1505 return im2;
1506 }
1507 }
1508
1509 im2 = evas_gl_common_image_new_from_data(re->win->gl_context,
1510 im->w, im->h, NULL, im->alpha,
1511 EVAS_COLORSPACE_ARGB8888);
1512 evas_gl_common_image_free(im);
1513 im = im2;
1514 if (native)
1515 {
1516 n = calloc(1, sizeof(Native));
1517 if (n)
1518 {
1519 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
1520
1521 eina_hash_add(re->win->gl_context->shared->native_tex_hash, &texid, im);
1522
1523 n->egl_surface = 0;
1524 n->pixmap = 0;
1525
1526 im->native.yinvert = 0;
1527 im->native.loose = 0;
1528 im->native.data = n;
1529 im->native.func.data = re;
1530 im->native.func.bind = _native_bind_cb;
1531 im->native.func.unbind = _native_unbind_cb;
1532 im->native.func.free = _native_free_cb;
1533 im->native.target = GL_TEXTURE_2D;
1534 im->native.mipmap = 0;
1535
1536 // FIXME: need to implement mapping sub texture regions
1537 // x, y, w, h for possible texture atlasing
1538
1539 evas_gl_common_image_native_enable(im);
1540 }
1541 }
1542 return im;
1543}
1544
1545static void *
1546eng_image_native_get(void *data EINA_UNUSED, void *image)
1547{
1548 Evas_GL_Image *im;
1549 Native *n;
1550
1551 if (!(im = image)) return NULL;
1552 if (!(n = im->native.data)) return NULL;
1553 return &(n->ns);
1554}
1555
1556static void *
1557eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
1558{
1559 Render_Engine *re;
1560
1561 re = (Render_Engine *)data;
1562 *error = EVAS_LOAD_ERROR_NONE;
1563 eng_window_use(re->win);
1564 return evas_gl_common_image_load(re->win->gl_context, file, key, lo, error);
1565}
1566
1567static void *
1568eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
1569{
1570 Render_Engine *re;
1571
1572 re = (Render_Engine *)data;
1573 eng_window_use(re->win);
1574 return evas_gl_common_image_new_from_data(re->win->gl_context, w, h, image_data, alpha, cspace);
1575}
1576
1577static void *
1578eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
1579{
1580 Render_Engine *re;
1581
1582 re = (Render_Engine *)data;
1583 eng_window_use(re->win);
1584 return evas_gl_common_image_new_from_copied_data(re->win->gl_context, w, h, image_data, alpha, cspace);
1585}
1586
1587static void
1588eng_image_free(void *data, void *image)
1589{
1590 Render_Engine *re;
1591
1592 re = (Render_Engine *)data;
1593 if (!image) return;
1594 eng_window_use(re->win);
1595}
1596
1597static void
1598eng_image_size_get(void *data EINA_UNUSED, void *image, int *w, int *h)
1599{
1600 if (!image)
1601 {
1602 *w = 0;
1603 *h = 0;
1604 return;
1605 }
1606 if (w) *w = ((Evas_GL_Image *)image)->w;
1607 if (h) *h = ((Evas_GL_Image *)image)->h;
1608}
1609
1610static void *
1611eng_image_size_set(void *data, void *image, int w, int h)
1612{
1613 Render_Engine *re;
1614 Evas_GL_Image *im = image;
1615 Evas_GL_Image *im_old;
1616
1617 re = (Render_Engine *)data;
1618 if (!im) return NULL;
1619 if (im->native.data)
1620 {
1621 im->w = w;
1622 im->h = h;
1623 return image;
1624 }
1625 eng_window_use(re->win);
1626 if ((im->tex) && (im->tex->pt->dyn.img))
1627 {
1628 evas_gl_common_texture_free(im->tex);
1629 im->tex = NULL;
1630 im->w = w;
1631 im->h = h;
1632 im->tex = evas_gl_common_texture_dynamic_new(im->gc, im);
1633 return image;
1634 }
1635 im_old = image;
1636
1637 switch (eng_image_colorspace_get(data, image))
1638 {
1639 case EVAS_COLORSPACE_YCBCR422P601_PL:
1640 case EVAS_COLORSPACE_YCBCR422P709_PL:
1641 case EVAS_COLORSPACE_YCBCR422601_PL:
1642 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
1643 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
1644 w &= ~0x1;
1645 break;
1646 }
1647
1648 if ((im_old->im) &&
1649 ((int)im_old->im->cache_entry.w == w) &&
1650 ((int)im_old->im->cache_entry.h == h))
1651 return image;
1652 if (im_old)
1653 {
1654 im = evas_gl_common_image_new(re->win->gl_context, w, h,
1655 eng_image_alpha_get(data, image),
1656 eng_image_colorspace_get(data, image));
1657 /*
1658 evas_common_load_image_data_from_file(im_old->im);
1659 if (im_old->im->image->data)
1660 {
1661 evas_common_blit_rectangle(im_old->im, im->im, 0, 0, w, h, 0, 0);
1662 evas_common_cpu_end_opt();
1663 }
1664 */
1665 evas_gl_common_image_free(im_old);
1666 }
1667 else
1668 im = evas_gl_common_image_new(re->win->gl_context, w, h, 1, EVAS_COLORSPACE_ARGB8888);
1669 return im;
1670}
1671
1672static void *
1673eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
1674{
1675 Render_Engine *re;
1676 Evas_GL_Image *im = image;
1677
1678 re = (Render_Engine *)data;
1679 if (!image) return NULL;
1680 if (im->native.data) return image;
1681 eng_window_use(re->win);
1682 evas_gl_common_image_dirty(image, x, y, w, h);
1683 return image;
1684}
1685
1686static void *
1687eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err)
1688{
1689 Render_Engine *re;
1690 Evas_GL_Image *im;
1691 int error;
1692
1693 re = (Render_Engine *)data;
1694 if (!image)
1695 {
1696 *image_data = NULL;
1697 if (err) *err = EVAS_LOAD_ERROR_GENERIC;
1698 return NULL;
1699 }
1700 im = image;
1701 if (im->native.data)
1702 {
1703 *image_data = NULL;
1704 if (err) *err = EVAS_LOAD_ERROR_NONE;
1705 return im;
1706 }
1707
1708 eng_window_use(re->win);
1709
1710 if ((im->tex) && (im->tex->pt) && (im->tex->pt->dyn.img) && (im->cs.space == EVAS_COLORSPACE_ARGB8888))
1711 {
1712 if (im->tex->pt->dyn.checked_out > 0)
1713 {
1714 im->tex->pt->dyn.checked_out++;
1715 *image_data = im->tex->pt->dyn.data;
1716 if (err) *err = EVAS_LOAD_ERROR_NONE;
1717 return im;
1718 }
1719 *image_data = im->tex->pt->dyn.data = glsym_eglMapImageSEC(re->win->egl_disp, im->tex->pt->dyn.img);
1720
1721 if (!im->tex->pt->dyn.data)
1722 {
1723 if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
1724 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1725 return im;
1726 }
1727 im->tex->pt->dyn.checked_out++;
1728
1729 if (err) *err = EVAS_LOAD_ERROR_NONE;
1730 return im;
1731 }
1732
1733 /* Engine can fail to create texture after cache drop like eng_image_content_hint_set function,
1734 so it is need to add code which check im->im's NULL value*/
1735
1736 if (!im->im)
1737 {
1738 *image_data = NULL;
1739 if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
1740 return NULL;
1741 }
1742
1743 error = evas_cache_image_load_data(&im->im->cache_entry);
1744 switch (im->cs.space)
1745 {
1746 case EVAS_COLORSPACE_ARGB8888:
1747 if (to_write)
1748 {
1749 if (im->references > 1)
1750 {
1751 Evas_GL_Image *im_new;
1752
1753 im_new = evas_gl_common_image_new_from_copied_data
1754 (im->gc, im->im->cache_entry.w, im->im->cache_entry.h,
1755 im->im->image.data,
1756 eng_image_alpha_get(data, image),
1757 eng_image_colorspace_get(data, image));
1758 if (!im_new)
1759 {
1760 *image_data = NULL;
1761 if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
1762 return NULL;
1763 }
1764 evas_gl_common_image_free(im);
1765 im = im_new;
1766 }
1767 else
1768 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
1769 }
1770 *image_data = im->im->image.data;
1771 break;
1772 case EVAS_COLORSPACE_YCBCR422P601_PL:
1773 case EVAS_COLORSPACE_YCBCR422P709_PL:
1774 case EVAS_COLORSPACE_YCBCR422601_PL:
1775 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
1776 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
1777 *image_data = im->cs.data;
1778 break;
1779 default:
1780 abort();
1781 break;
1782 }
1783 if (err) *err = error;
1784 return im;
1785}
1786
1787static void *
1788eng_image_data_put(void *data, void *image, DATA32 *image_data)
1789{
1790 Render_Engine *re;
1791 Evas_GL_Image *im, *im2;
1792
1793 re = (Render_Engine *)data;
1794 if (!image) return NULL;
1795 im = image;
1796 if (im->native.data) return image;
1797 eng_window_use(re->win);
1798 if ((im->tex) && (im->tex->pt)
1799 && (im->tex->pt->dyn.data)
1800 && (im->cs.space == EVAS_COLORSPACE_ARGB8888))
1801 {
1802 int w, h;
1803
1804 if (im->tex->pt->dyn.data == image_data)
1805 {
1806 im->tex->pt->dyn.checked_out--;
1807 if (im->tex->pt->dyn.checked_out == 0)
1808 glsym_eglUnmapImageSEC(re->win->egl_disp, im->tex->pt->dyn.img);
1809 return image;
1810 }
1811
1812 w = im->im->cache_entry.w;
1813 h = im->im->cache_entry.h;
1814 im2 = eng_image_new_from_data(data, w, h, image_data,
1815 eng_image_alpha_get(data, image),
1816 eng_image_colorspace_get(data, image));
1817 if (!im2) return im;
1818 evas_gl_common_image_free(im);
1819 im = im2;
1820 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
1821 return im;
1822 }
1823 switch (im->cs.space)
1824 {
1825 case EVAS_COLORSPACE_ARGB8888:
1826 if (image_data != im->im->image.data)
1827 {
1828 int w, h;
1829
1830 w = im->im->cache_entry.w;
1831 h = im->im->cache_entry.h;
1832 im2 = eng_image_new_from_data(data, w, h, image_data,
1833 eng_image_alpha_get(data, image),
1834 eng_image_colorspace_get(data, image));
1835 if (!im2) return im;
1836 evas_gl_common_image_free(im);
1837 im = im2;
1838 }
1839 break;
1840 case EVAS_COLORSPACE_YCBCR422P601_PL:
1841 case EVAS_COLORSPACE_YCBCR422P709_PL:
1842 case EVAS_COLORSPACE_YCBCR422601_PL:
1843 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
1844 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
1845 if (image_data != im->cs.data)
1846 {
1847 if (im->cs.data)
1848 {
1849 if (!im->cs.no_free) free(im->cs.data);
1850 }
1851 im->cs.data = image_data;
1852 }
1853 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
1854 break;
1855 default:
1856 abort();
1857 break;
1858 }
1859 return im;
1860}
1861
1862static void
1863eng_image_data_preload_request(void *data EINA_UNUSED, void *image, const void *target)
1864{
1865 Evas_GL_Image *gim = image;
1866 RGBA_Image *im;
1867
1868 if (!gim) return;
1869 if (gim->native.data) return;
1870 im = (RGBA_Image *)gim->im;
1871 if (!im) return;
1872 evas_cache_image_preload_data(&im->cache_entry, target);
1873}
1874
1875static void
1876eng_image_data_preload_cancel(void *data EINA_UNUSED, void *image, const void *target)
1877{
1878 Evas_GL_Image *gim = image;
1879 RGBA_Image *im;
1880
1881 if (!gim) return;
1882 if (gim->native.data) return;
1883 im = (RGBA_Image *)gim->im;
1884 if (!im) return;
1885 evas_cache_image_preload_cancel(&im->cache_entry, target);
1886}
1887
1888static Eina_Bool
1889eng_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth, Eina_Bool do_async EINA_UNUSED)
1890{
1891 Render_Engine *re;
1892
1893 re = (Render_Engine *)data;
1894 if (!image) return EINA_FALSE;
1895
1896 if ((gl_direct_img_obj) && (gl_direct_enabled))
1897 evas_object_image_pixels_dirty_set(gl_direct_img_obj, EINA_TRUE);
1898 else
1899 {
1900 eng_window_use(re->win);
1901 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
1902 re->win->gl_context->dc = context;
1903 evas_gl_common_image_draw(re->win->gl_context, image,
1904 src_x, src_y, src_w, src_h,
1905 dst_x, dst_y, dst_w, dst_h,
1906 smooth);
1907 }
1908
1909 return EINA_FALSE;
1910}
1911
1912static void
1913eng_image_scale_hint_set(void *data EINA_UNUSED, void *image, int hint)
1914{
1915 if (image) evas_gl_common_image_scale_hint_set(image, hint);
1916}
1917
1918static int
1919eng_image_scale_hint_get(void *data EINA_UNUSED, void *image)
1920{
1921 Evas_GL_Image *gim = image;
1922 if (!gim) return EVAS_IMAGE_SCALE_HINT_NONE;
1923 return gim->scale_hint;
1924}
1925
1926static Eina_Bool
1927eng_image_map_draw(void *data, void *context, void *surface, void *image, RGBA_Map *m, int smooth, int level, Eina_Bool do_async)
1928{
1929 Evas_GL_Image *gim = image;
1930 Render_Engine *re;
1931
1932 re = (Render_Engine *)data;
1933 if (!image) return EINA_FALSE;
1934 eng_window_use(re->win);
1935 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
1936 re->win->gl_context->dc = context;
1937 if (m->count != 4)
1938 {
1939 // FIXME: nash - you didn't fix this
1940 abort();
1941 }
1942 if ((m->pts[0].x == m->pts[3].x) &&
1943 (m->pts[1].x == m->pts[2].x) &&
1944 (m->pts[0].y == m->pts[1].y) &&
1945 (m->pts[3].y == m->pts[2].y) &&
1946 (m->pts[0].x <= m->pts[1].x) &&
1947 (m->pts[0].y <= m->pts[2].y) &&
1948 (m->pts[0].u == 0) &&
1949 (m->pts[0].v == 0) &&
1950 (m->pts[1].u == (gim->w << FP)) &&
1951 (m->pts[1].v == 0) &&
1952 (m->pts[2].u == (gim->w << FP)) &&
1953 (m->pts[2].v == (gim->h << FP)) &&
1954 (m->pts[3].u == 0) &&
1955 (m->pts[3].v == (gim->h << FP)) &&
1956 (m->pts[0].col == 0xffffffff) &&
1957 (m->pts[1].col == 0xffffffff) &&
1958 (m->pts[2].col == 0xffffffff) &&
1959 (m->pts[3].col == 0xffffffff))
1960 {
1961 int dx, dy, dw, dh;
1962
1963 dx = m->pts[0].x >> FP;
1964 dy = m->pts[0].y >> FP;
1965 dw = (m->pts[2].x >> FP) - dx;
1966 dh = (m->pts[2].y >> FP) - dy;
1967 eng_image_draw(data, context, surface, image,
1968 0, 0, gim->w, gim->h, dx, dy, dw, dh, smooth, do_async);
1969 }
1970 else
1971 {
1972 evas_gl_common_image_map_draw(re->win->gl_context, image, m->count,
1973 &m->pts[0], smooth, level);
1974 }
1975
1976 return EINA_FALSE;
1977}
1978
1979static void *
1980eng_image_map_surface_new(void *data, int w, int h, int alpha)
1981{
1982 Render_Engine *re;
1983
1984 re = (Render_Engine *)data;
1985 return evas_gl_common_image_surface_new(re->win->gl_context, w, h, alpha);
1986}
1987
1988static void
1989eng_image_map_surface_free(void *data EINA_UNUSED, void *surface)
1990{
1991 evas_gl_common_image_free(surface);
1992}
1993
1994static void
1995eng_image_content_hint_set(void *data EINA_UNUSED, void *image, int hint)
1996{
1997 if (image) evas_gl_common_image_content_hint_set(image, hint);
1998}
1999
2000static int
2001eng_image_content_hint_get(void *data EINA_UNUSED, void *image)
2002{
2003 Evas_GL_Image *gim = image;
2004 if (!gim) return EVAS_IMAGE_CONTENT_HINT_NONE;
2005 return gim->content_hint;
2006}
2007
2008static void
2009eng_image_cache_flush(void *data)
2010{
2011 Render_Engine *re;
2012 int tmp_size;
2013
2014 re = (Render_Engine *)data;
2015
2016 tmp_size = evas_common_image_get_cache();
2017 evas_common_image_set_cache(0);
2018 evas_common_rgba_image_scalecache_flush();
2019
2020 if ((re) && (re->win) && (re->win->gl_context))
2021 evas_gl_common_image_cache_flush(re->win->gl_context);
2022 evas_common_image_set_cache(tmp_size);
2023}
2024
2025static void
2026eng_image_cache_set(void *data, int bytes)
2027{
2028 Render_Engine *re;
2029
2030 re = (Render_Engine *)data;
2031 evas_common_image_set_cache(bytes);
2032 evas_common_rgba_image_scalecache_size_set(bytes);
2033 evas_gl_common_image_cache_flush(re->win->gl_context);
2034}
2035
2036static int
2037eng_image_cache_get(void *data EINA_UNUSED)
2038{
2039 return evas_common_image_get_cache();
2040}
2041
2042static void
2043eng_image_stride_get(void *data EINA_UNUSED, void *image, int *stride)
2044{
2045 Evas_GL_Image *im = image;
2046
2047 if ((im->tex) && (im->tex->pt->dyn.img))
2048 *stride = im->tex->pt->dyn.stride;
2049 else
2050 *stride = im->w * 4;
2051}
2052
2053static Eina_Bool
2054eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font EINA_UNUSED, int x, int y, int w EINA_UNUSED, int h EINA_UNUSED, int ow EINA_UNUSED, int oh EINA_UNUSED, Evas_Text_Props *intl_props, Eina_Bool do_async EINA_UNUSED)
2055{
2056 Render_Engine *re;
2057
2058 re = (Render_Engine *)data;
2059 eng_window_use(re->win);
2060 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
2061 re->win->gl_context->dc = context;
2062 {
2063 // FIXME: put im into context so we can free it
2064 static RGBA_Image *im = NULL;
2065
2066 if (!im)
2067 im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
2068 im->cache_entry.w = re->win->w;
2069 im->cache_entry.h = re->win->h;
2070 evas_common_draw_context_font_ext_set(context,
2071 re->win->gl_context,
2072 evas_gl_font_texture_new,
2073 evas_gl_font_texture_free,
2074 evas_gl_font_texture_draw);
2075 evas_common_font_draw_prepare(intl_props);
2076 evas_common_font_draw(im, context, x, y, intl_props->glyphs);
2077 evas_common_draw_context_font_ext_set(context, NULL, NULL, NULL, NULL);
2078 }
2079
2080 return EINA_FALSE;
2081}
2082
2083static Eina_Bool
2084eng_canvas_alpha_get(void *data, void *info EINA_UNUSED)
2085{
2086 Render_Engine *re = (Render_Engine *)data;
2087
2088 if ((!re) || (!re->win)) return EINA_FALSE;
2089 return re->win->alpha;
2090}
2091
2092static int
2093_set_internal_config(Render_Engine_GL_Surface *sfc, Evas_GL_Config *cfg)
2094{
2095 // Also initialize pixel format here as well...
2096 switch(cfg->color_format)
2097 {
2098 case EVAS_GL_RGB_888:
2099 sfc->rt_fmt = GL_RGB;
2100 sfc->rt_internal_fmt = GL_RGB;
2101 break;
2102 case EVAS_GL_RGBA_8888:
2103 sfc->rt_fmt = GL_RGBA;
2104 sfc->rt_internal_fmt = GL_RGBA;
2105 break;
2106 default:
2107 ERR("Invalid Color Format!");
2108 return 0;
2109 }
2110
2111 switch(cfg->depth_bits)
2112 {
2113 case EVAS_GL_DEPTH_NONE:
2114 break;
2115 case EVAS_GL_DEPTH_BIT_8:
2116 case EVAS_GL_DEPTH_BIT_16:
2117 case EVAS_GL_DEPTH_BIT_24:
2118 // 24 bit doesn't work... just cover it with 16 for now..
2119 sfc->rb_depth_fmt = GL_DEPTH_COMPONENT16;
2120 break;
2121 case EVAS_GL_DEPTH_BIT_32:
2122 default:
2123 ERR("Unsupported Depth Bits Format!");
2124 return 0;
2125 }
2126
2127 switch(cfg->stencil_bits)
2128 {
2129 case EVAS_GL_STENCIL_NONE:
2130 break;
2131 case EVAS_GL_STENCIL_BIT_1:
2132 case EVAS_GL_STENCIL_BIT_2:
2133 case EVAS_GL_STENCIL_BIT_4:
2134 case EVAS_GL_STENCIL_BIT_8:
2135 sfc->rb_stencil_fmt = GL_STENCIL_INDEX8;
2136 break;
2137 case EVAS_GL_STENCIL_BIT_16:
2138 default:
2139 ERR("Unsupported Stencil Bits Format!");
2140 return 0;
2141 }
2142
2143 // Do Packed Depth24_Stencil8 Later...
2144
2145 return 1;
2146}
2147
2148static int
2149_attach_fbo_surface(Render_Engine *data EINA_UNUSED,
2150 Render_Engine_GL_Surface *sfc, int fbo)
2151{
2152 int fb_status, curr_tex, curr_rb;
2153
2154 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
2155
2156 // Detach any previously attached buffers
2157 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2158 GL_TEXTURE_2D, 0, 0);
2159 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
2160 GL_RENDERBUFFER, 0);
2161 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2162 GL_RENDERBUFFER, 0);
2163 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
2164 GL_TEXTURE_2D, 0, 0);
2165 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2166 GL_TEXTURE_2D, 0, 0);
2167
2168 // Render Target Texture
2169 if (sfc->rt_tex)
2170 {
2171 curr_tex = 0;
2172 glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_tex);
2173 glBindTexture(GL_TEXTURE_2D, sfc->rt_tex );
2174 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2175 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2176 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2177 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2178 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sfc->w, sfc->h, 0,
2179 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
2180 glBindTexture(GL_TEXTURE_2D, curr_tex);
2181
2182 // Attach texture to FBO
2183 if (sfc->rt_msaa_samples)
2184 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER,
2185 GL_COLOR_ATTACHMENT0,
2186 GL_TEXTURE_2D, sfc->rt_tex,
2187 0, sfc->rt_msaa_samples);
2188 else
2189 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2190 GL_TEXTURE_2D, sfc->rt_tex, 0);
2191 }
2192
2193 // Depth Stencil RenderBuffer - Attach it to FBO
2194 if (sfc->rb_depth_stencil)
2195 {
2196 curr_tex = 0;
2197 glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_tex);
2198 glBindTexture(GL_TEXTURE_2D, sfc->rb_depth_stencil);
2199 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2200 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2201 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2202 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2203#ifdef GL_GLES
2204 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, sfc->w, sfc->h,
2205 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, NULL);
2206#else
2207 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL, sfc->w, sfc->h,
2208 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
2209#endif
2210 if (sfc->rt_msaa_samples)
2211 {
2212 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER,
2213 GL_DEPTH_ATTACHMENT,
2214 GL_TEXTURE_2D,
2215 sfc->rb_depth_stencil,
2216 0, sfc->rt_msaa_samples);
2217 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER,
2218 GL_STENCIL_ATTACHMENT,
2219 GL_TEXTURE_2D,
2220 sfc->rb_depth_stencil,
2221 0, sfc->rt_msaa_samples);
2222 }
2223 else
2224 {
2225 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
2226 GL_TEXTURE_2D, sfc->rb_depth_stencil, 0);
2227 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2228 GL_TEXTURE_2D, sfc->rb_depth_stencil, 0);
2229 }
2230 glBindTexture(GL_TEXTURE_2D, curr_tex);
2231 }
2232
2233 // Depth RenderBuffer - Attach it to FBO
2234 if (sfc->rb_depth)
2235 {
2236 curr_rb = 0;
2237 glGetIntegerv(GL_RENDERBUFFER_BINDING, &curr_rb);
2238
2239 glBindRenderbuffer(GL_RENDERBUFFER, sfc->rb_depth);
2240
2241 if (sfc->rt_msaa_samples)
2242 glsym_glRenderbufferStorageMultisample(GL_RENDERBUFFER,
2243 sfc->rt_msaa_samples,
2244 sfc->rb_depth_fmt,
2245 sfc->w, sfc->h);
2246 else
2247 glRenderbufferStorage(GL_RENDERBUFFER, sfc->rb_depth_fmt,
2248 sfc->w, sfc->h);
2249 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
2250 GL_RENDERBUFFER, sfc->rb_depth);
2251 glBindRenderbuffer(GL_RENDERBUFFER, curr_rb);
2252 }
2253
2254 // Stencil RenderBuffer - Attach it to FBO
2255 if (sfc->rb_stencil)
2256 {
2257 curr_rb = 0;
2258 glGetIntegerv(GL_RENDERBUFFER_BINDING, &curr_rb);
2259
2260 glBindRenderbuffer(GL_RENDERBUFFER, sfc->rb_stencil);
2261
2262 if (sfc->rt_msaa_samples)
2263 glsym_glRenderbufferStorageMultisample(GL_RENDERBUFFER,
2264 sfc->rt_msaa_samples,
2265 sfc->rb_stencil_fmt,
2266 sfc->w, sfc->h);
2267 else
2268 glRenderbufferStorage(GL_RENDERBUFFER, sfc->rb_stencil_fmt,
2269 sfc->w, sfc->h);
2270 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2271 GL_RENDERBUFFER, sfc->rb_stencil);
2272 glBindRenderbuffer(GL_RENDERBUFFER, curr_rb);
2273 }
2274
2275 // Check FBO for completeness
2276 fb_status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
2277 if (fb_status != GL_FRAMEBUFFER_COMPLETE)
2278 {
2279 ERR("FBO not complete. Error Code: %x!", fb_status);
2280// _print_gl_surface_info(sfc, 1);
2281 return 0;
2282 }
2283
2284 return 1;
2285}
2286
2287static int
2288_create_rt_buffers(Render_Engine *data EINA_UNUSED,
2289 Render_Engine_GL_Surface *sfc)
2290{
2291 int ret = 0;
2292 GLuint fbo = 0;
2293 GLint curr_fbo = 0;
2294
2295 if (sfc->rt_fmt)
2296 {
2297 // Render Target texture
2298 glGenTextures(1, &sfc->rt_tex );
2299 }
2300
2301 // First check if packed buffer is to be used.
2302 if (sfc->rb_depth_stencil_fmt)
2303 glGenTextures(1, &sfc->rb_depth_stencil);
2304 else
2305 {
2306 // Depth RenderBuffer - Create storage here...
2307 if (sfc->rb_depth_fmt)
2308 glGenRenderbuffers(1, &sfc->rb_depth);
2309
2310 // Stencil RenderBuffer - Create Storage here...
2311 if (sfc->rb_stencil_fmt)
2312 glGenRenderbuffers(1, &sfc->rb_stencil);
2313 }
2314 //------------------------------------//
2315 // Try attaching the given configuration
2316 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &curr_fbo);
2317 glGenFramebuffers(1 ,&fbo);
2318
2319 ret = _attach_fbo_surface(NULL, sfc, fbo);
2320
2321 if (fbo) glDeleteFramebuffers(1, &fbo);
2322 glBindFramebuffer(GL_FRAMEBUFFER, (GLuint)curr_fbo);
2323
2324 if (!ret)
2325 {
2326 if (sfc->rt_tex) glDeleteTextures(1, &sfc->rt_tex);
2327 if (sfc->rb_depth) glDeleteRenderbuffers(1, &sfc->rb_depth);
2328 if (sfc->rb_stencil) glDeleteRenderbuffers(1, &sfc->rb_stencil);
2329 if (sfc->rb_depth_stencil) glDeleteTextures(1, &sfc->rb_depth_stencil);
2330 ERR("_attach_fbo_surface() failed.");
2331 return 0;
2332 }
2333 else
2334 return 1;
2335}
2336
2337static int
2338_internal_resources_make_current(void *data)
2339{
2340 Render_Engine *re = (Render_Engine *)data;
2341 Render_Engine_GL_Resource *rsc;
2342 int ret = 0;
2343
2344 // Create internal resource context if it hasn't been created already
2345 if ((rsc = eina_tls_get(resource_key)) == NULL)
2346 {
2347 if ((rsc = _create_internal_glue_resources(re)) == NULL)
2348 {
2349 ERR("Error creating internal resources.");
2350 return 0;
2351 }
2352 }
2353
2354 // Use resource surface/context to create surface resrouces
2355 // Update the evas' window surface
2356 if (eina_main_loop_is()) rsc->surface = re->win->egl_surface[0];
2357
2358 ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
2359
2360 if (!ret)
2361 {
2362 ERR("eglMakeCurrent() failed. Error Code: %#x", eglGetError());
2363 return 0;
2364 }
2365 return 1;
2366}
2367
2368// Unfortunately, there is no query function to figure out which surface formats work.
2369// So, this is one way to test for surface config capability.
2370static int
2371_check_gl_surface_format(GLint int_fmt, GLenum fmt, GLenum attachment, GLenum attach_fmt, int mult_samples)
2372{
2373 GLuint fbo, tex, rb, ds_tex;
2374 int w, h, fb_status;
2375
2376 // Initialize Variables
2377 fbo = tex = rb = ds_tex = 0;
2378
2379 // Width/Heith for test purposes
2380 w = h = 2;
2381
2382 // Gen FBO
2383 glGenFramebuffers(1, &fbo);
2384 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
2385
2386 // Render Target Texture
2387 if (int_fmt)
2388 {
2389 glGenTextures(1, &tex);
2390 glBindTexture(GL_TEXTURE_2D, tex );
2391 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2392 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2393 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2394 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2395 glTexImage2D(GL_TEXTURE_2D, 0, int_fmt, w, h, 0, fmt, GL_UNSIGNED_BYTE, NULL);
2396 glBindTexture(GL_TEXTURE_2D, 0);
2397
2398 if (mult_samples)
2399 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0, mult_samples);
2400 else
2401 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
2402 }
2403
2404 // Render Target Attachment (Stencil or Depth)
2405 if (attachment)
2406 {
2407 // This is a little hacky but this is how we'll have to do for now.
2408 // PS: Now it's even more hacky.
2409#ifdef GL_GLES
2410 if (attach_fmt == GL_DEPTH_STENCIL_OES)
2411#else
2412 if (attach_fmt == GL_DEPTH_STENCIL)
2413#endif
2414 {
2415 glGenTextures(1, &ds_tex);
2416 glBindTexture(GL_TEXTURE_2D, ds_tex);
2417 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2418 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2419 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2420 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2421#ifdef GL_GLES
2422 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, w, h,
2423 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, NULL);
2424#else
2425 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL, w, h,
2426 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
2427#endif
2428 if (mult_samples)
2429 {
2430 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
2431 GL_TEXTURE_2D, ds_tex, 0, mult_samples);
2432 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2433 GL_TEXTURE_2D, ds_tex, 0, mult_samples);
2434 }
2435 else
2436 {
2437 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
2438 GL_TEXTURE_2D, ds_tex, 0);
2439 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2440 GL_TEXTURE_2D, ds_tex, 0);
2441 }
2442 glBindTexture(GL_TEXTURE_2D, 0);
2443 }
2444 else
2445 {
2446 glGenRenderbuffers(1, &rb);
2447 glBindRenderbuffer(GL_RENDERBUFFER, rb);
2448 if (mult_samples)
2449 glsym_glRenderbufferStorageMultisample(GL_RENDERBUFFER, mult_samples, attach_fmt, w, h);
2450 else
2451 glRenderbufferStorage(GL_RENDERBUFFER, attach_fmt, w, h);
2452 glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, rb);
2453 glBindRenderbuffer(GL_RENDERBUFFER, 0);
2454 }
2455
2456 }
2457
2458 // Check FBO for completeness
2459 fb_status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
2460
2461 // Delete Created Resources
2462 glBindFramebuffer(GL_FRAMEBUFFER, 0);
2463 if (fbo) glDeleteFramebuffers(1, &fbo);
2464 if (tex) glDeleteTextures(1, &tex);
2465 if (ds_tex) glDeleteTextures(1, &ds_tex);
2466 if (rb) glDeleteRenderbuffers(1, &rb);
2467
2468 if (fb_status != GL_FRAMEBUFFER_COMPLETE)
2469 return 0;
2470 else
2471 {
2472 if ((attachment) && (!mult_samples))
2473 return attach_fmt;
2474 else
2475 return 1;
2476 }
2477}
2478
2479static void
2480_set_gl_surface_cap(Render_Engine *re)
2481{
2482 int i, count;
2483 int max_samples = 0;
2484
2485 if (!re) return;
2486 if (re->gl_cap_initted) return;
2487
2488 glGetIntegerv(GL_MAX_SAMPLES_IMG, &max_samples);
2489
2490 // Check if msaa_support is supported
2491 if ((max_samples) &&
2492 (glsym_glFramebufferTexture2DMultisample) &&
2493 (glsym_glRenderbufferStorageMultisample))
2494 {
2495 re->gl_cap.msaa_support = 1;
2496
2497 re->gl_cap.msaa_samples[3] = max_samples;
2498 re->gl_cap.msaa_samples[2] = max_samples/2;
2499 re->gl_cap.msaa_samples[1] = max_samples/4;
2500 re->gl_cap.msaa_samples[0] = 0;
2501
2502 if (!re->gl_cap.msaa_samples[2])
2503 re->gl_cap.msaa_samples[2] = re->gl_cap.msaa_samples[3];
2504 if (!re->gl_cap.msaa_samples[1])
2505 re->gl_cap.msaa_samples[1] = re->gl_cap.msaa_samples[2];
2506 }
2507 else
2508 {
2509 re->gl_cap.msaa_support = 0;
2510 }
2511
2512
2513 glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &re->gl_cap.max_rb_size);
2514
2515 count = (re->gl_cap.msaa_support) ? 4 : 1;
2516
2517 for (i = 0; i < count; i++)
2518 {
2519 re->gl_cap.rgb_888[i] = _check_gl_surface_format(GL_RGB, GL_RGB, 0, 0, re->gl_cap.msaa_samples[i]);
2520 re->gl_cap.rgba_8888[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, 0, 0, re->gl_cap.msaa_samples[i]);
2521
2522 re->gl_cap.depth_8[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT, re->gl_cap.msaa_samples[i]);
2523 re->gl_cap.depth_16[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT16, re->gl_cap.msaa_samples[i]);
2524#ifdef GL_GLES
2525 re->gl_cap.depth_24[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT24_OES, re->gl_cap.msaa_samples[i]);
2526 re->gl_cap.depth_32[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT32_OES, re->gl_cap.msaa_samples[i]);
2527
2528 re->gl_cap.stencil_1[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX1_OES, re->gl_cap.msaa_samples[i]);
2529 re->gl_cap.stencil_4[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX4_OES, re->gl_cap.msaa_samples[i]);
2530 re->gl_cap.stencil_8[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX8, re->gl_cap.msaa_samples[i]);
2531
2532 re->gl_cap.depth_24_stencil_8[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_DEPTH_STENCIL_OES, GL_DEPTH_STENCIL_OES, re->gl_cap.msaa_samples[i]);
2533#else
2534 re->gl_cap.depth_24[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT24, re->gl_cap.msaa_samples[i]);
2535 re->gl_cap.depth_32[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT32, re->gl_cap.msaa_samples[i]);
2536
2537 re->gl_cap.stencil_1[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX1, re->gl_cap.msaa_samples[i]);
2538 re->gl_cap.stencil_4[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX4, re->gl_cap.msaa_samples[i]);
2539 re->gl_cap.stencil_8[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX8, re->gl_cap.msaa_samples[i]);
2540
2541 re->gl_cap.depth_24_stencil_8[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_DEPTH_STENCIL, GL_DEPTH_STENCIL, re->gl_cap.msaa_samples[i]);
2542#endif
2543 }
2544
2545// _print_gl_surface_cap(re, 0);
2546
2547 re->gl_cap_initted = 1;
2548}
2549
2550static void *
2551eng_gl_surface_create(void *data, void *config, int w, int h)
2552{
2553 Render_Engine *re;
2554 Render_Engine_GL_Surface *sfc;
2555 Evas_GL_Config *cfg;
2556 void *ret = NULL;
2557 int res;
2558
2559 sfc = calloc(1, sizeof(Render_Engine_GL_Surface));
2560 if (!sfc) return NULL;
2561
2562 re = (Render_Engine *)data;
2563 cfg = (Evas_GL_Config *)config;
2564
2565 sfc->initialized = 0;
2566 sfc->fbo_attached = 0;
2567 sfc->w = w;
2568 sfc->h = h;
2569 sfc->depth_bits = cfg->depth_bits;
2570 sfc->stencil_bits = cfg->stencil_bits;
2571 sfc->rt_tex = 0;
2572 sfc->rb_depth = 0;
2573 sfc->rb_stencil = 0;
2574
2575 // Allow alpha for evas gl direct rendering override
2576 // FIXME!!!: A little out of place but for now...
2577 if (!gl_direct_override)
2578 if (getenv("EVAS_GL_DIRECT_OVERRIDE")) gl_direct_override = 1;
2579
2580 // Set the internal format based on the config
2581 if (cfg->options_bits & EVAS_GL_OPTIONS_DIRECT)
2582 {
2583 DBG("Enabling Direct rendering to the Evas' window.");
2584 sfc->direct_sfc = re->win->egl_surface[0];
2585 }
2586
2587 // Use resource surface/context to do a make current
2588 if (!_internal_resources_make_current(re))
2589 {
2590 ERR("Error doing a make current with the internal resources.");
2591 goto finish;
2592 }
2593
2594 // Set the engine surface capability first if it hasn't been set
2595 if (!re->gl_cap_initted) _set_gl_surface_cap(re);
2596
2597 // Check the size of the surface
2598 if ( (w > re->gl_cap.max_rb_size) || (h > re->gl_cap.max_rb_size) )
2599 {
2600 ERR("Surface size greater than the supported size. Max Surface Size: %d", re->gl_cap.max_rb_size);
2601 goto finish;
2602 }
2603
2604 // Set the internal format based on the config
2605 if (!_set_internal_config(sfc, cfg))
2606 {
2607 ERR("Unsupported Format!");
2608 goto finish;
2609 }
2610
2611 // Create Render texture
2612 if (!_create_rt_buffers(re, sfc))
2613 {
2614 ERR("Unable Create Specificed Surfaces. Unsupported format!");
2615 goto finish;
2616 };
2617
2618 ret = sfc;
2619
2620finish:
2621
2622 res = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
2623 if (!res)
2624 {
2625 ERR("xxxMakeCurrent() (NULL, NULL) Error!");
2626 }
2627
2628 if (!ret)
2629 {
2630 if (sfc) free(sfc);
2631 }
2632 return ret;
2633}
2634
2635static int
2636eng_gl_surface_destroy(void *data, void *surface)
2637{
2638 Render_Engine *re;
2639 Render_Engine_GL_Surface *sfc;
2640 Render_Engine_GL_Resource *rsc;
2641 int ret;
2642
2643 re = (Render_Engine *)data;
2644 sfc = (Render_Engine_GL_Surface*)surface;
2645
2646 if (!sfc) return 0;
2647
2648 if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
2649
2650 if (re->win)
2651 {
2652 ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
2653 if (!ret)
2654 {
2655 ERR("xxxMakeCurrent() failed!");
2656 return 0;
2657 }
2658 }
2659
2660 // Delete FBO/RBO and Texture here
2661 if (sfc->rt_tex)
2662 glDeleteTextures(1, &sfc->rt_tex);
2663
2664 if (sfc->rb_depth)
2665 glDeleteRenderbuffers(1, &sfc->rb_depth);
2666
2667 if (sfc->rb_stencil)
2668 glDeleteRenderbuffers(1, &sfc->rb_stencil);
2669
2670 if (re->win)
2671 {
2672 ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
2673 if (!ret)
2674 {
2675 ERR("xxxMakeCurrent() failed!");
2676 free(sfc);
2677 return 0;
2678 }
2679 }
2680
2681 free(sfc);
2682 surface = NULL;
2683
2684 return 1;
2685}
2686
2687static void *
2688eng_gl_context_create(void *data, void *share_context)
2689{
2690 Render_Engine *re;
2691 Render_Engine_GL_Context *ctx;
2692 Render_Engine_GL_Context *share_ctx;
2693 int context_attrs[3];
2694
2695 ctx = calloc(1, sizeof(Render_Engine_GL_Context));
2696
2697 if (!ctx) return NULL;
2698
2699 re = (Render_Engine *)data;
2700 share_ctx = (Render_Engine_GL_Context *)share_context;
2701
2702 // Set the share context to Evas' GL context if share_context is NULL.
2703 // Otherwise set it to the given share_context.
2704
2705 // EGL
2706 context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
2707 context_attrs[1] = 2;
2708 context_attrs[2] = EGL_NONE;
2709
2710 if (share_ctx)
2711 {
2712 ctx->context = eglCreateContext(re->win->egl_disp,
2713 re->win->egl_config,
2714 share_ctx->context, // Share Context
2715 context_attrs);
2716 }
2717 else
2718 {
2719 ctx->context = eglCreateContext(re->win->egl_disp,
2720 re->win->egl_config,
2721 re->win->egl_context[0], // Evas' GL Context
2722 context_attrs);
2723 }
2724
2725 if (!ctx->context)
2726 {
2727 ERR("eglCreateContext() fail. code=%#x", eglGetError());
2728 return NULL;
2729 }
2730
2731 ctx->initialized = 0;
2732 ctx->context_fbo = 0;
2733 ctx->current_sfc = NULL;
2734
2735 return ctx;
2736}
2737
2738static int
2739eng_gl_context_destroy(void *data, void *context)
2740{
2741 Render_Engine *re;
2742 Render_Engine_GL_Context *ctx;
2743 Render_Engine_GL_Resource *rsc;
2744 int ret;
2745
2746 re = (Render_Engine *)data;
2747 ctx = (Render_Engine_GL_Context*)context;
2748
2749 if (!ctx) return 0;
2750
2751 if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
2752
2753 // 1. Do a make current with the given context
2754 if (re->win)
2755 {
2756 ret = eglMakeCurrent(re->win->egl_disp, rsc->surface,
2757 rsc->surface, ctx->context);
2758 if (!ret)
2759 {
2760 ERR("xxxMakeCurrent() failed!");
2761 return 0;
2762 }
2763 }
2764
2765 // 2. Delete the FBO
2766 if (ctx->context_fbo)
2767 glDeleteFramebuffers(1, &ctx->context_fbo);
2768
2769 // 3. Destroy the Context
2770 if (re->win)
2771 eglDestroyContext(re->win->egl_disp, ctx->context);
2772
2773 ctx->context = EGL_NO_CONTEXT;
2774
2775 if (re->win)
2776 {
2777 ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
2778 EGL_NO_SURFACE, EGL_NO_CONTEXT);
2779 if (!ret)
2780 {
2781 ERR("xxxMakeCurrent() failed!");
2782 return 0;
2783 }
2784 }
2785
2786 if (current_evgl_ctx == ctx)
2787 current_evgl_ctx = NULL;
2788
2789 free(ctx);
2790 context = NULL;
2791
2792 return 1;
2793}
2794
2795static int
2796eng_gl_make_current(void *data EINA_UNUSED, void *surface, void *context)
2797{
2798 Render_Engine *re;
2799 Render_Engine_GL_Surface *sfc;
2800 Render_Engine_GL_Context *ctx;
2801 int ret = 0;
2802 Render_Engine_GL_Resource *rsc;
2803
2804 re = (Render_Engine *)data;
2805 sfc = (Render_Engine_GL_Surface*)surface;
2806 ctx = (Render_Engine_GL_Context*)context;
2807
2808 current_engine = re;
2809
2810 // Unset surface/context
2811 if ((!sfc) || (!ctx))
2812 {
2813 ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
2814 EGL_NO_SURFACE, EGL_NO_CONTEXT);
2815 if (!ret)
2816 {
2817 ERR("xxxMakeCurrent() failed!");
2818 return 0;
2819 }
2820
2821 if (ctx) ctx->current_sfc = NULL;
2822 if (sfc) sfc->current_ctx = NULL;
2823 current_evgl_ctx = NULL;
2824 return 1;
2825 }
2826
2827 if ((sfc->direct_fb_opt) && ((gl_direct_img_obj) || (gl_direct_override)))
2828 {
2829 sfc->direct_sfc = re->win->egl_surface[0];
2830 gl_direct_enabled = EINA_TRUE;
2831 }
2832 else
2833 gl_direct_enabled = EINA_FALSE;
2834
2835 if (gl_direct_enabled)
2836 {
2837 GLint cur_fbo = 0;
2838
2839 if ((eglGetCurrentContext() != ctx->context))
2840 {
2841 eng_window_use(NULL);
2842 ret = eglMakeCurrent(re->win->egl_disp, sfc->direct_sfc,
2843 sfc->direct_sfc, ctx->context);
2844 if (!ret) return 0;
2845 }
2846 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &cur_fbo);
2847 if (ctx->context_fbo == (GLuint)cur_fbo)
2848 {
2849 ctx->current_fbo = 0;
2850 glBindFramebuffer(GL_FRAMEBUFFER, 0);
2851 }
2852 }
2853 else
2854 {
2855 if (eina_main_loop_is())
2856 {
2857 if ((eglGetCurrentContext() != ctx->context) ||
2858 (eglGetCurrentSurface(EGL_READ) != re->win->egl_surface[0]) ||
2859 (eglGetCurrentSurface(EGL_DRAW) != re->win->egl_surface[0]))
2860 {
2861 // Flush remainder of what's in Evas' pipeline
2862 eng_window_use(NULL);
2863
2864 // Do a make current
2865 if (re->win)
2866 ret = eglMakeCurrent(re->win->egl_disp,
2867 re->win->egl_surface[0],
2868 re->win->egl_surface[0],
2869 ctx->context);
2870
2871 if (!ret)
2872 {
2873 ERR("xxxMakeCurrent() failed!");
2874 return 0;
2875 }
2876 }
2877 }
2878 else
2879 {
2880 // Do a make current only if it's not already current
2881 if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
2882
2883 if ((eglGetCurrentContext() != ctx->context) ||
2884 (eglGetCurrentSurface(EGL_READ) != rsc->surface) ||
2885 (eglGetCurrentSurface(EGL_DRAW) != rsc->surface))
2886 {
2887 // Flush remainder of what's in Evas' pipeline
2888 eng_window_use(NULL);
2889
2890 // Do a make current
2891 ret = eglMakeCurrent(re->win->egl_disp, rsc->surface,
2892 rsc->surface, ctx->context);
2893
2894 if (!ret)
2895 {
2896 ERR("xxxMakeCurrent() failed!");
2897 return 0;
2898 }
2899 }
2900 }
2901
2902 // Create FBO if not already created
2903 if (!ctx->initialized)
2904 {
2905 glGenFramebuffers(1, &ctx->context_fbo);
2906 ctx->initialized = 1;
2907 }
2908
2909 // Attach FBO if it hasn't been attached or if surface changed
2910 if ((!sfc->fbo_attached) || (ctx->current_sfc != sfc))
2911 {
2912 if (!_attach_fbo_surface(re, sfc, ctx->context_fbo))
2913 {
2914 ERR("_attach_fbo_surface() failed.");
2915 return 0;
2916 }
2917
2918 if (ctx->current_fbo)
2919 // Bind to the previously bound buffer
2920 glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo);
2921 else
2922 // Bind FBO
2923 glBindFramebuffer(GL_FRAMEBUFFER, ctx->context_fbo);
2924
2925 sfc->fbo_attached = 1;
2926 }
2927 }
2928
2929 // Set the current surface/context
2930 ctx->current_sfc = sfc;
2931 sfc->current_ctx = ctx;
2932 current_evgl_ctx = ctx;
2933
2934 return 1;
2935}
2936
2937static void *
2938eng_gl_string_query(void *data EINA_UNUSED, int name)
2939{
2940 switch(name)
2941 {
2942 case EVAS_GL_EXTENSIONS:
2943 return (void*)_evasgl_ext_string;
2944 default:
2945 return NULL;
2946 };
2947}
2948
2949static void *
2950eng_gl_proc_address_get(void *data EINA_UNUSED, const char *name)
2951{
2952 if (glsym_eglGetProcAddress) return glsym_eglGetProcAddress(name);
2953 return dlsym(RTLD_DEFAULT, name);
2954}
2955
2956static int
2957eng_gl_native_surface_get(void *data EINA_UNUSED, void *surface, void *native_surface)
2958{
2959 /* Render_Engine *re; */
2960 Render_Engine_GL_Surface *sfc;
2961 Evas_Native_Surface *ns;
2962
2963 /* re = (Render_Engine *)data; */
2964 sfc = (Render_Engine_GL_Surface*)surface;
2965 ns = (Evas_Native_Surface*)native_surface;
2966
2967 ns->type = EVAS_NATIVE_SURFACE_OPENGL;
2968 ns->version = EVAS_NATIVE_SURFACE_VERSION;
2969
2970 if (sfc->direct_fb_opt)
2971 ns->data.opengl.framebuffer_id = 0;
2972 else
2973 ns->data.opengl.framebuffer_id = sfc->rt_tex;
2974
2975 ns->data.opengl.texture_id = sfc->rt_tex;
2976 ns->data.opengl.x = 0;
2977 ns->data.opengl.y = 0;
2978 ns->data.opengl.w = sfc->w;
2979 ns->data.opengl.h = sfc->h;
2980
2981 return 1;
2982}
2983
2984
2985static const GLubyte *
2986evgl_glGetString(GLenum name)
2987{
2988 if (name == GL_EXTENSIONS)
2989 return (GLubyte *)_gl_ext_string; //glGetString(GL_EXTENSIONS);
2990 else
2991 return glGetString(name);
2992}
2993
2994static void
2995evgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
2996{
2997 Render_Engine_GL_Context *ctx = current_evgl_ctx;
2998
2999 if (!ctx) return;
3000
3001 // Take care of BindFramebuffer 0 issue
3002 if (framebuffer==0)
3003 {
3004 if (gl_direct_enabled)
3005 glBindFramebuffer(target, 0);
3006 else
3007 glBindFramebuffer(target, ctx->context_fbo);
3008
3009 ctx->current_fbo = 0;
3010 }
3011 else
3012 {
3013 glBindFramebuffer(target, framebuffer);
3014
3015 // Save this for restore when doing make current
3016 ctx->current_fbo = framebuffer;
3017 }
3018}
3019
3020static void
3021evgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer)
3022{
3023 // Add logic to take care when renderbuffer=0
3024 // On a second thought we don't need this
3025 glBindRenderbuffer(target, renderbuffer);
3026}
3027
3028// Transform from Evas Coordinat to GL Coordinate
3029// returns: oc[4] original image object dimension in gl coord
3030// returns: nc[4] tranformed (x, y, width, heigth) in gl coord
3031static void
3032compute_gl_coordinates(Evas_Object *eo_obj, int rot, int clip,
3033 int x, int y, int width, int height,
3034 int imgc[4], int objc[4])
3035{
3036 Evas_Object_Protected_Data *obj = eo_data_get(eo_obj, EVAS_OBJ_CLASS);
3037 if (rot == 0)
3038 {
3039 // oringinal image object coordinate in gl coordinate
3040 imgc[0] = obj->cur.geometry.x;
3041 imgc[1] = obj->layer->evas->output.h - obj->cur.geometry.y - obj->cur.geometry.h;
3042 imgc[2] = imgc[0] + obj->cur.geometry.w;
3043 imgc[3] = imgc[1] + obj->cur.geometry.h;
3044
3045 // transformed (x,y,width,height) in gl coordinate
3046 objc[0] = imgc[0] + x;
3047 objc[1] = imgc[1] + y;
3048 objc[2] = objc[0] + width;
3049 objc[3] = objc[1] + height;
3050 }
3051 else if (rot == 180)
3052 {
3053 // oringinal image object coordinate in gl coordinate
3054 imgc[0] = obj->layer->evas->output.w - obj->cur.geometry.x - obj->cur.geometry.w;
3055 imgc[1] = obj->cur.geometry.y;
3056 imgc[2] = imgc[0] + obj->cur.geometry.w;
3057 imgc[3] = imgc[1] + obj->cur.geometry.h;
3058
3059 // transformed (x,y,width,height) in gl coordinate
3060 objc[0] = imgc[0] + obj->cur.geometry.w - x - width;
3061 objc[1] = imgc[1] + obj->cur.geometry.h - y - height;
3062 objc[2] = objc[0] + width;
3063 objc[3] = objc[1] + height;
3064
3065 }
3066 else if (rot == 90)
3067 {
3068 // oringinal image object coordinate in gl coordinate
3069 imgc[0] = obj->cur.geometry.y;
3070 imgc[1] = obj->cur.geometry.x;
3071 imgc[2] = imgc[0] + obj->cur.geometry.h;
3072 imgc[3] = imgc[1] + obj->cur.geometry.w;
3073
3074 // transformed (x,y,width,height) in gl coordinate
3075 objc[0] = imgc[0] + obj->cur.geometry.h - y - height;
3076 objc[1] = imgc[1] + x;
3077 objc[2] = objc[0] + height;
3078 objc[3] = objc[1] + width;
3079 }
3080 else if (rot == 270)
3081 {
3082 // oringinal image object coordinate in gl coordinate
3083 imgc[0] = obj->layer->evas->output.h - obj->cur.geometry.y - obj->cur.geometry.h;
3084 imgc[1] = obj->layer->evas->output.w - obj->cur.geometry.x - obj->cur.geometry.w;
3085 imgc[2] = imgc[0] + obj->cur.geometry.h;
3086 imgc[3] = imgc[1] + obj->cur.geometry.w;
3087
3088 // transformed (x,y,width,height) in gl coordinate
3089 objc[0] = imgc[0] + y;
3090 objc[1] = imgc[1] + obj->cur.geometry.w - x - width;
3091 objc[2] = objc[0] + height;
3092 objc[3] = objc[1] + width;
3093 }
3094 else
3095 {
3096 ERR("Invalid rotation angle %d.", rot);
3097 return;
3098 }
3099
3100 if (clip)
3101 {
3102 // Clip against original image object
3103 if (objc[0] < imgc[0]) objc[0] = imgc[0];
3104 if (objc[0] > imgc[2]) objc[0] = 0;
3105
3106 if (objc[1] < imgc[1]) objc[1] = imgc[1];
3107 if (objc[1] > imgc[3]) objc[1] = 0;
3108
3109 if (objc[2] < imgc[0]) objc[0] = 0;
3110 if (objc[2] > imgc[2]) objc[2] = imgc[2];
3111
3112 if (objc[3] < imgc[1]) objc[1] = 0;
3113 if (objc[3] > imgc[3]) objc[3] = imgc[3];
3114 }
3115
3116 imgc[2] = imgc[2]-imgc[0]; // width
3117 imgc[3] = imgc[3]-imgc[1]; // height
3118
3119 objc[2] = objc[2]-objc[0]; // width
3120 objc[3] = objc[3]-objc[1]; // height
3121}
3122
3123static void
3124evgl_glClear(GLbitfield mask)
3125{
3126 Render_Engine_GL_Context *ctx;
3127 int rot = 0;
3128 int oc[4], nc[4];
3129
3130 ctx = current_evgl_ctx;
3131 if ((gl_direct_img_obj) && (gl_direct_enabled) && (ctx) && (!ctx->current_fbo))
3132 {
3133 if ((current_engine) && (current_engine->win) && (current_engine->win->gl_context))
3134 rot = current_engine->win->gl_context->rot;
3135
3136 compute_gl_coordinates(gl_direct_img_obj, rot, 0, 0, 0, 0, 0, oc, nc);
3137 glScissor(oc[0], oc[1], oc[2], oc[3]);
3138 glClear(mask);
3139 }
3140 else
3141 glClear(mask);
3142}
3143
3144static void
3145evgl_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
3146{
3147 glClearColor(red, green, blue, alpha);
3148}
3149
3150static void
3151evgl_glEnable(GLenum cap)
3152{
3153 Render_Engine_GL_Context *ctx;
3154
3155 ctx = current_evgl_ctx;
3156 if (cap == GL_SCISSOR_TEST)
3157 if (ctx) ctx->scissor_enabled = 1;
3158 glEnable(cap);
3159}
3160
3161static void
3162evgl_glDisable(GLenum cap)
3163{
3164 Render_Engine_GL_Context *ctx;
3165
3166 ctx = current_evgl_ctx;
3167 if (cap == GL_SCISSOR_TEST)
3168 if (ctx) ctx->scissor_enabled = 0;
3169 glDisable(cap);
3170}
3171
3172static void
3173evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
3174{
3175 Render_Engine_GL_Context *ctx = current_evgl_ctx;
3176 int rot = 0;
3177 int oc[4], nc[4];
3178
3179 if ((gl_direct_img_obj) && (gl_direct_enabled) && (ctx) && (!ctx->current_fbo))
3180 {
3181 if ((current_engine) && (current_engine->win) && (current_engine->win->gl_context))
3182 rot = current_engine->win->gl_context->rot;
3183 else
3184 ERR("Unable to retrieve rotation angle: %d", rot);
3185
3186 compute_gl_coordinates(gl_direct_img_obj, rot, 1, x, y, width, height, oc, nc);
3187 glReadPixels(nc[0], nc[1], nc[2], nc[3], format, type, pixels);
3188 }
3189 else
3190 glReadPixels(x, y, width, height, format, type, pixels);
3191}
3192
3193static void
3194evgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
3195{
3196 Render_Engine_GL_Context *ctx = current_evgl_ctx;
3197 int rot = 0;
3198 int oc[4], nc[4];
3199
3200 if ((gl_direct_img_obj) && (gl_direct_enabled) && (ctx) && (!ctx->current_fbo))
3201 {
3202 if ((current_engine) && (current_engine->win) && (current_engine->win->gl_context))
3203 rot = current_engine->win->gl_context->rot;
3204 else
3205 ERR("Unable to retrieve rotation angle: %d", rot);
3206
3207 compute_gl_coordinates(gl_direct_img_obj, rot, 1, x, y, width, height, oc, nc);
3208 glScissor(nc[0], nc[1], nc[2], nc[3]);
3209 ctx->scissor_updated = 1;
3210 }
3211 else
3212 glScissor(x, y, width, height);
3213}
3214
3215static void
3216evgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
3217{
3218 Render_Engine_GL_Context *ctx = current_evgl_ctx;
3219 int rot = 0;
3220 int oc[4], nc[4];
3221
3222 if ((gl_direct_img_obj) && (gl_direct_enabled) && (ctx) && (!ctx->current_fbo))
3223 {
3224 if ((current_engine) && (current_engine->win) && (current_engine->win->gl_context))
3225 rot = current_engine->win->gl_context->rot;
3226 else
3227 ERR("Unable to retrieve rotation angle: %d", rot);
3228
3229 compute_gl_coordinates(gl_direct_img_obj, rot, 0, x, y, width, height, oc, nc);
3230 glEnable(GL_SCISSOR_TEST);
3231 glScissor(oc[0], oc[1], oc[2], oc[3]);
3232 glViewport(nc[0], nc[1], nc[2], nc[3]);
3233 }
3234 else
3235 glViewport(x, y, width, height);
3236}
3237
3238static void
3239evgl_glClearDepthf(GLclampf depth)
3240{
3241 glClearDepthf(depth);
3242}
3243
3244static void
3245evgl_glDepthRangef(GLclampf zNear, GLclampf zFar)
3246{
3247 glDepthRangef(zNear, zFar);
3248}
3249
3250static void
3251evgl_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
3252{
3253 glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
3254}
3255
3256static void
3257evgl_glReleaseShaderCompiler(void)
3258{
3259 glReleaseShaderCompiler();
3260}
3261
3262static void
3263evgl_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
3264{
3265 glShaderBinary(n, shaders, binaryformat, binary, length);
3266}
3267
3268//--------------------------------//
3269// EGL Extensions
3270static void *
3271evgl_evasglCreateImage(int target, void* buffer, int *attrib_list)
3272{
3273 if (current_engine)
3274 {
3275 return glsym_eglCreateImage(current_engine->win->egl_disp,
3276 EGL_NO_CONTEXT,
3277 target,
3278 buffer,
3279 attrib_list);
3280 }
3281 else
3282 {
3283 ERR("Invalid Engine... (Can't acccess EGL Display)\n");
3284 return NULL;
3285 }
3286}
3287
3288static void
3289evgl_evasglDestroyImage(EvasGLImage image)
3290{
3291 if (current_engine)
3292 glsym_eglDestroyImage(current_engine->win->egl_disp, image);
3293 else
3294 ERR("Invalid Engine... (Can't acccess EGL Display)\n");
3295}
3296
3297static void
3298evgl_glEvasGLImageTargetTexture2DOES(GLenum target, EvasGLImage image)
3299{
3300 glsym_glEGLImageTargetTexture2DOES(target, image);
3301}
3302
3303static void
3304evgl_glEvasGLImageTargetRenderbufferStorageOES(GLenum target, EvasGLImage image)
3305{
3306 glsym_glEGLImageTargetTexture2DOES(target, image);
3307}
3308
3309//--------------------------------//
3310
3311
3312static void *
3313eng_gl_api_get(void *data EINA_UNUSED)
3314{
3315 /* Render_Engine *re; */
3316
3317 /* re = (Render_Engine *)data; */
3318
3319 gl_funcs.version = EVAS_GL_API_VERSION;
3320
3321#define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, )
3322 // GLES 2.0
3323 ORD(glActiveTexture);
3324 ORD(glAttachShader);
3325 ORD(glBindAttribLocation);
3326 ORD(glBindBuffer);
3327 ORD(glBindTexture);
3328 ORD(glBlendColor);
3329 ORD(glBlendEquation);
3330 ORD(glBlendEquationSeparate);
3331 ORD(glBlendFunc);
3332 ORD(glBlendFuncSeparate);
3333 ORD(glBufferData);
3334 ORD(glBufferSubData);
3335 ORD(glCheckFramebufferStatus);
3336// ORD(glClear); /***/
3337// ORD(glClearColor);/***/
3338// ORD(glClearDepthf);
3339 ORD(glClearStencil);
3340 ORD(glColorMask);
3341 ORD(glCompileShader);
3342 ORD(glCompressedTexImage2D);
3343 ORD(glCompressedTexSubImage2D);
3344 ORD(glCopyTexImage2D);
3345 ORD(glCopyTexSubImage2D);
3346 ORD(glCreateProgram);
3347 ORD(glCreateShader);
3348 ORD(glCullFace);
3349 ORD(glDeleteBuffers);
3350 ORD(glDeleteFramebuffers);
3351 ORD(glDeleteProgram);
3352 ORD(glDeleteRenderbuffers);
3353 ORD(glDeleteShader);
3354 ORD(glDeleteTextures);
3355 ORD(glDepthFunc);
3356 ORD(glDepthMask);
3357// ORD(glDepthRangef);
3358 ORD(glDetachShader);
3359// ORD(glDisable);/***/
3360 ORD(glDisableVertexAttribArray);
3361 ORD(glDrawArrays);
3362 ORD(glDrawElements);
3363// ORD(glEnable);/***/
3364 ORD(glEnableVertexAttribArray);
3365 ORD(glFinish);
3366 ORD(glFlush);
3367 ORD(glFramebufferRenderbuffer);
3368 ORD(glFramebufferTexture2D);
3369 ORD(glFrontFace);
3370 ORD(glGenBuffers);
3371 ORD(glGenerateMipmap);
3372 ORD(glGenFramebuffers);
3373 ORD(glGenRenderbuffers);
3374 ORD(glGenTextures);
3375 ORD(glGetActiveAttrib);
3376 ORD(glGetActiveUniform);
3377 ORD(glGetAttachedShaders);
3378 ORD(glGetAttribLocation);
3379 ORD(glGetBooleanv);
3380 ORD(glGetBufferParameteriv);
3381 ORD(glGetError);
3382 ORD(glGetFloatv);
3383 ORD(glGetFramebufferAttachmentParameteriv);
3384 ORD(glGetIntegerv);
3385 ORD(glGetProgramiv);
3386 ORD(glGetProgramInfoLog);
3387 ORD(glGetRenderbufferParameteriv);
3388 ORD(glGetShaderiv);
3389 ORD(glGetShaderInfoLog);
3390// ORD(glGetShaderPrecisionFormat);
3391 ORD(glGetShaderSource);
3392// ORD(glGetString);
3393 ORD(glGetTexParameterfv);
3394 ORD(glGetTexParameteriv);
3395 ORD(glGetUniformfv);
3396 ORD(glGetUniformiv);
3397 ORD(glGetUniformLocation);
3398 ORD(glGetVertexAttribfv);
3399 ORD(glGetVertexAttribiv);
3400 ORD(glGetVertexAttribPointerv);
3401 ORD(glHint);
3402 ORD(glIsBuffer);
3403 ORD(glIsEnabled);
3404 ORD(glIsFramebuffer);
3405 ORD(glIsProgram);
3406 ORD(glIsRenderbuffer);
3407 ORD(glIsShader);
3408 ORD(glIsTexture);
3409 ORD(glLineWidth);
3410 ORD(glLinkProgram);
3411 ORD(glPixelStorei);
3412 ORD(glPolygonOffset);
3413 ORD(glReadPixels);
3414// ORD(glReleaseShaderCompiler);
3415 ORD(glRenderbufferStorage);
3416 ORD(glSampleCoverage);
3417// ORD(glScissor);/***/
3418// ORD(glShaderBinary);
3419// Deal with double glShaderSource signature
3420 gl_funcs.glShaderSource = (void (*)(GLuint, GLsizei, const char * const *, const GLint *))glShaderSource;
3421 ORD(glStencilFunc);
3422 ORD(glStencilFuncSeparate);
3423 ORD(glStencilMask);
3424 ORD(glStencilMaskSeparate);
3425 ORD(glStencilOp);
3426 ORD(glStencilOpSeparate);
3427 ORD(glTexImage2D);
3428 ORD(glTexParameterf);
3429 ORD(glTexParameterfv);
3430 ORD(glTexParameteri);
3431 ORD(glTexParameteriv);
3432 ORD(glTexSubImage2D);
3433 ORD(glUniform1f);
3434 ORD(glUniform1fv);
3435 ORD(glUniform1i);
3436 ORD(glUniform1iv);
3437 ORD(glUniform2f);
3438 ORD(glUniform2fv);
3439 ORD(glUniform2i);
3440 ORD(glUniform2iv);
3441 ORD(glUniform3f);
3442 ORD(glUniform3fv);
3443 ORD(glUniform3i);
3444 ORD(glUniform3iv);
3445 ORD(glUniform4f);
3446 ORD(glUniform4fv);
3447 ORD(glUniform4i);
3448 ORD(glUniform4iv);