1 #include "evas_common.h" /* Also includes international specific stuff */
2 #include "evas_private.h"
5 # include <dlfcn.h> /* dlopen,dlclose,etc */
8 # define EVAS_GL_NO_GL_H_CHECK 1
12 # warning software_generic will not be able to have Evas_GL API.
16 //----------------------------------//
19 #define OSMESA_MAJOR_VERSION 6
20 #define OSMESA_MINOR_VERSION 5
21 #define OSMESA_PATCH_VERSION 0
24 * Values for the format parameter of OSMesaCreateContext()
27 #define OSMESA_COLOR_INDEX GL_COLOR_INDEX
28 #define OSMESA_RGBA GL_RGBA
29 #define OSMESA_BGRA 0x1
30 #define OSMESA_ARGB 0x2
31 #define OSMESA_RGB GL_RGB
32 #define OSMESA_BGR 0x4
33 #define OSMESA_RGB_565 0x5
37 * OSMesaPixelStore() parameters:
40 #define OSMESA_ROW_LENGTH 0x10
41 #define OSMESA_Y_UP 0x11
45 * Accepted by OSMesaGetIntegerv:
47 #define OSMESA_WIDTH 0x20
48 #define OSMESA_HEIGHT 0x21
49 #define OSMESA_FORMAT 0x22
50 #define OSMESA_TYPE 0x23
51 #define OSMESA_MAX_WIDTH 0x24 /* new in 4.0 */
52 #define OSMESA_MAX_HEIGHT 0x25 /* new in 4.0 */
55 typedef void (*OSMESAproc)();
56 typedef struct osmesa_context *OSMesaContext;
59 typedef struct _Render_Engine_GL_Surface Render_Engine_GL_Surface;
60 typedef struct _Render_Engine_GL_Context Render_Engine_GL_Context;
62 struct _Render_Engine_GL_Surface
70 int internal_cpp; // Component per pixel. ie. RGB = 3
78 Render_Engine_GL_Context *current_ctx;
82 struct _Render_Engine_GL_Context
86 OSMesaContext context;
88 Render_Engine_GL_Context *share_ctx;
90 Render_Engine_GL_Surface *current_sfc;
93 //------------------------------------------------------//
94 typedef void (*_eng_fn) (void );
95 typedef _eng_fn (*glsym_func_eng_fn) ();
96 typedef void (*glsym_func_void) ();
97 typedef unsigned int (*glsym_func_uint) ();
98 typedef int (*glsym_func_int) ();
99 typedef unsigned char (*glsym_func_uchar) ();
100 typedef unsigned char *(*glsym_func_uchar_ptr) ();
101 typedef const unsigned char *(*glsym_func_const_uchar_ptr) ();
102 typedef char const *(*glsym_func_char_const_ptr) ();
103 typedef GLboolean (*glsym_func_bool) ();
104 typedef OSMesaContext (*glsym_func_osm_ctx) ();
105 //------------------------------------------------------//
107 /* Function table for GL APIs */
108 static Evas_GL_API gl_funcs;
109 static void *gl_lib_handle;
110 static int gl_lib_is_gles = 0;
111 static Evas_GL_API gl_funcs;
113 //------------------------------------------------------//
115 static OSMesaContext (*_sym_OSMesaCreateContextExt) (GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, OSMesaContext sharelist) = NULL;
116 static void (*_sym_OSMesaDestroyContext) (OSMesaContext ctx) = NULL;
117 static GLboolean (*_sym_OSMesaMakeCurrent) (OSMesaContext ctx, void *buffer, GLenum type, GLsizei width, GLsizei height) = NULL;
118 static void (*_sym_OSMesaPixelStore) (GLint pname, GLint value) = NULL;
119 static OSMESAproc (*_sym_OSMesaGetProcAddress) (const char *funcName);
122 //------------------------------------------------------//
124 static void (*_sym_glActiveTexture) (GLenum texture) = NULL;
125 static void (*_sym_glAttachShader) (GLuint program, GLuint shader) = NULL;
126 static void (*_sym_glBindAttribLocation) (GLuint program, GLuint index, const char* name) = NULL;
127 static void (*_sym_glBindBuffer) (GLenum target, GLuint buffer) = NULL;
128 static void (*_sym_glBindFramebuffer) (GLenum target, GLuint framebuffer) = NULL;
129 static void (*_sym_glBindRenderbuffer) (GLenum target, GLuint renderbuffer) = NULL;
130 static void (*_sym_glBindTexture) (GLenum target, GLuint texture) = NULL;
131 static void (*_sym_glBlendColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = NULL;
132 static void (*_sym_glBlendEquation) (GLenum mode) = NULL;
133 static void (*_sym_glBlendEquationSeparate) (GLenum modeRGB, GLenum modeAlpha) = NULL;
134 static void (*_sym_glBlendFunc) (GLenum sfactor, GLenum dfactor) = NULL;
135 static void (*_sym_glBlendFuncSeparate) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) = NULL;
136 static void (*_sym_glBufferData) (GLenum target, GLsizeiptr size, const void* data, GLenum usage) = NULL;
137 static void (*_sym_glBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, const void* data) = NULL;
138 static GLenum (*_sym_glCheckFramebufferStatus) (GLenum target) = NULL;
139 static void (*_sym_glClear) (GLbitfield mask) = NULL;
140 static void (*_sym_glClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = NULL;
141 static void (*_sym_glClearDepthf) (GLclampf depth) = NULL;
142 static void (*_sym_glClearStencil) (GLint s) = NULL;
143 static void (*_sym_glColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) = NULL;
144 static void (*_sym_glCompileShader) (GLuint shader) = NULL;
145 static void (*_sym_glCompressedTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) = NULL;
146 static void (*_sym_glCompressedTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) = NULL;
147 static void (*_sym_glCopyTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = NULL;
148 static void (*_sym_glCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
149 static GLuint (*_sym_glCreateProgram) (void) = NULL;
150 static GLuint (*_sym_glCreateShader) (GLenum type) = NULL;
151 static void (*_sym_glCullFace) (GLenum mode) = NULL;
152 static void (*_sym_glDeleteBuffers) (GLsizei n, const GLuint* buffers) = NULL;
153 static void (*_sym_glDeleteFramebuffers) (GLsizei n, const GLuint* framebuffers) = NULL;
154 static void (*_sym_glDeleteProgram) (GLuint program) = NULL;
155 static void (*_sym_glDeleteRenderbuffers) (GLsizei n, const GLuint* renderbuffers) = NULL;
156 static void (*_sym_glDeleteShader) (GLuint shader) = NULL;
157 static void (*_sym_glDeleteTextures) (GLsizei n, const GLuint* textures) = NULL;
158 static void (*_sym_glDepthFunc) (GLenum func) = NULL;
159 static void (*_sym_glDepthMask) (GLboolean flag) = NULL;
160 static void (*_sym_glDepthRangef) (GLclampf zNear, GLclampf zFar) = NULL;
161 static void (*_sym_glDetachShader) (GLuint program, GLuint shader) = NULL;
162 static void (*_sym_glDisable) (GLenum cap) = NULL;
163 static void (*_sym_glDisableVertexAttribArray) (GLuint index) = NULL;
164 static void (*_sym_glDrawArrays) (GLenum mode, GLint first, GLsizei count) = NULL;
165 static void (*_sym_glDrawElements) (GLenum mode, GLsizei count, GLenum type, const void* indices) = NULL;
166 static void (*_sym_glEnable) (GLenum cap) = NULL;
167 static void (*_sym_glEnableVertexAttribArray) (GLuint index) = NULL;
168 static void (*_sym_glFinish) (void) = NULL;
169 static void (*_sym_glFlush) (void) = NULL;
170 static void (*_sym_glFramebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL;
171 static void (*_sym_glFramebufferTexture2D) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL;
172 static void (*_sym_glFrontFace) (GLenum mode) = NULL;
173 static void (*_sym_glGenBuffers) (GLsizei n, GLuint* buffers) = NULL;
174 static void (*_sym_glGenerateMipmap) (GLenum target) = NULL;
175 static void (*_sym_glGenFramebuffers) (GLsizei n, GLuint* framebuffers) = NULL;
176 static void (*_sym_glGenRenderbuffers) (GLsizei n, GLuint* renderbuffers) = NULL;
177 static void (*_sym_glGenTextures) (GLsizei n, GLuint* textures) = NULL;
178 static void (*_sym_glGetActiveAttrib) (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = NULL;
179 static void (*_sym_glGetActiveUniform) (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = NULL;
180 static void (*_sym_glGetAttachedShaders) (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) = NULL;
181 static int (*_sym_glGetAttribLocation) (GLuint program, const char* name) = NULL;
182 static void (*_sym_glGetBooleanv) (GLenum pname, GLboolean* params) = NULL;
183 static void (*_sym_glGetBufferParameteriv) (GLenum target, GLenum pname, GLint* params) = NULL;
184 static GLenum (*_sym_glGetError) (void) = NULL;
185 static void (*_sym_glGetFloatv) (GLenum pname, GLfloat* params) = NULL;
186 static void (*_sym_glGetFramebufferAttachmentParameteriv) (GLenum target, GLenum attachment, GLenum pname, GLint* params) = NULL;
187 static void (*_sym_glGetIntegerv) (GLenum pname, GLint* params) = NULL;
188 static void (*_sym_glGetProgramiv) (GLuint program, GLenum pname, GLint* params) = NULL;
189 static void (*_sym_glGetProgramInfoLog) (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) = NULL;
190 static void (*_sym_glGetRenderbufferParameteriv) (GLenum target, GLenum pname, GLint* params) = NULL;
191 static void (*_sym_glGetShaderiv) (GLuint shader, GLenum pname, GLint* params) = NULL;
192 static void (*_sym_glGetShaderInfoLog) (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) = NULL;
193 static void (*_sym_glGetShaderPrecisionFormat) (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) = NULL;
194 static void (*_sym_glGetShaderSource) (GLuint shader, GLsizei bufsize, GLsizei* length, char* source) = NULL;
195 static const GLubyte *(*_sym_glGetString) (GLenum name) = NULL;
196 static void (*_sym_glGetTexParameterfv) (GLenum target, GLenum pname, GLfloat* params) = NULL;
197 static void (*_sym_glGetTexParameteriv) (GLenum target, GLenum pname, GLint* params) = NULL;
198 static void (*_sym_glGetUniformfv) (GLuint program, GLint location, GLfloat* params) = NULL;
199 static void (*_sym_glGetUniformiv) (GLuint program, GLint location, GLint* params) = NULL;
200 static int (*_sym_glGetUniformLocation) (GLuint program, const char* name) = NULL;
201 static void (*_sym_glGetVertexAttribfv) (GLuint index, GLenum pname, GLfloat* params) = NULL;
202 static void (*_sym_glGetVertexAttribiv) (GLuint index, GLenum pname, GLint* params) = NULL;
203 static void (*_sym_glGetVertexAttribPointerv) (GLuint index, GLenum pname, void** pointer) = NULL;
204 static void (*_sym_glHint) (GLenum target, GLenum mode) = NULL;
205 static GLboolean (*_sym_glIsBuffer) (GLuint buffer) = NULL;
206 static GLboolean (*_sym_glIsEnabled) (GLenum cap) = NULL;
207 static GLboolean (*_sym_glIsFramebuffer) (GLuint framebuffer) = NULL;
208 static GLboolean (*_sym_glIsProgram) (GLuint program) = NULL;
209 static GLboolean (*_sym_glIsRenderbuffer) (GLuint renderbuffer) = NULL;
210 static GLboolean (*_sym_glIsShader) (GLuint shader) = NULL;
211 static GLboolean (*_sym_glIsTexture) (GLuint texture) = NULL;
212 static void (*_sym_glLineWidth) (GLfloat width) = NULL;
213 static void (*_sym_glLinkProgram) (GLuint program) = NULL;
214 static void (*_sym_glPixelStorei) (GLenum pname, GLint param) = NULL;
215 static void (*_sym_glPolygonOffset) (GLfloat factor, GLfloat units) = NULL;
216 static void (*_sym_glReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) = NULL;
217 static void (*_sym_glReleaseShaderCompiler) (void) = NULL;
218 static void (*_sym_glRenderbufferStorage) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL;
219 static void (*_sym_glSampleCoverage) (GLclampf value, GLboolean invert) = NULL;
220 static void (*_sym_glScissor) (GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
221 static void (*_sym_glShaderBinary) (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) = NULL;
222 static void (*_sym_glShaderSource) (GLuint shader, GLsizei count, const char** string, const GLint* length) = NULL;
223 static void (*_sym_glStencilFunc) (GLenum func, GLint ref, GLuint mask) = NULL;
224 static void (*_sym_glStencilFuncSeparate) (GLenum face, GLenum func, GLint ref, GLuint mask) = NULL;
225 static void (*_sym_glStencilMask) (GLuint mask) = NULL;
226 static void (*_sym_glStencilMaskSeparate) (GLenum face, GLuint mask) = NULL;
227 static void (*_sym_glStencilOp) (GLenum fail, GLenum zfail, GLenum zpass) = NULL;
228 static void (*_sym_glStencilOpSeparate) (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) = NULL;
229 static void (*_sym_glTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) = NULL;
230 static void (*_sym_glTexParameterf) (GLenum target, GLenum pname, GLfloat param) = NULL;
231 static void (*_sym_glTexParameterfv) (GLenum target, GLenum pname, const GLfloat* params) = NULL;
232 static void (*_sym_glTexParameteri) (GLenum target, GLenum pname, GLint param) = NULL;
233 static void (*_sym_glTexParameteriv) (GLenum target, GLenum pname, const GLint* params) = NULL;
234 static void (*_sym_glTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) = NULL;
235 static void (*_sym_glUniform1f) (GLint location, GLfloat x) = NULL;
236 static void (*_sym_glUniform1fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
237 static void (*_sym_glUniform1i) (GLint location, GLint x) = NULL;
238 static void (*_sym_glUniform1iv) (GLint location, GLsizei count, const GLint* v) = NULL;
239 static void (*_sym_glUniform2f) (GLint location, GLfloat x, GLfloat y) = NULL;
240 static void (*_sym_glUniform2fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
241 static void (*_sym_glUniform2i) (GLint location, GLint x, GLint y) = NULL;
242 static void (*_sym_glUniform2iv) (GLint location, GLsizei count, const GLint* v) = NULL;
243 static void (*_sym_glUniform3f) (GLint location, GLfloat x, GLfloat y, GLfloat z) = NULL;
244 static void (*_sym_glUniform3fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
245 static void (*_sym_glUniform3i) (GLint location, GLint x, GLint y, GLint z) = NULL;
246 static void (*_sym_glUniform3iv) (GLint location, GLsizei count, const GLint* v) = NULL;
247 static void (*_sym_glUniform4f) (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
248 static void (*_sym_glUniform4fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
249 static void (*_sym_glUniform4i) (GLint location, GLint x, GLint y, GLint z, GLint w) = NULL;
250 static void (*_sym_glUniform4iv) (GLint location, GLsizei count, const GLint* v) = NULL;
251 static void (*_sym_glUniformMatrix2fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
252 static void (*_sym_glUniformMatrix3fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
253 static void (*_sym_glUniformMatrix4fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
254 static void (*_sym_glUseProgram) (GLuint program) = NULL;
255 static void (*_sym_glValidateProgram) (GLuint program) = NULL;
256 static void (*_sym_glVertexAttrib1f) (GLuint indx, GLfloat x) = NULL;
257 static void (*_sym_glVertexAttrib1fv) (GLuint indx, const GLfloat* values) = NULL;
258 static void (*_sym_glVertexAttrib2f) (GLuint indx, GLfloat x, GLfloat y) = NULL;
259 static void (*_sym_glVertexAttrib2fv) (GLuint indx, const GLfloat* values) = NULL;
260 static void (*_sym_glVertexAttrib3f) (GLuint indx, GLfloat x, GLfloat y, GLfloat z) = NULL;
261 static void (*_sym_glVertexAttrib3fv) (GLuint indx, const GLfloat* values) = NULL;
262 static void (*_sym_glVertexAttrib4f) (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
263 static void (*_sym_glVertexAttrib4fv) (GLuint indx, const GLfloat* values) = NULL;
264 static void (*_sym_glVertexAttribPointer) (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) = NULL;
265 static void (*_sym_glViewport) (GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
267 // GLES Extensions...
268 /* static void (*_sym_glGetProgramBinary) (GLuint a, GLsizei b, GLsizei* c, GLenum* d, void* e) = NULL; */
269 /* static void (*_sym_glProgramBinary) (GLuint a, GLenum b, const void* c, GLint d) = NULL; */
270 /* static void (*_sym_glProgramParameteri) (GLuint a, GLuint b, GLint d) = NULL; */
280 static int cpunum = 0;
281 static int _evas_soft_gen_log_dom = -1;
284 eng_output_dump(void *data __UNUSED__)
286 evas_common_image_image_all_unload();
287 evas_common_font_font_all_unload();
291 eng_context_new(void *data __UNUSED__)
293 return evas_common_draw_context_new();
297 eng_context_free(void *data __UNUSED__, void *context)
299 evas_common_draw_context_free(context);
303 eng_context_clip_set(void *data __UNUSED__, void *context, int x, int y, int w, int h)
305 evas_common_draw_context_set_clip(context, x, y, w, h);
309 eng_context_clip_clip(void *data __UNUSED__, void *context, int x, int y, int w, int h)
311 evas_common_draw_context_clip_clip(context, x, y, w, h);
315 eng_context_clip_unset(void *data __UNUSED__, void *context)
317 evas_common_draw_context_unset_clip(context);
321 eng_context_clip_get(void *data __UNUSED__, void *context, int *x, int *y, int *w, int *h)
323 *x = ((RGBA_Draw_Context *)context)->clip.x;
324 *y = ((RGBA_Draw_Context *)context)->clip.y;
325 *w = ((RGBA_Draw_Context *)context)->clip.w;
326 *h = ((RGBA_Draw_Context *)context)->clip.h;
327 return ((RGBA_Draw_Context *)context)->clip.use;
331 eng_context_color_set(void *data __UNUSED__, void *context, int r, int g, int b, int a)
333 evas_common_draw_context_set_color(context, r, g, b, a);
337 eng_context_color_get(void *data __UNUSED__, void *context, int *r, int *g, int *b, int *a)
339 *r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->col.col));
340 *g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->col.col));
341 *b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->col.col));
342 *a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->col.col));
347 eng_context_multiplier_set(void *data __UNUSED__, void *context, int r, int g, int b, int a)
349 evas_common_draw_context_set_multiplier(context, r, g, b, a);
353 eng_context_multiplier_unset(void *data __UNUSED__, void *context)
355 evas_common_draw_context_unset_multiplier(context);
359 eng_context_multiplier_get(void *data __UNUSED__, void *context, int *r, int *g, int *b, int *a)
361 *r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->mul.col));
362 *g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->mul.col));
363 *b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->mul.col));
364 *a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->mul.col));
365 return ((RGBA_Draw_Context *)context)->mul.use;
369 eng_context_mask_set(void *data __UNUSED__, void *context, void *mask, int x, int y, int w, int h)
371 evas_common_draw_context_set_mask(context, mask, x, y, w, h);
375 eng_context_mask_unset(void *data __UNUSED__, void *context)
377 evas_common_draw_context_unset_mask(context);
381 eng_context_mask_get(void *data __UNUSED__, void *context)
383 return ((RGBA_Draw_Context *)context)->mask.mask;
388 eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h)
390 evas_common_draw_context_add_cutout(context, x, y, w, h);
394 eng_context_cutout_clear(void *data __UNUSED__, void *context)
396 evas_common_draw_context_clear_cutouts(context);
400 eng_context_anti_alias_set(void *data __UNUSED__, void *context, unsigned char aa)
402 evas_common_draw_context_set_anti_alias(context, aa);
406 eng_context_anti_alias_get(void *data __UNUSED__, void *context)
408 return ((RGBA_Draw_Context *)context)->anti_alias;
412 eng_context_color_interpolation_set(void *data __UNUSED__, void *context, int color_space)
414 evas_common_draw_context_set_color_interpolation(context, color_space);
418 eng_context_color_interpolation_get(void *data __UNUSED__, void *context)
420 return ((RGBA_Draw_Context *)context)->interpolation.color_space;
424 eng_context_render_op_set(void *data __UNUSED__, void *context, int op)
426 evas_common_draw_context_set_render_op(context, op);
430 eng_context_render_op_get(void *data __UNUSED__, void *context)
432 return ((RGBA_Draw_Context *)context)->render_op;
438 eng_rectangle_draw(void *data __UNUSED__, void *context, void *surface, int x, int y, int w, int h)
440 #ifdef BUILD_PIPE_RENDER
442 #ifdef EVAS_FRAME_QUEUING
443 && evas_common_frameq_enabled()
446 evas_common_pipe_rectangle_draw(surface, context, x, y, w, h);
450 evas_common_rectangle_draw(surface, context, x, y, w, h);
451 evas_common_cpu_end_opt();
456 eng_line_draw(void *data __UNUSED__, void *context, void *surface, int x1, int y1, int x2, int y2)
458 #ifdef BUILD_PIPE_RENDER
460 #ifdef EVAS_FRAME_QUEUING
461 && evas_common_frameq_enabled()
464 evas_common_pipe_line_draw(surface, context, x1, y1, x2, y2);
468 evas_common_line_draw(surface, context, x1, y1, x2, y2);
469 evas_common_cpu_end_opt();
474 eng_polygon_point_add(void *data __UNUSED__, void *context __UNUSED__, void *polygon, int x, int y)
476 return evas_common_polygon_point_add(polygon, x, y);
480 eng_polygon_points_clear(void *data __UNUSED__, void *context __UNUSED__, void *polygon)
482 return evas_common_polygon_points_clear(polygon);
486 eng_polygon_draw(void *data __UNUSED__, void *context, void *surface, void *polygon, int x, int y)
488 #ifdef BUILD_PIPE_RENDER
490 #ifdef EVAS_FRAME_QUEUING
491 && evas_common_frameq_enabled()
494 evas_common_pipe_poly_draw(surface, context, polygon, x, y);
498 evas_common_polygon_draw(surface, context, polygon, x, y);
499 evas_common_cpu_end_opt();
504 eng_image_alpha_get(void *data __UNUSED__, void *image)
508 if (!image) return 1;
512 case EVAS_COLORSPACE_ARGB8888:
513 if (im->flags.alpha) return 1;
521 eng_image_colorspace_get(void *data __UNUSED__, void *image)
525 if (!image) return EVAS_COLORSPACE_ARGB8888;
531 eng_image_can_region_get(void *data __UNUSED__, void *image)
534 if (!image) return EINA_FALSE;
536 return ((Evas_Image_Load_Func*) im->info.loader)->do_region;
540 eng_image_mask_create(void *data __UNUSED__, void *image)
549 if (im->mask.mask && !im->mask.dirty) return;
551 if (im->mask.mask) free(im->mask.mask);
552 sz = im->cache_entry.w * im->cache_entry.h;
553 im->mask.mask = malloc(sz);
556 evas_cache_image_load_data(&im->cache_entry);
557 src = (void*) im->image.data;
559 for (end = dst + sz ; dst < end ; dst ++, src ++)
566 eng_image_alpha_set(void *data __UNUSED__, void *image, int has_alpha)
570 if (!image) return NULL;
572 if (im->cache_entry.space != EVAS_COLORSPACE_ARGB8888)
574 im->cache_entry.flags.alpha = 0;
577 im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
578 evas_common_image_colorspace_dirty(im);
580 im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
585 eng_image_border_set(void *data __UNUSED__, void *image, int l __UNUSED__, int r __UNUSED__, int t __UNUSED__, int b __UNUSED__)
594 eng_image_border_get(void *data __UNUSED__, void *image, int *l __UNUSED__, int *r __UNUSED__, int *t __UNUSED__, int *b __UNUSED__)
602 eng_image_comment_get(void *data __UNUSED__, void *image, char *key __UNUSED__)
606 if (!image) return NULL;
608 return im->info.comment;
612 eng_image_format_get(void *data __UNUSED__, void *image __UNUSED__)
618 eng_image_colorspace_set(void *data __UNUSED__, void *image, int cspace)
624 evas_cache_image_colorspace(im, cspace);
628 eng_image_native_set(void *data __UNUSED__, void *image, void *native __UNUSED__)
631 Evas_Native_Surface *ns = native;
632 Image_Entry *im = image, *im2 = NULL;
636 if ((!ns) && (ns->data.x11.visual))
638 im = evas_cache_image_data(evas_common_image_cache_get(),
640 ns->data.x11.visual, 1,
641 EVAS_COLORSPACE_ARGB8888);
648 if ((!ns) && (!im)) return im;
652 im2 = evas_cache_image_data(evas_common_image_cache_get(),
654 ns->data.x11.visual, 1,
655 EVAS_COLORSPACE_ARGB8888);
656 evas_cache_image_drop(im);
664 eng_image_native_get(void *data __UNUSED__, void *image __UNUSED__)
670 eng_image_load(void *data __UNUSED__, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
672 *error = EVAS_LOAD_ERROR_NONE;
673 return evas_common_load_image_from_file(file, key, lo, error);
677 eng_image_new_from_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
679 return evas_cache_image_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
683 eng_image_new_from_copied_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
685 return evas_cache_image_copied_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
689 eng_image_free(void *data __UNUSED__, void *image)
691 evas_cache_image_drop(image);
695 eng_image_size_get(void *data __UNUSED__, void *image, int *w, int *h)
705 eng_image_size_set(void *data __UNUSED__, void *image, int w, int h)
710 return evas_cache_image_size_set(image, w, h);
714 eng_image_dirty_region(void *data __UNUSED__, void *image, int x, int y, int w, int h)
716 Image_Entry *im = image;
718 if (!image) return NULL;
719 return evas_cache_image_dirty(im, x, y, w, h);
723 eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data, int *err)
734 error = evas_cache_image_load_data(&im->cache_entry);
735 switch (im->cache_entry.space)
737 case EVAS_COLORSPACE_ARGB8888:
739 im = (RGBA_Image *)evas_cache_image_alone(&im->cache_entry);
740 *image_data = im->image.data;
742 case EVAS_COLORSPACE_YCBCR422P601_PL:
743 case EVAS_COLORSPACE_YCBCR422P709_PL:
744 case EVAS_COLORSPACE_YCBCR422601_PL:
745 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
746 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
747 *image_data = im->cs.data;
753 if (err) *err = error;
758 eng_image_data_put(void *data, void *image, DATA32 *image_data)
760 RGBA_Image *im, *im2;
762 if (!image) return NULL;
764 switch (im->cache_entry.space)
766 case EVAS_COLORSPACE_ARGB8888:
767 if (image_data != im->image.data)
771 w = im->cache_entry.w;
772 h = im->cache_entry.h;
773 im2 = eng_image_new_from_data(data, w, h, image_data,
774 eng_image_alpha_get(data, image),
775 eng_image_colorspace_get(data, image));
776 evas_cache_image_drop(&im->cache_entry);
780 case EVAS_COLORSPACE_YCBCR422P601_PL:
781 case EVAS_COLORSPACE_YCBCR422P709_PL:
782 case EVAS_COLORSPACE_YCBCR422601_PL:
783 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
784 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
785 if (image_data != im->cs.data)
789 if (!im->cs.no_free) free(im->cs.data);
791 im->cs.data = image_data;
793 evas_common_image_colorspace_dirty(im);
803 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
805 RGBA_Image *im = image;
808 evas_cache_image_preload_data(&im->cache_entry, target);
812 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
814 RGBA_Image *im = image;
817 evas_cache_image_preload_cancel(&im->cache_entry, target);
821 eng_image_draw(void *data __UNUSED__, 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)
827 #ifdef BUILD_PIPE_RENDER
829 #ifdef EVAS_FRAME_QUEUING
830 && evas_common_frameq_enabled()
834 evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im),
835 surface, context, smooth,
836 src_x, src_y, src_w, src_h,
837 dst_x, dst_y, dst_w, dst_h);
839 evas_common_pipe_image_draw(im, surface, context, smooth,
840 src_x, src_y, src_w, src_h,
841 dst_x, dst_y, dst_w, dst_h);
846 // if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
847 // evas_cache_image_load_data(&im->cache_entry);
848 // evas_common_image_colorspace_normalize(im);
849 evas_common_rgba_image_scalecache_prepare(&im->cache_entry, surface, context, smooth,
850 src_x, src_y, src_w, src_h,
851 dst_x, dst_y, dst_w, dst_h);
852 evas_common_rgba_image_scalecache_do(&im->cache_entry, surface, context, smooth,
853 src_x, src_y, src_w, src_h,
854 dst_x, dst_y, dst_w, dst_h);
857 evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
858 src_x, src_y, src_w, src_h,
859 dst_x, dst_y, dst_w, dst_h);
861 evas_common_scale_rgba_in_to_out_clip_sample(im, surface, context,
862 src_x, src_y, src_w, src_h,
863 dst_x, dst_y, dst_w, dst_h);
865 evas_common_cpu_end_opt();
870 eng_image_map_draw(void *data __UNUSED__, void *context, void *surface, void *image, int npoints, RGBA_Map_Point *p, int smooth, int level)
875 if (npoints < 3) return;
878 if ((p[0].x == p[3].x) &&
879 (p[1].x == p[2].x) &&
880 (p[0].y == p[1].y) &&
881 (p[3].y == p[2].y) &&
882 (p[0].x <= p[1].x) &&
883 (p[0].y <= p[2].y) &&
886 (p[1].u == (int)(im->cache_entry.w << FP)) &&
888 (p[2].u == (int)(im->cache_entry.w << FP)) &&
889 (p[2].v == (int)(im->cache_entry.h << FP)) &&
891 (p[3].v == (int)(im->cache_entry.h << FP)) &&
892 (p[0].col == 0xffffffff) &&
893 (p[1].col == 0xffffffff) &&
894 (p[2].col == 0xffffffff) &&
895 (p[3].col == 0xffffffff))
901 dw = (p[2].x >> FP) - dx;
902 dh = (p[2].y >> FP) - dy;
904 (data, context, surface, image,
905 0, 0, im->cache_entry.w, im->cache_entry.h,
906 dx, dy, dw, dh, smooth);
910 #ifdef BUILD_PIPE_RENDER
912 # ifdef EVAS_FRAME_QUEUING
913 && evas_common_frameq_enabled()
916 evas_common_pipe_map_draw(im, surface, context, npoints, p, smooth, level);
919 evas_common_map_rgba(im, surface, context, npoints, p, smooth, level);
921 evas_common_cpu_end_opt();
925 eng_image_map_draw(data, context, surface, image, npoints - 2, p + 2,
931 eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
935 surface = evas_cache_image_copied_data(evas_common_image_cache_get(),
937 EVAS_COLORSPACE_ARGB8888);
938 pixels = evas_cache_image_pixels(surface);
943 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
945 evas_cache_image_drop(surface);
949 eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
955 im->scale_hint = hint;
959 eng_image_scale_hint_get(void *data __UNUSED__, void *image)
963 if (!image) return EVAS_IMAGE_SCALE_HINT_NONE;
965 return im->scale_hint;
969 eng_image_animated_get(void *data __UNUSED__, void *image)
973 if (!image) return EINA_FALSE;
975 return im->flags.animated;
979 eng_image_animated_frame_count_get(void *data __UNUSED__, void *image)
983 if (!image) return -1;
985 if (!im->flags.animated) return -1;
986 return im->frame_count;
989 static Evas_Image_Animated_Loop_Hint
990 eng_image_animated_loop_type_get(void *data __UNUSED__, void *image)
994 if (!image) return EVAS_IMAGE_ANIMATED_HINT_NONE;
996 if (!im->flags.animated) return EVAS_IMAGE_ANIMATED_HINT_NONE;
997 return im->loop_hint;
1001 eng_image_animated_loop_count_get(void *data __UNUSED__, void *image)
1005 if (!image) return -1;
1007 if (!im->flags.animated) return -1;
1008 return im->loop_count;
1012 eng_image_animated_frame_duration_get(void *data __UNUSED__, void *image, int start_frame, int frame_num)
1016 if (!image) return -1;
1018 if (!im->flags.animated) return -1;
1019 return evas_common_load_rgba_image_frame_duration_from_file(im, start_frame, frame_num);
1023 eng_image_animated_frame_set(void *data __UNUSED__, void *image, int frame_index)
1027 if (!image) return EINA_FALSE;
1029 if (!im->flags.animated) return EINA_FALSE;
1030 if (im->cur_frame == frame_index) return EINA_FALSE;
1031 im->cur_frame = frame_index;
1036 eng_image_cache_flush(void *data __UNUSED__)
1040 tmp_size = evas_common_image_get_cache();
1041 evas_common_image_set_cache(0);
1042 evas_common_rgba_image_scalecache_flush();
1043 evas_common_image_set_cache(tmp_size);
1047 eng_image_cache_set(void *data __UNUSED__, int bytes)
1049 evas_common_image_set_cache(bytes);
1050 evas_common_rgba_image_scalecache_size_set(bytes);
1054 eng_image_cache_get(void *data __UNUSED__)
1056 return evas_common_image_get_cache();
1059 static Evas_Font_Set *
1060 eng_font_load(void *data __UNUSED__, const char *name, int size,
1061 Font_Rend_Flags wanted_rend)
1063 return (Evas_Font_Set *) evas_common_font_load(name, size, wanted_rend);
1066 static Evas_Font_Set *
1067 eng_font_memory_load(void *data __UNUSED__, char *name, int size, const void *fdata, int fdata_size, Font_Rend_Flags wanted_rend)
1069 return (Evas_Font_Set *) evas_common_font_memory_load(name, size, fdata,
1070 fdata_size, wanted_rend);
1073 static Evas_Font_Set *
1074 eng_font_add(void *data __UNUSED__, Evas_Font_Set *font, const char *name, int size, Font_Rend_Flags wanted_rend)
1076 return (Evas_Font_Set *) evas_common_font_add((RGBA_Font *) font, name,
1080 static Evas_Font_Set *
1081 eng_font_memory_add(void *data __UNUSED__, Evas_Font_Set *font, char *name, int size, const void *fdata, int fdata_size, Font_Rend_Flags wanted_rend)
1083 return (Evas_Font_Set *) evas_common_font_memory_add((RGBA_Font *) font,
1084 name, size, fdata, fdata_size, wanted_rend);
1088 eng_font_free(void *data __UNUSED__, Evas_Font_Set *font)
1090 evas_common_font_free((RGBA_Font *) font);
1094 eng_font_ascent_get(void *data __UNUSED__, Evas_Font_Set *font)
1096 return evas_common_font_ascent_get((RGBA_Font *) font);
1100 eng_font_descent_get(void *data __UNUSED__, Evas_Font_Set *font)
1102 return evas_common_font_descent_get((RGBA_Font *) font);
1106 eng_font_max_ascent_get(void *data __UNUSED__, Evas_Font_Set *font)
1108 return evas_common_font_max_ascent_get((RGBA_Font *) font);
1112 eng_font_max_descent_get(void *data __UNUSED__, Evas_Font_Set *font)
1114 return evas_common_font_max_descent_get((RGBA_Font *) font);
1118 eng_font_string_size_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props, int *w, int *h)
1120 evas_common_font_query_size((RGBA_Font *) font, text_props, w, h);
1124 eng_font_inset_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1126 return evas_common_font_query_inset((RGBA_Font *) font, text_props);
1130 eng_font_right_inset_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1132 return evas_common_font_query_right_inset((RGBA_Font *) font, text_props);
1136 eng_font_h_advance_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1140 evas_common_font_query_advance((RGBA_Font *) font, text_props, &h, &v);
1145 eng_font_v_advance_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1149 evas_common_font_query_advance((RGBA_Font *) font, text_props, &h, &v);
1154 eng_font_pen_coords_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props, int pos, int *cpen_x, int *cy, int *cadv, int *ch)
1156 return evas_common_font_query_pen_coords((RGBA_Font *) font, text_props, pos, cpen_x, cy, cadv, ch);
1160 eng_font_text_props_info_create(void *data __UNUSED__, Evas_Font_Instance *fi, const Eina_Unicode *text, Evas_Text_Props *text_props, const Evas_BiDi_Paragraph_Props *par_props, size_t par_pos, size_t len)
1162 return evas_common_text_props_content_create((RGBA_Font_Int *) fi, text,
1163 text_props, par_props, par_pos, len);
1167 eng_font_char_coords_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props, int pos, int *cx, int *cy, int *cw, int *ch)
1169 return evas_common_font_query_char_coords((RGBA_Font *) font, text_props, pos, cx, cy, cw, ch);
1173 eng_font_char_at_coords_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props, int x, int y, int *cx, int *cy, int *cw, int *ch)
1175 return evas_common_font_query_char_at_coords((RGBA_Font *) font, text_props, x, y, cx, cy, cw, ch);
1179 eng_font_last_up_to_pos(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props, int x, int y)
1181 return evas_common_font_query_last_up_to_pos((RGBA_Font *) font, text_props, x, y);
1185 eng_font_run_font_end_get(void *data __UNUSED__, Evas_Font_Set *font, Evas_Font_Instance **script_fi, Evas_Font_Instance **cur_fi, Evas_Script_Type script, const Eina_Unicode *text, int run_len)
1187 return evas_common_font_query_run_font_end_get((RGBA_Font *) font,
1188 (RGBA_Font_Int **) script_fi, (RGBA_Font_Int **) cur_fi,
1189 script, text, run_len);
1193 eng_font_draw(void *data __UNUSED__, void *context, void *surface, Evas_Font_Set *font, int x, int y, int w __UNUSED__, int h __UNUSED__, int ow __UNUSED__, int oh __UNUSED__, const Evas_Text_Props *text_props)
1195 #ifdef BUILD_PIPE_RENDER
1197 #ifdef EVAS_FRAME_QUEUING
1198 && evas_common_frameq_enabled()
1201 evas_common_pipe_text_draw(surface, context, (RGBA_Font *) font, x, y,
1206 evas_common_font_draw(surface, context, (RGBA_Font *) font, x, y,
1208 evas_common_cpu_end_opt();
1213 eng_font_cache_flush(void *data __UNUSED__)
1217 tmp_size = evas_common_font_cache_get();
1218 evas_common_font_cache_set(0);
1219 evas_common_font_flush();
1220 evas_common_font_cache_set(tmp_size);
1224 eng_font_cache_set(void *data __UNUSED__, int bytes)
1226 evas_common_font_cache_set(bytes);
1230 eng_font_cache_get(void *data __UNUSED__)
1232 return evas_common_font_cache_get();
1236 eng_font_hinting_set(void *data __UNUSED__, Evas_Font_Set *font, int hinting)
1238 evas_common_font_hinting_set((RGBA_Font *) font, hinting);
1242 eng_font_hinting_can_hint(void *data __UNUSED__, int hinting)
1244 return evas_common_hinting_available(hinting);
1248 eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
1255 #if 0 // filtering disabled
1257 eng_image_draw_filtered(void *data __UNUSED__, void *context __UNUSED__,
1258 void *surface, void *image, Evas_Filter_Info *filter)
1260 Evas_Software_Filter_Fn fn;
1261 RGBA_Image *im = image;
1263 fn = evas_filter_software_get(filter);
1265 if (im->cache_entry.cache) evas_cache_image_load_data(&im->cache_entry);
1266 fn(filter, image, surface);
1270 static Filtered_Image *
1271 eng_image_filtered_get(void *image, uint8_t *key, size_t keylen)
1273 RGBA_Image *im = image;
1277 for (l = im->filtered ; l ; l = l->next)
1280 if (fi->keylen != keylen) continue;
1281 if (memcmp(key, fi->key, keylen) != 0) continue;
1289 static Filtered_Image *
1290 eng_image_filtered_save(void *image, void *fimage, uint8_t *key, size_t keylen)
1292 RGBA_Image *im = image;
1296 for (l = im->filtered ; l ; l = l->next)
1299 if (fi->keylen != keylen) continue;
1300 if (memcmp(key, fi->key, keylen) == 0) continue;
1301 evas_cache_image_drop((void *)fi->image);
1306 fi = calloc(1,sizeof(Filtered_Image));
1307 if (!fi) return NULL;
1309 fi->keylen = keylen;
1310 fi->key = malloc(keylen);
1311 memcpy(fi->key, key, keylen);
1315 im->filtered = eina_list_prepend(im->filtered, fi);
1321 eng_image_filtered_free(void *image, Filtered_Image *fi)
1323 RGBA_Image *im = image;
1326 if (fi->ref) return;
1329 evas_cache_image_drop(&fi->image->cache_entry);
1332 im->filtered = eina_list_remove(im->filtered, fi);
1337 eng_image_load_error_get(void *data __UNUSED__, void *image)
1341 if (!image) return EVAS_LOAD_ERROR_NONE;
1343 return im->cache_entry.load_error;
1346 //------------ Evas GL engine code ---------------//
1348 eng_gl_surface_create(void *data __UNUSED__, void *config, int w, int h)
1351 Render_Engine_GL_Surface *sfc;
1352 Evas_GL_Config *cfg;
1354 sfc = calloc(1, sizeof(Render_Engine_GL_Surface));
1355 if (!sfc) return NULL;
1357 cfg = (Evas_GL_Config *)config;
1359 sfc->initialized = 0;
1364 switch (cfg->color_format)
1367 case EVAS_GL_RGB_888:
1368 sfc->internal_fmt = OSMESA_RGB;
1369 sfc->internal_cpp = 3;
1371 case EVAS_GL_RGBA_8888:
1372 sfc->internal_fmt = OSMESA_BGRA;
1373 sfc->internal_cpp = 4;
1376 sfc->internal_fmt = OSMESA_RGBA;
1377 sfc->internal_cpp = 4;
1382 switch (cfg->depth_bits)
1384 case EVAS_GL_DEPTH_BIT_8:
1385 sfc->depth_bits = 8;
1387 case EVAS_GL_DEPTH_BIT_16:
1388 sfc->depth_bits = 16;
1390 case EVAS_GL_DEPTH_BIT_24:
1391 sfc->depth_bits = 24;
1393 case EVAS_GL_DEPTH_BIT_32:
1394 sfc->depth_bits = 32;
1396 case EVAS_GL_DEPTH_NONE:
1398 sfc->depth_bits = 0;
1403 switch (cfg->stencil_bits)
1405 case EVAS_GL_STENCIL_BIT_1:
1406 sfc->stencil_bits = 1;
1408 case EVAS_GL_STENCIL_BIT_2:
1409 sfc->stencil_bits = 2;
1411 case EVAS_GL_STENCIL_BIT_4:
1412 sfc->stencil_bits = 4;
1414 case EVAS_GL_STENCIL_BIT_8:
1415 sfc->stencil_bits = 8;
1417 case EVAS_GL_STENCIL_BIT_16:
1418 sfc->stencil_bits = 16;
1420 case EVAS_GL_STENCIL_NONE:
1422 sfc->stencil_bits = 0;
1426 sfc->buffer = malloc(sizeof(unsigned char)*sfc->internal_cpp*w*h);
1444 eng_gl_surface_destroy(void *data __UNUSED__, void *surface)
1447 Render_Engine_GL_Surface *sfc;
1449 sfc = (Render_Engine_GL_Surface*)surface;
1453 if (sfc->buffer) free(sfc->buffer);
1467 eng_gl_context_create(void *data __UNUSED__, void *share_context)
1470 Render_Engine_GL_Context *ctx;
1471 Render_Engine_GL_Context *share_ctx;
1473 ctx = calloc(1, sizeof(Render_Engine_GL_Context));
1475 if (!ctx) return NULL;
1477 share_ctx = (Render_Engine_GL_Context *)share_context;
1479 ctx->share_ctx = share_ctx;
1483 ctx->context = OSMesaCreateContextExt( OSMESA_RGBA, 8, 0, 0, share_ctx->context );
1485 ctx->context = OSMesaCreateContextExt( OSMESA_RGBA, 8, 0, 0, NULL );
1490 ERR("Error creating OSMesa Context.");
1496 ctx->initialized = 0;
1500 (void) share_context;
1506 eng_gl_context_destroy(void *data __UNUSED__, void *context)
1509 Render_Engine_GL_Context *ctx;
1511 ctx = (Render_Engine_GL_Context*)context;
1515 _sym_OSMesaDestroyContext(ctx->context);
1528 eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
1531 Render_Engine_GL_Surface *sfc;
1532 Render_Engine_GL_Context *ctx;
1533 OSMesaContext share_ctx;
1536 sfc = (Render_Engine_GL_Surface*)surface;
1537 ctx = (Render_Engine_GL_Context*)context;
1539 // Unset surface/context
1540 if ((!sfc) || (!ctx))
1542 if (ctx) ctx->current_sfc = NULL;
1543 if (sfc) sfc->current_ctx = NULL;
1547 // Initialize Context if it hasn't been.
1548 if (!ctx->initialized)
1551 share_ctx = ctx->share_ctx->context;
1555 ctx->context = _sym_OSMesaCreateContextExt(sfc->internal_fmt,
1562 ERR("Error initializing context.");
1566 ctx->initialized = 1;
1571 ret = _sym_OSMesaMakeCurrent(ctx->context, sfc->buffer, GL_UNSIGNED_BYTE,
1574 if (ret == GL_FALSE)
1576 ERR("Error doing MakeCurrent.");
1580 _sym_OSMesaPixelStore(OSMESA_Y_UP, 0);
1582 // Set the current surface/context
1583 ctx->current_sfc = sfc;
1584 sfc->current_ctx = ctx;
1594 // FIXME!!! Implement later
1596 eng_gl_string_query(void *data __UNUSED__, int name __UNUSED__)
1602 eng_gl_proc_address_get(void *data __UNUSED__, const char *name)
1605 if (_sym_OSMesaGetProcAddress) return _sym_OSMesaGetProcAddress(name);
1606 return dlsym(RTLD_DEFAULT, name);
1614 eng_gl_native_surface_get(void *data __UNUSED__, void *surface, void *native_surface)
1617 Render_Engine_GL_Surface *sfc;
1618 Evas_Native_Surface *ns;
1620 sfc = (Render_Engine_GL_Surface*)surface;
1621 ns = (Evas_Native_Surface*)native_surface;
1625 ns->type = EVAS_NATIVE_SURFACE_OPENGL;
1626 ns->version = EVAS_NATIVE_SURFACE_VERSION;
1627 ns->data.x11.visual = sfc->buffer;
1632 (void) native_surface;
1639 eng_gl_api_get(void *data __UNUSED__)
1648 //------------------------------------------------//
1659 static Evas_Func func =
1675 /* draw context virtual methods */
1677 eng_canvas_alpha_get,
1679 eng_context_clip_set,
1680 eng_context_clip_clip,
1681 eng_context_clip_unset,
1682 eng_context_clip_get,
1683 eng_context_mask_set,
1684 eng_context_mask_unset,
1685 eng_context_color_set,
1686 eng_context_color_get,
1687 eng_context_multiplier_set,
1688 eng_context_multiplier_unset,
1689 eng_context_multiplier_get,
1690 eng_context_cutout_add,
1691 eng_context_cutout_clear,
1692 eng_context_anti_alias_set,
1693 eng_context_anti_alias_get,
1694 eng_context_color_interpolation_set,
1695 eng_context_color_interpolation_get,
1696 eng_context_render_op_set,
1697 eng_context_render_op_get,
1698 /* rect draw funcs */
1700 /* line draw funcs */
1702 /* polygon draw funcs */
1703 eng_polygon_point_add,
1704 eng_polygon_points_clear,
1706 /* image draw funcs */
1708 eng_image_new_from_data,
1709 eng_image_new_from_copied_data,
1714 eng_image_dirty_region,
1717 eng_image_data_preload_request,
1718 eng_image_data_preload_cancel,
1719 eng_image_alpha_set,
1720 eng_image_alpha_get,
1721 eng_image_border_set,
1722 eng_image_border_get,
1724 eng_image_comment_get,
1725 eng_image_format_get,
1726 eng_image_colorspace_set,
1727 eng_image_colorspace_get,
1728 eng_image_can_region_get,
1729 eng_image_mask_create,
1730 eng_image_native_set,
1731 eng_image_native_get,
1732 /* image cache funcs */
1733 eng_image_cache_flush,
1734 eng_image_cache_set,
1735 eng_image_cache_get,
1736 /* font draw functions */
1738 eng_font_memory_load,
1740 eng_font_memory_add,
1742 eng_font_ascent_get,
1743 eng_font_descent_get,
1744 eng_font_max_ascent_get,
1745 eng_font_max_descent_get,
1746 eng_font_string_size_get,
1748 eng_font_h_advance_get,
1749 eng_font_v_advance_get,
1750 eng_font_char_coords_get,
1751 eng_font_char_at_coords_get,
1753 /* font cache functions */
1754 eng_font_cache_flush,
1757 /* font hinting functions */
1758 eng_font_hinting_set,
1759 eng_font_hinting_can_hint,
1760 eng_image_scale_hint_set,
1761 eng_image_scale_hint_get,
1762 /* more font draw functions */
1763 eng_font_last_up_to_pos,
1765 eng_image_map_surface_new,
1766 eng_image_map_surface_free,
1767 NULL, // eng_image_content_hint_set - software doesn't use it
1768 NULL, // eng_image_content_hint_get - software doesn't use it
1769 eng_font_pen_coords_get,
1770 eng_font_text_props_info_create,
1771 eng_font_right_inset_get,
1772 #if 0 // filtering disabled
1773 eng_image_draw_filtered,
1774 eng_image_filtered_get,
1775 eng_image_filtered_save,
1776 eng_image_filtered_free,
1778 NULL, // need software mesa for gl rendering <- gl_surface_create
1779 NULL, // need software mesa for gl rendering <- gl_surface_destroy
1780 NULL, // need software mesa for gl rendering <- gl_context_create
1781 NULL, // need software mesa for gl rendering <- gl_context_destroy
1782 NULL, // need software mesa for gl rendering <- gl_make_current
1783 NULL, // need software mesa for gl rendering <- gl_string_query
1784 NULL, // need software mesa for gl rendering <- gl_proc_address_get
1785 NULL, // need software mesa for gl rendering <- gl_native_surface_get
1786 NULL, // need software mesa for gl rendering <- gl_api_get
1787 eng_image_load_error_get,
1788 eng_font_run_font_end_get,
1789 eng_image_animated_get,
1790 eng_image_animated_frame_count_get,
1791 eng_image_animated_loop_type_get,
1792 eng_image_animated_loop_count_get,
1793 eng_image_animated_frame_duration_get,
1794 eng_image_animated_frame_set,
1796 /* FUTURE software generic calls go here */
1800 //----------------------------------------------------------------//
1804 //----------------------------------------------------------------//
1809 ERR("GL symbols missing!\n");
1815 //------------------------------------------------//
1816 // Use eglGetProcAddress
1817 #define FINDSYM(dst, sym, typ) \
1818 if (!dst) dst = (typeof(dst))dlsym(gl_lib_handle, sym); \
1821 ERR("Symbol not found %s\n", sym); \
1824 #define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
1826 //------------------------------------------------------//
1828 FINDSYM(_sym_OSMesaCreateContextExt, "OSMesaCreateContextExt", glsym_func_osm_ctx);
1829 FALLBAK(_sym_OSMesaCreateContextExt, glsym_func_void);
1831 FINDSYM(_sym_OSMesaDestroyContext, "OSMesaDestroyContext", glsym_func_void);
1832 FALLBAK(_sym_OSMesaDestroyContext, glsym_func_void);
1834 FINDSYM(_sym_OSMesaMakeCurrent, "OSMesaMakeCurrent", glsym_func_bool);
1835 FALLBAK(_sym_OSMesaMakeCurrent, glsym_func_void);
1837 FINDSYM(_sym_OSMesaPixelStore, "OSMesaPixelStore", glsym_func_void);
1838 FALLBAK(_sym_OSMesaPixelStore, glsym_func_void);
1840 FINDSYM(_sym_OSMesaGetProcAddress, "OSMesaGetProcAddress", glsym_func_eng_fn);
1841 FALLBAK(_sym_OSMesaGetProcAddress, glsym_func_void);
1852 //------------------------------------------------//
1853 #define FINDSYM(dst, sym, typ) \
1854 if (!dst) dst = (typeof(dst))dlsym(gl_lib_handle, sym); \
1855 if (!dst) DBG("Symbol not found %s\n", sym);
1856 #define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
1859 //------------------------------------------------------//
1861 FINDSYM(_sym_glActiveTexture, "glActiveTexture", glsym_func_void);
1862 FALLBAK(_sym_glActiveTexture, glsym_func_void);
1864 FINDSYM(_sym_glAttachShader, "glAttachShader", glsym_func_void);
1865 FALLBAK(_sym_glAttachShader, glsym_func_void);
1867 FINDSYM(_sym_glBindAttribLocation, "glBindAttribLocation", glsym_func_void);
1868 FALLBAK(_sym_glBindAttribLocation, glsym_func_void);
1870 FINDSYM(_sym_glBindBuffer, "glBindBuffer", glsym_func_void);
1871 FALLBAK(_sym_glBindBuffer, glsym_func_void);
1873 FINDSYM(_sym_glBindFramebuffer, "glBindFramebuffer", glsym_func_void);
1874 FALLBAK(_sym_glBindFramebuffer, glsym_func_void);
1876 FINDSYM(_sym_glBindRenderbuffer, "glBindRenderbuffer", glsym_func_void);
1877 FALLBAK(_sym_glBindRenderbuffer, glsym_func_void);
1879 FINDSYM(_sym_glBindTexture, "glBindTexture", glsym_func_void);
1880 FALLBAK(_sym_glBindTexture, glsym_func_void);
1882 FINDSYM(_sym_glBlendColor, "glBlendColor", glsym_func_void);
1883 FALLBAK(_sym_glBlendColor, glsym_func_void);
1885 FINDSYM(_sym_glBlendEquation, "glBlendEquation", glsym_func_void);
1886 FALLBAK(_sym_glBlendEquation, glsym_func_void);
1888 FINDSYM(_sym_glBlendEquationSeparate, "glBlendEquationSeparate", glsym_func_void);
1889 FALLBAK(_sym_glBlendEquationSeparate, glsym_func_void);
1891 FINDSYM(_sym_glBlendFunc, "glBlendFunc", glsym_func_void);
1892 FALLBAK(_sym_glBlendFunc, glsym_func_void);
1894 FINDSYM(_sym_glBlendFuncSeparate, "glBlendFuncSeparate", glsym_func_void);
1895 FALLBAK(_sym_glBlendFuncSeparate, glsym_func_void);
1897 FINDSYM(_sym_glBufferData, "glBufferData", glsym_func_void);
1898 FALLBAK(_sym_glBufferData, glsym_func_void);
1900 FINDSYM(_sym_glBufferSubData, "glBufferSubData", glsym_func_void);
1901 FALLBAK(_sym_glBufferSubData, glsym_func_void);
1903 FINDSYM(_sym_glCheckFramebufferStatus, "glCheckFramebufferStatus", glsym_func_uint);
1904 FALLBAK(_sym_glCheckFramebufferStatus, glsym_func_uint);
1906 FINDSYM(_sym_glClear, "glClear", glsym_func_void);
1907 FALLBAK(_sym_glClear, glsym_func_void);
1909 FINDSYM(_sym_glClearColor, "glClearColor", glsym_func_void);
1910 FALLBAK(_sym_glClearColor, glsym_func_void);
1912 FINDSYM(_sym_glClearDepthf, "glClearDepthf", glsym_func_void);
1913 FINDSYM(_sym_glClearDepthf, "glClearDepth", glsym_func_void);
1914 FALLBAK(_sym_glClearDepthf, glsym_func_void);
1916 FINDSYM(_sym_glClearStencil, "glClearStencil", glsym_func_void);
1917 FALLBAK(_sym_glClearStencil, glsym_func_void);
1919 FINDSYM(_sym_glColorMask, "glColorMask", glsym_func_void);
1920 FALLBAK(_sym_glColorMask, glsym_func_void);
1922 FINDSYM(_sym_glCompileShader, "glCompileShader", glsym_func_void);
1923 FALLBAK(_sym_glCompileShader, glsym_func_void);
1925 FINDSYM(_sym_glCompressedTexImage2D, "glCompressedTexImage2D", glsym_func_void);
1926 FALLBAK(_sym_glCompressedTexImage2D, glsym_func_void);
1928 FINDSYM(_sym_glCompressedTexSubImage2D, "glCompressedTexSubImage2D", glsym_func_void);
1929 FALLBAK(_sym_glCompressedTexSubImage2D, glsym_func_void);
1931 FINDSYM(_sym_glCopyTexImage2D, "glCopyTexImage2D", glsym_func_void);
1932 FALLBAK(_sym_glCopyTexImage2D, glsym_func_void);
1934 FINDSYM(_sym_glCopyTexSubImage2D, "glCopyTexSubImage2D", glsym_func_void);
1935 FALLBAK(_sym_glCopyTexSubImage2D, glsym_func_void);
1937 FINDSYM(_sym_glCreateProgram, "glCreateProgram", glsym_func_uint);
1938 FALLBAK(_sym_glCreateProgram, glsym_func_uint);
1940 FINDSYM(_sym_glCreateShader, "glCreateShader", glsym_func_uint);
1941 FALLBAK(_sym_glCreateShader, glsym_func_uint);
1943 FINDSYM(_sym_glCullFace, "glCullFace", glsym_func_void);
1944 FALLBAK(_sym_glCullFace, glsym_func_void);
1946 FINDSYM(_sym_glDeleteBuffers, "glDeleteBuffers", glsym_func_void);
1947 FALLBAK(_sym_glDeleteBuffers, glsym_func_void);
1949 FINDSYM(_sym_glDeleteFramebuffers, "glDeleteFramebuffers", glsym_func_void);
1950 FALLBAK(_sym_glDeleteFramebuffers, glsym_func_void);
1952 FINDSYM(_sym_glDeleteProgram, "glDeleteProgram", glsym_func_void);
1953 FALLBAK(_sym_glDeleteProgram, glsym_func_void);
1955 FINDSYM(_sym_glDeleteRenderbuffers, "glDeleteRenderbuffers", glsym_func_void);
1956 FALLBAK(_sym_glDeleteRenderbuffers, glsym_func_void);
1958 FINDSYM(_sym_glDeleteShader, "glDeleteShader", glsym_func_void);
1959 FALLBAK(_sym_glDeleteShader, glsym_func_void);
1961 FINDSYM(_sym_glDeleteTextures, "glDeleteTextures", glsym_func_void);
1962 FALLBAK(_sym_glDeleteTextures, glsym_func_void);
1964 FINDSYM(_sym_glDepthFunc, "glDepthFunc", glsym_func_void);
1965 FALLBAK(_sym_glDepthFunc, glsym_func_void);
1967 FINDSYM(_sym_glDepthMask, "glDepthMask", glsym_func_void);
1968 FALLBAK(_sym_glDepthMask, glsym_func_void);
1970 FINDSYM(_sym_glDepthRangef, "glDepthRangef", glsym_func_void);
1971 FINDSYM(_sym_glDepthRangef, "glDepthRange", glsym_func_void);
1972 FALLBAK(_sym_glDepthRangef, glsym_func_void);
1974 FINDSYM(_sym_glDetachShader, "glDetachShader", glsym_func_void);
1975 FALLBAK(_sym_glDetachShader, glsym_func_void);
1977 FINDSYM(_sym_glDisable, "glDisable", glsym_func_void);
1978 FALLBAK(_sym_glDisable, glsym_func_void);
1980 FINDSYM(_sym_glDisableVertexAttribArray, "glDisableVertexAttribArray", glsym_func_void);
1981 FALLBAK(_sym_glDisableVertexAttribArray, glsym_func_void);
1983 FINDSYM(_sym_glDrawArrays, "glDrawArrays", glsym_func_void);
1984 FALLBAK(_sym_glDrawArrays, glsym_func_void);
1986 FINDSYM(_sym_glDrawElements, "glDrawElements", glsym_func_void);
1987 FALLBAK(_sym_glDrawElements, glsym_func_void);
1989 FINDSYM(_sym_glEnable, "glEnable", glsym_func_void);
1990 FALLBAK(_sym_glEnable, glsym_func_void);
1992 FINDSYM(_sym_glEnableVertexAttribArray, "glEnableVertexAttribArray", glsym_func_void);
1993 FALLBAK(_sym_glEnableVertexAttribArray, glsym_func_void);
1995 FINDSYM(_sym_glFinish, "glFinish", glsym_func_void);
1996 FALLBAK(_sym_glFinish, glsym_func_void);
1998 FINDSYM(_sym_glFlush, "glFlush", glsym_func_void);
1999 FALLBAK(_sym_glFlush, glsym_func_void);
2001 FINDSYM(_sym_glFramebufferRenderbuffer, "glFramebufferRenderbuffer", glsym_func_void);
2002 FALLBAK(_sym_glFramebufferRenderbuffer, glsym_func_void);
2004 FINDSYM(_sym_glFramebufferTexture2D, "glFramebufferTexture2D", glsym_func_void);
2005 FALLBAK(_sym_glFramebufferTexture2D, glsym_func_void);
2007 FINDSYM(_sym_glFrontFace, "glFrontFace", glsym_func_void);
2008 FALLBAK(_sym_glFrontFace, glsym_func_void);
2010 FINDSYM(_sym_glGenBuffers, "glGenBuffers", glsym_func_void);
2011 FALLBAK(_sym_glGenBuffers, glsym_func_void);
2013 FINDSYM(_sym_glGenerateMipmap, "glGenerateMipmap", glsym_func_void);
2014 FALLBAK(_sym_glGenerateMipmap, glsym_func_void);
2016 FINDSYM(_sym_glGenFramebuffers, "glGenFramebuffers", glsym_func_void);
2017 FALLBAK(_sym_glGenFramebuffers, glsym_func_void);
2019 FINDSYM(_sym_glGenRenderbuffers, "glGenRenderbuffers", glsym_func_void);
2020 FALLBAK(_sym_glGenRenderbuffers, glsym_func_void);
2022 FINDSYM(_sym_glGenTextures, "glGenTextures", glsym_func_void);
2023 FALLBAK(_sym_glGenTextures, glsym_func_void);
2025 FINDSYM(_sym_glGetActiveAttrib, "glGetActiveAttrib", glsym_func_void);
2026 FALLBAK(_sym_glGetActiveAttrib, glsym_func_void);
2028 FINDSYM(_sym_glGetActiveUniform, "glGetActiveUniform", glsym_func_void);
2029 FALLBAK(_sym_glGetActiveUniform, glsym_func_void);
2031 FINDSYM(_sym_glGetAttachedShaders, "glGetAttachedShaders", glsym_func_void);
2032 FALLBAK(_sym_glGetAttachedShaders, glsym_func_void);
2034 FINDSYM(_sym_glGetAttribLocation, "glGetAttribLocation", glsym_func_int);
2035 FALLBAK(_sym_glGetAttribLocation, glsym_func_int);
2037 FINDSYM(_sym_glGetBooleanv, "glGetBooleanv", glsym_func_void);
2038 FALLBAK(_sym_glGetBooleanv, glsym_func_void);
2040 FINDSYM(_sym_glGetBufferParameteriv, "glGetBufferParameteriv", glsym_func_void);
2041 FALLBAK(_sym_glGetBufferParameteriv, glsym_func_void);
2043 FINDSYM(_sym_glGetError, "glGetError", glsym_func_uint);
2044 FALLBAK(_sym_glGetError, glsym_func_uint);
2046 FINDSYM(_sym_glGetFloatv, "glGetFloatv", glsym_func_void);
2047 FALLBAK(_sym_glGetFloatv, glsym_func_void);
2049 FINDSYM(_sym_glGetFramebufferAttachmentParameteriv, "glGetFramebufferAttachmentParameteriv", glsym_func_void);
2050 FALLBAK(_sym_glGetFramebufferAttachmentParameteriv, glsym_func_void);
2052 FINDSYM(_sym_glGetIntegerv, "glGetIntegerv", glsym_func_void);
2053 FALLBAK(_sym_glGetIntegerv, glsym_func_void);
2055 FINDSYM(_sym_glGetProgramiv, "glGetProgramiv", glsym_func_void);
2056 FALLBAK(_sym_glGetProgramiv, glsym_func_void);
2058 FINDSYM(_sym_glGetProgramInfoLog, "glGetProgramInfoLog", glsym_func_void);
2059 FALLBAK(_sym_glGetProgramInfoLog, glsym_func_void);
2061 FINDSYM(_sym_glGetRenderbufferParameteriv, "glGetRenderbufferParameteriv", glsym_func_void);
2062 FALLBAK(_sym_glGetRenderbufferParameteriv, glsym_func_void);
2064 FINDSYM(_sym_glGetShaderiv, "glGetShaderiv", glsym_func_void);
2065 FALLBAK(_sym_glGetShaderiv, glsym_func_void);
2067 FINDSYM(_sym_glGetShaderInfoLog, "glGetShaderInfoLog", glsym_func_void);
2068 FALLBAK(_sym_glGetShaderInfoLog, glsym_func_void);
2070 FINDSYM(_sym_glGetShaderPrecisionFormat, "glGetShaderPrecisionFormat", glsym_func_void);
2071 FALLBAK(_sym_glGetShaderPrecisionFormat, glsym_func_void);
2073 FINDSYM(_sym_glGetShaderSource, "glGetShaderSource", glsym_func_void);
2074 FALLBAK(_sym_glGetShaderSource, glsym_func_void);
2076 FINDSYM(_sym_glGetString, "glGetString", glsym_func_uchar_ptr);
2077 FALLBAK(_sym_glGetString, glsym_func_const_uchar_ptr);
2079 FINDSYM(_sym_glGetTexParameterfv, "glGetTexParameterfv", glsym_func_void);
2080 FALLBAK(_sym_glGetTexParameterfv, glsym_func_void);
2082 FINDSYM(_sym_glGetTexParameteriv, "glGetTexParameteriv", glsym_func_void);
2083 FALLBAK(_sym_glGetTexParameteriv, glsym_func_void);
2085 FINDSYM(_sym_glGetUniformfv, "glGetUniformfv", glsym_func_void);
2086 FALLBAK(_sym_glGetUniformfv, glsym_func_void);
2088 FINDSYM(_sym_glGetUniformiv, "glGetUniformiv", glsym_func_void);
2089 FALLBAK(_sym_glGetUniformiv, glsym_func_void);
2091 FINDSYM(_sym_glGetUniformLocation, "glGetUniformLocation", glsym_func_int);
2092 FALLBAK(_sym_glGetUniformLocation, glsym_func_int);
2094 FINDSYM(_sym_glGetVertexAttribfv, "glGetVertexAttribfv", glsym_func_void);
2095 FALLBAK(_sym_glGetVertexAttribfv, glsym_func_void);
2097 FINDSYM(_sym_glGetVertexAttribiv, "glGetVertexAttribiv", glsym_func_void);
2098 FALLBAK(_sym_glGetVertexAttribiv, glsym_func_void);
2100 FINDSYM(_sym_glGetVertexAttribPointerv, "glGetVertexAttribPointerv", glsym_func_void);
2101 FALLBAK(_sym_glGetVertexAttribPointerv, glsym_func_void);
2103 FINDSYM(_sym_glHint, "glHint", glsym_func_void);
2104 FALLBAK(_sym_glHint, glsym_func_void);
2106 FINDSYM(_sym_glIsBuffer, "glIsBuffer", glsym_func_uchar);
2107 FALLBAK(_sym_glIsBuffer, glsym_func_uchar);
2109 FINDSYM(_sym_glIsEnabled, "glIsEnabled", glsym_func_uchar);
2110 FALLBAK(_sym_glIsEnabled, glsym_func_uchar);
2112 FINDSYM(_sym_glIsFramebuffer, "glIsFramebuffer", glsym_func_uchar);
2113 FALLBAK(_sym_glIsFramebuffer, glsym_func_uchar);
2115 FINDSYM(_sym_glIsProgram, "glIsProgram", glsym_func_uchar);
2116 FALLBAK(_sym_glIsProgram, glsym_func_uchar);
2118 FINDSYM(_sym_glIsRenderbuffer, "glIsRenderbuffer", glsym_func_uchar);
2119 FALLBAK(_sym_glIsRenderbuffer, glsym_func_uchar);
2121 FINDSYM(_sym_glIsShader, "glIsShader", glsym_func_uchar);
2122 FALLBAK(_sym_glIsShader, glsym_func_uchar);
2124 FINDSYM(_sym_glIsTexture, "glIsTexture", glsym_func_uchar);
2125 FALLBAK(_sym_glIsTexture, glsym_func_uchar);
2127 FINDSYM(_sym_glLineWidth, "glLineWidth", glsym_func_void);
2128 FALLBAK(_sym_glLineWidth, glsym_func_void);
2130 FINDSYM(_sym_glLinkProgram, "glLinkProgram", glsym_func_void);
2131 FALLBAK(_sym_glLinkProgram, glsym_func_void);
2133 FINDSYM(_sym_glPixelStorei, "glPixelStorei", glsym_func_void);
2134 FALLBAK(_sym_glPixelStorei, glsym_func_void);
2136 FINDSYM(_sym_glPolygonOffset, "glPolygonOffset", glsym_func_void);
2137 FALLBAK(_sym_glPolygonOffset, glsym_func_void);
2139 FINDSYM(_sym_glReadPixels, "glReadPixels", glsym_func_void);
2140 FALLBAK(_sym_glReadPixels, glsym_func_void);
2142 FINDSYM(_sym_glReleaseShaderCompiler, "glReleaseShaderCompiler", glsym_func_void);
2143 FALLBAK(_sym_glReleaseShaderCompiler, glsym_func_void);
2145 FINDSYM(_sym_glRenderbufferStorage, "glRenderbufferStorage", glsym_func_void);
2146 FALLBAK(_sym_glRenderbufferStorage, glsym_func_void);
2148 FINDSYM(_sym_glSampleCoverage, "glSampleCoverage", glsym_func_void);
2149 FALLBAK(_sym_glSampleCoverage, glsym_func_void);
2151 FINDSYM(_sym_glScissor, "glScissor", glsym_func_void);
2152 FALLBAK(_sym_glScissor, glsym_func_void);
2154 FINDSYM(_sym_glShaderBinary, "glShaderBinary", glsym_func_void);
2155 FALLBAK(_sym_glShaderBinary, glsym_func_void);
2157 FINDSYM(_sym_glShaderSource, "glShaderSource", glsym_func_void);
2158 FALLBAK(_sym_glShaderSource, glsym_func_void);
2160 FINDSYM(_sym_glStencilFunc, "glStencilFunc", glsym_func_void);
2161 FALLBAK(_sym_glStencilFunc, glsym_func_void);
2163 FINDSYM(_sym_glStencilFuncSeparate, "glStencilFuncSeparate", glsym_func_void);
2164 FALLBAK(_sym_glStencilFuncSeparate, glsym_func_void);
2166 FINDSYM(_sym_glStencilMask, "glStencilMask", glsym_func_void);
2167 FALLBAK(_sym_glStencilMask, glsym_func_void);
2169 FINDSYM(_sym_glStencilMaskSeparate, "glStencilMaskSeparate", glsym_func_void);
2170 FALLBAK(_sym_glStencilMaskSeparate, glsym_func_void);
2172 FINDSYM(_sym_glStencilOp, "glStencilOp", glsym_func_void);
2173 FALLBAK(_sym_glStencilOp, glsym_func_void);
2175 FINDSYM(_sym_glStencilOpSeparate, "glStencilOpSeparate", glsym_func_void);
2176 FALLBAK(_sym_glStencilOpSeparate, glsym_func_void);
2178 FINDSYM(_sym_glTexImage2D, "glTexImage2D", glsym_func_void);
2179 FALLBAK(_sym_glTexImage2D, glsym_func_void);
2181 FINDSYM(_sym_glTexParameterf, "glTexParameterf", glsym_func_void);
2182 FALLBAK(_sym_glTexParameterf, glsym_func_void);
2184 FINDSYM(_sym_glTexParameterfv, "glTexParameterfv", glsym_func_void);
2185 FALLBAK(_sym_glTexParameterfv, glsym_func_void);
2187 FINDSYM(_sym_glTexParameteri, "glTexParameteri", glsym_func_void);
2188 FALLBAK(_sym_glTexParameteri, glsym_func_void);
2190 FINDSYM(_sym_glTexParameteriv, "glTexParameteriv", glsym_func_void);
2191 FALLBAK(_sym_glTexParameteriv, glsym_func_void);
2193 FINDSYM(_sym_glTexSubImage2D, "glTexSubImage2D", glsym_func_void);
2194 FALLBAK(_sym_glTexSubImage2D, glsym_func_void);
2196 FINDSYM(_sym_glUniform1f, "glUniform1f", glsym_func_void);
2197 FALLBAK(_sym_glUniform1f, glsym_func_void);
2199 FINDSYM(_sym_glUniform1fv, "glUniform1fv", glsym_func_void);
2200 FALLBAK(_sym_glUniform1fv, glsym_func_void);
2202 FINDSYM(_sym_glUniform1i, "glUniform1i", glsym_func_void);
2203 FALLBAK(_sym_glUniform1i, glsym_func_void);
2205 FINDSYM(_sym_glUniform1iv, "glUniform1iv", glsym_func_void);
2206 FALLBAK(_sym_glUniform1iv, glsym_func_void);
2208 FINDSYM(_sym_glUniform2f, "glUniform2f", glsym_func_void);
2209 FALLBAK(_sym_glUniform2f, glsym_func_void);
2211 FINDSYM(_sym_glUniform2fv, "glUniform2fv", glsym_func_void);
2212 FALLBAK(_sym_glUniform2fv, glsym_func_void);
2214 FINDSYM(_sym_glUniform2i, "glUniform2i", glsym_func_void);
2215 FALLBAK(_sym_glUniform2i, glsym_func_void);
2217 FINDSYM(_sym_glUniform2iv, "glUniform2iv", glsym_func_void);
2218 FALLBAK(_sym_glUniform2iv, glsym_func_void);
2220 FINDSYM(_sym_glUniform3f, "glUniform3f", glsym_func_void);
2221 FALLBAK(_sym_glUniform3f, glsym_func_void);
2223 FINDSYM(_sym_glUniform3fv, "glUniform3fv", glsym_func_void);
2224 FALLBAK(_sym_glUniform3fv, glsym_func_void);
2226 FINDSYM(_sym_glUniform3i, "glUniform3i", glsym_func_void);
2227 FALLBAK(_sym_glUniform3i, glsym_func_void);
2229 FINDSYM(_sym_glUniform3iv, "glUniform3iv", glsym_func_void);
2230 FALLBAK(_sym_glUniform3iv, glsym_func_void);
2232 FINDSYM(_sym_glUniform4f, "glUniform4f", glsym_func_void);
2233 FALLBAK(_sym_glUniform4f, glsym_func_void);
2235 FINDSYM(_sym_glUniform4fv, "glUniform4fv", glsym_func_void);
2236 FALLBAK(_sym_glUniform4fv, glsym_func_void);
2238 FINDSYM(_sym_glUniform4i, "glUniform4i", glsym_func_void);
2239 FALLBAK(_sym_glUniform4i, glsym_func_void);
2241 FINDSYM(_sym_glUniform4iv, "glUniform4iv", glsym_func_void);
2242 FALLBAK(_sym_glUniform4iv, glsym_func_void);
2244 FINDSYM(_sym_glUniformMatrix2fv, "glUniformMatrix2fv", glsym_func_void);
2245 FALLBAK(_sym_glUniformMatrix2fv, glsym_func_void);
2247 FINDSYM(_sym_glUniformMatrix3fv, "glUniformMatrix3fv", glsym_func_void);
2248 FALLBAK(_sym_glUniformMatrix3fv, glsym_func_void);
2250 FINDSYM(_sym_glUniformMatrix4fv, "glUniformMatrix4fv", glsym_func_void);
2251 FALLBAK(_sym_glUniformMatrix4fv, glsym_func_void);
2253 FINDSYM(_sym_glUseProgram, "glUseProgram", glsym_func_void);
2254 FALLBAK(_sym_glUseProgram, glsym_func_void);
2256 FINDSYM(_sym_glValidateProgram, "glValidateProgram", glsym_func_void);
2257 FALLBAK(_sym_glValidateProgram, glsym_func_void);
2259 FINDSYM(_sym_glVertexAttrib1f, "glVertexAttrib1f", glsym_func_void);
2260 FALLBAK(_sym_glVertexAttrib1f, glsym_func_void);
2262 FINDSYM(_sym_glVertexAttrib1fv, "glVertexAttrib1fv", glsym_func_void);
2263 FALLBAK(_sym_glVertexAttrib1fv, glsym_func_void);
2265 FINDSYM(_sym_glVertexAttrib2f, "glVertexAttrib2f", glsym_func_void);
2266 FALLBAK(_sym_glVertexAttrib2f, glsym_func_void);
2268 FINDSYM(_sym_glVertexAttrib2fv, "glVertexAttrib2fv", glsym_func_void);
2269 FALLBAK(_sym_glVertexAttrib2fv, glsym_func_void);
2271 FINDSYM(_sym_glVertexAttrib3f, "glVertexAttrib3f", glsym_func_void);
2272 FALLBAK(_sym_glVertexAttrib3f, glsym_func_void);
2274 FINDSYM(_sym_glVertexAttrib3fv, "glVertexAttrib3fv", glsym_func_void);
2275 FALLBAK(_sym_glVertexAttrib3fv, glsym_func_void);
2277 FINDSYM(_sym_glVertexAttrib4f, "glVertexAttrib4f", glsym_func_void);
2278 FALLBAK(_sym_glVertexAttrib4f, glsym_func_void);
2280 FINDSYM(_sym_glVertexAttrib4fv, "glVertexAttrib4fv", glsym_func_void);
2281 FALLBAK(_sym_glVertexAttrib4fv, glsym_func_void);
2283 FINDSYM(_sym_glVertexAttribPointer, "glVertexAttribPointer", glsym_func_void);
2284 FALLBAK(_sym_glVertexAttribPointer, glsym_func_void);
2286 FINDSYM(_sym_glViewport, "glViewport", glsym_func_void);
2287 FALLBAK(_sym_glViewport, glsym_func_void);
2292 // Checking to see if this function exists is a poor but reasonable way to
2293 // check if it's gles but it works for now
2294 if (_sym_glGetShaderPrecisionFormat != (typeof(_sym_glGetShaderPrecisionFormat))sym_missing )
2296 DBG("GL Library is GLES.");
2303 //--------------------------------------------------------------//
2304 // Wrapped GL APIs to handle desktop compatibility
2306 // Stripping precision code from GLES shader for desktop compatibility
2307 // Code adopted from Meego GL code. Temporary Fix.
2309 opengl_strtok(const char *s, int *n, char **saveptr, char *prevbuf)
2315 static const char *delim = " \t\n\r/";
2317 if (prevbuf) free(prevbuf);
2320 *saveptr = (char *)s;
2323 if (!(*saveptr) || !(*n))
2328 for (; *n && strchr(delim, *s); s++, (*n)--)
2330 if (*s == '/' && *n > 1)
2338 while (*n > 1 && s[1] != '\n' && s[1] != '\r');
2340 else if (s[1] == '*')
2346 while (*n > 2 && (s[1] != '*' || s[2] != '/'));
2353 for (; *n && *s && !strchr(delim, *s); s++, (*n)--);
2354 if (*n > 0) s++, (*n)--;
2356 *saveptr = (char *)s;
2359 ret = malloc(retlen + 1);
2364 if (*start == '/' && retlen > 1)
2366 if (start[1] == '/')
2372 while (retlen > 1 && start[1] != '\n' && start[1] != '\r');
2376 else if (start[1] == '*')
2382 while (retlen > 2 && (start[1] != '*' || start[2] != '/'));
2383 start += 3, retlen -= 3;
2387 *(p++) = *(start++), retlen--;
2395 patch_gles_shader(const char *source, int length, int *patched_len)
2397 char *saveptr = NULL;
2401 if (!length) length = strlen(source);
2404 int patched_size = length;
2405 char *patched = malloc(patched_size + 1);
2407 if (!patched) return NULL;
2409 p = (char *)opengl_strtok(source, &length, &saveptr, NULL);
2410 for (; p; p = (char *)opengl_strtok(0, &length, &saveptr, p))
2412 if (!strncmp(p, "lowp", 4) || !strncmp(p, "mediump", 7) || !strncmp(p, "highp", 5))
2416 else if (!strncmp(p, "precision", 9))
2418 while ((p = (char *)opengl_strtok(0, &length, &saveptr, p)) && !strchr(p, ';'));
2422 if (!strncmp(p, "gl_MaxVertexUniformVectors", 26))
2424 p = "(gl_MaxVertexUniformComponents / 4)";
2426 else if (!strncmp(p, "gl_MaxFragmentUniformVectors", 28))
2428 p = "(gl_MaxFragmentUniformComponents / 4)";
2430 else if (!strncmp(p, "gl_MaxVaryingVectors", 20))
2432 p = "(gl_MaxVaryingFloats / 4)";
2435 int new_len = strlen(p);
2436 if (*patched_len + new_len > patched_size)
2439 patched = realloc(patched, patched_size + 1);
2445 memcpy(patched + *patched_len, p, new_len);
2446 *patched_len += new_len;
2450 patched[*patched_len] = 0;
2451 /* check that we don't leave dummy preprocessor lines */
2452 for (sp = patched; *sp;)
2454 for (; *sp == ' ' || *sp == '\t'; sp++);
2455 if (!strncmp(sp, "#define", 7))
2457 for (p = sp + 7; *p == ' ' || *p == '\t'; p++);
2458 if (*p == '\n' || *p == '\r' || *p == '/')
2460 memset(sp, 0x20, 7);
2463 for (; *sp && *sp != '\n' && *sp != '\r'; sp++);
2464 for (; *sp == '\n' || *sp == '\r'; sp++);
2470 evgl_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
2474 char **s = malloc(count * sizeof(char*));
2475 GLint *l = malloc(count * sizeof(GLint));
2477 memset(s, 0, count * sizeof(char*));
2478 memset(l, 0, count * sizeof(GLint));
2480 for (i = 0; i < count; ++i)
2486 len = string[i] ? strlen(string[i]) : 0;
2489 len = string[i] ? strlen(string[i]) : 0;
2493 s[i] = patch_gles_shader(string[i], len, &l[i]);
2501 DBG("Patching Shader Failed.");
2512 _sym_glShaderSource(shader, count, (const char **)s, l);
2522 evgl_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
2526 range[0] = -126; // floor(log2(FLT_MIN))
2527 range[1] = 127; // floor(log2(FLT_MAX))
2531 precision[0] = 24; // floor(-log2((1.0/16777218.0)));
2534 shadertype = precisiontype = 0;
2538 evgl_glReleaseShaderCompiler(void)
2540 DBG("Not supported in Desktop GL");
2545 evgl_glShaderBinary(GLsizei n __UNUSED__, const GLuint* shaders __UNUSED__, GLenum binaryformat __UNUSED__, const void* binary __UNUSED__, GLsizei length __UNUSED__)
2547 // FIXME: need to dlsym/getprocaddress for this
2548 DBG("Not supported in Desktop GL");
2550 //n = binaryformat = length = 0;
2551 //shaders = binary = 0;
2554 //--------------------------------------------------------------//
2559 override_gl_apis(Evas_GL_API *api)
2562 api->version = EVAS_GL_API_VERSION;
2564 #define ORD(f) EVAS_API_OVERRIDE(f, api, _sym_)
2566 ORD(glActiveTexture);
2567 ORD(glAttachShader);
2568 ORD(glBindAttribLocation);
2572 ORD(glBlendEquation);
2573 ORD(glBlendEquationSeparate);
2575 ORD(glBlendFuncSeparate);
2577 ORD(glBufferSubData);
2578 ORD(glCheckFramebufferStatus);
2582 ORD(glClearStencil);
2584 ORD(glCompileShader);
2585 ORD(glCompressedTexImage2D);
2586 ORD(glCompressedTexSubImage2D);
2587 ORD(glCopyTexImage2D);
2588 ORD(glCopyTexSubImage2D);
2589 ORD(glCreateProgram);
2590 ORD(glCreateShader);
2592 ORD(glDeleteBuffers);
2593 ORD(glDeleteFramebuffers);
2594 ORD(glDeleteProgram);
2595 ORD(glDeleteRenderbuffers);
2596 ORD(glDeleteShader);
2597 ORD(glDeleteTextures);
2601 ORD(glDetachShader);
2603 ORD(glDisableVertexAttribArray);
2605 ORD(glDrawElements);
2607 ORD(glEnableVertexAttribArray);
2610 ORD(glFramebufferRenderbuffer);
2611 ORD(glFramebufferTexture2D);
2614 ORD(glGenerateMipmap);
2615 ORD(glGenFramebuffers);
2616 ORD(glGenRenderbuffers);
2618 ORD(glGetActiveAttrib);
2619 ORD(glGetActiveUniform);
2620 ORD(glGetAttachedShaders);
2621 ORD(glGetAttribLocation);
2623 ORD(glGetBufferParameteriv);
2626 ORD(glGetFramebufferAttachmentParameteriv);
2628 ORD(glGetProgramiv);
2629 ORD(glGetProgramInfoLog);
2630 ORD(glGetRenderbufferParameteriv);
2632 ORD(glGetShaderInfoLog);
2633 ORD(glGetShaderPrecisionFormat);
2634 ORD(glGetShaderSource);
2635 ORD(glGetString); // FIXME
2636 ORD(glGetTexParameterfv);
2637 ORD(glGetTexParameteriv);
2638 ORD(glGetUniformfv);
2639 ORD(glGetUniformiv);
2640 ORD(glGetUniformLocation);
2641 ORD(glGetVertexAttribfv);
2642 ORD(glGetVertexAttribiv);
2643 ORD(glGetVertexAttribPointerv);
2647 ORD(glIsFramebuffer);
2649 ORD(glIsRenderbuffer);
2655 ORD(glPolygonOffset);
2657 ORD(glReleaseShaderCompiler);
2658 ORD(glRenderbufferStorage);
2659 ORD(glSampleCoverage);
2661 ORD(glShaderBinary);
2662 ORD(glShaderSource);
2664 ORD(glStencilFuncSeparate);
2666 ORD(glStencilMaskSeparate);
2668 ORD(glStencilOpSeparate);
2670 ORD(glTexParameterf);
2671 ORD(glTexParameterfv);
2672 ORD(glTexParameteri);
2673 ORD(glTexParameteriv);
2674 ORD(glTexSubImage2D);
2691 ORD(glUniformMatrix2fv);
2692 ORD(glUniformMatrix3fv);
2693 ORD(glUniformMatrix4fv);
2695 ORD(glValidateProgram);
2696 ORD(glVertexAttrib1f);
2697 ORD(glVertexAttrib1fv);
2698 ORD(glVertexAttrib2f);
2699 ORD(glVertexAttrib2fv);
2700 ORD(glVertexAttrib3f);
2701 ORD(glVertexAttrib3fv);
2702 ORD(glVertexAttrib4f);
2703 ORD(glVertexAttrib4fv);
2704 ORD(glVertexAttribPointer);
2708 #define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, evgl_)
2709 if (!gl_lib_is_gles)
2711 // Override functions wrapped by Evas_GL
2712 // GLES2.0 API compat on top of desktop gl
2713 ORD(glGetShaderPrecisionFormat);
2714 ORD(glReleaseShaderCompiler);
2715 ORD(glShaderBinary);
2718 ORD(glShaderSource); // Do precision stripping in both cases
2723 //-------------------------------------------//
2729 gl_lib_handle = dlopen("libOSMesa.so.1", RTLD_NOW);
2730 if (!gl_lib_handle) gl_lib_handle = dlopen("libOSMesa.so", RTLD_NOW);
2733 DBG("Unable to open libOSMesa: %s", dlerror());
2737 //------------------------------------------------//
2738 if (!glue_sym_init()) return 0;
2739 if (!gl_sym_init()) return 0;
2741 override_gl_apis(&gl_funcs);
2753 DBG("Initializing Software OpenGL APIs...\n");
2756 DBG("Unable to support EvasGL in this engine module. Install OSMesa to get it running");
2759 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
2760 ORD(gl_surface_create);
2761 ORD(gl_surface_destroy);
2762 ORD(gl_context_create);
2763 ORD(gl_context_destroy);
2764 ORD(gl_make_current);
2765 ORD(gl_string_query); // FIXME: Need to implement
2766 ORD(gl_proc_address_get); // FIXME: Need to implement
2767 ORD(gl_native_surface_get);
2777 ** MODULE ACCESSIBLE API API
2783 module_open(Evas_Module *em)
2786 _evas_soft_gen_log_dom = eina_log_domain_register
2787 ("evas-software_generic", EVAS_DEFAULT_LOG_COLOR);
2788 if(_evas_soft_gen_log_dom<0)
2790 EINA_LOG_ERR("Can not create a module log domain.");
2796 em->functions = (void *)(&func);
2797 cpunum = eina_cpu_count();
2802 module_close(Evas_Module *em __UNUSED__)
2804 eina_log_domain_unregister(_evas_soft_gen_log_dom);
2807 static Evas_Module_Api evas_modapi =
2809 EVAS_MODULE_API_VERSION,
2818 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_generic);
2820 #ifndef EVAS_STATIC_BUILD_SOFTWARE_GENERIC
2821 EVAS_EINA_MODULE_DEFINE(engine, software_generic);