1 #include "evas_common.h" /* Also includes international specific stuff */
2 #include "evas_engine.h"
5 # include <dlfcn.h> /* dlopen,dlclose,etc */
7 # error gl_x11 should not get compiled if dlsym is not found on the system!
10 #define EVAS_GL_NO_GL_H_CHECK 1
13 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
15 # if defined(GLES_VARIETY_S3C6410)
16 # elif defined(GLES_VARIETY_SGX)
22 typedef struct _Render_Engine Render_Engine;
23 typedef struct _Render_Engine_GL_Surface Render_Engine_GL_Surface;
24 typedef struct _Render_Engine_GL_Context Render_Engine_GL_Context;
25 typedef struct _Render_Engine_GL_Resource Render_Engine_GL_Resource;
26 typedef struct _Extension_Entry Extension_Entry;
30 Evas_GL_X11_Window *win;
31 Evas_Engine_Info_GL_X11 *info;
36 XrmDatabase xrdb; // xres - dpi
37 struct { // xres - dpi
38 int dpi; // xres - dpi
44 // GL Surface Capability
65 int depth_24_stencil_8[4];
71 struct _Render_Engine_GL_Surface
82 // Render target Texture/Buffers
83 GLint rt_msaa_samples;
86 GLint rt_internal_fmt;
91 GLenum rb_stencil_fmt;
92 GLuint rb_depth_stencil;
93 GLenum rb_depth_stencil_fmt;
95 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
96 EGLSurface direct_sfc;
101 Render_Engine_GL_Context *current_ctx;
104 struct _Render_Engine_GL_Context
107 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
118 Render_Engine_GL_Surface *current_sfc;
121 // Resources used per thread
122 struct _Render_Engine_GL_Resource
124 // Resource context/surface per Thread in TLS for evasgl use
125 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
133 // Extension Handling
134 struct _Extension_Entry
137 const char *real_name;
141 static int initted = 0;
142 static int gl_wins = 0;
143 static int gl_direct_override = 0;
144 static int gl_direct_enabled = 0;
145 static Render_Engine_GL_Context *current_evgl_ctx = NULL;
146 static Render_Engine *current_engine = NULL;
147 static Evas_Object *gl_direct_img_obj = NULL;
149 static int _ext_initted = 0;
150 static char *_gl_ext_string = NULL;
151 static char *_evasgl_ext_string = NULL;
153 // Resource context/surface per Thread in TLS for evasgl use
154 static Eina_TLS resource_key;
155 static Eina_List *resource_list;
158 typedef void (*_eng_fn) (void);
159 typedef _eng_fn (*glsym_func_eng_fn) ();
160 typedef void (*glsym_func_void) ();
161 typedef void *(*glsym_func_void_ptr) ();
162 typedef int (*glsym_func_int) ();
163 typedef unsigned int (*glsym_func_uint) ();
164 typedef unsigned char (*glsym_func_uchar) ();
165 typedef unsigned char *(*glsym_func_uchar_ptr) ();
166 typedef const char *(*glsym_func_const_char_ptr) ();
168 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
170 #ifndef EGL_NATIVE_PIXMAP_KHR
171 # define EGL_NATIVE_PIXMAP_KHR 0x30b0
173 _eng_fn (*glsym_eglGetProcAddress) (const char *a) = NULL;
174 void (*glsym_eglBindTexImage) (EGLDisplay a, EGLSurface b, int c) = NULL;
175 void (*glsym_eglReleaseTexImage) (EGLDisplay a, EGLSurface b, int c) = NULL;
176 void *(*glsym_eglCreateImage) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, const int *e) = NULL;
177 void (*glsym_eglDestroyImage) (EGLDisplay a, void *b) = NULL;
178 void (*glsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL;
179 void (*glsym_glEGLImageTargetRenderbufferStorageOES) (int a, void *b) = NULL;
180 void *(*glsym_eglMapImageSEC) (void *a, void *b) = NULL;
181 unsigned int (*glsym_eglUnmapImageSEC) (void *a, void *b) = NULL;
182 const char *(*glsym_eglQueryString) (EGLDisplay a, int name) = NULL;
184 unsigned int (*glsym_eglLockSurface) (EGLDisplay a, EGLSurface b, const int *attrib_list) = NULL;
185 unsigned int (*glsym_eglUnlockSurface) (EGLDisplay a, EGLSurface b) = NULL;
188 typedef XID (*glsym_func_xid) ();
190 _eng_fn (*glsym_glXGetProcAddress) (const char *a) = NULL;
191 void (*glsym_glXBindTexImage) (Display *a, GLXDrawable b, int c, int *d) = NULL;
192 void (*glsym_glXReleaseTexImage) (Display *a, GLXDrawable b, int c) = NULL;
193 int (*glsym_glXGetVideoSync) (unsigned int *a) = NULL;
194 int (*glsym_glXWaitVideoSync) (int a, int b, unsigned int *c) = NULL;
195 XID (*glsym_glXCreatePixmap) (Display *a, void *b, Pixmap c, const int *d) = NULL;
196 void (*glsym_glXDestroyPixmap) (Display *a, XID b) = NULL;
197 void (*glsym_glXQueryDrawable) (Display *a, XID b, int c, unsigned int *d) = NULL;
198 int (*glsym_glXSwapIntervalSGI) (int a) = NULL;
199 void (*glsym_glXSwapIntervalEXT) (Display *s, GLXDrawable b, int c) = NULL;
201 const char *(*glsym_glXQueryExtensionsString) (Display *a, int screen) = NULL;
205 void (*glsym_glGetProgramBinaryOES) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary) = NULL;
206 void (*glsym_glProgramBinaryOES) (GLuint program, GLenum binaryFormat, const void *binary, GLint length) = NULL;
207 void* (*glsym_glMapBufferOES) (GLenum target, GLenum access) = NULL;
208 unsigned char (*glsym_glUnmapBufferOES) (GLenum target) = NULL;
209 void (*glsym_glGetBufferPointervOES) (GLenum target, GLenum pname, void** params) = NULL;
210 void (*glsym_glTexImage3DOES) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels) = NULL;
211 void (*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;
212 void (*glsym_glCopyTexSubImage3DOES) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
213 void (*glsym_glCompressedTexImage3DOES) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data) = NULL;
214 void (*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;
215 void (*glsym_glFramebufferTexture3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) = NULL;
216 void (*glsym_glGetPerfMonitorGroupsAMD) (GLint* numGroups, GLsizei groupsSize, GLuint* groups) = NULL;
217 void (*glsym_glGetPerfMonitorCountersAMD) (GLuint group, GLint* numCounters, GLint* maxActiveCounters, GLsizei counterSize, GLuint* counters) = NULL;
218 void (*glsym_glGetPerfMonitorGroupStringAMD) (GLuint group, GLsizei bufSize, GLsizei* length, char* groupString) = NULL;
219 void (*glsym_glGetPerfMonitorCounterStringAMD) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, char* counterString) = NULL;
220 void (*glsym_glGetPerfMonitorCounterInfoAMD) (GLuint group, GLuint counter, GLenum pname, void* data) = NULL;
221 void (*glsym_glGenPerfMonitorsAMD) (GLsizei n, GLuint* monitors) = NULL;
222 void (*glsym_glDeletePerfMonitorsAMD) (GLsizei n, GLuint* monitors) = NULL;
223 void (*glsym_glSelectPerfMonitorCountersAMD) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* countersList) = NULL;
224 void (*glsym_glBeginPerfMonitorAMD) (GLuint monitor) = NULL;
225 void (*glsym_glEndPerfMonitorAMD) (GLuint monitor) = NULL;
226 void (*glsym_glGetPerfMonitorCounterDataAMD) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint* bytesWritten) = NULL;
227 void (*glsym_glDiscardFramebufferEXT) (GLenum target, GLsizei numAttachments, const GLenum* attachments) = NULL;
228 void (*glsym_glMultiDrawArraysEXT) (GLenum mode, GLint* first, GLsizei* count, GLsizei primcount) = NULL;
229 void (*glsym_glMultiDrawElementsEXT) (GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount) = NULL;
230 void (*glsym_glDeleteFencesNV) (GLsizei n, const GLuint* fences) = NULL;
231 void (*glsym_glGenFencesNV) (GLsizei n, GLuint* fences) = NULL;
232 unsigned char (*glsym_glIsFenceNV) (GLuint fence) = NULL;
233 unsigned char (*glsym_glTestFenceNV) (GLuint fence) = NULL;
234 void (*glsym_glGetFenceivNV) (GLuint fence, GLenum pname, GLint* params) = NULL;
235 void (*glsym_glFinishFenceNV) (GLuint fence) = NULL;
236 void (*glsym_glSetFenceNV) (GLuint, GLenum) = NULL;
237 void (*glsym_glRenderbufferStorageMultisample) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) = NULL;
238 void (*glsym_glFramebufferTexture2DMultisample) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) = NULL;
239 void (*glsym_glGetDriverControlsQCOM) (GLint* num, GLsizei size, GLuint* driverControls) = NULL;
240 void (*glsym_glGetDriverControlStringQCOM) (GLuint driverControl, GLsizei bufSize, GLsizei* length, char* driverControlString) = NULL;
241 void (*glsym_glEnableDriverControlQCOM) (GLuint driverControl) = NULL;
242 void (*glsym_glDisableDriverControlQCOM) (GLuint driverControl) = NULL;
243 void (*glsym_glExtGetTexturesQCOM) (GLuint* textures, GLint maxTextures, GLint* numTextures) = NULL;
244 void (*glsym_glExtGetBuffersQCOM) (GLuint* buffers, GLint maxBuffers, GLint* numBuffers) = NULL;
245 void (*glsym_glExtGetRenderbuffersQCOM) (GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers) = NULL;
246 void (*glsym_glExtGetFramebuffersQCOM) (GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers) = NULL;
247 void (*glsym_glExtGetTexLevelParameterivQCOM) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params) = NULL;
248 void (*glsym_glExtTexObjectStateOverrideiQCOM) (GLenum target, GLenum pname, GLint param) = NULL;
249 void (*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;
250 void (*glsym_glExtGetBufferPointervQCOM) (GLenum target, void** params) = NULL;
251 void (*glsym_glExtGetShadersQCOM) (GLuint* shaders, GLint maxShaders, GLint* numShaders) = NULL;
252 void (*glsym_glExtGetProgramsQCOM) (GLuint* programs, GLint maxPrograms, GLint* numPrograms) = NULL;
253 unsigned char (*glsym_glExtIsProgramBinaryQCOM) (GLuint program) = NULL;
254 void (*glsym_glExtGetProgramBinarySourceQCOM) (GLuint program, GLenum shadertype, char* source, GLint* length) = NULL;
257 //------ GLES 2.0 Extensions supported in EvasGL -----//
258 static Extension_Entry _gl_ext_entries[] = {
259 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
260 //--- Function Extensions ---//
261 { "GL_OES_get_program_binary", "get_program_binary", 0 },
262 { "GL_OES_mapbuffer", "mapbuffer", 0 },
263 { "GL_OES_texture_3D", "texture_3D", 0 },
264 { "AMD_performance_monitor", "AMD_performance_monitor", 0 },
265 { "GL_EXT_discard_framebuffer", "discard_framebuffer", 0 },
266 { "GL_EXT_multi_draw_arrays", "multi_draw_arrays", 0 },
267 { "GL_NV_fence", "NV_fence", 0 },
268 { "GL_QCOM_driver_control", "QCOM_driver_control", 0 },
269 { "GL_QCOM_extended_get", "QCOM_extended_get", 0 },
270 { "GL_QCOM_extended_get2", "QCOM_extended_get2", 0 },
271 { "GL_IMG_multlisampled_render_to_texture", "multisampled_render_to_texture", 0 },
273 //--- Define Extensions ---//
274 { "GL_OES_compressed_ETC1_RGB8_texture", "compressed_ETC1_RGB8_texture", 0 },
275 { "GL_OES_compressed_paletted_texture", "compressed_paletted_texture", 0 },
276 { "GL_OES_depth24", "depth24", 0 },
277 { "GL_OES_depth32", "depth32", 0 },
278 { "GL_OES_EvasGL_image", "EGL_image", 0 },
279 { "GL_OES_packed_depth_stencil", "packed_depth_stencil", 0 },
280 { "GL_OES_rgb8_rgba8", "rgb8_rgba8", 0 },
281 { "GL_OES_standard_derivatives", "standard_derivatives", 0 },
282 { "GL_OES_stencil1", "stencil1", 0 },
283 { "GL_OES_stencil4", "stencil4", 0 },
284 { "GL_OES_texture_float", "texture_float", 0 },
285 { "GL_OES_texture_half_float", "texture_half_float", 0 },
286 { "GL_OES_texture_half_float_linear", "texture_half_float_linear", 0 },
287 { "GL_OES_texture_npot", "texture_npot", 0 },
288 { "GL_OES_vertex_half_float", "vertex_half_float", 0 },
289 { "GL_OES_vertex_type_10_10_10_2", "vertex_type_10_10_10_2", 0 },
290 { "GL_AMD_compressed_3DC_texture", "compressed_3DC_texture", 0 },
291 { "GL_AMD_compressed_ATC_texture", "compressed_ATC_texture", 0 },
292 { "GL_AMD_program_binary_Z400", "program_binary_Z400", 0 },
293 { "GL_EXT_blend_minmax", "blend_minmax", 0 },
294 { "GL_EXT_read_format_bgra", "read_format_bgra", 0 },
295 { "GL_EXT_texture_filter_anisotropic", "texture_filter_anisotrophic", 0 },
296 { "GL_EXT_texture_format_BGRA8888", "texture_format_BGRA8888", 0 },
297 { "GL_EXT_texture_type_2_10_10_10_REV", "texture_type_2_10_10_10_rev", 0 },
298 { "GL_IMG_program_binary", "IMG_program_binary", 0 },
299 { "GL_IMG_read_format", "IMG_read_format", 0 },
300 { "GL_IMG_shader_binary", "IMG_shader_binary", 0 },
301 { "GL_IMG_texture_compression_pvrtc", "IMG_texture_compression_pvrtc", 0 },
302 { "GL_QCOM_perfmon_global_mode", "QCOM_perfmon_global_mode", 0 },
303 { "GL_QCOM_writeonly_rendering", "QCOM_writeonly_rendering", 0 },
305 //--- Function Extensions ---//
306 { "GL_OES_get_program_binary", "get_program_binary", 0 },
307 { "GL_OES_mapbuffer", "mapbuffer", 0 },
308 { "GL_OES_texture_3D", "texture_3D", 0 },
309 { "AMD_performance_monitor", "AMD_performance_monitor", 0 },
310 { "GL_EXT_discard_framebuffer", "discard_framebuffer", 0 },
311 { "GL_EXT_multi_draw_arrays", "multi_draw_arrays", 0 },
312 { "GL_NV_fence", "NV_fence", 0 },
313 { "GL_QCOM_driver_control", "QCOM_driver_control", 0 },
314 { "GL_QCOM_extended_get", "QCOM_extended_get", 0 },
315 { "GL_QCOM_extended_get2", "QCOM_extended_get2", 0 },
316 { "GL_IMG_multlisampled_render_to_texture", "multisampled_render_to_texture", 0 },
318 //--- Define Extensions ---//
319 { "GL_OES_compressed_ETC1_RGB8_texture", "compressed_ETC1_RGB8_texture", 0 },
320 { "GL_OES_compressed_paletted_texture", "compressed_paletted_texture", 0 },
321 { "GL_OES_depth24", "depth24", 0 },
322 { "GL_OES_depth32", "depth32", 0 },
323 { "GL_OES_EvasGL_image", "EGL_image", 0 },
324 { "GL_OES_packed_depth_stencil", "packed_depth_stencil", 0 },
325 { "GL_OES_rgb8_rgba8", "rgb8_rgba8", 0 },
326 { "GL_OES_standard_derivatives", "standard_derivatives", 0 },
327 { "GL_OES_stencil1", "stencil1", 0 },
328 { "GL_OES_stencil4", "stencil4", 0 },
329 { "GL_OES_texture_float", "texture_float", 0 },
330 { "GL_OES_texture_half_float", "texture_half_float", 0 },
331 { "GL_OES_texture_half_float_linear", "texture_half_float_linear", 0 },
332 { "GL_OES_texture_npot", "texture_non_power_of_two", 0 }, // Desktop differs
333 { "GL_OES_vertex_half_float", "half_float_vertex", 0 }, // Desktop differs
334 { "GL_OES_vertex_type_10_10_10_2", "vertex_type_10_10_10_2", 0 },
335 { "GL_AMD_compressed_3DC_texture", "compressed_3DC_texture", 0 },
336 { "GL_AMD_compressed_ATC_texture", "compressed_ATC_texture", 0 },
337 { "GL_AMD_program_binary_Z400", "program_binary_Z400", 0 },
338 { "GL_EXT_blend_minmax", "blend_minmax", 0 },
339 { "GL_EXT_read_format_bgra", "bgra", 0 }, // Desktop differs
340 { "GL_EXT_texture_filter_anisotropic", "texture_filter_anisotrophic", 0 },
341 { "GL_EXT_texture_format_BGRA8888", "bgra", 0 }, // Desktop differs
342 { "GL_EXT_texture_type_2_10_10_10_REV", "vertex_type_2_10_10_10_rev", 0 }, // Desktop differs ???
343 { "GL_IMG_program_binary", "IMG_program_binary", 0 },
344 { "GL_IMG_read_format", "IMG_read_format", 0 },
345 { "GL_IMG_shader_binary", "IMG_shader_binary", 0 },
346 { "GL_IMG_texture_compression_pvrtc", "IMG_texture_compression_pvrtc", 0 },
347 { "GL_QCOM_perfmon_global_mode", "QCOM_perfmon_global_mode", 0 },
348 { "GL_QCOM_writeonly_rendering", "QCOM_writeonly_rendering", 0 },
354 //------ Extensions supported in EvasGL -----//
355 static Extension_Entry _evasgl_ext_entries[] = {
356 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
357 { "EvasGL_KHR_image", "EGL_KHR_image", 0 },
358 { "EvasGL_KHR_vg_parent_image", "EGL_KHR_vg_parent_image", 0 },
359 { "EvasGL_KHR_gl_texture_2D_image", "EGL_KHR_gl_texture_2D_image", 0 },
360 { "EvasGL_KHR_gl_texture_cubemap_image", "EGL_KHR_gl_texture_cubemap_image", 0 },
361 { "EvasGL_KHR_gl_texture_3D_image", "EGL_KHR_gl_texture_3D_image", 0 },
362 { "EvasGL_KHR_gl_renderbuffer_image", "EGL_KHR_gl_renderbuffer_image", 0 },
369 _gl_ext_sym_init(void)
375 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
376 #define FINDSYM(dst, sym, typ) \
377 if ((!dst) && (glsym_eglGetProcAddress)) dst = (typ)glsym_eglGetProcAddress(sym); \
378 if (!dst) dst = (typ)dlsym(RTLD_DEFAULT, sym)
380 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddress", glsym_func_eng_fn);
381 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressEXT", glsym_func_eng_fn);
382 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressARB", glsym_func_eng_fn);
383 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressKHR", glsym_func_eng_fn);
385 FINDSYM(glsym_eglBindTexImage, "eglBindTexImage", glsym_func_void);
386 FINDSYM(glsym_eglBindTexImage, "eglBindTexImageEXT", glsym_func_void);
387 FINDSYM(glsym_eglBindTexImage, "eglBindTexImageARB", glsym_func_void);
388 FINDSYM(glsym_eglBindTexImage, "eglBindTexImageKHR", glsym_func_void);
390 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImage", glsym_func_void);
391 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageEXT", glsym_func_void);
392 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageARB", glsym_func_void);
393 FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageKHR", glsym_func_void);
395 FINDSYM(glsym_eglCreateImage, "eglCreateImage", glsym_func_void_ptr);
396 FINDSYM(glsym_eglCreateImage, "eglCreateImageEXT", glsym_func_void_ptr);
397 FINDSYM(glsym_eglCreateImage, "eglCreateImageARB", glsym_func_void_ptr);
398 FINDSYM(glsym_eglCreateImage, "eglCreateImageKHR", glsym_func_void_ptr);
400 FINDSYM(glsym_eglDestroyImage, "eglDestroyImage", glsym_func_void);
401 FINDSYM(glsym_eglDestroyImage, "eglDestroyImageEXT", glsym_func_void);
402 FINDSYM(glsym_eglDestroyImage, "eglDestroyImageARB", glsym_func_void);
403 FINDSYM(glsym_eglDestroyImage, "eglDestroyImageKHR", glsym_func_void);
405 FINDSYM(glsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", glsym_func_void);
407 FINDSYM(glsym_glEGLImageTargetRenderbufferStorageOES, "glEGLImageTargetRenderbufferStorageOES", glsym_func_void);
409 FINDSYM(glsym_eglMapImageSEC, "eglMapImageSEC", glsym_func_void_ptr);
410 FINDSYM(glsym_eglUnmapImageSEC, "eglUnmapImageSEC", glsym_func_uint);
412 FINDSYM(glsym_eglQueryString, "eglQueryString", glsym_func_const_char_ptr);
414 FINDSYM(glsym_eglLockSurface, "eglLockSurface", glsym_func_uint);
415 FINDSYM(glsym_eglLockSurface, "eglLockSurfaceEXT", glsym_func_uint);
416 FINDSYM(glsym_eglLockSurface, "eglLockSurfaceARB", glsym_func_uint);
417 FINDSYM(glsym_eglLockSurface, "eglLockSurfaceKHR", glsym_func_uint);
419 FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurface", glsym_func_uint);
420 FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurfaceEXT", glsym_func_uint);
421 FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurfaceARB", glsym_func_uint);
422 FINDSYM(glsym_eglUnlockSurface, "eglUnlockSurfaceKHR", glsym_func_uint);
425 #define FINDSYM(dst, sym, typ) \
426 if ((!dst) && (glsym_glXGetProcAddress)) dst = (typ)glsym_glXGetProcAddress(sym); \
427 if (!dst) dst = (typ)dlsym(RTLD_DEFAULT, sym)
429 FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddress", glsym_func_eng_fn);
430 FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddressEXT", glsym_func_eng_fn);
431 FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddressARB", glsym_func_eng_fn);
433 FINDSYM(glsym_glXBindTexImage, "glXBindTexImage", glsym_func_void);
434 FINDSYM(glsym_glXBindTexImage, "glXBindTexImageEXT", glsym_func_void);
435 FINDSYM(glsym_glXBindTexImage, "glXBindTexImageARB", glsym_func_void);
437 FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImage", glsym_func_void);
438 FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImageEXT", glsym_func_void);
439 FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImageARB", glsym_func_void);
441 FINDSYM(glsym_glXGetVideoSync, "glXGetVideoSyncSGI", glsym_func_int);
443 FINDSYM(glsym_glXWaitVideoSync, "glXWaitVideoSyncSGI", glsym_func_int);
445 FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmap", glsym_func_xid);
446 FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmapEXT", glsym_func_xid);
447 FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmapARB", glsym_func_xid);
449 FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmap", glsym_func_void);
450 FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmapEXT", glsym_func_void);
451 FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmapARB", glsym_func_void);
453 FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawable", glsym_func_void);
454 FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawableEXT", glsym_func_void);
455 FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawableARB", glsym_func_void);
457 FINDSYM(glsym_glXSwapIntervalSGI, "glXSwapIntervalMESA", glsym_func_int);
458 FINDSYM(glsym_glXSwapIntervalSGI, "glXSwapIntervalSGI", glsym_func_int);
460 FINDSYM(glsym_glXSwapIntervalEXT, "glXSwapIntervalEXT", glsym_func_void);
462 FINDSYM(glsym_glXQueryExtensionsString, "glXQueryExtensionsString", glsym_func_const_char_ptr);
465 //----------- GLES 2.0 Extensions ------------//
466 // If the symbol's not found, they get set to NULL
467 // If one of the functions in the extension exists, the extension in supported
468 /* GL_OES_get_program_binary */
469 FINDSYM(glsym_glGetProgramBinaryOES, "glGetProgramBinary", glsym_func_void);
470 FINDSYM(glsym_glGetProgramBinaryOES, "glGetProgramBinaryEXT", glsym_func_void);
471 FINDSYM(glsym_glGetProgramBinaryOES, "glGetProgramBinaryARB", glsym_func_void);
472 FINDSYM(glsym_glGetProgramBinaryOES, "glGetProgramBinaryOES", glsym_func_void);
474 FINDSYM(glsym_glProgramBinaryOES, "glProgramBinary", glsym_func_void);
475 FINDSYM(glsym_glProgramBinaryOES, "glProgramBinaryEXT", glsym_func_void);
476 FINDSYM(glsym_glProgramBinaryOES, "glProgramBinaryARB", glsym_func_void);
477 FINDSYM(glsym_glProgramBinaryOES, "glProgramBinaryOES", glsym_func_void);
479 // Check the first function to see if the extension is supported...
480 if (glsym_glGetProgramBinaryOES) _gl_ext_entries[0].supported = 1;
483 /* GL_OES_mapbuffer */
484 FINDSYM(glsym_glMapBufferOES, "glMapBuffer", glsym_func_void_ptr);
485 FINDSYM(glsym_glMapBufferOES, "glMapBufferEXT", glsym_func_void_ptr);
486 FINDSYM(glsym_glMapBufferOES, "glMapBufferARB", glsym_func_void_ptr);
487 FINDSYM(glsym_glMapBufferOES, "glMapBufferOES", glsym_func_void_ptr);
489 FINDSYM(glsym_glUnmapBufferOES, "glUnmapBuffer", glsym_func_uchar);
490 FINDSYM(glsym_glUnmapBufferOES, "glUnmapBufferEXT", glsym_func_uchar);
491 FINDSYM(glsym_glUnmapBufferOES, "glUnmapBufferARB", glsym_func_uchar);
492 FINDSYM(glsym_glUnmapBufferOES, "glUnmapBufferOES", glsym_func_uchar);
494 FINDSYM(glsym_glGetBufferPointervOES, "glGetBufferPointerv", glsym_func_void);
495 FINDSYM(glsym_glGetBufferPointervOES, "glGetBufferPointervEXT", glsym_func_void);
496 FINDSYM(glsym_glGetBufferPointervOES, "glGetBufferPointervARB", glsym_func_void);
497 FINDSYM(glsym_glGetBufferPointervOES, "glGetBufferPointervOES", glsym_func_void);
499 if (glsym_glMapBufferOES) _gl_ext_entries[1].supported = 1;
501 /* GL_OES_texture_3D */
502 FINDSYM(glsym_glTexImage3DOES, "glTexImage3D", glsym_func_void);
503 FINDSYM(glsym_glTexImage3DOES, "glTexImage3DEXT", glsym_func_void);
504 FINDSYM(glsym_glTexImage3DOES, "glTexImage3DARB", glsym_func_void);
505 FINDSYM(glsym_glTexImage3DOES, "glTexImage3DOES", glsym_func_void);
507 FINDSYM(glsym_glTexSubImage3DOES, "glTexSubImage3D", glsym_func_void);
508 FINDSYM(glsym_glTexSubImage3DOES, "glTexSubImage3DEXT", glsym_func_void);
509 FINDSYM(glsym_glTexSubImage3DOES, "glTexSubImage3DARB", glsym_func_void);
510 FINDSYM(glsym_glTexSubImage3DOES, "glTexSubImage3DOES", glsym_func_void);
512 FINDSYM(glsym_glCopyTexSubImage3DOES, "glCopyTexSubImage3D", glsym_func_void);
513 FINDSYM(glsym_glCopyTexSubImage3DOES, "glCopyTexSubImage3DARB", glsym_func_void);
514 FINDSYM(glsym_glCopyTexSubImage3DOES, "glCopyTexSubImage3DEXT", glsym_func_void);
515 FINDSYM(glsym_glCopyTexSubImage3DOES, "glCopyTexSubImage3DOES", glsym_func_void);
517 FINDSYM(glsym_glCompressedTexImage3DOES, "glCompressedTexImage3D", glsym_func_void);
518 FINDSYM(glsym_glCompressedTexImage3DOES, "glCompressedTexImage3DARB", glsym_func_void);
519 FINDSYM(glsym_glCompressedTexImage3DOES, "glCompressedTexImage3DEXT", glsym_func_void);
520 FINDSYM(glsym_glCompressedTexImage3DOES, "glCompressedTexImage3DOES", glsym_func_void);
522 FINDSYM(glsym_glCompressedTexSubImage3DOES, "glCompressedTexSubImage3D", glsym_func_void);
523 FINDSYM(glsym_glCompressedTexSubImage3DOES, "glCompressedTexSubImage3DARB", glsym_func_void);
524 FINDSYM(glsym_glCompressedTexSubImage3DOES, "glCompressedTexSubImage3DEXT", glsym_func_void);
525 FINDSYM(glsym_glCompressedTexSubImage3DOES, "glCompressedTexSubImage3DOES", glsym_func_void);
527 FINDSYM(glsym_glFramebufferTexture3DOES, "glFramebufferTexture3D", glsym_func_void);
528 FINDSYM(glsym_glFramebufferTexture3DOES, "glFramebufferTexture3DARB", glsym_func_void);
529 FINDSYM(glsym_glFramebufferTexture3DOES, "glFramebufferTexture3DEXT", glsym_func_void);
530 FINDSYM(glsym_glFramebufferTexture3DOES, "glFramebufferTexture3DOES", glsym_func_void);
532 if (glsym_glTexSubImage3DOES) _gl_ext_entries[2].supported = 1;
534 /* AMD_performance_monitor */
535 FINDSYM(glsym_glGetPerfMonitorGroupsAMD, "glGetPerfMonitorGroupsAMD", glsym_func_void);
536 FINDSYM(glsym_glGetPerfMonitorCountersAMD, "glGetPerfMonitorCountersAMD", glsym_func_void);
537 FINDSYM(glsym_glGetPerfMonitorGroupStringAMD, "glGetPerfMonitorGroupStringAMD", glsym_func_void);
538 FINDSYM(glsym_glGetPerfMonitorCounterStringAMD, "glGetPerfMonitorCounterStringAMD", glsym_func_void);
539 FINDSYM(glsym_glGetPerfMonitorCounterInfoAMD, "glGetPerfMonitorCounterInfoAMD", glsym_func_void);
540 FINDSYM(glsym_glGenPerfMonitorsAMD, "glGenPerfMonitorsAMD", glsym_func_void);
541 FINDSYM(glsym_glDeletePerfMonitorsAMD, "glDeletePerfMonitorsAMD", glsym_func_void);
542 FINDSYM(glsym_glSelectPerfMonitorCountersAMD, "glSelectPerfMonitorCountersAMD", glsym_func_void);
543 FINDSYM(glsym_glBeginPerfMonitorAMD, "glBeginPerfMonitorAMD", glsym_func_void);
544 FINDSYM(glsym_glEndPerfMonitorAMD, "glEndPerfMonitorAMD", glsym_func_void);
545 FINDSYM(glsym_glGetPerfMonitorCounterDataAMD, "glGetPerfMonitorCounterDataAMD", glsym_func_void);
547 if (glsym_glGetPerfMonitorGroupsAMD) _gl_ext_entries[3].supported = 1;
549 /* GL_EXT_discard_framebuffer */
550 FINDSYM(glsym_glDiscardFramebufferEXT, "glDiscardFramebuffer", glsym_func_void);
551 FINDSYM(glsym_glDiscardFramebufferEXT, "glDiscardFramebufferARB", glsym_func_void);
552 FINDSYM(glsym_glDiscardFramebufferEXT, "glDiscardFramebufferEXT", glsym_func_void);
554 if (glsym_glDiscardFramebufferEXT) _gl_ext_entries[4].supported = 1;
556 /* GL_EXT_multi_draw_arrays */
557 FINDSYM(glsym_glMultiDrawArraysEXT, "glMultiDrawArrays", glsym_func_void);
558 FINDSYM(glsym_glMultiDrawArraysEXT, "glMultiDrawArraysARB", glsym_func_void);
559 FINDSYM(glsym_glMultiDrawArraysEXT, "glMultiDrawArraysEXT", glsym_func_void);
561 FINDSYM(glsym_glMultiDrawElementsEXT, "glMultiDrawElements", glsym_func_void);
562 FINDSYM(glsym_glMultiDrawElementsEXT, "glMultiDrawElementsARB", glsym_func_void);
563 FINDSYM(glsym_glMultiDrawElementsEXT, "glMultiDrawElementsEXT", glsym_func_void);
565 if (glsym_glMultiDrawArraysEXT) _gl_ext_entries[5].supported = 1;
568 FINDSYM(glsym_glDeleteFencesNV, "glDeleteFencesNV", glsym_func_void);
569 FINDSYM(glsym_glGenFencesNV, "glGenFencesNV", glsym_func_void);
570 FINDSYM(glsym_glIsFenceNV, "glIsFenceNV", glsym_func_uchar);
571 FINDSYM(glsym_glTestFenceNV, "glTestFenceNV", glsym_func_uchar);
572 FINDSYM(glsym_glGetFenceivNV, "glGetFenceivNV", glsym_func_void);
573 FINDSYM(glsym_glFinishFenceNV, "glFinishFenceNV", glsym_func_void);
574 FINDSYM(glsym_glSetFenceNV, "glSetFenceNV", glsym_func_void);
576 if (glsym_glDeleteFencesNV) _gl_ext_entries[6].supported = 1;
578 /* GL_QCOM_driver_control */
579 FINDSYM(glsym_glGetDriverControlsQCOM, "glGetDriverControlsQCOM", glsym_func_void);
580 FINDSYM(glsym_glGetDriverControlStringQCOM, "glGetDriverControlStringQCOM", glsym_func_void);
581 FINDSYM(glsym_glEnableDriverControlQCOM, "glEnableDriverControlQCOM", glsym_func_void);
582 FINDSYM(glsym_glDisableDriverControlQCOM, "glDisableDriverControlQCOM", glsym_func_void);
584 if (glsym_glGetDriverControlsQCOM) _gl_ext_entries[7].supported = 1;
586 /* GL_QCOM_extended_get */
587 FINDSYM(glsym_glExtGetTexturesQCOM, "glExtGetTexturesQCOM", glsym_func_void);
588 FINDSYM(glsym_glExtGetBuffersQCOM, "glExtGetBuffersQCOM", glsym_func_void);
589 FINDSYM(glsym_glExtGetRenderbuffersQCOM, "glExtGetRenderbuffersQCOM", glsym_func_void);
590 FINDSYM(glsym_glExtGetFramebuffersQCOM, "glExtGetFramebuffersQCOM", glsym_func_void);
591 FINDSYM(glsym_glExtGetTexLevelParameterivQCOM, "glExtGetTexLevelParameterivQCOM", glsym_func_void);
592 FINDSYM(glsym_glExtTexObjectStateOverrideiQCOM, "glExtTexObjectStateOverrideiQCOM", glsym_func_void);
593 FINDSYM(glsym_glExtGetTexSubImageQCOM, "glExtGetTexSubImageQCOM", glsym_func_void);
594 FINDSYM(glsym_glExtGetBufferPointervQCOM, "glExtGetBufferPointervQCOM", glsym_func_void);
596 if (glsym_glExtGetTexturesQCOM) _gl_ext_entries[8].supported = 1;
598 /* GL_QCOM_extended_get2 */
599 FINDSYM(glsym_glExtGetShadersQCOM, "glExtGetShadersQCOM", glsym_func_void);
600 FINDSYM(glsym_glExtGetProgramsQCOM, "glExtGetProgramsQCOM", glsym_func_void);
601 FINDSYM(glsym_glExtIsProgramBinaryQCOM, "glExtIsProgramBinaryQCOM", glsym_func_uchar);
602 FINDSYM(glsym_glExtGetProgramBinarySourceQCOM, "glExtGetProgramBinarySourceQCOM", glsym_func_void);
604 if (glsym_glExtGetShadersQCOM) _gl_ext_entries[9].supported = 1;
606 /* GL_IMG_multisampled_render_to_texture */
607 FINDSYM(glsym_glRenderbufferStorageMultisample, "glRenderbufferStorageMultisampleIMG", glsym_func_void);
608 FINDSYM(glsym_glRenderbufferStorageMultisample, "glRenderbufferStorageMultisampleEXT", glsym_func_void);
609 FINDSYM(glsym_glFramebufferTexture2DMultisample, "glFramebufferTexture2DMultisampleIMG", glsym_func_void);
610 FINDSYM(glsym_glFramebufferTexture2DMultisample, "glFramebufferTexture2DMultisampleEXT", glsym_func_void);
615 _gl_ext_init(Render_Engine *re)
618 const char *glexts, *evasglexts;
620 // GLES 2.0 Extensions
621 glexts = (const char*)glGetString(GL_EXTENSIONS);
623 ext_len = strlen(glexts);
626 DBG("GL Get Extension string NULL: No extensions supported");
630 _gl_ext_string = calloc(1, sizeof(char) * ext_len * 2);
633 ERR("Error allocating _gl_ext_string.");
637 DBG("--------GLES 2.0 Extensions--------");
638 for (i = 0; _gl_ext_entries[i].name != NULL; i++)
640 if ( (strstr(glexts, _gl_ext_entries[i].name) != NULL) ||
641 (strstr(glexts, _gl_ext_entries[i].real_name) != NULL) )
643 _gl_ext_entries[i].supported = 1;
644 strcat(_gl_ext_string, _gl_ext_entries[i].name);
645 strcat(_gl_ext_string, " ");
646 DBG("\t%s", _gl_ext_entries[i].name);
652 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
654 if (glsym_eglQueryString)
656 evasglexts = glsym_eglQueryString(re->win->egl_disp, EGL_EXTENSIONS);
658 if (glsym_glXQueryExtensionsString)
660 evasglexts = glXQueryExtensionsString(re->info->info.display,
661 re->info->info.screen);
663 ext_len = strlen(evasglexts);
667 DBG("GL Get Extension string NULL: No extensions supported");
671 _evasgl_ext_string = calloc(1, sizeof(char) * ext_len * 2);
672 if (!_evasgl_ext_string)
674 ERR("Error allocating _evasgl_ext_string.");
678 DBG("--------EvasGL Supported Extensions----------");
679 for (i = 0; _evasgl_ext_entries[i].name != NULL; i++)
681 if ( (strstr(evasglexts, _evasgl_ext_entries[i].name) != NULL) ||
682 (strstr(evasglexts, _evasgl_ext_entries[i].real_name) != NULL) )
684 _evasgl_ext_entries[i].supported = 1;
685 strcat(_evasgl_ext_string, _evasgl_ext_entries[i].name);
686 strcat(_evasgl_ext_string, " ");
687 DBG("\t%s", _evasgl_ext_entries[i].name);
694 int _evas_engine_GL_X11_log_dom = -1;
695 /* function tables - filled in later (func and parent func) */
696 static Evas_Func func, pfunc;
698 /* Function table for GL APIs */
699 static Evas_GL_API gl_funcs;
707 static struct xrdb_user xrdb_user = {0, 0, NULL};
710 xrdb_user_query(const char *name, const char *cls, char **type, XrmValue *val)
712 time_t last = xrdb_user.last_stat, now = time(NULL);
714 xrdb_user.last_stat = now;
715 if (last != now) // don't stat() more than once every second
718 const char *home = getenv("HOME");
721 if (!home) goto failed;
722 snprintf(tmp, sizeof(tmp), "%s/.Xdefaults", home);
723 if (stat(tmp, &st) != 0) goto failed;
724 if (xrdb_user.last_mtime != st.st_mtime)
726 if (xrdb_user.db) XrmDestroyDatabase(xrdb_user.db);
727 xrdb_user.db = XrmGetFileDatabase(tmp);
728 if (!xrdb_user.db) goto failed;
729 xrdb_user.last_mtime = st.st_mtime;
733 if (!xrdb_user.db) return EINA_FALSE;
734 return XrmGetResource(xrdb_user.db, name, cls, type, val);
739 XrmDestroyDatabase(xrdb_user.db);
742 xrdb_user.last_mtime = 0;
750 Evas_Engine_Info_GL_X11 *info;
752 info = calloc(1, sizeof(Evas_Engine_Info_GL_X11));
753 info->magic.magic = rand();
754 info->func.best_visual_get = eng_best_visual_get;
755 info->func.best_colormap_get = eng_best_colormap_get;
756 info->func.best_depth_get = eng_best_depth_get;
757 info->render_mode = EVAS_RENDER_MODE_BLOCKING;
763 eng_info_free(Evas *e __UNUSED__, void *info)
765 Evas_Engine_Info_GL_X11 *in;
766 // dont free! why bother? its not worth it
767 // eina_log_domain_unregister(_evas_engine_GL_X11_log_dom);
768 in = (Evas_Engine_Info_GL_X11 *)info;
773 _re_wincheck(Render_Engine *re)
775 if (re->win->surf) return 1;
776 eng_window_resurf(re->win);
779 ERR("GL engine can't re-create window surface!");
785 _re_winfree(Render_Engine *re)
787 if (!re->win->surf) return;
788 eng_window_unsurf(re->win);
791 static Render_Engine_GL_Resource *
792 _create_internal_glue_resources(void *data)
794 Render_Engine *re = (Render_Engine *)data;
795 Render_Engine_GL_Resource *rsc;
797 rsc = calloc(1, sizeof(Render_Engine_GL_Resource));
799 if (!rsc) return NULL;
801 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
803 int context_attrs[3];
804 context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
805 context_attrs[1] = 2;
806 context_attrs[2] = EGL_NONE;
808 if (eina_main_loop_is())
810 rsc->surface = re->win->egl_surface[0];
814 // Create resource surface for EGL
815 rsc->surface = eglCreateWindowSurface(re->win->egl_disp,
817 (EGLNativeWindowType)DefaultRootWindow(re->info->info.display),
821 ERR("Creating internal resource surface failed.");
827 // Create a resource context for EGL
828 rsc->context = eglCreateContext(re->win->egl_disp,
830 re->win->egl_context[0], // Evas' GL Context
834 ERR("Internal Resource Context Creations Failed.");
839 // Add to the resource resource list for cleanup
841 resource_list = eina_list_prepend(resource_list, rsc);
844 // Set the resource in TLS
845 if (eina_tls_set(resource_key, (void*)rsc) == EINA_FALSE)
847 ERR("Failed setting TLS Resource");
854 rsc->context = glXCreateContext(re->info->info.display,
856 re->win->context, // Evas' GL Context
860 ERR("Internal Resource Context Creations Failed.");
865 // Add to the resource resource list for cleanup
867 resource_list = eina_list_prepend(resource_list, rsc);
870 // Set the resource in TLS
871 if (eina_tls_set(resource_key, (void*)rsc) == EINA_FALSE)
873 ERR("Failed setting TLS Resource");
885 _destroy_internal_glue_resources(void *data)
887 Render_Engine *re = (Render_Engine *)data;
889 Render_Engine_GL_Resource *rsc;
891 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
893 // Delete the Resources
895 EINA_LIST_FOREACH(resource_list, l, rsc)
897 if ((rsc->surface) && (rsc->surface != re->win->egl_surface[0]))
898 eglDestroySurface(re->win->egl_disp, rsc->surface);
900 eglDestroyContext(re->win->egl_disp, rsc->context);
903 eina_list_free(resource_list);
907 eina_tls_free(resource_key);
910 // Delete the Resources
912 EINA_LIST_FOREACH(resource_list, l, rsc)
916 glXDestroyContext(re->info->info.display, rsc->context);
920 eina_list_free(resource_list);
924 eina_tls_free(resource_key);
927 // Free the extension strings
931 free(_gl_ext_string);
932 if (_evasgl_ext_string)
933 free(_evasgl_ext_string);
935 _gl_ext_string = NULL;
936 _evasgl_ext_string = NULL;
946 eng_setup(Evas *e, void *in)
949 Evas_Engine_Info_GL_X11 *info;
951 info = (Evas_Engine_Info_GL_X11 *)in;
952 if (!e->engine.data.output)
954 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
958 if (!glXQueryExtension(info->info.display, &eb, &evb)) return 0;
960 re = calloc(1, sizeof(Render_Engine));
964 e->engine.data.output = re;
967 re->win = eng_window_new(re->info->info.display,
968 re->info->info.drawable,
969 re->info->info.screen,
970 re->info->info.visual,
971 re->info->info.colormap,
972 re->info->info.depth,
976 re->info->info.destination_alpha,
977 re->info->info.rotation);
981 e->engine.data.output = NULL;
992 re->xr.dpi = 75000; // dpy * 1000
994 status = xrdb_user_query("Xft.dpi", "Xft.Dpi", &type, &val);
995 if ((!status) || (!type))
997 if (!re->xrdb) re->xrdb = XrmGetDatabase(re->info->info.display);
999 status = XrmGetResource(re->xrdb,
1000 "Xft.dpi", "Xft.Dpi", &type, &val);
1003 if ((status) && (type))
1005 if (!strcmp(type, "String"))
1007 const char *str, *dp;
1010 dp = strchr(str, '.');
1011 if (!dp) dp = strchr(str, ',');
1018 buf = alloca(dp - str + 1);
1019 strncpy(buf, str, dp - str);
1021 len = strlen(dp + 1);
1022 subdpi = atoi(dp + 1);
1026 for (i = len; i < 3; i++) subdpi *= 10;
1030 for (i = len; i > 3; i--) subdpi /= 10;
1032 re->xr.dpi = atoi(buf) * 1000;
1035 re->xr.dpi = atoi(str) * 1000;
1036 evas_common_font_dpi_set(re->xr.dpi / 1000);
1043 evas_common_cpu_init();
1045 evas_common_blend_init();
1046 evas_common_image_init();
1047 evas_common_convert_init();
1048 evas_common_scale_init();
1049 evas_common_rectangle_init();
1050 evas_common_polygon_init();
1051 evas_common_line_init();
1052 evas_common_font_init();
1053 evas_common_draw_init();
1054 evas_common_tilebuf_init();
1057 if (eina_tls_new(&resource_key) == EINA_FALSE)
1058 ERR("Error creating tls key");
1059 DBG("TLS KEY create... %d", resource_key);
1066 re = e->engine.data.output;
1067 if (_re_wincheck(re))
1069 if ((re->info->info.display != re->win->disp) ||
1070 (re->info->info.drawable != re->win->win) ||
1071 (re->info->info.screen != re->win->screen) ||
1072 (re->info->info.visual != re->win->visual) ||
1073 (re->info->info.colormap != re->win->colormap) ||
1074 (re->info->info.depth != re->win->depth) ||
1075 (re->info->info.destination_alpha != re->win->alpha) ||
1076 (re->info->info.rotation != re->win->rot))
1082 re->win->gl_context->references++;
1083 eng_window_free(re->win);
1087 re->w = e->output.w;
1088 re->h = e->output.h;
1089 re->win = eng_window_new(re->info->info.display,
1090 re->info->info.drawable,
1091 re->info->info.screen,
1092 re->info->info.visual,
1093 re->info->info.colormap,
1094 re->info->info.depth,
1098 re->info->info.destination_alpha,
1099 re->info->info.rotation);
1100 eng_window_use(re->win);
1101 if (re->win) gl_wins++;
1102 if ((re->win) && (inc))
1103 re->win->gl_context->references--;
1105 else if ((re->win->w != e->output.w) ||
1106 (re->win->h != e->output.h))
1108 re->w = e->output.w;
1109 re->h = e->output.h;
1110 re->win->w = e->output.w;
1111 re->win->h = e->output.h;
1112 eng_window_use(re->win);
1113 evas_gl_common_context_resize(re->win->gl_context, re->win->w, re->win->h, re->win->rot);
1123 if (!e->engine.data.output)
1127 eng_window_free(re->win);
1133 re->tb = evas_common_tilebuf_new(re->win->w, re->win->h);
1138 eng_window_free(re->win);
1144 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
1146 if (!e->engine.data.context)
1147 e->engine.data.context =
1148 e->engine.func->context_new(e->engine.data.output);
1149 eng_window_use(re->win);
1164 eng_output_free(void *data)
1168 re = (Render_Engine *)data;
1172 // NOTE: XrmGetDatabase() result is shared per connection, do not free it.
1173 // if (re->xrdb) XrmDestroyDatabase(re->xrdb);
1176 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1177 // Destroy the resource surface
1178 // Only required for EGL case
1180 eglDestroySurface(re->win->egl_disp, re->surface);
1183 // Destroy the resource context
1184 _destroy_internal_context(re, context);
1188 if ((initted == 1) && (gl_wins == 1))
1189 _destroy_internal_glue_resources(re);
1190 eng_window_free(re->win);
1193 evas_common_tilebuf_free(re->tb);
1196 if ((initted == 1) && (gl_wins == 0))
1198 evas_common_image_shutdown();
1199 evas_common_font_shutdown();
1205 eng_output_resize(void *data, int w, int h)
1209 re = (Render_Engine *)data;
1212 eng_window_use(re->win);
1213 evas_gl_common_context_resize(re->win->gl_context, w, h, re->win->rot);
1214 evas_common_tilebuf_free(re->tb);
1215 re->tb = evas_common_tilebuf_new(w, h);
1217 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
1221 eng_output_tile_size_set(void *data, int w, int h)
1225 re = (Render_Engine *)data;
1226 evas_common_tilebuf_set_tile_size(re->tb, w, h);
1230 eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
1234 re = (Render_Engine *)data;
1235 eng_window_use(re->win);
1236 evas_gl_common_context_resize(re->win->gl_context, re->win->w, re->win->h, re->win->rot);
1237 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
1239 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, re->win->w, re->win->h);
1240 if ((w <= 0) || (h <= 0)) return;
1241 if (!re->win->draw.redraw)
1244 re->win->draw.x1 = x;
1245 re->win->draw.y1 = y;
1246 re->win->draw.x2 = x + w - 1;
1247 re->win->draw.y2 = y + h - 1;
1249 re->win->draw.x1 = 0;
1250 re->win->draw.y1 = 0;
1251 re->win->draw.x2 = re->win->w - 1;
1252 re->win->draw.y2 = re->win->h - 1;
1257 if (x < re->win->draw.x1) re->win->draw.x1 = x;
1258 if (y < re->win->draw.y1) re->win->draw.y1 = y;
1259 if ((x + w - 1) > re->win->draw.x2) re->win->draw.x2 = x + w - 1;
1260 if ((y + h - 1) > re->win->draw.y2) re->win->draw.y2 = y + h - 1;
1262 re->win->draw.redraw = 1;
1266 eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
1270 re = (Render_Engine *)data;
1271 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
1275 eng_output_redraws_clear(void *data)
1279 re = (Render_Engine *)data;
1280 evas_common_tilebuf_clear(re->tb);
1281 /* re->win->draw.redraw = 0;*/
1282 // INF("GL: finish update cycle!");
1285 /* vsync games - not for now though */
1286 #define VSYNC_TO_SCREEN 1
1289 eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
1292 Tilebuf_Rect *rects;
1294 re = (Render_Engine *)data;
1295 /* get the upate rect surface - return engine data as dummy */
1296 rects = evas_common_tilebuf_get_render_rects(re->tb);
1302 printf("REAAAAACCTS\n");
1303 EINA_INLIST_FOREACH(EINA_INLIST_GET(rects), r)
1305 printf(" %i %i %ix%i\n", r->x, r->y, r->w, r->h);
1308 evas_common_tilebuf_free_render_rects(rects);
1309 evas_common_tilebuf_clear(re->tb);
1310 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1311 // dont need to for egl - eng_window_use() can check for other ctxt's
1313 eng_window_use(NULL);
1315 eng_window_use(re->win);
1316 if (!_re_wincheck(re)) return NULL;
1317 evas_gl_common_context_flush(re->win->gl_context);
1318 evas_gl_common_context_newframe(re->win->gl_context);
1321 if (w) *w = re->win->w;
1322 if (h) *h = re->win->h;
1325 if (cw) *cw = re->win->w;
1326 if (ch) *ch = re->win->h;
1327 return re->win->gl_context->def_surface;
1331 if (!re->win->draw.redraw) return NULL;
1332 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1333 // dont need to for egl - eng_window_use() can check for other ctxt's
1335 eng_window_use(NULL);
1337 eng_window_use(re->win);
1338 if (!_re_wincheck(re)) return NULL;
1339 evas_gl_common_context_flush(re->win->gl_context);
1340 evas_gl_common_context_newframe(re->win->gl_context);
1341 if (x) *x = re->win->draw.x1;
1342 if (y) *y = re->win->draw.y1;
1343 if (w) *w = re->win->draw.x2 - re->win->draw.x1 + 1;
1344 if (h) *h = re->win->draw.y2 - re->win->draw.y1 + 1;
1345 if (cx) *cx = re->win->draw.x1;
1346 if (cy) *cy = re->win->draw.y1;
1347 if (cw) *cw = re->win->draw.x2 - re->win->draw.x1 + 1;
1348 if (ch) *ch = re->win->draw.y2 - re->win->draw.y1 + 1;
1349 return re->win->gl_context->def_surface;
1353 //#define FRAMECOUNT 1
1359 struct timeval timev;
1361 gettimeofday(&timev, NULL);
1362 return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
1366 static int safe_native = -1;
1369 eng_output_redraws_next_update_push(void *data, void *surface __UNUSED__, int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__)
1373 static double pt = 0.0;
1377 re = (Render_Engine *)data;
1378 /* put back update surface.. in this case just unflag redraw */
1379 if (!_re_wincheck(re)) return;
1380 re->win->draw.redraw = 0;
1381 re->win->draw.drew = 1;
1382 evas_gl_common_context_flush(re->win->gl_context);
1383 if (safe_native == -1)
1385 const char *s = getenv("EVAS_GL_SAFE_NATIVE");
1387 if (s) safe_native = atoi(s);
1390 s = (const char *)glGetString(GL_RENDERER);
1393 if (strstr(s, "PowerVR SGX 540") ||
1394 strstr(s, "Mali-400 MP"))
1399 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1400 // this is needed to make sure all previous rendering is flushed to
1403 double t0 = get_time();
1407 // previous rendering should be done and swapped
1408 if (!safe_native) eglWaitNative(EGL_CORE_NATIVE_ENGINE);
1410 double t1 = get_time();
1412 printf("... %1.5f -> %1.5f | ", ta, tb);
1414 // if (eglGetError() != EGL_SUCCESS)
1416 // printf("Error: eglWaitNative(EGL_CORE_NATIVE_ENGINE) fail.\n");
1419 // previous rendering should be done and swapped
1420 if (!safe_native) glXWaitX();
1422 //x// printf("frame -> push\n");
1426 eng_output_flush(void *data)
1430 re = (Render_Engine *)data;
1431 if (!_re_wincheck(re)) return;
1432 if (!re->win->draw.drew) return;
1433 //x// printf("frame -> flush\n");
1434 re->win->draw.drew = 0;
1435 eng_window_use(re->win);
1437 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1439 double t0 = get_time();
1443 if (re->info->vsync) eglSwapInterval(re->win->egl_disp, 1);
1444 else eglSwapInterval(re->win->egl_disp, 0);
1447 if (re->info->callback.pre_swap)
1449 re->info->callback.pre_swap(re->info->callback.data, re->evas);
1451 eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]);
1452 if (!safe_native) eglWaitGL();
1453 if (re->info->callback.post_swap)
1455 re->info->callback.post_swap(re->info->callback.data, re->evas);
1458 double t1 = get_time();
1459 printf("%1.5f\n", t1 - t0);
1461 // if (eglGetError() != EGL_SUCCESS)
1463 // printf("Error: eglSwapBuffers() fail.\n");
1466 #ifdef VSYNC_TO_SCREEN
1467 if ((re->info->vsync)/* || (1)*/)
1469 if (glsym_glXSwapIntervalEXT)
1473 if (re->info->vsync) glsym_glXSwapIntervalEXT(re->win->disp, re->win->win, 1);
1474 else glsym_glXSwapIntervalEXT(re->win->disp, re->win->win, 0);
1478 if (glsym_glXSwapIntervalSGI)
1482 if (re->info->vsync) glsym_glXSwapIntervalSGI(1);
1483 else glsym_glXSwapIntervalSGI(0);
1489 if ((glsym_glXGetVideoSync) && (glsym_glXWaitVideoSync))
1493 glsym_glXGetVideoSync(&rc);
1494 glsym_glXWaitVideoSync(1, 0, &rc);
1499 if (re->info->callback.pre_swap)
1501 re->info->callback.pre_swap(re->info->callback.data, re->evas);
1506 if ((re->win->draw.x1 == 0) && (re->win->draw.y1 == 0) && (re->win->draw.x2 == (re->win->w - 1)) && (re->win->draw.y2 == (re->win->h - 1)))
1509 // double t, t2 = 0.0;
1511 glXSwapBuffers(re->win->disp, re->win->win);
1512 // t = get_time() - t;
1513 // if (!safe_native)
1517 // t2 = get_time() - t2;
1519 // printf("swap: %3.5f (%3.5fms), x wait gl: %3.5f (%3.5fms)\n",
1520 // t, t * 1000.0, t2, t2 * 1000.0);
1524 // FIXME: this doesn't work.. why oh why?
1527 sx = re->win->draw.x1;
1528 sy = re->win->draw.y1;
1529 sw = (re->win->draw.x2 - re->win->draw.x1) + 1;
1530 sh = (re->win->draw.y2 - re->win->draw.y1) + 1;
1531 sy = re->win->h - sy - sh;
1533 glBitmap(0, 0, 0, 0, sx, re->win->h - sy, NULL);
1534 glEnable(GL_SCISSOR_TEST);
1535 glScissor(sx, sy, sw, sh);
1536 glDrawBuffer(GL_FRONT);
1537 glCopyPixels(sx, sy, sw, sh, GL_COLOR);
1538 glDrawBuffer(GL_BACK);
1539 glDisable(GL_SCISSOR_TEST);
1540 glBitmap(0, 0, 0, 0, 0, 0, NULL);
1543 if (re->info->callback.post_swap)
1545 re->info->callback.post_swap(re->info->callback.data, re->evas);
1551 eng_output_idle_flush(void *data)
1555 re = (Render_Engine *)data;
1559 eng_output_dump(void *data)
1563 re = (Render_Engine *)data;
1564 evas_common_image_image_all_unload();
1565 evas_common_font_font_all_unload();
1566 evas_gl_common_image_all_unload(re->win->gl_context);
1571 eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h)
1573 // Render_Engine *re;
1575 // re = (Render_Engine *)data;
1576 // re->win->gl_context->dc = context;
1577 evas_common_draw_context_add_cutout(context, x, y, w, h);
1581 eng_context_cutout_clear(void *data __UNUSED__, void *context)
1583 // Render_Engine *re;
1585 // re = (Render_Engine *)data;
1586 // re->win->gl_context->dc = context;
1587 evas_common_draw_context_clear_cutouts(context);
1591 eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h)
1595 re = (Render_Engine *)data;
1596 eng_window_use(re->win);
1597 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
1598 re->win->gl_context->dc = context;
1599 evas_gl_common_rect_draw(re->win->gl_context, x, y, w, h);
1603 eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2)
1607 re = (Render_Engine *)data;
1608 eng_window_use(re->win);
1609 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
1610 re->win->gl_context->dc = context;
1611 evas_gl_common_line_draw(re->win->gl_context, x1, y1, x2, y2);
1615 eng_polygon_point_add(void *data, void *context __UNUSED__, void *polygon, int x, int y)
1619 re = (Render_Engine *)data;
1620 return evas_gl_common_poly_point_add(polygon, x, y);
1624 eng_polygon_points_clear(void *data, void *context __UNUSED__, void *polygon)
1628 re = (Render_Engine *)data;
1629 return evas_gl_common_poly_points_clear(polygon);
1633 eng_polygon_draw(void *data, void *context, void *surface __UNUSED__, void *polygon, int x, int y)
1637 re = (Render_Engine *)data;
1638 eng_window_use(re->win);
1639 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
1640 re->win->gl_context->dc = context;
1641 evas_gl_common_poly_draw(re->win->gl_context, polygon, x, y);
1645 eng_image_alpha_get(void *data __UNUSED__, void *image)
1647 // Render_Engine *re;
1650 // re = (Render_Engine *)data;
1651 if (!image) return 1;
1657 eng_image_colorspace_get(void *data __UNUSED__, void *image)
1659 // Render_Engine *re;
1662 // re = (Render_Engine *)data;
1663 if (!image) return EVAS_COLORSPACE_ARGB8888;
1665 return im->cs.space;
1669 eng_image_mask_create(void *data __UNUSED__, void *image)
1675 if (!im->im->image.data)
1676 evas_cache_image_load_data(&im->im->cache_entry);
1678 im->tex = evas_gl_common_texture_new(im->gc, im->im);
1683 eng_image_alpha_set(void *data, void *image, int has_alpha)
1688 re = (Render_Engine *)data;
1689 if (!image) return NULL;
1691 if (im->alpha == has_alpha) return image;
1692 if (im->native.data)
1694 im->alpha = has_alpha;
1697 eng_window_use(re->win);
1698 if ((im->tex) && (im->tex->pt->dyn.img))
1700 im->alpha = has_alpha;
1701 im->tex->alpha = im->alpha;
1704 /* FIXME: can move to gl_common */
1705 if (im->cs.space != EVAS_COLORSPACE_ARGB8888) return im;
1706 if ((has_alpha) && (im->im->cache_entry.flags.alpha)) return image;
1707 else if ((!has_alpha) && (!im->im->cache_entry.flags.alpha)) return image;
1708 if (im->references > 1)
1710 Evas_GL_Image *im_new;
1712 im_new = evas_gl_common_image_new_from_copied_data
1713 (im->gc, im->im->cache_entry.w, im->im->cache_entry.h,
1715 eng_image_alpha_get(data, image),
1716 eng_image_colorspace_get(data, image));
1717 if (!im_new) return im;
1718 evas_gl_common_image_free(im);
1722 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
1723 return evas_gl_common_image_alpha_set(im, has_alpha ? 1 : 0);
1724 // im->im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
1729 eng_image_border_set(void *data __UNUSED__, void *image, int l __UNUSED__, int r __UNUSED__, int t __UNUSED__, int b __UNUSED__)
1731 // Render_Engine *re;
1733 // re = (Render_Engine *)data;
1738 eng_image_border_get(void *data __UNUSED__, void *image __UNUSED__, int *l __UNUSED__, int *r __UNUSED__, int *t __UNUSED__, int *b __UNUSED__)
1740 // Render_Engine *re;
1742 // re = (Render_Engine *)data;
1746 eng_image_comment_get(void *data __UNUSED__, void *image, char *key __UNUSED__)
1748 // Render_Engine *re;
1751 // re = (Render_Engine *)data;
1752 if (!image) return NULL;
1754 if (!im->im) return NULL;
1755 return im->im->info.comment;
1759 eng_image_format_get(void *data __UNUSED__, void *image)
1761 // Render_Engine *re;
1764 // re = (Render_Engine *)data;
1770 eng_image_colorspace_set(void *data, void *image, int cspace)
1775 re = (Render_Engine *)data;
1778 if (im->native.data) return;
1779 /* FIXME: can move to gl_common */
1780 if (im->cs.space == cspace) return;
1781 eng_window_use(re->win);
1782 evas_cache_image_colorspace(&im->im->cache_entry, cspace);
1785 case EVAS_COLORSPACE_ARGB8888:
1788 if (!im->cs.no_free) free(im->cs.data);
1793 case EVAS_COLORSPACE_YCBCR422P601_PL:
1794 case EVAS_COLORSPACE_YCBCR422P709_PL:
1795 case EVAS_COLORSPACE_YCBCR422601_PL:
1796 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
1797 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
1798 if (im->tex) evas_gl_common_texture_free(im->tex);
1802 if (!im->cs.no_free) free(im->cs.data);
1804 if (im->im->cache_entry.h > 0)
1806 calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
1815 im->cs.space = cspace;
1818 /////////////////////////////////////////////////////////////////////////
1821 typedef struct _Native Native;
1825 Evas_Native_Surface ns;
1829 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1837 // FIXME: this is enabled so updates happen - but its SLOOOOOOOOOOOOOOOW
1838 // (i am sure this is the reason) not to mention seemingly superfluous. but
1839 // i need to enable it for it to work on fglrx at least. havent tried nvidia.
1841 // why is this the case? does anyone know? has anyone tried it on other gfx
1844 //#define GLX_TEX_PIXMAP_RECREATE 1
1847 _native_bind_cb(void *data, void *image)
1849 Evas_GL_Image *im = image;
1850 Native *n = im->native.data;
1852 if (n->ns.type == EVAS_NATIVE_SURFACE_X11)
1854 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1857 if (glsym_glEGLImageTargetTexture2DOES)
1859 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface);
1860 if (eglGetError() != EGL_SUCCESS)
1861 ERR("glEGLImageTargetTexture2DOES() failed.");
1864 ERR("Try glEGLImageTargetTexture2DOES on EGL with no support");
1867 # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
1868 Render_Engine *re = data;
1870 if (glsym_glXBindTexImage)
1872 glsym_glXBindTexImage(re->win->disp, n->glx_pixmap,
1873 GLX_FRONT_LEFT_EXT, NULL);
1874 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1877 ERR("Try glXBindTexImage on GLX with no support");
1881 else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
1883 glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id);
1884 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1891 _native_unbind_cb(void *data, void *image)
1893 Evas_GL_Image *im = image;
1894 Native *n = im->native.data;
1896 if (n->ns.type == EVAS_NATIVE_SURFACE_X11)
1898 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1901 # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
1902 Render_Engine *re = data;
1904 if (glsym_glXReleaseTexImage)
1906 glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
1907 GLX_FRONT_LEFT_EXT);
1908 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1911 ERR("Try glXReleaseTexImage on GLX with no support");
1915 else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
1917 glBindTexture(GL_TEXTURE_2D, 0);
1918 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1925 _native_free_cb(void *data, void *image)
1927 Render_Engine *re = data;
1928 Evas_GL_Image *im = image;
1929 Native *n = im->native.data;
1930 uint32_t pmid, texid;
1932 if (n->ns.type == EVAS_NATIVE_SURFACE_X11)
1935 eina_hash_del(re->win->gl_context->shared->native_pm_hash, &pmid, im);
1936 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
1939 if (glsym_eglDestroyImage)
1941 glsym_eglDestroyImage(re->win->egl_disp,
1943 if (eglGetError() != EGL_SUCCESS)
1944 ERR("eglDestroyImage() failed.");
1947 ERR("Try eglDestroyImage on EGL with no support");
1950 # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
1953 if (im->native.loose)
1955 if (glsym_glXReleaseTexImage)
1957 glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
1958 GLX_FRONT_LEFT_EXT);
1959 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1962 ERR("Try glXReleaseTexImage on GLX with no support");
1964 if (glsym_glXDestroyPixmap)
1966 glsym_glXDestroyPixmap(re->win->disp, n->glx_pixmap);
1967 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1970 ERR("Try glXDestroyPixmap on GLX with no support");
1976 else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
1978 texid = n->ns.data.opengl.texture_id;
1979 eina_hash_del(re->win->gl_context->shared->native_tex_hash, &texid, im);
1981 im->native.data = NULL;
1982 im->native.func.data = NULL;
1983 im->native.func.bind = NULL;
1984 im->native.func.unbind = NULL;
1985 im->native.func.free = NULL;
1990 eng_image_native_set(void *data, void *image, void *native)
1992 Render_Engine *re = (Render_Engine *)data;
1993 Evas_Native_Surface *ns = native;
1994 Evas_GL_Image *im = image, *im2 = NULL;
1998 uint32_t pmid, texid;
1999 unsigned int tex = 0;
2000 unsigned int fbo = 0;
2004 if ((!ns) && (ns->type == EVAS_NATIVE_SURFACE_OPENGL))
2006 im = evas_gl_common_image_new_from_data(re->win->gl_context,
2010 EVAS_COLORSPACE_ARGB8888);
2018 if (ns->type == EVAS_NATIVE_SURFACE_X11)
2020 vis = ns->data.x11.visual;
2021 pm = ns->data.x11.pixmap;
2022 if (im->native.data)
2024 Evas_Native_Surface *ens = im->native.data;
2025 if ((ens->data.x11.visual == vis) &&
2026 (ens->data.x11.pixmap == pm))
2030 else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL)
2032 tex = ns->data.opengl.texture_id;
2033 fbo = ns->data.opengl.framebuffer_id;
2034 if (im->native.data)
2036 Evas_Native_Surface *ens = im->native.data;
2037 if ((ens->data.opengl.texture_id == tex) &&
2038 (ens->data.opengl.framebuffer_id == fbo))
2043 if ((!ns) && (!im->native.data)) return im;
2045 eng_window_use(re->win);
2047 if (im->native.data)
2049 if (im->native.func.free)
2050 im->native.func.free(im->native.func.data, im);
2051 evas_gl_common_image_native_disable(im);
2056 if (ns->type == EVAS_NATIVE_SURFACE_X11)
2059 im2 = eina_hash_find(re->win->gl_context->shared->native_pm_hash, &pmid);
2060 if (im2 == im) return im;
2063 n = im2->native.data;
2066 evas_gl_common_image_ref(im2);
2067 evas_gl_common_image_free(im);
2072 else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL)
2075 im2 = eina_hash_find(re->win->gl_context->shared->native_tex_hash, &texid);
2076 if (im2 == im) return im;
2079 n = im2->native.data;
2082 evas_gl_common_image_ref(im2);
2083 evas_gl_common_image_free(im);
2089 im2 = evas_gl_common_image_new_from_data(re->win->gl_context,
2090 im->w, im->h, NULL, im->alpha,
2091 EVAS_COLORSPACE_ARGB8888);
2092 evas_gl_common_image_free(im);
2094 if (ns->type == EVAS_NATIVE_SURFACE_X11)
2096 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
2099 n = calloc(1, sizeof(Native));
2102 EGLConfig egl_config;
2103 int config_attrs[20];
2104 int num_config, i = 0;
2106 eina_hash_add(re->win->gl_context->shared->native_pm_hash, &pmid, im);
2108 config_attrs[i++] = EGL_RED_SIZE;
2109 config_attrs[i++] = 8;
2110 config_attrs[i++] = EGL_GREEN_SIZE;
2111 config_attrs[i++] = 8;
2112 config_attrs[i++] = EGL_BLUE_SIZE;
2113 config_attrs[i++] = 8;
2114 config_attrs[i++] = EGL_ALPHA_SIZE;
2115 config_attrs[i++] = 8;
2116 config_attrs[i++] = EGL_DEPTH_SIZE;
2117 config_attrs[i++] = 0;
2118 config_attrs[i++] = EGL_STENCIL_SIZE;
2119 config_attrs[i++] = 0;
2120 config_attrs[i++] = EGL_RENDERABLE_TYPE;
2121 config_attrs[i++] = EGL_OPENGL_ES2_BIT;
2122 config_attrs[i++] = EGL_SURFACE_TYPE;
2123 config_attrs[i++] = EGL_PIXMAP_BIT;
2124 config_attrs[i++] = EGL_NONE;
2126 if (!eglChooseConfig(re->win->egl_disp, config_attrs,
2127 &egl_config, 1, &num_config))
2128 ERR("eglChooseConfig() failed for pixmap 0x%x, num_config = %i", (unsigned int)pm, num_config);
2129 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
2132 if (glsym_eglCreateImage)
2133 n->egl_surface = glsym_eglCreateImage(re->win->egl_disp,
2135 EGL_NATIVE_PIXMAP_KHR,
2139 ERR("Try eglCreateImage on EGL with no support");
2140 if (!n->egl_surface)
2141 ERR("eglCreatePixmapSurface() for 0x%x failed", (unsigned int)pm);
2142 im->native.yinvert = 1;
2143 im->native.loose = 0;
2144 im->native.data = n;
2145 im->native.func.data = re;
2146 im->native.func.bind = _native_bind_cb;
2147 im->native.func.unbind = _native_unbind_cb;
2148 im->native.func.free = _native_free_cb;
2149 im->native.target = GL_TEXTURE_2D;
2150 im->native.mipmap = 0;
2151 evas_gl_common_image_native_enable(im);
2155 # ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
2159 unsigned int w, h, depth = 32, border;
2162 // fixme: round trip :(
2163 XGetGeometry(re->win->disp, pm, &wdummy, &dummy, &dummy,
2164 &w, &h, &border, &depth);
2165 n = calloc(1, sizeof(Native));
2169 unsigned int target = 0;
2172 eina_hash_add(re->win->gl_context->shared->native_pm_hash, &pmid, im);
2173 if ((re->win->depth_cfg[depth].tex_target &
2174 GLX_TEXTURE_2D_BIT_EXT)
2175 // && (1) // we assume npo2 for now
2176 // size is pow2 || mnpo2 supported
2178 target = GLX_TEXTURE_2D_EXT;
2179 else if ((re->win->depth_cfg[depth].tex_target &
2180 GLX_TEXTURE_RECTANGLE_BIT_EXT))
2182 ERR("rect!!! (not handled)");
2183 target = GLX_TEXTURE_RECTANGLE_EXT;
2187 ERR("broken text-from-pixmap");
2188 if (!(re->win->depth_cfg[depth].tex_target &
2189 GLX_TEXTURE_2D_BIT_EXT))
2190 target = GLX_TEXTURE_RECTANGLE_EXT;
2191 else if (!(re->win->depth_cfg[depth].tex_target &
2192 GLX_TEXTURE_RECTANGLE_BIT_EXT))
2193 target = GLX_TEXTURE_2D_EXT;
2197 pixmap_att[i++] = GLX_TEXTURE_FORMAT_EXT;
2198 pixmap_att[i++] = re->win->depth_cfg[depth].tex_format;
2199 pixmap_att[i++] = GLX_MIPMAP_TEXTURE_EXT;
2200 pixmap_att[i++] = re->win->depth_cfg[depth].mipmap;
2204 pixmap_att[i++] = GLX_TEXTURE_TARGET_EXT;
2205 pixmap_att[i++] = target;
2208 pixmap_att[i++] = 0;
2210 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
2213 n->fbc = re->win->depth_cfg[depth].fbc;
2214 if (glsym_glXCreatePixmap)
2215 n->glx_pixmap = glsym_glXCreatePixmap(re->win->disp,
2220 ERR("Try glXCreatePixmap on GLX with no support");
2223 // printf("%p: new native texture for %x | %4i x %4i @ %2i = %p\n",
2224 // n, pm, w, h, depth, n->glx_pixmap);
2227 ERR("no target :(");
2228 if (glsym_glXQueryDrawable)
2229 glsym_glXQueryDrawable(re->win->disp,
2231 GLX_TEXTURE_TARGET_EXT,
2234 if (target == GLX_TEXTURE_2D_EXT)
2236 im->native.target = GL_TEXTURE_2D;
2237 im->native.mipmap = re->win->depth_cfg[depth].mipmap;
2239 # ifdef GL_TEXTURE_RECTANGLE_ARB
2240 else if (target == GLX_TEXTURE_RECTANGLE_EXT)
2242 im->native.target = GL_TEXTURE_RECTANGLE_ARB;
2243 im->native.mipmap = 0;
2248 im->native.target = GL_TEXTURE_2D;
2249 im->native.mipmap = 0;
2250 ERR("still unknown target");
2254 ERR("GLX Pixmap create fail");
2255 im->native.yinvert = re->win->depth_cfg[depth].yinvert;
2256 im->native.loose = re->win->detected.loose_binding;
2257 im->native.data = n;
2258 im->native.func.data = re;
2259 im->native.func.bind = _native_bind_cb;
2260 im->native.func.unbind = _native_unbind_cb;
2261 im->native.func.free = _native_free_cb;
2263 evas_gl_common_image_native_enable(im);
2269 else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL)
2273 n = calloc(1, sizeof(Native));
2276 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
2278 eina_hash_add(re->win->gl_context->shared->native_tex_hash, &texid, im);
2282 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
2289 im->native.yinvert = 0;
2290 im->native.loose = 0;
2291 im->native.data = n;
2292 im->native.func.data = re;
2293 im->native.func.bind = _native_bind_cb;
2294 im->native.func.unbind = _native_unbind_cb;
2295 im->native.func.free = _native_free_cb;
2296 im->native.target = GL_TEXTURE_2D;
2297 im->native.mipmap = 0;
2299 // FIXME: need to implement mapping sub texture regions
2300 // x, y, w, h for possible texture atlasing
2302 evas_gl_common_image_native_enable(im);
2311 eng_image_native_get(void *data __UNUSED__, void *image)
2313 Evas_GL_Image *im = image;
2315 if (!im) return NULL;
2316 n = im->native.data;
2317 if (!n) return NULL;
2321 #if 0 // filtering disabled
2323 eng_image_draw_filtered(void *data, void *context, void *surface,
2324 void *image, Evas_Filter_Info *filter)
2326 Render_Engine *re = data;
2329 eng_window_use(re->win);
2330 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
2331 re->win->gl_context->dc = context;
2333 evas_gl_common_filter_draw(re->win->gl_context, image, filter);
2336 static Filtered_Image *
2337 eng_image_filtered_get(void *im, uint8_t *key, size_t keylen)
2339 return evas_gl_common_image_filtered_get(im, key, keylen);
2342 static Filtered_Image *
2343 eng_image_filtered_save(void *im, void *fim, uint8_t *key, size_t keylen)
2345 return evas_gl_common_image_filtered_save(im, fim, key, keylen);
2349 eng_image_filtered_free(void *im, Filtered_Image *fim)
2351 evas_gl_common_image_filtered_free(im, fim);
2358 /////////////////////////////////////////////////////////////////////////
2361 eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
2365 re = (Render_Engine *)data;
2366 *error = EVAS_LOAD_ERROR_NONE;
2367 eng_window_use(re->win);
2368 return evas_gl_common_image_load(re->win->gl_context, file, key, lo, error);
2372 eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
2376 re = (Render_Engine *)data;
2377 eng_window_use(re->win);
2378 return evas_gl_common_image_new_from_data(re->win->gl_context, w, h, image_data, alpha, cspace);
2382 eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
2386 re = (Render_Engine *)data;
2387 eng_window_use(re->win);
2388 return evas_gl_common_image_new_from_copied_data(re->win->gl_context, w, h, image_data, alpha, cspace);
2392 eng_image_free(void *data, void *image)
2396 re = (Render_Engine *)data;
2398 eng_window_use(re->win);
2399 evas_gl_common_image_free(image);
2403 eng_image_size_get(void *data __UNUSED__, void *image, int *w, int *h)
2411 if (w) *w = ((Evas_GL_Image *)image)->w;
2412 if (h) *h = ((Evas_GL_Image *)image)->h;
2416 eng_image_size_set(void *data, void *image, int w, int h)
2419 Evas_GL_Image *im = image;
2420 Evas_GL_Image *im_old;
2422 re = (Render_Engine *)data;
2423 if (!im) return NULL;
2424 if (im->native.data)
2430 eng_window_use(re->win);
2431 if ((im->tex) && (im->tex->pt->dyn.img))
2433 evas_gl_common_texture_free(im->tex);
2437 im->tex = evas_gl_common_texture_dynamic_new(im->gc, im);
2442 switch (eng_image_colorspace_get(data, image))
2444 case EVAS_COLORSPACE_YCBCR422P601_PL:
2445 case EVAS_COLORSPACE_YCBCR422P709_PL:
2446 case EVAS_COLORSPACE_YCBCR422601_PL:
2447 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
2448 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
2454 ((int)im_old->im->cache_entry.w == w) &&
2455 ((int)im_old->im->cache_entry.h == h))
2459 im = evas_gl_common_image_new(re->win->gl_context, w, h,
2460 eng_image_alpha_get(data, image),
2461 eng_image_colorspace_get(data, image));
2463 evas_common_load_image_data_from_file(im_old->im);
2464 if (im_old->im->image->data)
2466 evas_common_blit_rectangle(im_old->im, im->im, 0, 0, w, h, 0, 0);
2467 evas_common_cpu_end_opt();
2470 evas_gl_common_image_free(im_old);
2473 im = evas_gl_common_image_new(re->win->gl_context, w, h, 1, EVAS_COLORSPACE_ARGB8888);
2478 eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
2481 Evas_GL_Image *im = image;
2483 re = (Render_Engine *)data;
2484 if (!image) return NULL;
2485 if (im->native.data) return image;
2486 eng_window_use(re->win);
2487 evas_gl_common_image_dirty(image, x, y, w, h);
2492 eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, int *err)
2498 re = (Render_Engine *)data;
2502 if (err) *err = EVAS_LOAD_ERROR_GENERIC;
2506 if (im->native.data)
2509 if (err) *err = EVAS_LOAD_ERROR_NONE;
2513 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
2514 eng_window_use(re->win);
2516 if ((im->tex) && (im->tex->pt) && (im->tex->pt->dyn.img) && (im->cs.space == EVAS_COLORSPACE_ARGB8888))
2518 if (im->tex->pt->dyn.checked_out > 0)
2520 im->tex->pt->dyn.checked_out++;
2521 *image_data = im->tex->pt->dyn.data;
2522 if (err) *err = EVAS_LOAD_ERROR_NONE;
2525 *image_data = im->tex->pt->dyn.data = glsym_eglMapImageSEC(re->win->egl_disp, im->tex->pt->dyn.img);
2527 if (!im->tex->pt->dyn.data)
2529 if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
2530 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
2533 im->tex->pt->dyn.checked_out++;
2535 if (err) *err = EVAS_LOAD_ERROR_NONE;
2539 if ((im->tex) && (im->tex->pt) && (im->tex->pt->dyn.data))
2541 *image_data = im->tex->pt->dyn.data;
2542 if (err) *err = EVAS_LOAD_ERROR_NONE;
2546 eng_window_use(re->win);
2549 /* Engine can be fail to create texture after cache drop like eng_image_content_hint_set function,
2550 so it is need to add code which check im->im's NULL value*/
2555 if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
2559 error = evas_cache_image_load_data(&im->im->cache_entry);
2560 switch (im->cs.space)
2562 case EVAS_COLORSPACE_ARGB8888:
2565 if (im->references > 1)
2567 Evas_GL_Image *im_new;
2569 im_new = evas_gl_common_image_new_from_copied_data
2570 (im->gc, im->im->cache_entry.w, im->im->cache_entry.h,
2572 eng_image_alpha_get(data, image),
2573 eng_image_colorspace_get(data, image));
2577 if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
2580 evas_gl_common_image_free(im);
2584 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
2586 *image_data = im->im->image.data;
2588 case EVAS_COLORSPACE_YCBCR422P601_PL:
2589 case EVAS_COLORSPACE_YCBCR422P709_PL:
2590 case EVAS_COLORSPACE_YCBCR422601_PL:
2591 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
2592 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
2593 *image_data = im->cs.data;
2599 if (err) *err = error;
2604 eng_image_data_put(void *data, void *image, DATA32 *image_data)
2607 Evas_GL_Image *im, *im2;
2609 re = (Render_Engine *)data;
2610 if (!image) return NULL;
2612 if (im->native.data) return image;
2613 eng_window_use(re->win);
2614 if ((im->tex) && (im->tex->pt)
2615 && (im->tex->pt->dyn.data)
2616 && (im->cs.space == EVAS_COLORSPACE_ARGB8888))
2620 if (im->tex->pt->dyn.data == image_data)
2622 if (im->tex->pt->dyn.checked_out > 0)
2624 im->tex->pt->dyn.checked_out--;
2625 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
2626 if (im->tex->pt->dyn.checked_out == 0)
2627 glsym_eglUnmapImageSEC(re->win->egl_disp, im->tex->pt->dyn.img);
2634 w = im->im->cache_entry.w;
2635 h = im->im->cache_entry.h;
2636 im2 = eng_image_new_from_data(data, w, h, image_data,
2637 eng_image_alpha_get(data, image),
2638 eng_image_colorspace_get(data, image));
2639 if (!im2) return im;
2640 evas_gl_common_image_free(im);
2642 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
2645 switch (im->cs.space)
2647 case EVAS_COLORSPACE_ARGB8888:
2648 if (image_data != im->im->image.data)
2652 w = im->im->cache_entry.w;
2653 h = im->im->cache_entry.h;
2654 im2 = eng_image_new_from_data(data, w, h, image_data,
2655 eng_image_alpha_get(data, image),
2656 eng_image_colorspace_get(data, image));
2657 if (!im2) return im;
2658 evas_gl_common_image_free(im);
2662 case EVAS_COLORSPACE_YCBCR422P601_PL:
2663 case EVAS_COLORSPACE_YCBCR422P709_PL:
2664 case EVAS_COLORSPACE_YCBCR422601_PL:
2665 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
2666 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
2667 if (image_data != im->cs.data)
2671 if (!im->cs.no_free) free(im->cs.data);
2673 im->cs.data = image_data;
2675 evas_gl_common_image_dirty(im, 0, 0, 0, 0);
2685 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
2687 Evas_GL_Image *gim = image;
2691 if (gim->native.data) return;
2692 im = (RGBA_Image *)gim->im;
2694 evas_cache_image_preload_data(&im->cache_entry, target);
2698 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
2700 Evas_GL_Image *gim = image;
2704 if (gim->native.data) return;
2705 im = (RGBA_Image *)gim->im;
2707 evas_cache_image_preload_cancel(&im->cache_entry, target);
2711 eng_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)
2715 re = (Render_Engine *)data;
2718 if ((gl_direct_img_obj) && (gl_direct_enabled))
2720 DBG("Rendering Directly to the window");
2721 evas_object_image_pixels_dirty_set(gl_direct_img_obj, EINA_TRUE);
2725 eng_window_use(re->win);
2726 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
2727 re->win->gl_context->dc = context;
2728 evas_gl_common_image_draw(re->win->gl_context, image,
2729 src_x, src_y, src_w, src_h,
2730 dst_x, dst_y, dst_w, dst_h,
2736 eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
2738 if (image) evas_gl_common_image_scale_hint_set(image, hint);
2742 eng_image_scale_hint_get(void *data __UNUSED__, void *image)
2744 Evas_GL_Image *gim = image;
2745 if (!gim) return EVAS_IMAGE_SCALE_HINT_NONE;
2746 return gim->scale_hint;
2750 eng_image_map_draw(void *data, void *context, void *surface, void *image, int npoints, RGBA_Map_Point *p, int smooth, int level)
2752 Evas_GL_Image *gim = image;
2755 re = (Render_Engine *)data;
2757 eng_window_use(re->win);
2758 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
2759 re->win->gl_context->dc = context;
2762 // FIXME: nash - you didn't fix this
2765 if ((p[0].x == p[3].x) &&
2766 (p[1].x == p[2].x) &&
2767 (p[0].y == p[1].y) &&
2768 (p[3].y == p[2].y) &&
2769 (p[0].x <= p[1].x) &&
2770 (p[0].y <= p[2].y) &&
2773 (p[1].u == (gim->w << FP)) &&
2775 (p[2].u == (gim->w << FP)) &&
2776 (p[2].v == (gim->h << FP)) &&
2778 (p[3].v == (gim->h << FP)) &&
2779 (p[0].col == 0xffffffff) &&
2780 (p[1].col == 0xffffffff) &&
2781 (p[2].col == 0xffffffff) &&
2782 (p[3].col == 0xffffffff))
2788 dw = (p[2].x >> FP) - dx;
2789 dh = (p[2].y >> FP) - dy;
2790 eng_image_draw(data, context, surface, image,
2791 0, 0, gim->w, gim->h, dx, dy, dw, dh, smooth);
2795 evas_gl_common_image_map_draw(re->win->gl_context, image, npoints, p,
2801 eng_image_map_surface_new(void *data, int w, int h, int alpha)
2805 re = (Render_Engine *)data;
2806 return evas_gl_common_image_surface_new(re->win->gl_context, w, h, alpha);
2810 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
2812 evas_gl_common_image_free(surface);
2816 eng_image_content_hint_set(void *data __UNUSED__, void *image, int hint)
2818 if (image) evas_gl_common_image_content_hint_set(image, hint);
2822 eng_image_content_hint_get(void *data __UNUSED__, void *image)
2824 Evas_GL_Image *gim = image;
2825 if (!gim) return EVAS_IMAGE_CONTENT_HINT_NONE;
2826 return gim->content_hint;
2830 eng_image_cache_flush(void *data)
2835 re = (Render_Engine *)data;
2837 tmp_size = evas_common_image_get_cache();
2838 evas_common_image_set_cache(0);
2839 evas_common_rgba_image_scalecache_flush();
2840 evas_gl_common_image_cache_flush(re->win->gl_context);
2841 evas_common_image_set_cache(tmp_size);
2845 eng_image_cache_set(void *data, int bytes)
2849 re = (Render_Engine *)data;
2850 evas_common_image_set_cache(bytes);
2851 evas_common_rgba_image_scalecache_size_set(bytes);
2852 evas_gl_common_image_cache_flush(re->win->gl_context);
2856 eng_image_cache_get(void *data __UNUSED__)
2858 return evas_common_image_get_cache();
2862 eng_image_stride_get(void *data __UNUSED__, void *image, int *stride)
2864 Evas_GL_Image *im = image;
2866 if ((im->tex) && (im->tex->pt->dyn.img))
2867 *stride = im->tex->pt->dyn.stride;
2869 *stride = im->w * 4;
2873 eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font __UNUSED__, int x, int y, int w __UNUSED__, int h __UNUSED__, int ow __UNUSED__, int oh __UNUSED__, Evas_Text_Props *intl_props)
2877 re = (Render_Engine *)data;
2878 eng_window_use(re->win);
2879 evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
2880 re->win->gl_context->dc = context;
2882 // FIXME: put im into context so we can free it
2883 static RGBA_Image *im = NULL;
2886 im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
2887 im->cache_entry.w = re->win->w;
2888 im->cache_entry.h = re->win->h;
2889 evas_common_draw_context_font_ext_set(context,
2890 re->win->gl_context,
2891 evas_gl_font_texture_new,
2892 evas_gl_font_texture_free,
2893 evas_gl_font_texture_draw);
2894 evas_common_font_draw_prepare(intl_props);
2895 evas_common_font_draw(im, context, x, y, intl_props);
2896 evas_common_draw_context_font_ext_set(context,
2905 eng_canvas_alpha_get(void *data, void *info __UNUSED__)
2907 Render_Engine *re = (Render_Engine *)data;
2908 return re->win->alpha;
2912 // Unfortunately, there is no query function to figure out which surface formats work.
2913 // So, this is one way to test for surface config capability.
2915 _check_gl_surface_format(GLint int_fmt, GLenum fmt, GLenum attachment, GLenum attach_fmt, int mult_samples)
2917 GLuint fbo, tex, rb, ds_tex;
2918 int w, h, fb_status;
2920 // Initialize Variables
2921 fbo = tex = rb = ds_tex = 0;
2923 // Width/Heith for test purposes
2927 glGenFramebuffers(1, &fbo);
2928 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
2930 // Render Target Texture
2933 glGenTextures(1, &tex);
2934 glBindTexture(GL_TEXTURE_2D, tex );
2935 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2936 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2937 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2938 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2939 glTexImage2D(GL_TEXTURE_2D, 0, int_fmt, w, h, 0, fmt, GL_UNSIGNED_BYTE, NULL);
2940 glBindTexture(GL_TEXTURE_2D, 0);
2943 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0, mult_samples);
2945 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
2948 // Render Target Attachment (Stencil or Depth)
2951 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
2952 // This is a little hacky but this is how we'll have to do for now.
2953 if (attach_fmt == GL_DEPTH_STENCIL_OES)
2955 glGenTextures(1, &ds_tex);
2956 glBindTexture(GL_TEXTURE_2D, ds_tex);
2957 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2958 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2959 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2960 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2961 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, w, h,
2962 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, NULL);
2965 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
2966 GL_TEXTURE_2D, ds_tex, 0, mult_samples);
2967 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2968 GL_TEXTURE_2D, ds_tex, 0, mult_samples);
2972 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
2973 GL_TEXTURE_2D, ds_tex, 0);
2974 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
2975 GL_TEXTURE_2D, ds_tex, 0);
2977 glBindTexture(GL_TEXTURE_2D, 0);
2982 glGenRenderbuffers(1, &rb);
2983 glBindRenderbuffer(GL_RENDERBUFFER, rb);
2985 glsym_glRenderbufferStorageMultisample(GL_RENDERBUFFER, mult_samples, attach_fmt, w, h);
2987 glRenderbufferStorage(GL_RENDERBUFFER, attach_fmt, w, h);
2988 glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, rb);
2989 glBindRenderbuffer(GL_RENDERBUFFER, 0);
2994 // Check FBO for completeness
2995 fb_status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
2998 // Delete Created Resources
2999 glBindFramebuffer(GL_FRAMEBUFFER, 0);
3000 if (fbo) glDeleteFramebuffers(1, &fbo);
3001 if (tex) glDeleteTextures(1, &tex);
3002 if (ds_tex) glDeleteTextures(1, &ds_tex);
3003 if (rb) glDeleteRenderbuffers(1, &rb);
3005 if (fb_status != GL_FRAMEBUFFER_COMPLETE)
3009 if ((attachment) && (!mult_samples))
3017 _print_gl_surface_info(Render_Engine_GL_Surface *sfc, int error)
3019 #define PRINT_LOG(...) \
3025 PRINT_LOG("----------Surface Info------------");
3026 PRINT_LOG(" [Surface] %x", (unsigned int)sfc);
3027 PRINT_LOG(" Width: %d", sfc->w);
3028 PRINT_LOG(" Height: %d", sfc->h);
3029 PRINT_LOG(" Direct Surface: %x", (unsigned int)sfc->direct_sfc);
3030 PRINT_LOG(" Current Context: %x", (unsigned int)sfc->current_ctx);
3031 PRINT_LOG(" [-------Config-------]");
3032 PRINT_LOG(" Depth Bits : %d", sfc->depth_bits);
3033 PRINT_LOG(" Stencil Bits : %d", sfc->stencil_bits);
3034 PRINT_LOG(" Direct FB Opt : %d", sfc->direct_fb_opt);
3035 PRINT_LOG(" Multisample Bits: %d", sfc->multisample_bits);
3036 PRINT_LOG(" MSAA Samples : %d", sfc->rt_msaa_samples);
3037 PRINT_LOG(" [-------Internal-----]");
3038 PRINT_LOG(" RenderTarget Texture : %d", sfc->rt_tex);
3039 PRINT_LOG(" RenderTarget Internal Format : %x", sfc->rt_internal_fmt);
3040 PRINT_LOG(" RenderTaret Format : %x", sfc->rt_fmt);
3041 PRINT_LOG(" RenderBuffer Depth : %x", sfc->rb_depth);
3042 PRINT_LOG(" RenderBuffer Depth Format : %x", sfc->rb_depth_fmt);
3043 PRINT_LOG(" RenderBuffer Stencil : %d", sfc->rb_stencil);
3044 PRINT_LOG(" RenderBuffer Stencil Format : %x", sfc->rb_stencil_fmt);
3045 PRINT_LOG(" RenderBuffer Depth Stencil : %x", sfc->rb_depth_stencil);
3046 PRINT_LOG(" RenderBuffer Depth Stencil Format: %x", sfc->rb_depth_stencil_fmt);
3047 PRINT_LOG("--------------------------------------");
3053 _print_gl_surface_cap(Render_Engine *re, int error)
3055 #define PRINT_LOG(...) \
3061 PRINT_LOG("----------------------------------------------------");
3062 PRINT_LOG(" EvasGL Supported Surface Format ");
3064 PRINT_LOG(" [Max Renderbuffer Size] : %d", re->gl_cap.max_rb_size);
3065 PRINT_LOG(" [Multisample Support ] : %d", re->gl_cap.msaa_support);
3066 PRINT_LOG(" [Low Samples] : %d", re->gl_cap.msaa_samples[1]);
3067 PRINT_LOG(" [Med Samples] : %d", re->gl_cap.msaa_samples[2]);
3068 PRINT_LOG(" [High Samples] : %d", re->gl_cap.msaa_samples[3]);
3069 PRINT_LOG(" [--Multisamples--] ");
3070 PRINT_LOG(" [Norm] [Low] [Med] [High]");
3071 PRINT_LOG(" [RGB Format] : %4x %d %d %d", re->gl_cap.rgb_888[0], re->gl_cap.rgb_888[1], re->gl_cap.rgb_888[2], re->gl_cap.rgb_888[3]);
3072 PRINT_LOG(" [RGBA Format] : %4x %d %d %d", re->gl_cap.rgba_8888[0], re->gl_cap.rgba_8888[1], re->gl_cap.rgba_8888[2], re->gl_cap.rgba_8888[3]);
3073 PRINT_LOG(" [Depth 8 Bits] : %4x %d %d %d", re->gl_cap.depth_8[0], re->gl_cap.depth_8[1], re->gl_cap.depth_8[2], re->gl_cap.depth_8[3]);
3074 PRINT_LOG(" [Depth 16 Bits] : %4x %d %d %d", re->gl_cap.depth_16[0], re->gl_cap.depth_16[1], re->gl_cap.depth_16[2], re->gl_cap.depth_16[3]);
3075 PRINT_LOG(" [Depth 24 Bits] : %4x %d %d %d", re->gl_cap.depth_24[0], re->gl_cap.depth_24[1], re->gl_cap.depth_24[2], re->gl_cap.depth_24[3]);
3076 PRINT_LOG(" [Depth 32 Bits] : %4x %d %d %d", re->gl_cap.depth_32[0], re->gl_cap.depth_32[1], re->gl_cap.depth_32[2], re->gl_cap.depth_32[3]);
3077 PRINT_LOG(" [Stencil 1 Bits] : %4x %d %d %d", re->gl_cap.stencil_1[0], re->gl_cap.stencil_1[1], re->gl_cap.stencil_1[2], re->gl_cap.stencil_1[3]);
3078 PRINT_LOG(" [Stencil 2 Bits] : %4x %d %d %d", re->gl_cap.stencil_2[0], re->gl_cap.stencil_2[1], re->gl_cap.stencil_2[2], re->gl_cap.stencil_2[3]);
3079 PRINT_LOG(" [Stencil 4 Bits] : %4x %d %d %d", re->gl_cap.stencil_4[0], re->gl_cap.stencil_4[1], re->gl_cap.stencil_4[2], re->gl_cap.stencil_4[3]);
3080 PRINT_LOG(" [Stencil 8 Bits] : %4x %d %d %d", re->gl_cap.stencil_8[0], re->gl_cap.stencil_8[1], re->gl_cap.stencil_8[2], re->gl_cap.stencil_8[3]);
3081 PRINT_LOG(" [Stencil 16 Bits] : %4x %d %d %d", re->gl_cap.stencil_16[0], re->gl_cap.stencil_16[1], re->gl_cap.stencil_16[2], re->gl_cap.stencil_16[3]);
3082 PRINT_LOG(" [Depth 24 Stencil 8 Bits]: %4x %d %d %d", re->gl_cap.depth_24_stencil_8[0], re->gl_cap.depth_24_stencil_8[1], re->gl_cap.depth_24_stencil_8[2], re->gl_cap.depth_24_stencil_8[3]);
3083 PRINT_LOG("----------------------------------------------------");
3088 _set_gl_surface_cap(Render_Engine *re)
3090 GLuint fbo, tex, depth, stencil;
3096 if (re->gl_cap_initted) return;
3098 // Width/Heith for test purposes
3101 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3102 int max_samples = 0;
3104 glGetIntegerv(GL_MAX_SAMPLES_IMG, &max_samples);
3106 // Check if msaa_support is supported
3107 if ((max_samples) &&
3108 (glsym_glFramebufferTexture2DMultisample) &&
3109 (glsym_glRenderbufferStorageMultisample))
3111 re->gl_cap.msaa_support = 1;
3113 re->gl_cap.msaa_samples[3] = max_samples;
3114 re->gl_cap.msaa_samples[2] = max_samples/2;
3115 re->gl_cap.msaa_samples[1] = max_samples/4;
3116 re->gl_cap.msaa_samples[0] = 0;
3118 if (!re->gl_cap.msaa_samples[2]) re->gl_cap.msaa_samples[3];
3119 if (!re->gl_cap.msaa_samples[1]) re->gl_cap.msaa_samples[2];
3123 re->gl_cap.msaa_support = 0;
3128 glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &re->gl_cap.max_rb_size);
3130 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3131 count = (re->gl_cap.msaa_support) ? 4 : 1;
3133 for (i = 0; i < count; i++)
3135 re->gl_cap.rgb_888[i] = _check_gl_surface_format(GL_RGB, GL_RGB, 0, 0, re->gl_cap.msaa_samples[i]);
3136 re->gl_cap.rgba_8888[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, 0, 0, re->gl_cap.msaa_samples[i]);
3138 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]);
3139 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]);
3140 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]);
3141 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]);
3143 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]);
3144 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]);
3145 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]);
3147 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]);
3151 count = (re->gl_cap.msaa_support) ? 4 : 1;
3153 for (i = 0; i < count; i++)
3155 re->gl_cap.rgb_888[i] = _check_gl_surface_format(GL_RGB, GL_RGB, 0, 0, re->gl_cap.msaa_samples[i]);
3156 re->gl_cap.rgba_8888[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, 0, 0, re->gl_cap.msaa_samples[i]);
3158 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]);
3159 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]);
3160 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]);
3161 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]);
3163 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]);
3164 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]);
3165 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]);
3167 re->gl_cap.depth_24_stencil_8[i] = _check_gl_surface_format(GL_RGBA, GL_RGBA, GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH24_STENCIL8, re->gl_cap.msaa_samples[i]);
3171 _print_gl_surface_cap(re, 0);
3173 re->gl_cap_initted = 1;
3177 _set_internal_config(Render_Engine *re, Render_Engine_GL_Surface *sfc, Evas_GL_Config *cfg)
3179 // Check if color formats are supported
3180 switch((int)cfg->color_format)
3182 case EVAS_GL_RGB_888:
3183 if (re->gl_cap.rgb_888[0])
3185 sfc->rt_fmt = GL_RGB;
3186 sfc->rt_internal_fmt = GL_RGB;
3189 case EVAS_GL_RGBA_8888:
3190 if (re->gl_cap.rgba_8888[0])
3192 sfc->rt_fmt = GL_RGBA;
3193 sfc->rt_internal_fmt = GL_RGBA;
3194 cfg->color_format = EVAS_GL_RGBA_8888;
3198 ERR("Color Format Not Supported: %d", cfg->color_format);
3199 _print_gl_surface_cap(re, 1);
3203 switch((int)cfg->depth_bits)
3205 case EVAS_GL_DEPTH_NONE:
3207 case EVAS_GL_DEPTH_BIT_8:
3208 if (re->gl_cap.depth_8[0])
3210 sfc->rb_depth_fmt = re->gl_cap.depth_8[0];
3211 cfg->depth_bits = EVAS_GL_DEPTH_BIT_8;
3214 case EVAS_GL_DEPTH_BIT_16:
3215 if (re->gl_cap.depth_16[0])
3217 sfc->rb_depth_fmt = re->gl_cap.depth_16[0];
3218 cfg->depth_bits = EVAS_GL_DEPTH_BIT_16;
3221 case EVAS_GL_DEPTH_BIT_24:
3222 if (re->gl_cap.depth_24[0])
3224 sfc->rb_depth_fmt = re->gl_cap.depth_24[0];
3225 cfg->depth_bits = EVAS_GL_DEPTH_BIT_24;
3228 else if (re->gl_cap.depth_24_stencil_8[0])
3230 sfc->rb_depth_stencil_fmt = re->gl_cap.depth_24_stencil_8[0];
3231 sfc->rb_depth_fmt = re->gl_cap.depth_24_stencil_8[0];
3232 cfg->depth_bits = EVAS_GL_DEPTH_BIT_24;
3235 case EVAS_GL_DEPTH_BIT_32:
3236 if (re->gl_cap.depth_32[0])
3238 sfc->rb_depth_fmt = re->gl_cap.depth_32[0];
3239 cfg->depth_bits = EVAS_GL_DEPTH_BIT_32;
3243 ERR("Unsupported Depth Bits Format: %d", cfg->depth_bits);
3244 _print_gl_surface_cap(re, 1);
3248 switch((int)cfg->stencil_bits)
3250 case EVAS_GL_STENCIL_NONE:
3252 case EVAS_GL_STENCIL_BIT_1:
3253 if (re->gl_cap.stencil_1[0])
3255 sfc->rb_stencil_fmt = re->gl_cap.stencil_1[0];
3256 cfg->stencil_bits = EVAS_GL_STENCIL_BIT_1;
3259 case EVAS_GL_STENCIL_BIT_2:
3260 if (re->gl_cap.stencil_2[0])
3262 sfc->rb_stencil_fmt = re->gl_cap.stencil_2[0];
3263 cfg->stencil_bits = EVAS_GL_STENCIL_BIT_2;
3266 case EVAS_GL_STENCIL_BIT_4:
3267 if (re->gl_cap.stencil_4[0])
3269 sfc->rb_stencil_fmt = re->gl_cap.stencil_4[0];
3270 cfg->stencil_bits = EVAS_GL_STENCIL_BIT_4;
3273 case EVAS_GL_STENCIL_BIT_8:
3274 if ((sfc->rb_depth_fmt == re->gl_cap.depth_24_stencil_8[0]) ||
3275 (sfc->rb_depth_fmt == re->gl_cap.depth_24[0]) ||
3276 (!(re->gl_cap.stencil_8[0]) && (re->gl_cap.depth_24_stencil_8[0])))
3278 sfc->rb_depth_stencil_fmt = re->gl_cap.depth_24_stencil_8[0];
3279 sfc->rb_stencil_fmt = re->gl_cap.depth_24_stencil_8[0];
3280 cfg->stencil_bits = EVAS_GL_STENCIL_BIT_8;
3283 else if (re->gl_cap.stencil_8[0])
3285 sfc->rb_stencil_fmt = re->gl_cap.stencil_8[0];
3286 cfg->stencil_bits = EVAS_GL_STENCIL_BIT_8;
3289 case EVAS_GL_STENCIL_BIT_16:
3290 if (re->gl_cap.stencil_16[0])
3292 sfc->rb_stencil_fmt = re->gl_cap.stencil_16[0];
3293 cfg->stencil_bits = EVAS_GL_STENCIL_BIT_16;
3297 ERR("Unsupported Stencil Bits Format: %d", cfg->stencil_bits);
3298 _print_gl_surface_cap(re, 1);
3302 if (cfg->options_bits)
3304 if (cfg->options_bits & EVAS_GL_OPTIONS_DIRECT)
3306 sfc->direct_fb_opt = 1;
3307 DBG("########################################################");
3308 DBG("######### [Evas] Direct option bit is enabled ##########");
3309 DBG("########################################################");
3311 // Add other options here...
3315 if (re->gl_cap.msaa_support)
3317 if ( ((int)(cfg->multisample_bits) > (int)EVAS_GL_MULTISAMPLE_HIGH) ||
3318 ((int)(cfg->multisample_bits) < 0) )
3320 ERR("Unsupported Multisample Bits Format!");
3321 _print_gl_surface_cap(re, 1);
3326 sfc->rt_msaa_samples = re->gl_cap.msaa_samples[(int)cfg->multisample_bits];
3334 _attach_fbo_surface(Render_Engine *data __UNUSED__,
3335 Render_Engine_GL_Surface *sfc,
3338 int fb_status, curr_tex, curr_rb;
3340 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
3342 // Detach any previously attached buffers
3343 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
3344 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
3345 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
3346 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3347 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
3348 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
3350 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
3354 // Render Target Texture
3358 glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_tex);
3359 glBindTexture(GL_TEXTURE_2D, sfc->rt_tex );
3360 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
3361 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
3362 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3363 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3364 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sfc->w, sfc->h, 0,
3365 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
3366 glBindTexture(GL_TEXTURE_2D, curr_tex);
3368 // Attach texture to FBO
3369 if (sfc->rt_msaa_samples)
3370 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sfc->rt_tex, 0, sfc->rt_msaa_samples);
3372 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
3373 GL_TEXTURE_2D, sfc->rt_tex, 0);
3377 // Depth Stencil RenderBuffer - Attach it to FBO
3378 if (sfc->rb_depth_stencil)
3380 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3382 glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_tex);
3383 glBindTexture(GL_TEXTURE_2D, sfc->rb_depth_stencil);
3384 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
3385 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
3386 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
3387 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3388 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, sfc->w, sfc->h,
3389 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, NULL);
3390 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
3391 GL_TEXTURE_2D, sfc->rb_depth_stencil, 0);
3392 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
3393 GL_TEXTURE_2D, sfc->rb_depth_stencil, 0);
3394 glBindTexture(GL_TEXTURE_2D, curr_tex);
3398 glGetIntegerv(GL_RENDERBUFFER_BINDING, &curr_rb);
3399 glBindRenderbuffer(GL_RENDERBUFFER, sfc->rb_depth_stencil);
3400 glRenderbufferStorage(GL_RENDERBUFFER, sfc->rb_depth_stencil_fmt,
3402 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
3403 GL_RENDERBUFFER, sfc->rb_depth_stencil);
3404 glBindRenderbuffer(GL_RENDERBUFFER, curr_rb);
3408 // Depth RenderBuffer - Attach it to FBO
3412 glGetIntegerv(GL_RENDERBUFFER_BINDING, &curr_rb);
3414 glBindRenderbuffer(GL_RENDERBUFFER, sfc->rb_depth);
3416 if (sfc->rt_msaa_samples)
3417 glsym_glRenderbufferStorageMultisample(GL_RENDERBUFFER,
3418 sfc->rt_msaa_samples,
3422 glRenderbufferStorage(GL_RENDERBUFFER, sfc->rb_depth_fmt,
3424 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
3425 GL_RENDERBUFFER, sfc->rb_depth);
3426 glBindRenderbuffer(GL_RENDERBUFFER, curr_rb);
3429 // Stencil RenderBuffer - Attach it to FBO
3430 if (sfc->rb_stencil)
3433 glGetIntegerv(GL_RENDERBUFFER_BINDING, &curr_rb);
3435 glBindRenderbuffer(GL_RENDERBUFFER, sfc->rb_stencil);
3437 if (sfc->rt_msaa_samples)
3438 glsym_glRenderbufferStorageMultisample(GL_RENDERBUFFER,
3439 sfc->rt_msaa_samples,
3440 sfc->rb_stencil_fmt,
3443 glRenderbufferStorage(GL_RENDERBUFFER, sfc->rb_stencil_fmt,
3445 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
3446 GL_RENDERBUFFER, sfc->rb_stencil);
3447 glBindRenderbuffer(GL_RENDERBUFFER, curr_rb);
3450 // Check FBO for completeness
3451 fb_status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
3452 if (fb_status != GL_FRAMEBUFFER_COMPLETE)
3454 ERR("FBO not complete. Error Code: %x!", fb_status);
3455 _print_gl_surface_info(sfc, 1);
3463 _create_rt_buffers(Render_Engine *data __UNUSED__,
3464 Render_Engine_GL_Surface *sfc)
3467 GLuint fbo = 0, curr_fbo = 0;
3469 //------------------------------------//
3470 // Render Target texture
3473 glGenTextures(1, &sfc->rt_tex);
3476 // First check if packed buffer is to be used.
3477 if (sfc->rb_depth_stencil_fmt)
3479 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3480 glGenTextures(1, &sfc->rb_depth_stencil);
3482 glGenRenderbuffers(1, &sfc->rb_depth_stencil);
3487 // Depth RenderBuffer - Create storage here...
3488 if (sfc->rb_depth_fmt)
3489 glGenRenderbuffers(1, &sfc->rb_depth);
3491 // Stencil RenderBuffer - Create Storage here...
3492 if (sfc->rb_stencil_fmt)
3493 glGenRenderbuffers(1, &sfc->rb_stencil);
3495 //------------------------------------//
3496 // Try attaching the given configuration
3497 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &curr_fbo);
3498 glGenFramebuffers(1 ,&fbo);
3500 ret = _attach_fbo_surface(NULL, sfc, fbo);
3502 if (fbo) glDeleteFramebuffers(1, &fbo);
3503 glBindFramebuffer(GL_FRAMEBUFFER, curr_fbo);
3507 if (sfc->rt_tex) glDeleteTextures(1, &sfc->rt_tex);
3508 if (sfc->rb_depth) glDeleteRenderbuffers(1, &sfc->rb_depth);
3509 if (sfc->rb_stencil) glDeleteRenderbuffers(1, &sfc->rb_stencil);
3510 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3511 if (sfc->rb_depth_stencil) glDeleteTextures(1, &sfc->rb_depth_stencil);
3513 if (sfc->rb_depth_stencil) glDeleteRenderbuffers(1, &sfc->rb_depth_stencil);
3515 ERR("_attach_fbo_surface() failed.");
3524 eng_gl_surface_create(void *data, void *config, int w, int h)
3527 Render_Engine_GL_Surface *sfc;
3528 Render_Engine_GL_Resource *rsc;
3529 Evas_GL_Config *cfg;
3533 re = (Render_Engine *)data;
3534 cfg = (Evas_GL_Config *)config;
3536 // Allocate surface and fill in values
3537 sfc = calloc(1, sizeof(Render_Engine_GL_Surface));
3540 ERR("Surface allocation failed.");
3546 sfc->depth_bits = cfg->depth_bits;
3547 sfc->stencil_bits = cfg->stencil_bits;
3549 // Allow alpha for evas gl direct rendering override
3550 // FIXME!!!: A little out of place but for now...
3551 if (!gl_direct_override)
3552 if (getenv("EVAS_GL_DIRECT_OVERRIDE")) gl_direct_override = 1;
3554 // Set the internal format based on the config
3555 if (cfg->options_bits & EVAS_GL_OPTIONS_DIRECT)
3557 DBG("Enabling Direct rendering to the Evas' window.");
3558 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3559 sfc->direct_sfc = re->win->egl_surface[0];
3561 sfc->direct_sfc = re->win->win;
3565 // Create internal resource context if it hasn't been created already
3566 if ((rsc = eina_tls_get(resource_key)) == NULL)
3568 if ((rsc = _create_internal_glue_resources(re)) == NULL)
3570 ERR("Error creating internal resources.");
3575 // Use resource surface/context to create surface resrouces
3576 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3577 res = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
3579 res = glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
3583 ERR("xxxMakeCurrent() finish!");
3587 // Set the engine surface capability first if it hasn't been set
3588 if (!re->gl_cap_initted) _set_gl_surface_cap(re);
3590 // Check the size of the surface
3591 if ( (w > re->gl_cap.max_rb_size) || (h > re->gl_cap.max_rb_size) )
3593 ERR("Surface size greater than the supported size. Max Surface Size: %d", re->gl_cap.max_rb_size);
3597 // Set the internal config value
3598 if (!_set_internal_config(re, sfc, cfg))
3600 ERR("Unsupported Format!");
3604 // Create Render texture
3605 if (!_create_rt_buffers(re, sfc))
3607 ERR("Unable Create Specificed Surfaces. Unsupported format!");
3615 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3616 res = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
3618 res = glXMakeCurrent(re->info->info.display, None, NULL);
3622 ERR("xxxMakeCurrent() (NULL, NULL) Error!");
3633 eng_gl_surface_destroy(void *data, void *surface)
3636 Render_Engine_GL_Surface *sfc;
3637 Render_Engine_GL_Resource *rsc;
3640 re = (Render_Engine *)data;
3641 sfc = (Render_Engine_GL_Surface*)surface;
3645 if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
3647 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3648 ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
3650 ret = glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
3654 ERR("xxxMakeCurrent() failed!");
3658 // Reset the Framebuffer binding point
3659 if ((current_evgl_ctx) && (current_evgl_ctx->current_fbo == current_evgl_ctx->context_fbo))
3661 //glBindFramebuffer(GL_FRAMEBUFFER, 0);
3662 current_evgl_ctx->current_fbo = 0;
3663 current_evgl_ctx->current_sfc = NULL;
3666 // Clear direct rendering flag
3667 gl_direct_enabled = 0;
3669 // Delete FBO/RBO and Texture here
3671 glDeleteTextures(1, &sfc->rt_tex);
3674 glDeleteRenderbuffers(1, &sfc->rb_depth);
3676 if (sfc->rb_stencil)
3677 glDeleteRenderbuffers(1, &sfc->rb_stencil);
3679 if (sfc->rb_depth_stencil)
3681 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3682 glDeleteTextures(1, &sfc->rb_depth_stencil);
3684 glDeleteRenderbuffers(1, &sfc->rb_depth_stencil);
3689 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3690 ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
3692 ret = glXMakeCurrent(re->info->info.display, None, NULL);
3696 ERR("xxxMakeCurrent() failed!");
3708 eng_gl_context_create(void *data, void *share_context)
3711 Render_Engine_GL_Context *ctx;
3712 Render_Engine_GL_Context *share_ctx;
3713 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3714 int context_attrs[3];
3717 ctx = calloc(1, sizeof(Render_Engine_GL_Context));
3719 if (!ctx) return NULL;
3721 re = (Render_Engine *)data;
3722 share_ctx = (Render_Engine_GL_Context *)share_context;
3724 // Set the share context to Evas' GL context if share_context is NULL.
3725 // Otherwise set it to the given share_context.
3726 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3728 context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
3729 context_attrs[1] = 2;
3730 context_attrs[2] = EGL_NONE;
3734 ctx->context = eglCreateContext(re->win->egl_disp,
3735 re->win->egl_config,
3736 share_ctx->context, // Share Context
3741 ctx->context = eglCreateContext(re->win->egl_disp,
3742 re->win->egl_config,
3743 re->win->egl_context[0], // Evas' GL Context
3749 ERR("eglCreateContext() fail. code=%#x", eglGetError());
3756 ctx->context = glXCreateContext(re->info->info.display,
3757 re->win->visualinfo,
3758 share_ctx->context, // Share Context
3763 ctx->context = glXCreateContext(re->info->info.display,
3764 re->win->visualinfo,
3765 re->win->context, // Evas' GL Context
3771 ERR("glXCreateContext() fail.");
3776 ctx->initialized = 0;
3777 ctx->context_fbo = 0;
3778 ctx->current_sfc = NULL;
3784 eng_gl_context_destroy(void *data, void *context)
3787 Render_Engine_GL_Context *ctx;
3788 Render_Engine_GL_Resource *rsc;
3791 re = (Render_Engine *)data;
3792 ctx = (Render_Engine_GL_Context*)context;
3796 if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
3798 // Do a make current with the given context
3799 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3800 ret = eglMakeCurrent(re->win->egl_disp, rsc->surface,
3801 rsc->surface, ctx->context);
3803 ret = glXMakeCurrent(re->info->info.display, re->win->win,
3808 ERR("xxxMakeCurrent() failed!");
3813 if (ctx->context_fbo)
3814 glDeleteFramebuffers(1, &ctx->context_fbo);
3816 // Destroy the Context
3817 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3818 eglDestroyContext(re->win->egl_disp, ctx->context);
3820 ctx->context = EGL_NO_CONTEXT;
3822 ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
3823 EGL_NO_SURFACE, EGL_NO_CONTEXT);
3825 glXDestroyContext(re->info->info.display, ctx->context);
3829 ret = glXMakeCurrent(re->info->info.display, None, NULL);
3833 ERR("xxxMakeCurrent() failed!");
3844 eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
3847 Render_Engine_GL_Surface *sfc;
3848 Render_Engine_GL_Context *ctx;
3850 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3851 Render_Engine_GL_Resource *rsc;
3854 re = (Render_Engine *)data;
3855 sfc = (Render_Engine_GL_Surface*)surface;
3856 ctx = (Render_Engine_GL_Context*)context;
3858 current_engine = re;
3860 // Unset surface/context
3861 if ((!sfc) || (!ctx))
3863 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3864 ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
3865 EGL_NO_SURFACE, EGL_NO_CONTEXT);
3867 ret = glXMakeCurrent(re->info->info.display, None, NULL);
3871 ERR("xxxMakeCurrent() failed!");
3875 if (ctx) ctx->current_sfc = NULL;
3876 if (sfc) sfc->current_ctx = NULL;
3877 current_evgl_ctx = NULL;
3881 // Check if direct rendering is possible:
3882 // It's possible when direct_fb_opt is on and either current image
3883 // object is valid or gl_direct_override is on. Override allows
3884 // rendering outside of pixel getter but it doesn't guarantee
3885 // correct rendering.
3886 if ((sfc->direct_fb_opt) && (gl_direct_img_obj || gl_direct_override))
3887 gl_direct_enabled = 1;
3889 gl_direct_enabled = 0;
3891 if (gl_direct_enabled)
3895 // Do a make current only if it's not already current
3896 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3897 if ((eglGetCurrentContext() != ctx->context) ||
3898 (eglGetCurrentSurface(EGL_READ) != sfc->direct_sfc) ||
3899 (eglGetCurrentSurface(EGL_DRAW) != sfc->direct_sfc) )
3901 DBG("Rendering Directly to the window\n");
3903 // Flush remainder of what's in Evas' pipeline
3904 eng_window_use(NULL);
3906 // Do a make current
3907 ret = eglMakeCurrent(re->win->egl_disp, sfc->direct_sfc,
3908 sfc->direct_sfc, ctx->context);
3911 ERR("xxxMakeCurrent() failed! code=%#x", eglGetError());
3912 //ERR("xxxMakeCurrent() failed!");
3917 if ((glXGetCurrentContext() != ctx->context))
3919 // Flush remainder of what's in Evas' pipeline
3920 eng_window_use(NULL);
3922 // Do a make current
3923 ret = glXMakeCurrent(re->info->info.display, sfc->direct_sfc, ctx->context);
3926 ERR("xxxMakeCurrent() failed!");
3931 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &curr_fbo);
3932 if (ctx->context_fbo == curr_fbo)
3934 ctx->current_fbo = 0;
3935 glBindFramebuffer(GL_FRAMEBUFFER, 0);
3941 // Do a make current only if it's not already current
3942 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3943 if (eina_main_loop_is())
3945 if ((eglGetCurrentContext() != ctx->context) ||
3946 (eglGetCurrentSurface(EGL_READ) != re->win->egl_surface[0]) ||
3947 (eglGetCurrentSurface(EGL_DRAW) != re->win->egl_surface[0]) )
3950 // Flush remainder of what's in Evas' pipeline
3951 eng_window_use(NULL);
3953 // Do a make current
3954 ret = eglMakeCurrent(re->win->egl_disp, re->win->egl_surface[0],
3955 re->win->egl_surface[0], ctx->context);
3958 ERR("xxxMakeCurrent() failed! code=%#x", eglGetError());
3965 if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
3967 if ((eglGetCurrentContext() != ctx->context) ||
3968 (eglGetCurrentSurface(EGL_READ) != rsc->surface) ||
3969 (eglGetCurrentSurface(EGL_DRAW) != rsc->surface) )
3971 // Flush remainder of what's in Evas' pipeline
3972 eng_window_use(NULL);
3974 // Do a make current
3975 ret = eglMakeCurrent(re->win->egl_disp, rsc->surface,
3976 rsc->surface, ctx->context);
3979 ERR("xxxMakeCurrent() failed!");
3985 if ((glXGetCurrentContext() != ctx->context) ||
3986 (glXGetCurrentDrawable() != re->win->win) )
3988 // Flush remainder of what's in Evas' pipeline
3989 eng_window_use(NULL);
3991 // Do a make current
3992 ret = glXMakeCurrent(re->info->info.display, re->win->win, ctx->context);
3995 ERR("xxxMakeCurrent() failed!");
4001 // Create FBO if not already created
4002 if (!ctx->initialized)
4004 glGenFramebuffers(1, &ctx->context_fbo);
4005 ctx->initialized = 1;
4008 // Attach FBO if it hasn't been attached or if surface changed
4009 if ((!sfc->fbo_attached) || (ctx->current_sfc != sfc))
4011 if (!_attach_fbo_surface(re, sfc, ctx->context_fbo))
4013 ERR("_attach_fbo_surface() failed.");
4014 _print_gl_surface_info(sfc, 1);
4018 if (ctx->current_fbo)
4019 // Bind to the previously bound buffer
4020 glBindFramebuffer(GL_FRAMEBUFFER, ctx->current_fbo);
4023 glBindFramebuffer(GL_FRAMEBUFFER, ctx->context_fbo);
4025 sfc->fbo_attached = 1;
4029 // Set the current surface/context
4030 ctx->current_sfc = sfc;
4031 sfc->current_ctx = ctx;
4032 current_evgl_ctx = ctx;
4033 current_engine = re;
4039 eng_gl_string_query(void *data __UNUSED__, int name)
4043 case EVAS_GL_EXTENSIONS:
4044 return (void*)_evasgl_ext_string;
4051 eng_gl_proc_address_get(void *data __UNUSED__, const char *name)
4053 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
4054 if (glsym_eglGetProcAddress) return glsym_eglGetProcAddress(name);
4055 return dlsym(RTLD_DEFAULT, name);
4057 if (glsym_glXGetProcAddress) return glsym_glXGetProcAddress(name);
4058 return dlsym(RTLD_DEFAULT, name);
4063 eng_gl_native_surface_get(void *data __UNUSED__, void *surface, void *native_surface)
4065 Render_Engine_GL_Surface *sfc;
4066 Evas_Native_Surface *ns;
4068 sfc = (Render_Engine_GL_Surface*)surface;
4069 ns = (Evas_Native_Surface*)native_surface;
4071 if (sfc->direct_fb_opt)
4073 ns->type = EVAS_NATIVE_SURFACE_OPENGL;
4074 ns->version = EVAS_NATIVE_SURFACE_VERSION;
4075 ns->data.opengl.texture_id = sfc->rt_tex;
4076 ns->data.opengl.framebuffer_id = 0;
4077 ns->data.opengl.x = 0;
4078 ns->data.opengl.y = 0;
4079 ns->data.opengl.w = sfc->w;
4080 ns->data.opengl.h = sfc->h;
4084 ns->type = EVAS_NATIVE_SURFACE_OPENGL;
4085 ns->version = EVAS_NATIVE_SURFACE_VERSION;
4086 ns->data.opengl.texture_id = sfc->rt_tex;
4087 ns->data.opengl.framebuffer_id = sfc->rt_tex;
4088 ns->data.opengl.x = 0;
4089 ns->data.opengl.y = 0;
4090 ns->data.opengl.w = sfc->w;
4091 ns->data.opengl.h = sfc->h;
4098 static const GLubyte *
4099 evgl_glGetString(GLenum name)
4101 if (name == GL_EXTENSIONS)
4102 return (GLubyte *)_gl_ext_string; //glGetString(GL_EXTENSIONS);
4104 return glGetString(name);
4108 evgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
4110 Render_Engine_GL_Context *ctx = current_evgl_ctx;
4114 ERR("No current context set.");
4118 // Take care of BindFramebuffer 0 issue
4121 if (gl_direct_enabled)
4122 glBindFramebuffer(target, 0);
4124 glBindFramebuffer(target, ctx->context_fbo);
4125 ctx->current_fbo = 0;
4129 glBindFramebuffer(target, framebuffer);
4131 // Save this for restore when doing make current
4132 ctx->current_fbo = framebuffer;
4137 evgl_glBindRenderbuffer(GLenum target, GLuint renderbuffer)
4139 // Add logic to take care when renderbuffer=0
4140 // On a second thought we don't need this
4141 glBindRenderbuffer(target, renderbuffer);
4144 // Transform from Evas Coordinat to GL Coordinate
4145 // returns: oc[4] original image object dimension in gl coord
4146 // returns: nc[4] tranformed (x, y, width, heigth) in gl coord
4148 compute_gl_coordinates(Evas_Object *obj, int rot, int clip,
4149 int x, int y, int width, int height,
4150 int imgc[4], int objc[4])
4154 // oringinal image object coordinate in gl coordinate
4155 imgc[0] = obj->cur.geometry.x;
4156 imgc[1] = obj->layer->evas->output.h - obj->cur.geometry.y - obj->cur.geometry.h;
4157 imgc[2] = imgc[0] + obj->cur.geometry.w;
4158 imgc[3] = imgc[1] + obj->cur.geometry.h;
4160 // transformed (x,y,width,height) in gl coordinate
4161 objc[0] = imgc[0] + x;
4162 objc[1] = imgc[1] + y;
4163 objc[2] = objc[0] + width;
4164 objc[3] = objc[1] + height;
4166 else if (rot == 180)
4168 // oringinal image object coordinate in gl coordinate
4169 imgc[0] = obj->layer->evas->output.w - obj->cur.geometry.x - obj->cur.geometry.w;
4170 imgc[1] = obj->cur.geometry.y;
4171 imgc[2] = imgc[0] + obj->cur.geometry.w;
4172 imgc[3] = imgc[1] + obj->cur.geometry.h;
4174 // transformed (x,y,width,height) in gl coordinate
4175 objc[0] = imgc[0] + obj->cur.geometry.w - x - width;
4176 objc[1] = imgc[1] + obj->cur.geometry.h - y - height;
4177 objc[2] = objc[0] + width;
4178 objc[3] = objc[1] + height;
4183 // oringinal image object coordinate in gl coordinate
4184 imgc[0] = obj->cur.geometry.y;
4185 imgc[1] = obj->cur.geometry.x;
4186 imgc[2] = imgc[0] + obj->cur.geometry.h;
4187 imgc[3] = imgc[1] + obj->cur.geometry.w;
4189 // transformed (x,y,width,height) in gl coordinate
4190 objc[0] = imgc[0] + obj->cur.geometry.h - y - height;
4191 objc[1] = imgc[1] + x;
4192 objc[2] = objc[0] + height;
4193 objc[3] = objc[1] + width;
4195 else if (rot == 270)
4197 // oringinal image object coordinate in gl coordinate
4198 imgc[0] = obj->layer->evas->output.h - obj->cur.geometry.y - obj->cur.geometry.h;
4199 imgc[1] = obj->layer->evas->output.w - obj->cur.geometry.x - obj->cur.geometry.w;
4200 imgc[2] = imgc[0] + obj->cur.geometry.h;
4201 imgc[3] = imgc[1] + obj->cur.geometry.w;
4203 // transformed (x,y,width,height) in gl coordinate
4204 objc[0] = imgc[0] + y;
4205 objc[1] = imgc[1] + obj->cur.geometry.w - x - width;
4206 objc[2] = objc[0] + height;
4207 objc[3] = objc[1] + width;
4211 ERR("Invalid rotation angle %d.", rot);
4217 // Clip against original image object
4218 if (objc[0] < imgc[0]) objc[0] = imgc[0];
4219 if (objc[0] > imgc[2]) objc[0] = 0;
4221 if (objc[1] < imgc[1]) objc[1] = imgc[1];
4222 if (objc[1] > imgc[3]) objc[1] = 0;
4224 if (objc[2] < imgc[0]) objc[0] = 0;
4225 if (objc[2] > imgc[2]) objc[2] = imgc[2];
4227 if (objc[3] < imgc[1]) objc[1] = 0;
4228 if (objc[3] > imgc[3]) objc[3] = imgc[3];
4231 imgc[2] = imgc[2]-imgc[0]; // width
4232 imgc[3] = imgc[3]-imgc[1]; // height
4234 objc[2] = objc[2]-objc[0]; // width
4235 objc[3] = objc[3]-objc[1]; // height
4239 evgl_glClear(GLbitfield mask)
4241 Render_Engine_GL_Context *ctx = current_evgl_ctx;
4245 if ((gl_direct_img_obj) && (gl_direct_enabled) && (ctx) && (!ctx->current_fbo))
4247 if ((current_engine) && (current_engine->win) && (current_engine->win->gl_context))
4248 rot = current_engine->win->gl_context->rot;
4250 ERR("Unable to retrieve rotation angle: %d", rot);
4252 compute_gl_coordinates(gl_direct_img_obj, rot, 0, 0, 0, 0, 0, oc, nc);
4253 glScissor(oc[0], oc[1], oc[2], oc[3]);
4261 evgl_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
4263 glClearColor(red, green, blue, alpha);
4267 evgl_glEnable(GLenum cap)
4269 Render_Engine_GL_Context *ctx = current_evgl_ctx;
4271 if (cap == GL_SCISSOR_TEST)
4272 if (ctx) ctx->scissor_enabled = 1;
4277 evgl_glDisable(GLenum cap)
4279 Render_Engine_GL_Context *ctx = current_evgl_ctx;
4281 if (cap == GL_SCISSOR_TEST)
4282 if (ctx) ctx->scissor_enabled = 0;
4288 evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
4290 Render_Engine_GL_Context *ctx = current_evgl_ctx;
4294 if ((gl_direct_img_obj) && (gl_direct_enabled) && (ctx) && (!ctx->current_fbo))
4296 if ((current_engine) && (current_engine->win) && (current_engine->win->gl_context))
4297 rot = current_engine->win->gl_context->rot;
4299 ERR("Unable to retrieve rotation angle: %d", rot);
4301 compute_gl_coordinates(gl_direct_img_obj, rot, 1, x, y, width, height, oc, nc);
4302 glReadPixels(nc[0], nc[1], nc[2], nc[3], format, type, pixels);
4305 glReadPixels(x, y, width, height, format, type, pixels);
4309 evgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
4311 Render_Engine_GL_Context *ctx = current_evgl_ctx;
4315 if ((gl_direct_img_obj) && (gl_direct_enabled) && (ctx) && (!ctx->current_fbo))
4317 if ((current_engine) && (current_engine->win) && (current_engine->win->gl_context))
4318 rot = current_engine->win->gl_context->rot;
4320 ERR("Unable to retrieve rotation angle: %d", rot);
4322 compute_gl_coordinates(gl_direct_img_obj, rot, 1, x, y, width, height, oc, nc);
4323 glScissor(nc[0], nc[1], nc[2], nc[3]);
4324 ctx->scissor_upated = 1;
4327 glScissor(x, y, width, height);
4331 evgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
4333 Render_Engine_GL_Context *ctx = current_evgl_ctx;
4337 if ((gl_direct_img_obj) && (gl_direct_enabled) && (ctx) && (!ctx->current_fbo))
4339 if ((current_engine) && (current_engine->win) && (current_engine->win->gl_context))
4340 rot = current_engine->win->gl_context->rot;
4342 ERR("Unable to retrieve rotation angle: %d", rot);
4344 compute_gl_coordinates(gl_direct_img_obj, rot, 0, x, y, width, height, oc, nc);
4345 glEnable(GL_SCISSOR_TEST);
4346 glScissor(oc[0], oc[1], oc[2], oc[3]);
4347 glViewport(nc[0], nc[1], nc[2], nc[3]);
4350 glViewport(x, y, width, height);
4355 //----------------------------------------------//
4358 evgl_glClearDepthf(GLclampf depth)
4360 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
4361 glClearDepthf(depth);
4363 glClearDepth(depth);
4368 evgl_glDepthRangef(GLclampf zNear, GLclampf zFar)
4370 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
4371 glDepthRangef(zNear, zFar);
4373 glDepthRange(zNear, zFar);
4378 evgl_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
4380 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
4381 glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
4385 range[0] = -126; // floor(log2(FLT_MIN))
4386 range[1] = 127; // floor(log2(FLT_MAX))
4390 precision[0] = 24; // floor(-log2((1.0/16777218.0)));
4397 evgl_glReleaseShaderCompiler(void)
4399 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
4400 glReleaseShaderCompiler();
4406 evgl_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
4408 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
4409 glShaderBinary(n, shaders, binaryformat, binary, length);
4411 // FIXME: need to dlsym/getprocaddress for this
4413 n = binaryformat = length = 0;
4414 shaders = binary = 0;
4418 //--------------------------------//
4419 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
4422 evgl_evasglCreateImage(int target, void* buffer, int *attrib_list)
4426 return glsym_eglCreateImage(current_engine->win->egl_disp,
4434 ERR("Invalid Engine... (Can't acccess EGL Display)\n");
4440 evgl_evasglDestroyImage(EvasGLImage image)
4443 glsym_eglDestroyImage(current_engine->win->egl_disp, image);
4445 ERR("Invalid Engine... (Can't acccess EGL Display)\n");
4449 evgl_glEvasGLImageTargetTexture2DOES(GLenum target, EvasGLImage image)
4451 glsym_glEGLImageTargetTexture2DOES(target, image);
4455 evgl_glEvasGLImageTargetRenderbufferStorageOES(GLenum target, EvasGLImage image)
4457 glsym_glEGLImageTargetTexture2DOES(target, image);
4462 //--------------------------------//
4466 eng_gl_api_get(void *data)
4470 re = (Render_Engine *)data;
4472 gl_funcs.version = EVAS_GL_API_VERSION;
4474 #define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, )
4476 ORD(glActiveTexture);
4477 ORD(glAttachShader);
4478 ORD(glBindAttribLocation);
4482 ORD(glBlendEquation);
4483 ORD(glBlendEquationSeparate);
4485 ORD(glBlendFuncSeparate);
4487 ORD(glBufferSubData);
4488 ORD(glCheckFramebufferStatus);
4490 // ORD(glClearColor);
4491 // ORD(glClearDepthf);
4492 ORD(glClearStencil);
4494 ORD(glCompileShader);
4495 ORD(glCompressedTexImage2D);
4496 ORD(glCompressedTexSubImage2D);
4497 ORD(glCopyTexImage2D);
4498 ORD(glCopyTexSubImage2D);
4499 ORD(glCreateProgram);
4500 ORD(glCreateShader);
4502 ORD(glDeleteBuffers);
4503 ORD(glDeleteFramebuffers);
4504 ORD(glDeleteProgram);
4505 ORD(glDeleteRenderbuffers);
4506 ORD(glDeleteShader);
4507 ORD(glDeleteTextures);
4510 // ORD(glDepthRangef);
4511 ORD(glDetachShader);
4513 ORD(glDisableVertexAttribArray);
4515 ORD(glDrawElements);
4517 ORD(glEnableVertexAttribArray);
4520 ORD(glFramebufferRenderbuffer);
4521 ORD(glFramebufferTexture2D);
4524 ORD(glGenerateMipmap);
4525 ORD(glGenFramebuffers);
4526 ORD(glGenRenderbuffers);
4528 ORD(glGetActiveAttrib);
4529 ORD(glGetActiveUniform);
4530 ORD(glGetAttachedShaders);
4531 ORD(glGetAttribLocation);
4533 ORD(glGetBufferParameteriv);
4536 ORD(glGetFramebufferAttachmentParameteriv);
4538 ORD(glGetProgramiv);
4539 ORD(glGetProgramInfoLog);
4540 ORD(glGetRenderbufferParameteriv);
4542 ORD(glGetShaderInfoLog);
4543 // ORD(glGetShaderPrecisionFormat);
4544 ORD(glGetShaderSource);
4545 // ORD(glGetString);
4546 ORD(glGetTexParameterfv);
4547 ORD(glGetTexParameteriv);
4548 ORD(glGetUniformfv);
4549 ORD(glGetUniformiv);
4550 ORD(glGetUniformLocation);
4551 ORD(glGetVertexAttribfv);
4552 ORD(glGetVertexAttribiv);
4553 ORD(glGetVertexAttribPointerv);
4557 ORD(glIsFramebuffer);
4559 ORD(glIsRenderbuffer);
4565 ORD(glPolygonOffset);
4567 // ORD(glReleaseShaderCompiler);
4568 ORD(glRenderbufferStorage);
4569 ORD(glSampleCoverage);
4571 // ORD(glShaderBinary);
4572 ORD(glShaderSource);
4574 ORD(glStencilFuncSeparate);
4576 ORD(glStencilMaskSeparate);
4578 ORD(glStencilOpSeparate);
4580 ORD(glTexParameterf);
4581 ORD(glTexParameterfv);
4582 ORD(glTexParameteri);
4583 ORD(glTexParameteriv);
4584 ORD(glTexSubImage2D);
4601 ORD(glUniformMatrix2fv);
4602 ORD(glUniformMatrix3fv);
4603 ORD(glUniformMatrix4fv);
4605 ORD(glValidateProgram);
4606 ORD(glVertexAttrib1f);
4607 ORD(glVertexAttrib1fv);
4608 ORD(glVertexAttrib2f);
4609 ORD(glVertexAttrib2fv);
4610 ORD(glVertexAttrib3f);
4611 ORD(glVertexAttrib3fv);
4612 ORD(glVertexAttrib4f);
4613 ORD(glVertexAttrib4fv);
4614 ORD(glVertexAttribPointer);
4618 #define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, glsym_)
4620 ORD(glGetProgramBinaryOES);
4621 ORD(glProgramBinaryOES);
4622 ORD(glMapBufferOES);
4623 ORD(glUnmapBufferOES);
4624 ORD(glGetBufferPointervOES);
4625 ORD(glTexImage3DOES);
4626 ORD(glTexSubImage3DOES);
4627 ORD(glCopyTexSubImage3DOES);
4628 ORD(glCompressedTexImage3DOES);
4629 ORD(glCompressedTexSubImage3DOES);
4630 ORD(glFramebufferTexture3DOES);
4631 ORD(glGetPerfMonitorGroupsAMD);
4632 ORD(glGetPerfMonitorCountersAMD);
4633 ORD(glGetPerfMonitorGroupStringAMD);
4634 ORD(glGetPerfMonitorCounterStringAMD);
4635 ORD(glGetPerfMonitorCounterInfoAMD);
4636 ORD(glGenPerfMonitorsAMD);
4637 ORD(glDeletePerfMonitorsAMD);
4638 ORD(glSelectPerfMonitorCountersAMD);
4639 ORD(glBeginPerfMonitorAMD);
4640 ORD(glEndPerfMonitorAMD);
4641 ORD(glGetPerfMonitorCounterDataAMD);
4642 ORD(glDiscardFramebufferEXT);
4643 ORD(glMultiDrawArraysEXT);
4644 ORD(glMultiDrawElementsEXT);
4645 ORD(glDeleteFencesNV);
4649 ORD(glGetFenceivNV);
4650 ORD(glFinishFenceNV);
4652 ORD(glGetDriverControlsQCOM);
4653 ORD(glGetDriverControlStringQCOM);
4654 ORD(glEnableDriverControlQCOM);
4655 ORD(glDisableDriverControlQCOM);
4656 ORD(glExtGetTexturesQCOM);
4657 ORD(glExtGetBuffersQCOM);
4658 ORD(glExtGetRenderbuffersQCOM);
4659 ORD(glExtGetFramebuffersQCOM);
4660 ORD(glExtGetTexLevelParameterivQCOM);
4661 ORD(glExtTexObjectStateOverrideiQCOM);
4662 ORD(glExtGetTexSubImageQCOM);
4663 ORD(glExtGetBufferPointervQCOM);
4664 ORD(glExtGetShadersQCOM);
4665 ORD(glExtGetProgramsQCOM);
4666 ORD(glExtIsProgramBinaryQCOM);
4667 ORD(glExtGetProgramBinarySourceQCOM);
4670 // Override functions wrapped by Evas_GL
4671 #define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, evgl_)
4672 ORD(glBindFramebuffer);
4673 ORD(glBindRenderbuffer);
4683 // GLES2.0 API compat on top of desktop gl
4686 ORD(glGetShaderPrecisionFormat);
4687 ORD(glReleaseShaderCompiler);
4688 ORD(glShaderBinary);
4692 #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
4693 // GLES 2.0 Extensions that needs wrapping
4694 ORD(evasglCreateImage);
4695 ORD(evasglDestroyImage);
4696 ORD(glEvasGLImageTargetTexture2DOES);
4697 ORD(glEvasGLImageTargetRenderbufferStorageOES);
4706 eng_gl_img_obj_set(void *data, void *image, int has_alpha)
4708 Render_Engine *re = (Render_Engine *)data;
4710 gl_direct_img_obj = NULL;
4712 // Normally direct rendering isn't allowed if alpha is on and
4713 // rotation is not 0. BUT, if override is on, allow it.
4714 if ((has_alpha) || (re->win->gl_context->rot!=0))
4716 if (gl_direct_override)
4717 gl_direct_img_obj = image;
4720 gl_direct_img_obj = image;
4724 eng_image_load_error_get(void *data __UNUSED__, void *image)
4728 if (!image) return EVAS_LOAD_ERROR_NONE;
4730 return im->im->cache_entry.load_error;
4734 eng_image_animated_get(void *data __UNUSED__, void *image)
4736 Evas_GL_Image *gim = image;
4739 if (!gim) return EINA_FALSE;
4740 im = (Image_Entry *)gim->im;
4741 if (!im) return EINA_FALSE;
4743 return im->flags.animated;
4747 eng_image_animated_frame_count_get(void *data __UNUSED__, void *image)
4749 Evas_GL_Image *gim = image;
4752 if (!gim) return -1;
4753 im = (Image_Entry *)gim->im;
4756 if (!im->flags.animated) return -1;
4757 return im->frame_count;
4760 static Evas_Image_Animated_Loop_Hint
4761 eng_image_animated_loop_type_get(void *data __UNUSED__, void *image)
4763 Evas_GL_Image *gim = image;
4766 if (!gim) return EVAS_IMAGE_ANIMATED_HINT_NONE;
4767 im = (Image_Entry *)gim->im;
4768 if (!im) return EVAS_IMAGE_ANIMATED_HINT_NONE;
4770 if (!im->flags.animated) return EVAS_IMAGE_ANIMATED_HINT_NONE;
4771 return im->loop_hint;
4775 eng_image_animated_loop_count_get(void *data __UNUSED__, void *image)
4777 Evas_GL_Image *gim = image;
4780 if (!gim) return -1;
4781 im = (Image_Entry *)gim->im;
4784 if (!im->flags.animated) return -1;
4785 return im->loop_count;
4789 eng_image_animated_frame_duration_get(void *data __UNUSED__, void *image, int start_frame, int frame_num)
4791 Evas_GL_Image *gim = image;
4794 if (!gim) return -1;
4795 im = (Image_Entry *)gim->im;
4798 if (!im->flags.animated) return -1;
4799 return evas_common_load_rgba_image_frame_duration_from_file(im, start_frame, frame_num);
4803 eng_image_animated_frame_set(void *data __UNUSED__, void *image, int frame_index)
4805 Evas_GL_Image *gim = image;
4808 if (!gim) return EINA_FALSE;
4809 im = (Image_Entry *)gim->im;
4810 if (!im) return EINA_FALSE;
4812 if (!im->flags.animated) return EINA_FALSE;
4813 if (im->cur_frame == frame_index) return EINA_FALSE;
4815 im->cur_frame = frame_index;
4820 eng_image_can_region_get(void *data __UNUSED__, void *image)
4822 Evas_GL_Image *gim = image;
4824 if (!gim) return EINA_FALSE;
4825 im = (Image_Entry *)gim->im;
4826 if (!im) return EINA_FALSE;
4827 return ((Evas_Image_Load_Func*) im->info.loader)->do_region;
4832 eng_image_max_size_get(void *data, int *maxw, int *maxh)
4834 Render_Engine *re = (Render_Engine *)data;
4835 if (maxw) *maxw = re->win->gl_context->shared->info.max_texture_size;
4836 if (maxh) *maxh = re->win->gl_context->shared->info.max_texture_size;
4840 module_open(Evas_Module *em)
4842 static Eina_Bool xrm_inited = EINA_FALSE;
4845 xrm_inited = EINA_TRUE;
4850 if (!evas_gl_common_module_open()) return 0;
4851 /* get whatever engine module we inherit from */
4852 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
4853 if (_evas_engine_GL_X11_log_dom < 0)
4854 _evas_engine_GL_X11_log_dom = eina_log_domain_register
4855 ("evas-gl_x11", EVAS_DEFAULT_LOG_COLOR);
4856 if (_evas_engine_GL_X11_log_dom < 0)
4858 EINA_LOG_ERR("Can not create a module log domain.");
4863 /* Allow alpha for evas gl direct rendering */
4864 if (getenv("EVAS_GL_DIRECT_OVERRIDE"))
4866 gl_direct_override = 1;
4867 DBG("########################################################");
4868 DBG("######### [Evas] Direct overriding is enabled ##########");
4869 DBG("########################################################");
4872 /* store it for later use */
4874 /* now to override methods */
4875 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
4879 ORD(canvas_alpha_get);
4882 ORD(output_tile_size_set);
4883 ORD(output_redraws_rect_add);
4884 ORD(output_redraws_rect_del);
4885 ORD(output_redraws_clear);
4886 ORD(output_redraws_next_update_get);
4887 ORD(output_redraws_next_update_push);
4888 ORD(context_cutout_add);
4889 ORD(context_cutout_clear);
4891 ORD(output_idle_flush);
4893 ORD(rectangle_draw);
4895 ORD(polygon_point_add);
4896 ORD(polygon_points_clear);
4900 ORD(image_new_from_data);
4901 ORD(image_new_from_copied_data);
4903 ORD(image_size_get);
4904 ORD(image_size_set);
4905 ORD(image_dirty_region);
4906 ORD(image_data_get);
4907 ORD(image_data_put);
4908 ORD(image_data_preload_request);
4909 ORD(image_data_preload_cancel);
4910 ORD(image_alpha_set);
4911 ORD(image_alpha_get);
4912 ORD(image_border_set);
4913 ORD(image_border_get);
4915 ORD(image_comment_get);
4916 ORD(image_format_get);
4917 ORD(image_colorspace_set);
4918 ORD(image_colorspace_get);
4919 ORD(image_can_region_get);
4920 ORD(image_mask_create);
4921 ORD(image_native_set);
4922 ORD(image_native_get);
4923 #if 0 // filtering disabled
4924 ORD(image_draw_filtered);
4925 ORD(image_filtered_get);
4926 ORD(image_filtered_save);
4927 ORD(image_filtered_free);
4932 ORD(image_scale_hint_set);
4933 ORD(image_scale_hint_get);
4934 ORD(image_stride_get);
4936 ORD(image_map_draw);
4937 ORD(image_map_surface_new);
4938 ORD(image_map_surface_free);
4940 ORD(image_content_hint_set);
4941 ORD(image_content_hint_get);
4943 ORD(image_cache_flush);
4944 ORD(image_cache_set);
4945 ORD(image_cache_get);
4947 ORD(gl_surface_create);
4948 ORD(gl_surface_destroy);
4949 ORD(gl_context_create);
4950 ORD(gl_context_destroy);
4951 ORD(gl_make_current);
4952 ORD(gl_string_query);
4953 ORD(gl_proc_address_get);
4954 ORD(gl_native_surface_get);
4956 ORD(gl_img_obj_set);
4958 ORD(image_load_error_get);
4960 /* now advertise out own api */
4961 ORD(image_animated_get);
4962 ORD(image_animated_frame_count_get);
4963 ORD(image_animated_loop_type_get);
4964 ORD(image_animated_loop_count_get);
4965 ORD(image_animated_frame_duration_get);
4966 ORD(image_animated_frame_set);
4968 ORD(image_max_size_get);
4970 /* now advertise out own api */
4971 em->functions = (void *)(&func);
4976 module_close(Evas_Module *em __UNUSED__)
4978 eina_log_domain_unregister(_evas_engine_GL_X11_log_dom);
4982 XrmDestroyDatabase(xrdb_user.db);
4983 xrdb_user.last_stat = 0;
4984 xrdb_user.last_mtime = 0;
4985 xrdb_user.db = NULL;
4988 evas_gl_common_module_close();
4991 static Evas_Module_Api evas_modapi =
4993 EVAS_MODULE_API_VERSION,
5002 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, gl_x11);
5004 #ifndef EVAS_STATIC_BUILD_GL_XLIB
5005 EVAS_EINA_MODULE_DEFINE(engine, gl_x11);
5008 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/