1 #include "evas_common.h" /* Also includes international specific stuff */
2 #include "evas_private.h"
4 #include "evas_cs2_private.h"
8 # include <dlfcn.h> /* dlopen,dlclose,etc */
11 # define EVAS_GL_NO_GL_H_CHECK 1
15 # warning software_generic will not be able to have Evas_GL API.
19 //----------------------------------//
22 #define OSMESA_MAJOR_VERSION 6
23 #define OSMESA_MINOR_VERSION 5
24 #define OSMESA_PATCH_VERSION 0
27 * Values for the format parameter of OSMesaCreateContext()
30 #define OSMESA_COLOR_INDEX GL_COLOR_INDEX
31 #define OSMESA_RGBA GL_RGBA
32 #define OSMESA_BGRA 0x1
33 #define OSMESA_ARGB 0x2
34 #define OSMESA_RGB GL_RGB
35 #define OSMESA_BGR 0x4
36 #define OSMESA_RGB_565 0x5
40 * OSMesaPixelStore() parameters:
43 #define OSMESA_ROW_LENGTH 0x10
44 #define OSMESA_Y_UP 0x11
48 * Accepted by OSMesaGetIntegerv:
50 #define OSMESA_WIDTH 0x20
51 #define OSMESA_HEIGHT 0x21
52 #define OSMESA_FORMAT 0x22
53 #define OSMESA_TYPE 0x23
54 #define OSMESA_MAX_WIDTH 0x24 /* new in 4.0 */
55 #define OSMESA_MAX_HEIGHT 0x25 /* new in 4.0 */
58 typedef void (*OSMESAproc)();
59 typedef struct osmesa_context *OSMesaContext;
62 typedef struct _Render_Engine_GL_Surface Render_Engine_GL_Surface;
63 typedef struct _Render_Engine_GL_Context Render_Engine_GL_Context;
65 struct _Render_Engine_GL_Surface
73 int internal_cpp; // Component per pixel. ie. RGB = 3
81 Render_Engine_GL_Context *current_ctx;
85 struct _Render_Engine_GL_Context
89 OSMesaContext context;
91 Render_Engine_GL_Context *share_ctx;
93 Render_Engine_GL_Surface *current_sfc;
96 //------------------------------------------------------//
97 typedef void (*_eng_fn) (void );
98 typedef _eng_fn (*glsym_func_eng_fn) ();
99 typedef void (*glsym_func_void) ();
100 typedef unsigned int (*glsym_func_uint) ();
101 typedef int (*glsym_func_int) ();
102 typedef unsigned char (*glsym_func_uchar) ();
103 typedef unsigned char *(*glsym_func_uchar_ptr) ();
104 typedef const unsigned char *(*glsym_func_const_uchar_ptr) ();
105 typedef char const *(*glsym_func_char_const_ptr) ();
106 typedef GLboolean (*glsym_func_bool) ();
107 typedef OSMesaContext (*glsym_func_osm_ctx) ();
108 //------------------------------------------------------//
110 /* Function table for GL APIs */
111 static Evas_GL_API gl_funcs;
112 static void *gl_lib_handle;
113 static int gl_lib_is_gles = 0;
114 static Evas_GL_API gl_funcs;
116 //------------------------------------------------------//
118 static OSMesaContext (*_sym_OSMesaCreateContextExt) (GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, OSMesaContext sharelist) = NULL;
119 static void (*_sym_OSMesaDestroyContext) (OSMesaContext ctx) = NULL;
120 static GLboolean (*_sym_OSMesaMakeCurrent) (OSMesaContext ctx, void *buffer, GLenum type, GLsizei width, GLsizei height) = NULL;
121 static void (*_sym_OSMesaPixelStore) (GLint pname, GLint value) = NULL;
122 static OSMESAproc (*_sym_OSMesaGetProcAddress) (const char *funcName);
125 //------------------------------------------------------//
127 static void (*_sym_glActiveTexture) (GLenum texture) = NULL;
128 static void (*_sym_glAttachShader) (GLuint program, GLuint shader) = NULL;
129 static void (*_sym_glBindAttribLocation) (GLuint program, GLuint index, const char* name) = NULL;
130 static void (*_sym_glBindBuffer) (GLenum target, GLuint buffer) = NULL;
131 static void (*_sym_glBindFramebuffer) (GLenum target, GLuint framebuffer) = NULL;
132 static void (*_sym_glBindRenderbuffer) (GLenum target, GLuint renderbuffer) = NULL;
133 static void (*_sym_glBindTexture) (GLenum target, GLuint texture) = NULL;
134 static void (*_sym_glBlendColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = NULL;
135 static void (*_sym_glBlendEquation) (GLenum mode) = NULL;
136 static void (*_sym_glBlendEquationSeparate) (GLenum modeRGB, GLenum modeAlpha) = NULL;
137 static void (*_sym_glBlendFunc) (GLenum sfactor, GLenum dfactor) = NULL;
138 static void (*_sym_glBlendFuncSeparate) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) = NULL;
139 static void (*_sym_glBufferData) (GLenum target, GLsizeiptr size, const void* data, GLenum usage) = NULL;
140 static void (*_sym_glBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, const void* data) = NULL;
141 static GLenum (*_sym_glCheckFramebufferStatus) (GLenum target) = NULL;
142 static void (*_sym_glClear) (GLbitfield mask) = NULL;
143 static void (*_sym_glClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = NULL;
144 static void (*_sym_glClearDepthf) (GLclampf depth) = NULL;
145 static void (*_sym_glClearStencil) (GLint s) = NULL;
146 static void (*_sym_glColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) = NULL;
147 static void (*_sym_glCompileShader) (GLuint shader) = NULL;
148 static void (*_sym_glCompressedTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) = NULL;
149 static void (*_sym_glCompressedTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) = NULL;
150 static void (*_sym_glCopyTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = NULL;
151 static void (*_sym_glCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
152 static GLuint (*_sym_glCreateProgram) (void) = NULL;
153 static GLuint (*_sym_glCreateShader) (GLenum type) = NULL;
154 static void (*_sym_glCullFace) (GLenum mode) = NULL;
155 static void (*_sym_glDeleteBuffers) (GLsizei n, const GLuint* buffers) = NULL;
156 static void (*_sym_glDeleteFramebuffers) (GLsizei n, const GLuint* framebuffers) = NULL;
157 static void (*_sym_glDeleteProgram) (GLuint program) = NULL;
158 static void (*_sym_glDeleteRenderbuffers) (GLsizei n, const GLuint* renderbuffers) = NULL;
159 static void (*_sym_glDeleteShader) (GLuint shader) = NULL;
160 static void (*_sym_glDeleteTextures) (GLsizei n, const GLuint* textures) = NULL;
161 static void (*_sym_glDepthFunc) (GLenum func) = NULL;
162 static void (*_sym_glDepthMask) (GLboolean flag) = NULL;
163 static void (*_sym_glDepthRangef) (GLclampf zNear, GLclampf zFar) = NULL;
164 static void (*_sym_glDetachShader) (GLuint program, GLuint shader) = NULL;
165 static void (*_sym_glDisable) (GLenum cap) = NULL;
166 static void (*_sym_glDisableVertexAttribArray) (GLuint index) = NULL;
167 static void (*_sym_glDrawArrays) (GLenum mode, GLint first, GLsizei count) = NULL;
168 static void (*_sym_glDrawElements) (GLenum mode, GLsizei count, GLenum type, const void* indices) = NULL;
169 static void (*_sym_glEnable) (GLenum cap) = NULL;
170 static void (*_sym_glEnableVertexAttribArray) (GLuint index) = NULL;
171 static void (*_sym_glFinish) (void) = NULL;
172 static void (*_sym_glFlush) (void) = NULL;
173 static void (*_sym_glFramebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL;
174 static void (*_sym_glFramebufferTexture2D) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL;
175 static void (*_sym_glFrontFace) (GLenum mode) = NULL;
176 static void (*_sym_glGenBuffers) (GLsizei n, GLuint* buffers) = NULL;
177 static void (*_sym_glGenerateMipmap) (GLenum target) = NULL;
178 static void (*_sym_glGenFramebuffers) (GLsizei n, GLuint* framebuffers) = NULL;
179 static void (*_sym_glGenRenderbuffers) (GLsizei n, GLuint* renderbuffers) = NULL;
180 static void (*_sym_glGenTextures) (GLsizei n, GLuint* textures) = NULL;
181 static void (*_sym_glGetActiveAttrib) (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = NULL;
182 static void (*_sym_glGetActiveUniform) (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = NULL;
183 static void (*_sym_glGetAttachedShaders) (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) = NULL;
184 static int (*_sym_glGetAttribLocation) (GLuint program, const char* name) = NULL;
185 static void (*_sym_glGetBooleanv) (GLenum pname, GLboolean* params) = NULL;
186 static void (*_sym_glGetBufferParameteriv) (GLenum target, GLenum pname, GLint* params) = NULL;
187 static GLenum (*_sym_glGetError) (void) = NULL;
188 static void (*_sym_glGetFloatv) (GLenum pname, GLfloat* params) = NULL;
189 static void (*_sym_glGetFramebufferAttachmentParameteriv) (GLenum target, GLenum attachment, GLenum pname, GLint* params) = NULL;
190 static void (*_sym_glGetIntegerv) (GLenum pname, GLint* params) = NULL;
191 static void (*_sym_glGetProgramiv) (GLuint program, GLenum pname, GLint* params) = NULL;
192 static void (*_sym_glGetProgramInfoLog) (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) = NULL;
193 static void (*_sym_glGetRenderbufferParameteriv) (GLenum target, GLenum pname, GLint* params) = NULL;
194 static void (*_sym_glGetShaderiv) (GLuint shader, GLenum pname, GLint* params) = NULL;
195 static void (*_sym_glGetShaderInfoLog) (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) = NULL;
196 static void (*_sym_glGetShaderPrecisionFormat) (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) = NULL;
197 static void (*_sym_glGetShaderSource) (GLuint shader, GLsizei bufsize, GLsizei* length, char* source) = NULL;
198 static const GLubyte *(*_sym_glGetString) (GLenum name) = NULL;
199 static void (*_sym_glGetTexParameterfv) (GLenum target, GLenum pname, GLfloat* params) = NULL;
200 static void (*_sym_glGetTexParameteriv) (GLenum target, GLenum pname, GLint* params) = NULL;
201 static void (*_sym_glGetUniformfv) (GLuint program, GLint location, GLfloat* params) = NULL;
202 static void (*_sym_glGetUniformiv) (GLuint program, GLint location, GLint* params) = NULL;
203 static int (*_sym_glGetUniformLocation) (GLuint program, const char* name) = NULL;
204 static void (*_sym_glGetVertexAttribfv) (GLuint index, GLenum pname, GLfloat* params) = NULL;
205 static void (*_sym_glGetVertexAttribiv) (GLuint index, GLenum pname, GLint* params) = NULL;
206 static void (*_sym_glGetVertexAttribPointerv) (GLuint index, GLenum pname, void** pointer) = NULL;
207 static void (*_sym_glHint) (GLenum target, GLenum mode) = NULL;
208 static GLboolean (*_sym_glIsBuffer) (GLuint buffer) = NULL;
209 static GLboolean (*_sym_glIsEnabled) (GLenum cap) = NULL;
210 static GLboolean (*_sym_glIsFramebuffer) (GLuint framebuffer) = NULL;
211 static GLboolean (*_sym_glIsProgram) (GLuint program) = NULL;
212 static GLboolean (*_sym_glIsRenderbuffer) (GLuint renderbuffer) = NULL;
213 static GLboolean (*_sym_glIsShader) (GLuint shader) = NULL;
214 static GLboolean (*_sym_glIsTexture) (GLuint texture) = NULL;
215 static void (*_sym_glLineWidth) (GLfloat width) = NULL;
216 static void (*_sym_glLinkProgram) (GLuint program) = NULL;
217 static void (*_sym_glPixelStorei) (GLenum pname, GLint param) = NULL;
218 static void (*_sym_glPolygonOffset) (GLfloat factor, GLfloat units) = NULL;
219 static void (*_sym_glReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) = NULL;
220 static void (*_sym_glReleaseShaderCompiler) (void) = NULL;
221 static void (*_sym_glRenderbufferStorage) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL;
222 static void (*_sym_glSampleCoverage) (GLclampf value, GLboolean invert) = NULL;
223 static void (*_sym_glScissor) (GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
224 static void (*_sym_glShaderBinary) (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) = NULL;
225 static void (*_sym_glShaderSource) (GLuint shader, GLsizei count, const char** string, const GLint* length) = NULL;
226 static void (*_sym_glStencilFunc) (GLenum func, GLint ref, GLuint mask) = NULL;
227 static void (*_sym_glStencilFuncSeparate) (GLenum face, GLenum func, GLint ref, GLuint mask) = NULL;
228 static void (*_sym_glStencilMask) (GLuint mask) = NULL;
229 static void (*_sym_glStencilMaskSeparate) (GLenum face, GLuint mask) = NULL;
230 static void (*_sym_glStencilOp) (GLenum fail, GLenum zfail, GLenum zpass) = NULL;
231 static void (*_sym_glStencilOpSeparate) (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) = NULL;
232 static void (*_sym_glTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) = NULL;
233 static void (*_sym_glTexParameterf) (GLenum target, GLenum pname, GLfloat param) = NULL;
234 static void (*_sym_glTexParameterfv) (GLenum target, GLenum pname, const GLfloat* params) = NULL;
235 static void (*_sym_glTexParameteri) (GLenum target, GLenum pname, GLint param) = NULL;
236 static void (*_sym_glTexParameteriv) (GLenum target, GLenum pname, const GLint* params) = NULL;
237 static void (*_sym_glTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) = NULL;
238 static void (*_sym_glUniform1f) (GLint location, GLfloat x) = NULL;
239 static void (*_sym_glUniform1fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
240 static void (*_sym_glUniform1i) (GLint location, GLint x) = NULL;
241 static void (*_sym_glUniform1iv) (GLint location, GLsizei count, const GLint* v) = NULL;
242 static void (*_sym_glUniform2f) (GLint location, GLfloat x, GLfloat y) = NULL;
243 static void (*_sym_glUniform2fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
244 static void (*_sym_glUniform2i) (GLint location, GLint x, GLint y) = NULL;
245 static void (*_sym_glUniform2iv) (GLint location, GLsizei count, const GLint* v) = NULL;
246 static void (*_sym_glUniform3f) (GLint location, GLfloat x, GLfloat y, GLfloat z) = NULL;
247 static void (*_sym_glUniform3fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
248 static void (*_sym_glUniform3i) (GLint location, GLint x, GLint y, GLint z) = NULL;
249 static void (*_sym_glUniform3iv) (GLint location, GLsizei count, const GLint* v) = NULL;
250 static void (*_sym_glUniform4f) (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
251 static void (*_sym_glUniform4fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
252 static void (*_sym_glUniform4i) (GLint location, GLint x, GLint y, GLint z, GLint w) = NULL;
253 static void (*_sym_glUniform4iv) (GLint location, GLsizei count, const GLint* v) = NULL;
254 static void (*_sym_glUniformMatrix2fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
255 static void (*_sym_glUniformMatrix3fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
256 static void (*_sym_glUniformMatrix4fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
257 static void (*_sym_glUseProgram) (GLuint program) = NULL;
258 static void (*_sym_glValidateProgram) (GLuint program) = NULL;
259 static void (*_sym_glVertexAttrib1f) (GLuint indx, GLfloat x) = NULL;
260 static void (*_sym_glVertexAttrib1fv) (GLuint indx, const GLfloat* values) = NULL;
261 static void (*_sym_glVertexAttrib2f) (GLuint indx, GLfloat x, GLfloat y) = NULL;
262 static void (*_sym_glVertexAttrib2fv) (GLuint indx, const GLfloat* values) = NULL;
263 static void (*_sym_glVertexAttrib3f) (GLuint indx, GLfloat x, GLfloat y, GLfloat z) = NULL;
264 static void (*_sym_glVertexAttrib3fv) (GLuint indx, const GLfloat* values) = NULL;
265 static void (*_sym_glVertexAttrib4f) (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
266 static void (*_sym_glVertexAttrib4fv) (GLuint indx, const GLfloat* values) = NULL;
267 static void (*_sym_glVertexAttribPointer) (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) = NULL;
268 static void (*_sym_glViewport) (GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
270 // GLES Extensions...
271 /* static void (*_sym_glGetProgramBinary) (GLuint a, GLsizei b, GLsizei* c, GLenum* d, void* e) = NULL; */
272 /* static void (*_sym_glProgramBinary) (GLuint a, GLenum b, const void* c, GLint d) = NULL; */
273 /* static void (*_sym_glProgramParameteri) (GLuint a, GLuint b, GLint d) = NULL; */
283 static int cpunum = 0;
284 static int _evas_soft_gen_log_dom = -1;
287 eng_output_dump(void *data __UNUSED__)
289 evas_common_image_image_all_unload();
290 evas_common_font_font_all_unload();
294 eng_context_new(void *data __UNUSED__)
296 return evas_common_draw_context_new();
300 eng_context_free(void *data __UNUSED__, void *context)
302 evas_common_draw_context_free(context);
306 eng_context_clip_set(void *data __UNUSED__, void *context, int x, int y, int w, int h)
308 evas_common_draw_context_set_clip(context, x, y, w, h);
312 eng_context_clip_clip(void *data __UNUSED__, void *context, int x, int y, int w, int h)
314 evas_common_draw_context_clip_clip(context, x, y, w, h);
318 eng_context_clip_unset(void *data __UNUSED__, void *context)
320 evas_common_draw_context_unset_clip(context);
324 eng_context_clip_get(void *data __UNUSED__, void *context, int *x, int *y, int *w, int *h)
326 *x = ((RGBA_Draw_Context *)context)->clip.x;
327 *y = ((RGBA_Draw_Context *)context)->clip.y;
328 *w = ((RGBA_Draw_Context *)context)->clip.w;
329 *h = ((RGBA_Draw_Context *)context)->clip.h;
330 return ((RGBA_Draw_Context *)context)->clip.use;
334 eng_context_color_set(void *data __UNUSED__, void *context, int r, int g, int b, int a)
336 evas_common_draw_context_set_color(context, r, g, b, a);
340 eng_context_color_get(void *data __UNUSED__, void *context, int *r, int *g, int *b, int *a)
342 *r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->col.col));
343 *g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->col.col));
344 *b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->col.col));
345 *a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->col.col));
350 eng_context_multiplier_set(void *data __UNUSED__, void *context, int r, int g, int b, int a)
352 evas_common_draw_context_set_multiplier(context, r, g, b, a);
356 eng_context_multiplier_unset(void *data __UNUSED__, void *context)
358 evas_common_draw_context_unset_multiplier(context);
362 eng_context_multiplier_get(void *data __UNUSED__, void *context, int *r, int *g, int *b, int *a)
364 *r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->mul.col));
365 *g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->mul.col));
366 *b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->mul.col));
367 *a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->mul.col));
368 return ((RGBA_Draw_Context *)context)->mul.use;
372 eng_context_mask_set(void *data __UNUSED__, void *context, void *mask, int x, int y, int w, int h)
374 evas_common_draw_context_set_mask(context, mask, x, y, w, h);
378 eng_context_mask_unset(void *data __UNUSED__, void *context)
380 evas_common_draw_context_unset_mask(context);
384 eng_context_mask_get(void *data __UNUSED__, void *context)
386 return ((RGBA_Draw_Context *)context)->mask.mask;
391 eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h)
393 evas_common_draw_context_add_cutout(context, x, y, w, h);
397 eng_context_cutout_clear(void *data __UNUSED__, void *context)
399 evas_common_draw_context_clear_cutouts(context);
403 eng_context_anti_alias_set(void *data __UNUSED__, void *context, unsigned char aa)
405 evas_common_draw_context_set_anti_alias(context, aa);
409 eng_context_anti_alias_get(void *data __UNUSED__, void *context)
411 return ((RGBA_Draw_Context *)context)->anti_alias;
415 eng_context_color_interpolation_set(void *data __UNUSED__, void *context, int color_space)
417 evas_common_draw_context_set_color_interpolation(context, color_space);
421 eng_context_color_interpolation_get(void *data __UNUSED__, void *context)
423 return ((RGBA_Draw_Context *)context)->interpolation.color_space;
427 eng_context_render_op_set(void *data __UNUSED__, void *context, int op)
429 evas_common_draw_context_set_render_op(context, op);
433 eng_context_render_op_get(void *data __UNUSED__, void *context)
435 return ((RGBA_Draw_Context *)context)->render_op;
441 eng_rectangle_draw(void *data __UNUSED__, void *context, void *surface, int x, int y, int w, int h)
443 #ifdef BUILD_PIPE_RENDER
445 evas_common_pipe_rectangle_draw(surface, context, x, y, w, h);
449 evas_common_rectangle_draw(surface, context, x, y, w, h);
450 evas_common_cpu_end_opt();
455 eng_line_draw(void *data __UNUSED__, void *context, void *surface, int x1, int y1, int x2, int y2)
457 #ifdef BUILD_PIPE_RENDER
459 evas_common_pipe_line_draw(surface, context, x1, y1, x2, y2);
463 evas_common_line_draw(surface, context, x1, y1, x2, y2);
464 evas_common_cpu_end_opt();
469 eng_polygon_point_add(void *data __UNUSED__, void *context __UNUSED__, void *polygon, int x, int y)
471 return evas_common_polygon_point_add(polygon, x, y);
475 eng_polygon_points_clear(void *data __UNUSED__, void *context __UNUSED__, void *polygon)
477 return evas_common_polygon_points_clear(polygon);
481 eng_polygon_draw(void *data __UNUSED__, void *context, void *surface, void *polygon, int x, int y)
483 #ifdef BUILD_PIPE_RENDER
485 evas_common_pipe_poly_draw(surface, context, polygon, x, y);
489 evas_common_polygon_draw(surface, context, polygon, x, y);
490 evas_common_cpu_end_opt();
495 eng_image_alpha_get(void *data __UNUSED__, void *image)
499 if (!image) return 1;
503 case EVAS_COLORSPACE_ARGB8888:
504 if (im->flags.alpha) return 1;
512 eng_image_colorspace_get(void *data __UNUSED__, void *image)
516 if (!image) return EVAS_COLORSPACE_ARGB8888;
522 eng_image_can_region_get(void *data __UNUSED__, void *image)
525 if (!image) return EINA_FALSE;
527 return ((Evas_Image_Load_Func*) im->info.loader)->do_region;
531 eng_image_mask_create(void *data __UNUSED__, void *image)
540 if (im->mask.mask && !im->mask.dirty) return;
542 if (im->mask.mask) free(im->mask.mask);
543 sz = im->cache_entry.w * im->cache_entry.h;
544 im->mask.mask = malloc(sz);
547 evas_cache_image_load_data(&im->cache_entry);
548 src = (void*) im->image.data;
550 for (end = dst + sz ; dst < end ; dst ++, src ++)
557 eng_image_alpha_set(void *data __UNUSED__, void *image, int has_alpha)
561 if (!image) return NULL;
563 if (im->cache_entry.space != EVAS_COLORSPACE_ARGB8888)
565 im->cache_entry.flags.alpha = 0;
568 im = (RGBA_Image *) evas_cache_image_alone(&im->cache_entry);
569 im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
570 evas_common_image_colorspace_dirty(im);
575 eng_image_border_set(void *data __UNUSED__, void *image, int l __UNUSED__, int r __UNUSED__, int t __UNUSED__, int b __UNUSED__)
584 eng_image_border_get(void *data __UNUSED__, void *image __UNUSED__, int *l __UNUSED__, int *r __UNUSED__, int *t __UNUSED__, int *b __UNUSED__)
589 eng_image_comment_get(void *data __UNUSED__, void *image, char *key __UNUSED__)
593 if (!image) return NULL;
595 return im->info.comment;
599 eng_image_format_get(void *data __UNUSED__, void *image __UNUSED__)
605 eng_image_colorspace_set(void *data __UNUSED__, void *image, int cspace)
611 evas_cache_image_colorspace(im, cspace);
615 eng_image_native_set(void *data __UNUSED__, void *image, void *native __UNUSED__)
618 Evas_Native_Surface *ns = native;
619 Image_Entry *im = image, *im2 = NULL;
623 if ((!ns) && (ns->data.x11.visual))
625 im = evas_cache_image_data(evas_common_image_cache_get(),
627 ns->data.x11.visual, 1,
628 EVAS_COLORSPACE_ARGB8888);
635 if ((!ns) && (!im)) return im;
639 im2 = evas_cache_image_data(evas_common_image_cache_get(),
641 ns->data.x11.visual, 1,
642 EVAS_COLORSPACE_ARGB8888);
643 evas_cache_image_drop(im);
651 eng_image_native_get(void *data __UNUSED__, void *image __UNUSED__)
657 eng_image_load(void *data __UNUSED__, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
659 *error = EVAS_LOAD_ERROR_NONE;
661 if (evas_cserve2_use_get())
664 ie = evas_cache2_image_open(evas_common_image_cache2_get(),
665 file, key, lo, error);
667 evas_cache2_image_open_wait(ie);
672 return evas_common_load_image_from_file(file, key, lo, error);
676 eng_image_new_from_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
679 if (evas_cserve2_use_get())
681 Evas_Cache2 *cache = evas_common_image_cache2_get();
682 return evas_cache2_image_data(cache, w, h, image_data, alpha, cspace);
685 return evas_cache_image_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
689 eng_image_new_from_copied_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
692 if (evas_cserve2_use_get())
694 Evas_Cache2 *cache = evas_common_image_cache2_get();
695 return evas_cache2_image_copied_data(cache, w, h, image_data, alpha,
699 return evas_cache_image_copied_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
703 eng_image_free(void *data __UNUSED__, void *image)
706 if (evas_cserve2_use_get())
708 evas_cache2_image_close(image);
712 evas_cache_image_drop(image);
716 eng_image_size_get(void *data __UNUSED__, void *image, int *w, int *h)
726 eng_image_size_set(void *data __UNUSED__, void *image, int w, int h)
728 Image_Entry *im = image;
729 if (!im) return NULL;
731 if (evas_cserve2_use_get())
732 return evas_cache2_image_size_set(im, w, h);
734 return evas_cache_image_size_set(im, w, h);
738 eng_image_dirty_region(void *data __UNUSED__, void *image, int x, int y, int w, int h)
740 Image_Entry *im = image;
741 if (!im) return NULL;
743 if (evas_cserve2_use_get())
744 return evas_cache2_image_dirty(im, x, y, w, h);
746 return evas_cache_image_dirty(im, x, y, w, h);
750 eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data, int *err)
753 int error = EVAS_LOAD_ERROR_NONE;
763 if (evas_cserve2_use_get())
765 error = evas_cache2_image_load_data(&im->cache_entry);
766 if (err) *err = error;
769 im = (RGBA_Image *)evas_cache2_image_writable(&im->cache_entry);
771 *image_data = im->image.data;
776 error = evas_cache_image_load_data(&im->cache_entry);
777 switch (im->cache_entry.space)
779 case EVAS_COLORSPACE_ARGB8888:
781 im = (RGBA_Image *)evas_cache_image_alone(&im->cache_entry);
782 *image_data = im->image.data;
784 case EVAS_COLORSPACE_YCBCR422P601_PL:
785 case EVAS_COLORSPACE_YCBCR422P709_PL:
786 case EVAS_COLORSPACE_YCBCR422601_PL:
787 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
788 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
789 *image_data = im->cs.data;
795 if (err) *err = error;
800 eng_image_data_put(void *data, void *image, DATA32 *image_data)
802 RGBA_Image *im, *im2;
804 if (!image) return NULL;
806 switch (im->cache_entry.space)
808 case EVAS_COLORSPACE_ARGB8888:
809 if (image_data != im->image.data)
813 w = im->cache_entry.w;
814 h = im->cache_entry.h;
815 im2 = eng_image_new_from_data(data, w, h, image_data,
816 eng_image_alpha_get(data, image),
817 eng_image_colorspace_get(data, image));
819 if (evas_cserve2_use_get())
821 evas_cache2_image_close(&im->cache_entry);
826 evas_cache_image_drop(&im->cache_entry);
830 case EVAS_COLORSPACE_YCBCR422P601_PL:
831 case EVAS_COLORSPACE_YCBCR422P709_PL:
832 case EVAS_COLORSPACE_YCBCR422601_PL:
833 case EVAS_COLORSPACE_YCBCR420NV12601_PL:
834 case EVAS_COLORSPACE_YCBCR420TM12601_PL:
835 if (image_data != im->cs.data)
839 if (!im->cs.no_free) free(im->cs.data);
841 im->cs.data = image_data;
843 evas_common_image_colorspace_dirty(im);
853 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
855 RGBA_Image *im = image;
859 if (evas_cserve2_use_get())
861 evas_cache2_image_preload_data(&im->cache_entry, target);
865 evas_cache_image_preload_data(&im->cache_entry, target);
869 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
871 RGBA_Image *im = image;
873 if (evas_cserve2_use_get())
878 evas_cache_image_preload_cancel(&im->cache_entry, target);
882 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)
888 #ifdef BUILD_PIPE_RENDER
892 if (evas_cserve2_use_get())
893 evas_cache2_image_load_data(&im->cache_entry);
895 evas_common_rgba_image_scalecache_prepare((Image_Entry *)(im),
896 surface, context, smooth,
897 src_x, src_y, src_w, src_h,
898 dst_x, dst_y, dst_w, dst_h);
900 evas_common_pipe_image_draw(im, surface, context, smooth,
901 src_x, src_y, src_w, src_h,
902 dst_x, dst_y, dst_w, dst_h);
909 if (evas_cserve2_use_get())
911 evas_cache2_image_load_data(&im->cache_entry);
915 if (im->cache_entry.space == EVAS_COLORSPACE_ARGB8888)
916 evas_cache_image_load_data(&im->cache_entry);
917 evas_common_image_colorspace_normalize(im);
921 evas_common_rgba_image_scalecache_prepare(&im->cache_entry, surface, context, smooth,
922 src_x, src_y, src_w, src_h,
923 dst_x, dst_y, dst_w, dst_h);
924 evas_common_rgba_image_scalecache_do(&im->cache_entry, surface, context, smooth,
925 src_x, src_y, src_w, src_h,
926 dst_x, dst_y, dst_w, dst_h);
929 evas_common_scale_rgba_in_to_out_clip_smooth(im, surface, context,
930 src_x, src_y, src_w, src_h,
931 dst_x, dst_y, dst_w, dst_h);
933 evas_common_scale_rgba_in_to_out_clip_sample(im, surface, context,
934 src_x, src_y, src_w, src_h,
935 dst_x, dst_y, dst_w, dst_h);
937 evas_common_cpu_end_opt();
942 eng_image_map_draw(void *data __UNUSED__, void *context, void *surface, void *image, int npoints, RGBA_Map_Point *p, int smooth, int level)
947 if (npoints < 3) return;
950 if ((p[0].x == p[3].x) &&
951 (p[1].x == p[2].x) &&
952 (p[0].y == p[1].y) &&
953 (p[3].y == p[2].y) &&
954 (p[0].x <= p[1].x) &&
955 (p[0].y <= p[2].y) &&
958 (p[1].u == (int)(im->cache_entry.w << FP)) &&
960 (p[2].u == (int)(im->cache_entry.w << FP)) &&
961 (p[2].v == (int)(im->cache_entry.h << FP)) &&
963 (p[3].v == (int)(im->cache_entry.h << FP)) &&
964 (p[0].col == 0xffffffff) &&
965 (p[1].col == 0xffffffff) &&
966 (p[2].col == 0xffffffff) &&
967 (p[3].col == 0xffffffff))
973 dw = (p[2].x >> FP) - dx;
974 dh = (p[2].y >> FP) - dy;
976 (data, context, surface, image,
977 0, 0, im->cache_entry.w, im->cache_entry.h,
978 dx, dy, dw, dh, smooth);
982 #ifdef BUILD_PIPE_RENDER
984 evas_common_pipe_map_draw(im, surface, context, npoints, p, smooth, level);
987 evas_common_map_rgba(im, surface, context, npoints, p, smooth, level);
989 evas_common_cpu_end_opt();
993 eng_image_map_draw(data, context, surface, image, npoints - 2, p + 2,
999 eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
1003 if (evas_cserve2_use_get())
1005 surface = evas_cache2_image_copied_data(evas_common_image_cache2_get(),
1007 EVAS_COLORSPACE_ARGB8888);
1008 evas_cache2_image_pixels(surface);
1012 surface = evas_cache_image_copied_data(evas_common_image_cache_get(),
1014 EVAS_COLORSPACE_ARGB8888);
1015 evas_cache_image_pixels(surface);
1020 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
1023 if (evas_cserve2_use_get())
1025 evas_cache2_image_unload_data(surface);
1029 evas_cache_image_drop(surface);
1033 eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
1039 im->scale_hint = hint;
1043 eng_image_scale_hint_get(void *data __UNUSED__, void *image)
1047 if (!image) return EVAS_IMAGE_SCALE_HINT_NONE;
1049 return im->scale_hint;
1053 eng_image_animated_get(void *data __UNUSED__, void *image)
1057 if (!image) return EINA_FALSE;
1059 return im->flags.animated;
1063 eng_image_animated_frame_count_get(void *data __UNUSED__, void *image)
1067 if (!image) return -1;
1069 if (!im->flags.animated) return -1;
1070 return im->frame_count;
1073 static Evas_Image_Animated_Loop_Hint
1074 eng_image_animated_loop_type_get(void *data __UNUSED__, void *image)
1078 if (!image) return EVAS_IMAGE_ANIMATED_HINT_NONE;
1080 if (!im->flags.animated) return EVAS_IMAGE_ANIMATED_HINT_NONE;
1081 return im->loop_hint;
1085 eng_image_animated_loop_count_get(void *data __UNUSED__, void *image)
1089 if (!image) return -1;
1091 if (!im->flags.animated) return -1;
1092 return im->loop_count;
1096 eng_image_animated_frame_duration_get(void *data __UNUSED__, void *image, int start_frame, int frame_num)
1100 if (!image) return -1;
1102 if (!im->flags.animated) return -1;
1103 return evas_common_load_rgba_image_frame_duration_from_file(im, start_frame, frame_num);
1107 eng_image_animated_frame_set(void *data __UNUSED__, void *image, int frame_index)
1111 if (!image) return EINA_FALSE;
1113 if (!im->flags.animated) return EINA_FALSE;
1114 if (im->cur_frame == frame_index) return EINA_FALSE;
1115 im->cur_frame = frame_index;
1120 eng_image_cache_flush(void *data __UNUSED__)
1124 tmp_size = evas_common_image_get_cache();
1125 evas_common_image_set_cache(0);
1126 evas_common_rgba_image_scalecache_flush();
1127 evas_common_image_set_cache(tmp_size);
1131 eng_image_cache_set(void *data __UNUSED__, int bytes)
1133 evas_common_image_set_cache(bytes);
1134 evas_common_rgba_image_scalecache_size_set(bytes);
1138 eng_image_cache_get(void *data __UNUSED__)
1140 return evas_common_image_get_cache();
1143 static Evas_Font_Set *
1144 eng_font_load(void *data __UNUSED__, const char *name, int size,
1145 Font_Rend_Flags wanted_rend)
1147 return (Evas_Font_Set *) evas_common_font_load(name, size, wanted_rend);
1150 static Evas_Font_Set *
1151 eng_font_memory_load(void *data __UNUSED__, char *name, int size, const void *fdata, int fdata_size, Font_Rend_Flags wanted_rend)
1153 return (Evas_Font_Set *) evas_common_font_memory_load(name, size, fdata,
1154 fdata_size, wanted_rend);
1157 static Evas_Font_Set *
1158 eng_font_add(void *data __UNUSED__, Evas_Font_Set *font, const char *name, int size, Font_Rend_Flags wanted_rend)
1160 return (Evas_Font_Set *) evas_common_font_add((RGBA_Font *) font, name,
1164 static Evas_Font_Set *
1165 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)
1167 return (Evas_Font_Set *) evas_common_font_memory_add((RGBA_Font *) font,
1168 name, size, fdata, fdata_size, wanted_rend);
1172 eng_font_free(void *data __UNUSED__, Evas_Font_Set *font)
1174 evas_common_font_free((RGBA_Font *) font);
1178 eng_font_ascent_get(void *data __UNUSED__, Evas_Font_Set *font)
1180 return evas_common_font_ascent_get((RGBA_Font *) font);
1184 eng_font_descent_get(void *data __UNUSED__, Evas_Font_Set *font)
1186 return evas_common_font_descent_get((RGBA_Font *) font);
1190 eng_font_max_ascent_get(void *data __UNUSED__, Evas_Font_Set *font)
1192 return evas_common_font_max_ascent_get((RGBA_Font *) font);
1196 eng_font_max_descent_get(void *data __UNUSED__, Evas_Font_Set *font)
1198 return evas_common_font_max_descent_get((RGBA_Font *) font);
1202 eng_font_string_size_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props, int *w, int *h)
1204 evas_common_font_query_size((RGBA_Font *) font, text_props, w, h);
1208 eng_font_inset_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1210 return evas_common_font_query_inset((RGBA_Font *) font, text_props);
1214 eng_font_right_inset_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1216 return evas_common_font_query_right_inset((RGBA_Font *) font, text_props);
1220 eng_font_h_advance_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1224 evas_common_font_query_advance((RGBA_Font *) font, text_props, &h, &v);
1229 eng_font_v_advance_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1233 evas_common_font_query_advance((RGBA_Font *) font, text_props, &h, &v);
1238 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)
1240 return evas_common_font_query_pen_coords((RGBA_Font *) font, text_props, pos, cpen_x, cy, cadv, ch);
1244 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)
1246 return evas_common_text_props_content_create((RGBA_Font_Int *) fi, text,
1247 text_props, par_props, par_pos, len);
1251 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)
1253 return evas_common_font_query_char_coords((RGBA_Font *) font, text_props, pos, cx, cy, cw, ch);
1257 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)
1259 return evas_common_font_query_char_at_coords((RGBA_Font *) font, text_props, x, y, cx, cy, cw, ch);
1263 eng_font_last_up_to_pos(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props, int x, int y)
1265 return evas_common_font_query_last_up_to_pos((RGBA_Font *) font, text_props, x, y);
1269 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)
1271 return evas_common_font_query_run_font_end_get((RGBA_Font *) font,
1272 (RGBA_Font_Int **) script_fi, (RGBA_Font_Int **) cur_fi,
1273 script, text, run_len);
1277 eng_font_draw(void *data __UNUSED__, 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__, const Evas_Text_Props *text_props)
1279 #ifdef BUILD_PIPE_RENDER
1281 evas_common_pipe_text_draw(surface, context, x, y, text_props);
1285 evas_common_font_draw(surface, context, x, y, text_props);
1286 evas_common_cpu_end_opt();
1291 eng_font_cache_flush(void *data __UNUSED__)
1295 tmp_size = evas_common_font_cache_get();
1296 evas_common_font_cache_set(0);
1297 evas_common_font_flush();
1298 evas_common_font_cache_set(tmp_size);
1302 eng_font_cache_set(void *data __UNUSED__, int bytes)
1304 evas_common_font_cache_set(bytes);
1308 eng_font_cache_get(void *data __UNUSED__)
1310 return evas_common_font_cache_get();
1314 eng_font_hinting_set(void *data __UNUSED__, Evas_Font_Set *font, int hinting)
1316 evas_common_font_hinting_set((RGBA_Font *) font, hinting);
1320 eng_font_hinting_can_hint(void *data __UNUSED__, int hinting)
1322 return evas_common_hinting_available(hinting);
1326 eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
1333 #if 0 // filtering disabled
1335 eng_image_draw_filtered(void *data __UNUSED__, void *context __UNUSED__,
1336 void *surface, void *image, Evas_Filter_Info *filter)
1338 Evas_Software_Filter_Fn fn;
1339 RGBA_Image *im = image;
1341 fn = evas_filter_software_get(filter);
1343 if (im->cache_entry.cache) evas_cache_image_load_data(&im->cache_entry);
1344 fn(filter, image, surface);
1348 static Filtered_Image *
1349 eng_image_filtered_get(void *image, uint8_t *key, size_t keylen)
1351 RGBA_Image *im = image;
1355 for (l = im->filtered ; l ; l = l->next)
1358 if (fi->keylen != keylen) continue;
1359 if (memcmp(key, fi->key, keylen) != 0) continue;
1367 static Filtered_Image *
1368 eng_image_filtered_save(void *image, void *fimage, uint8_t *key, size_t keylen)
1370 RGBA_Image *im = image;
1374 for (l = im->filtered ; l ; l = l->next)
1377 if (fi->keylen != keylen) continue;
1378 if (memcmp(key, fi->key, keylen) == 0) continue;
1379 evas_cache_image_drop((void *)fi->image);
1384 fi = calloc(1,sizeof(Filtered_Image));
1385 if (!fi) return NULL;
1387 fi->keylen = keylen;
1388 fi->key = malloc(keylen);
1389 memcpy(fi->key, key, keylen);
1393 im->filtered = eina_list_prepend(im->filtered, fi);
1399 eng_image_filtered_free(void *image, Filtered_Image *fi)
1401 RGBA_Image *im = image;
1404 if (fi->ref) return;
1407 evas_cache_image_drop(&fi->image->cache_entry);
1410 im->filtered = eina_list_remove(im->filtered, fi);
1415 eng_image_load_error_get(void *data __UNUSED__, void *image)
1419 if (!image) return EVAS_LOAD_ERROR_NONE;
1421 return im->cache_entry.load_error;
1424 //------------ Evas GL engine code ---------------//
1426 eng_gl_surface_create(void *data __UNUSED__, void *config, int w, int h)
1429 Render_Engine_GL_Surface *sfc;
1430 Evas_GL_Config *cfg;
1432 sfc = calloc(1, sizeof(Render_Engine_GL_Surface));
1433 if (!sfc) return NULL;
1435 cfg = (Evas_GL_Config *)config;
1437 sfc->initialized = 0;
1442 switch (cfg->color_format)
1445 case EVAS_GL_RGB_888:
1446 sfc->internal_fmt = OSMESA_RGB;
1447 sfc->internal_cpp = 3;
1449 case EVAS_GL_RGBA_8888:
1450 sfc->internal_fmt = OSMESA_BGRA;
1451 sfc->internal_cpp = 4;
1454 sfc->internal_fmt = OSMESA_RGBA;
1455 sfc->internal_cpp = 4;
1460 switch (cfg->depth_bits)
1462 case EVAS_GL_DEPTH_BIT_8:
1463 sfc->depth_bits = 8;
1465 case EVAS_GL_DEPTH_BIT_16:
1466 sfc->depth_bits = 16;
1468 case EVAS_GL_DEPTH_BIT_24:
1469 sfc->depth_bits = 24;
1471 case EVAS_GL_DEPTH_BIT_32:
1472 sfc->depth_bits = 32;
1474 case EVAS_GL_DEPTH_NONE:
1476 sfc->depth_bits = 0;
1481 switch (cfg->stencil_bits)
1483 case EVAS_GL_STENCIL_BIT_1:
1484 sfc->stencil_bits = 1;
1486 case EVAS_GL_STENCIL_BIT_2:
1487 sfc->stencil_bits = 2;
1489 case EVAS_GL_STENCIL_BIT_4:
1490 sfc->stencil_bits = 4;
1492 case EVAS_GL_STENCIL_BIT_8:
1493 sfc->stencil_bits = 8;
1495 case EVAS_GL_STENCIL_BIT_16:
1496 sfc->stencil_bits = 16;
1498 case EVAS_GL_STENCIL_NONE:
1500 sfc->stencil_bits = 0;
1504 sfc->buffer = malloc(sizeof(unsigned char)*sfc->internal_cpp*w*h);
1522 eng_gl_surface_destroy(void *data __UNUSED__, void *surface)
1525 Render_Engine_GL_Surface *sfc;
1527 sfc = (Render_Engine_GL_Surface*)surface;
1531 if (sfc->buffer) free(sfc->buffer);
1545 eng_gl_context_create(void *data __UNUSED__, void *share_context)
1548 Render_Engine_GL_Context *ctx;
1549 Render_Engine_GL_Context *share_ctx;
1551 ctx = calloc(1, sizeof(Render_Engine_GL_Context));
1553 if (!ctx) return NULL;
1555 share_ctx = (Render_Engine_GL_Context *)share_context;
1557 ctx->share_ctx = share_ctx;
1561 ctx->context = OSMesaCreateContextExt( OSMESA_RGBA, 8, 0, 0, share_ctx->context );
1563 ctx->context = OSMesaCreateContextExt( OSMESA_RGBA, 8, 0, 0, NULL );
1568 ERR("Error creating OSMesa Context.");
1574 ctx->initialized = 0;
1578 (void) share_context;
1584 eng_gl_context_destroy(void *data __UNUSED__, void *context)
1587 Render_Engine_GL_Context *ctx;
1589 ctx = (Render_Engine_GL_Context*)context;
1593 _sym_OSMesaDestroyContext(ctx->context);
1606 eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
1609 Render_Engine_GL_Surface *sfc;
1610 Render_Engine_GL_Context *ctx;
1611 OSMesaContext share_ctx;
1614 sfc = (Render_Engine_GL_Surface*)surface;
1615 ctx = (Render_Engine_GL_Context*)context;
1617 // Unset surface/context
1618 if ((!sfc) || (!ctx))
1620 if (ctx) ctx->current_sfc = NULL;
1621 if (sfc) sfc->current_ctx = NULL;
1625 // Initialize Context if it hasn't been.
1626 if (!ctx->initialized)
1629 share_ctx = ctx->share_ctx->context;
1633 ctx->context = _sym_OSMesaCreateContextExt(sfc->internal_fmt,
1640 ERR("Error initializing context.");
1644 ctx->initialized = 1;
1649 ret = _sym_OSMesaMakeCurrent(ctx->context, sfc->buffer, GL_UNSIGNED_BYTE,
1652 if (ret == GL_FALSE)
1654 ERR("Error doing MakeCurrent.");
1658 _sym_OSMesaPixelStore(OSMESA_Y_UP, 0);
1660 // Set the current surface/context
1661 ctx->current_sfc = sfc;
1662 sfc->current_ctx = ctx;
1672 // FIXME!!! Implement later
1674 eng_gl_string_query(void *data __UNUSED__, int name __UNUSED__)
1680 eng_gl_proc_address_get(void *data __UNUSED__, const char *name)
1683 if (_sym_OSMesaGetProcAddress) return _sym_OSMesaGetProcAddress(name);
1684 return dlsym(RTLD_DEFAULT, name);
1692 eng_gl_native_surface_get(void *data __UNUSED__, void *surface, void *native_surface)
1695 Render_Engine_GL_Surface *sfc;
1696 Evas_Native_Surface *ns;
1698 sfc = (Render_Engine_GL_Surface*)surface;
1699 ns = (Evas_Native_Surface*)native_surface;
1703 ns->type = EVAS_NATIVE_SURFACE_OPENGL;
1704 ns->version = EVAS_NATIVE_SURFACE_VERSION;
1705 ns->data.x11.visual = sfc->buffer;
1710 (void) native_surface;
1717 eng_gl_api_get(void *data __UNUSED__)
1726 //------------------------------------------------//
1737 static Evas_Func func =
1753 /* draw context virtual methods */
1755 eng_canvas_alpha_get,
1757 eng_context_clip_set,
1758 eng_context_clip_clip,
1759 eng_context_clip_unset,
1760 eng_context_clip_get,
1761 eng_context_mask_set,
1762 eng_context_mask_unset,
1763 eng_context_color_set,
1764 eng_context_color_get,
1765 eng_context_multiplier_set,
1766 eng_context_multiplier_unset,
1767 eng_context_multiplier_get,
1768 eng_context_cutout_add,
1769 eng_context_cutout_clear,
1770 eng_context_anti_alias_set,
1771 eng_context_anti_alias_get,
1772 eng_context_color_interpolation_set,
1773 eng_context_color_interpolation_get,
1774 eng_context_render_op_set,
1775 eng_context_render_op_get,
1776 /* rect draw funcs */
1778 /* line draw funcs */
1780 /* polygon draw funcs */
1781 eng_polygon_point_add,
1782 eng_polygon_points_clear,
1784 /* image draw funcs */
1786 eng_image_new_from_data,
1787 eng_image_new_from_copied_data,
1792 eng_image_dirty_region,
1795 eng_image_data_preload_request,
1796 eng_image_data_preload_cancel,
1797 eng_image_alpha_set,
1798 eng_image_alpha_get,
1799 eng_image_border_set,
1800 eng_image_border_get,
1802 eng_image_comment_get,
1803 eng_image_format_get,
1804 eng_image_colorspace_set,
1805 eng_image_colorspace_get,
1806 eng_image_can_region_get,
1807 eng_image_mask_create,
1808 eng_image_native_set,
1809 eng_image_native_get,
1810 /* image cache funcs */
1811 eng_image_cache_flush,
1812 eng_image_cache_set,
1813 eng_image_cache_get,
1814 /* font draw functions */
1816 eng_font_memory_load,
1818 eng_font_memory_add,
1820 eng_font_ascent_get,
1821 eng_font_descent_get,
1822 eng_font_max_ascent_get,
1823 eng_font_max_descent_get,
1824 eng_font_string_size_get,
1826 eng_font_h_advance_get,
1827 eng_font_v_advance_get,
1828 eng_font_char_coords_get,
1829 eng_font_char_at_coords_get,
1831 /* font cache functions */
1832 eng_font_cache_flush,
1835 /* font hinting functions */
1836 eng_font_hinting_set,
1837 eng_font_hinting_can_hint,
1838 eng_image_scale_hint_set,
1839 eng_image_scale_hint_get,
1840 /* more font draw functions */
1841 eng_font_last_up_to_pos,
1843 eng_image_map_surface_new,
1844 eng_image_map_surface_free,
1845 NULL, // eng_image_content_hint_set - software doesn't use it
1846 NULL, // eng_image_content_hint_get - software doesn't use it
1847 eng_font_pen_coords_get,
1848 eng_font_text_props_info_create,
1849 eng_font_right_inset_get,
1850 #if 0 // filtering disabled
1851 eng_image_draw_filtered,
1852 eng_image_filtered_get,
1853 eng_image_filtered_save,
1854 eng_image_filtered_free,
1856 NULL, // need software mesa for gl rendering <- gl_surface_create
1857 NULL, // need software mesa for gl rendering <- gl_surface_destroy
1858 NULL, // need software mesa for gl rendering <- gl_context_create
1859 NULL, // need software mesa for gl rendering <- gl_context_destroy
1860 NULL, // need software mesa for gl rendering <- gl_make_current
1861 NULL, // need software mesa for gl rendering <- gl_string_query
1862 NULL, // need software mesa for gl rendering <- gl_proc_address_get
1863 NULL, // need software mesa for gl rendering <- gl_native_surface_get
1864 NULL, // need software mesa for gl rendering <- gl_api_get
1865 NULL, // need software mesa for gl rendering <- gl_img_obj_set
1866 eng_image_load_error_get,
1867 eng_font_run_font_end_get,
1868 eng_image_animated_get,
1869 eng_image_animated_frame_count_get,
1870 eng_image_animated_loop_type_get,
1871 eng_image_animated_loop_count_get,
1872 eng_image_animated_frame_duration_get,
1873 eng_image_animated_frame_set,
1875 /* FUTURE software generic calls go here */
1879 //----------------------------------------------------------------//
1883 //----------------------------------------------------------------//
1888 ERR("GL symbols missing!\n");
1894 //------------------------------------------------//
1895 // Use eglGetProcAddress
1896 #define FINDSYM(dst, sym, typ) \
1897 if (!dst) dst = (typeof(dst))dlsym(gl_lib_handle, sym); \
1900 ERR("Symbol not found %s\n", sym); \
1903 #define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
1905 //------------------------------------------------------//
1907 FINDSYM(_sym_OSMesaCreateContextExt, "OSMesaCreateContextExt", glsym_func_osm_ctx);
1908 FALLBAK(_sym_OSMesaCreateContextExt, glsym_func_void);
1910 FINDSYM(_sym_OSMesaDestroyContext, "OSMesaDestroyContext", glsym_func_void);
1911 FALLBAK(_sym_OSMesaDestroyContext, glsym_func_void);
1913 FINDSYM(_sym_OSMesaMakeCurrent, "OSMesaMakeCurrent", glsym_func_bool);
1914 FALLBAK(_sym_OSMesaMakeCurrent, glsym_func_void);
1916 FINDSYM(_sym_OSMesaPixelStore, "OSMesaPixelStore", glsym_func_void);
1917 FALLBAK(_sym_OSMesaPixelStore, glsym_func_void);
1919 FINDSYM(_sym_OSMesaGetProcAddress, "OSMesaGetProcAddress", glsym_func_eng_fn);
1920 FALLBAK(_sym_OSMesaGetProcAddress, glsym_func_void);
1931 //------------------------------------------------//
1932 #define FINDSYM(dst, sym, typ) \
1933 if (!dst) dst = (typeof(dst))dlsym(gl_lib_handle, sym); \
1934 if (!dst) DBG("Symbol not found %s\n", sym);
1935 #define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
1938 //------------------------------------------------------//
1940 FINDSYM(_sym_glActiveTexture, "glActiveTexture", glsym_func_void);
1941 FALLBAK(_sym_glActiveTexture, glsym_func_void);
1943 FINDSYM(_sym_glAttachShader, "glAttachShader", glsym_func_void);
1944 FALLBAK(_sym_glAttachShader, glsym_func_void);
1946 FINDSYM(_sym_glBindAttribLocation, "glBindAttribLocation", glsym_func_void);
1947 FALLBAK(_sym_glBindAttribLocation, glsym_func_void);
1949 FINDSYM(_sym_glBindBuffer, "glBindBuffer", glsym_func_void);
1950 FALLBAK(_sym_glBindBuffer, glsym_func_void);
1952 FINDSYM(_sym_glBindFramebuffer, "glBindFramebuffer", glsym_func_void);
1953 FALLBAK(_sym_glBindFramebuffer, glsym_func_void);
1955 FINDSYM(_sym_glBindRenderbuffer, "glBindRenderbuffer", glsym_func_void);
1956 FALLBAK(_sym_glBindRenderbuffer, glsym_func_void);
1958 FINDSYM(_sym_glBindTexture, "glBindTexture", glsym_func_void);
1959 FALLBAK(_sym_glBindTexture, glsym_func_void);
1961 FINDSYM(_sym_glBlendColor, "glBlendColor", glsym_func_void);
1962 FALLBAK(_sym_glBlendColor, glsym_func_void);
1964 FINDSYM(_sym_glBlendEquation, "glBlendEquation", glsym_func_void);
1965 FALLBAK(_sym_glBlendEquation, glsym_func_void);
1967 FINDSYM(_sym_glBlendEquationSeparate, "glBlendEquationSeparate", glsym_func_void);
1968 FALLBAK(_sym_glBlendEquationSeparate, glsym_func_void);
1970 FINDSYM(_sym_glBlendFunc, "glBlendFunc", glsym_func_void);
1971 FALLBAK(_sym_glBlendFunc, glsym_func_void);
1973 FINDSYM(_sym_glBlendFuncSeparate, "glBlendFuncSeparate", glsym_func_void);
1974 FALLBAK(_sym_glBlendFuncSeparate, glsym_func_void);
1976 FINDSYM(_sym_glBufferData, "glBufferData", glsym_func_void);
1977 FALLBAK(_sym_glBufferData, glsym_func_void);
1979 FINDSYM(_sym_glBufferSubData, "glBufferSubData", glsym_func_void);
1980 FALLBAK(_sym_glBufferSubData, glsym_func_void);
1982 FINDSYM(_sym_glCheckFramebufferStatus, "glCheckFramebufferStatus", glsym_func_uint);
1983 FALLBAK(_sym_glCheckFramebufferStatus, glsym_func_uint);
1985 FINDSYM(_sym_glClear, "glClear", glsym_func_void);
1986 FALLBAK(_sym_glClear, glsym_func_void);
1988 FINDSYM(_sym_glClearColor, "glClearColor", glsym_func_void);
1989 FALLBAK(_sym_glClearColor, glsym_func_void);
1991 FINDSYM(_sym_glClearDepthf, "glClearDepthf", glsym_func_void);
1992 FINDSYM(_sym_glClearDepthf, "glClearDepth", glsym_func_void);
1993 FALLBAK(_sym_glClearDepthf, glsym_func_void);
1995 FINDSYM(_sym_glClearStencil, "glClearStencil", glsym_func_void);
1996 FALLBAK(_sym_glClearStencil, glsym_func_void);
1998 FINDSYM(_sym_glColorMask, "glColorMask", glsym_func_void);
1999 FALLBAK(_sym_glColorMask, glsym_func_void);
2001 FINDSYM(_sym_glCompileShader, "glCompileShader", glsym_func_void);
2002 FALLBAK(_sym_glCompileShader, glsym_func_void);
2004 FINDSYM(_sym_glCompressedTexImage2D, "glCompressedTexImage2D", glsym_func_void);
2005 FALLBAK(_sym_glCompressedTexImage2D, glsym_func_void);
2007 FINDSYM(_sym_glCompressedTexSubImage2D, "glCompressedTexSubImage2D", glsym_func_void);
2008 FALLBAK(_sym_glCompressedTexSubImage2D, glsym_func_void);
2010 FINDSYM(_sym_glCopyTexImage2D, "glCopyTexImage2D", glsym_func_void);
2011 FALLBAK(_sym_glCopyTexImage2D, glsym_func_void);
2013 FINDSYM(_sym_glCopyTexSubImage2D, "glCopyTexSubImage2D", glsym_func_void);
2014 FALLBAK(_sym_glCopyTexSubImage2D, glsym_func_void);
2016 FINDSYM(_sym_glCreateProgram, "glCreateProgram", glsym_func_uint);
2017 FALLBAK(_sym_glCreateProgram, glsym_func_uint);
2019 FINDSYM(_sym_glCreateShader, "glCreateShader", glsym_func_uint);
2020 FALLBAK(_sym_glCreateShader, glsym_func_uint);
2022 FINDSYM(_sym_glCullFace, "glCullFace", glsym_func_void);
2023 FALLBAK(_sym_glCullFace, glsym_func_void);
2025 FINDSYM(_sym_glDeleteBuffers, "glDeleteBuffers", glsym_func_void);
2026 FALLBAK(_sym_glDeleteBuffers, glsym_func_void);
2028 FINDSYM(_sym_glDeleteFramebuffers, "glDeleteFramebuffers", glsym_func_void);
2029 FALLBAK(_sym_glDeleteFramebuffers, glsym_func_void);
2031 FINDSYM(_sym_glDeleteProgram, "glDeleteProgram", glsym_func_void);
2032 FALLBAK(_sym_glDeleteProgram, glsym_func_void);
2034 FINDSYM(_sym_glDeleteRenderbuffers, "glDeleteRenderbuffers", glsym_func_void);
2035 FALLBAK(_sym_glDeleteRenderbuffers, glsym_func_void);
2037 FINDSYM(_sym_glDeleteShader, "glDeleteShader", glsym_func_void);
2038 FALLBAK(_sym_glDeleteShader, glsym_func_void);
2040 FINDSYM(_sym_glDeleteTextures, "glDeleteTextures", glsym_func_void);
2041 FALLBAK(_sym_glDeleteTextures, glsym_func_void);
2043 FINDSYM(_sym_glDepthFunc, "glDepthFunc", glsym_func_void);
2044 FALLBAK(_sym_glDepthFunc, glsym_func_void);
2046 FINDSYM(_sym_glDepthMask, "glDepthMask", glsym_func_void);
2047 FALLBAK(_sym_glDepthMask, glsym_func_void);
2049 FINDSYM(_sym_glDepthRangef, "glDepthRangef", glsym_func_void);
2050 FINDSYM(_sym_glDepthRangef, "glDepthRange", glsym_func_void);
2051 FALLBAK(_sym_glDepthRangef, glsym_func_void);
2053 FINDSYM(_sym_glDetachShader, "glDetachShader", glsym_func_void);
2054 FALLBAK(_sym_glDetachShader, glsym_func_void);
2056 FINDSYM(_sym_glDisable, "glDisable", glsym_func_void);
2057 FALLBAK(_sym_glDisable, glsym_func_void);
2059 FINDSYM(_sym_glDisableVertexAttribArray, "glDisableVertexAttribArray", glsym_func_void);
2060 FALLBAK(_sym_glDisableVertexAttribArray, glsym_func_void);
2062 FINDSYM(_sym_glDrawArrays, "glDrawArrays", glsym_func_void);
2063 FALLBAK(_sym_glDrawArrays, glsym_func_void);
2065 FINDSYM(_sym_glDrawElements, "glDrawElements", glsym_func_void);
2066 FALLBAK(_sym_glDrawElements, glsym_func_void);
2068 FINDSYM(_sym_glEnable, "glEnable", glsym_func_void);
2069 FALLBAK(_sym_glEnable, glsym_func_void);
2071 FINDSYM(_sym_glEnableVertexAttribArray, "glEnableVertexAttribArray", glsym_func_void);
2072 FALLBAK(_sym_glEnableVertexAttribArray, glsym_func_void);
2074 FINDSYM(_sym_glFinish, "glFinish", glsym_func_void);
2075 FALLBAK(_sym_glFinish, glsym_func_void);
2077 FINDSYM(_sym_glFlush, "glFlush", glsym_func_void);
2078 FALLBAK(_sym_glFlush, glsym_func_void);
2080 FINDSYM(_sym_glFramebufferRenderbuffer, "glFramebufferRenderbuffer", glsym_func_void);
2081 FALLBAK(_sym_glFramebufferRenderbuffer, glsym_func_void);
2083 FINDSYM(_sym_glFramebufferTexture2D, "glFramebufferTexture2D", glsym_func_void);
2084 FALLBAK(_sym_glFramebufferTexture2D, glsym_func_void);
2086 FINDSYM(_sym_glFrontFace, "glFrontFace", glsym_func_void);
2087 FALLBAK(_sym_glFrontFace, glsym_func_void);
2089 FINDSYM(_sym_glGenBuffers, "glGenBuffers", glsym_func_void);
2090 FALLBAK(_sym_glGenBuffers, glsym_func_void);
2092 FINDSYM(_sym_glGenerateMipmap, "glGenerateMipmap", glsym_func_void);
2093 FALLBAK(_sym_glGenerateMipmap, glsym_func_void);
2095 FINDSYM(_sym_glGenFramebuffers, "glGenFramebuffers", glsym_func_void);
2096 FALLBAK(_sym_glGenFramebuffers, glsym_func_void);
2098 FINDSYM(_sym_glGenRenderbuffers, "glGenRenderbuffers", glsym_func_void);
2099 FALLBAK(_sym_glGenRenderbuffers, glsym_func_void);
2101 FINDSYM(_sym_glGenTextures, "glGenTextures", glsym_func_void);
2102 FALLBAK(_sym_glGenTextures, glsym_func_void);
2104 FINDSYM(_sym_glGetActiveAttrib, "glGetActiveAttrib", glsym_func_void);
2105 FALLBAK(_sym_glGetActiveAttrib, glsym_func_void);
2107 FINDSYM(_sym_glGetActiveUniform, "glGetActiveUniform", glsym_func_void);
2108 FALLBAK(_sym_glGetActiveUniform, glsym_func_void);
2110 FINDSYM(_sym_glGetAttachedShaders, "glGetAttachedShaders", glsym_func_void);
2111 FALLBAK(_sym_glGetAttachedShaders, glsym_func_void);
2113 FINDSYM(_sym_glGetAttribLocation, "glGetAttribLocation", glsym_func_int);
2114 FALLBAK(_sym_glGetAttribLocation, glsym_func_int);
2116 FINDSYM(_sym_glGetBooleanv, "glGetBooleanv", glsym_func_void);
2117 FALLBAK(_sym_glGetBooleanv, glsym_func_void);
2119 FINDSYM(_sym_glGetBufferParameteriv, "glGetBufferParameteriv", glsym_func_void);
2120 FALLBAK(_sym_glGetBufferParameteriv, glsym_func_void);
2122 FINDSYM(_sym_glGetError, "glGetError", glsym_func_uint);
2123 FALLBAK(_sym_glGetError, glsym_func_uint);
2125 FINDSYM(_sym_glGetFloatv, "glGetFloatv", glsym_func_void);
2126 FALLBAK(_sym_glGetFloatv, glsym_func_void);
2128 FINDSYM(_sym_glGetFramebufferAttachmentParameteriv, "glGetFramebufferAttachmentParameteriv", glsym_func_void);
2129 FALLBAK(_sym_glGetFramebufferAttachmentParameteriv, glsym_func_void);
2131 FINDSYM(_sym_glGetIntegerv, "glGetIntegerv", glsym_func_void);
2132 FALLBAK(_sym_glGetIntegerv, glsym_func_void);
2134 FINDSYM(_sym_glGetProgramiv, "glGetProgramiv", glsym_func_void);
2135 FALLBAK(_sym_glGetProgramiv, glsym_func_void);
2137 FINDSYM(_sym_glGetProgramInfoLog, "glGetProgramInfoLog", glsym_func_void);
2138 FALLBAK(_sym_glGetProgramInfoLog, glsym_func_void);
2140 FINDSYM(_sym_glGetRenderbufferParameteriv, "glGetRenderbufferParameteriv", glsym_func_void);
2141 FALLBAK(_sym_glGetRenderbufferParameteriv, glsym_func_void);
2143 FINDSYM(_sym_glGetShaderiv, "glGetShaderiv", glsym_func_void);
2144 FALLBAK(_sym_glGetShaderiv, glsym_func_void);
2146 FINDSYM(_sym_glGetShaderInfoLog, "glGetShaderInfoLog", glsym_func_void);
2147 FALLBAK(_sym_glGetShaderInfoLog, glsym_func_void);
2149 FINDSYM(_sym_glGetShaderPrecisionFormat, "glGetShaderPrecisionFormat", glsym_func_void);
2150 FALLBAK(_sym_glGetShaderPrecisionFormat, glsym_func_void);
2152 FINDSYM(_sym_glGetShaderSource, "glGetShaderSource", glsym_func_void);
2153 FALLBAK(_sym_glGetShaderSource, glsym_func_void);
2155 FINDSYM(_sym_glGetString, "glGetString", glsym_func_uchar_ptr);
2156 FALLBAK(_sym_glGetString, glsym_func_const_uchar_ptr);
2158 FINDSYM(_sym_glGetTexParameterfv, "glGetTexParameterfv", glsym_func_void);
2159 FALLBAK(_sym_glGetTexParameterfv, glsym_func_void);
2161 FINDSYM(_sym_glGetTexParameteriv, "glGetTexParameteriv", glsym_func_void);
2162 FALLBAK(_sym_glGetTexParameteriv, glsym_func_void);
2164 FINDSYM(_sym_glGetUniformfv, "glGetUniformfv", glsym_func_void);
2165 FALLBAK(_sym_glGetUniformfv, glsym_func_void);
2167 FINDSYM(_sym_glGetUniformiv, "glGetUniformiv", glsym_func_void);
2168 FALLBAK(_sym_glGetUniformiv, glsym_func_void);
2170 FINDSYM(_sym_glGetUniformLocation, "glGetUniformLocation", glsym_func_int);
2171 FALLBAK(_sym_glGetUniformLocation, glsym_func_int);
2173 FINDSYM(_sym_glGetVertexAttribfv, "glGetVertexAttribfv", glsym_func_void);
2174 FALLBAK(_sym_glGetVertexAttribfv, glsym_func_void);
2176 FINDSYM(_sym_glGetVertexAttribiv, "glGetVertexAttribiv", glsym_func_void);
2177 FALLBAK(_sym_glGetVertexAttribiv, glsym_func_void);
2179 FINDSYM(_sym_glGetVertexAttribPointerv, "glGetVertexAttribPointerv", glsym_func_void);
2180 FALLBAK(_sym_glGetVertexAttribPointerv, glsym_func_void);
2182 FINDSYM(_sym_glHint, "glHint", glsym_func_void);
2183 FALLBAK(_sym_glHint, glsym_func_void);
2185 FINDSYM(_sym_glIsBuffer, "glIsBuffer", glsym_func_uchar);
2186 FALLBAK(_sym_glIsBuffer, glsym_func_uchar);
2188 FINDSYM(_sym_glIsEnabled, "glIsEnabled", glsym_func_uchar);
2189 FALLBAK(_sym_glIsEnabled, glsym_func_uchar);
2191 FINDSYM(_sym_glIsFramebuffer, "glIsFramebuffer", glsym_func_uchar);
2192 FALLBAK(_sym_glIsFramebuffer, glsym_func_uchar);
2194 FINDSYM(_sym_glIsProgram, "glIsProgram", glsym_func_uchar);
2195 FALLBAK(_sym_glIsProgram, glsym_func_uchar);
2197 FINDSYM(_sym_glIsRenderbuffer, "glIsRenderbuffer", glsym_func_uchar);
2198 FALLBAK(_sym_glIsRenderbuffer, glsym_func_uchar);
2200 FINDSYM(_sym_glIsShader, "glIsShader", glsym_func_uchar);
2201 FALLBAK(_sym_glIsShader, glsym_func_uchar);
2203 FINDSYM(_sym_glIsTexture, "glIsTexture", glsym_func_uchar);
2204 FALLBAK(_sym_glIsTexture, glsym_func_uchar);
2206 FINDSYM(_sym_glLineWidth, "glLineWidth", glsym_func_void);
2207 FALLBAK(_sym_glLineWidth, glsym_func_void);
2209 FINDSYM(_sym_glLinkProgram, "glLinkProgram", glsym_func_void);
2210 FALLBAK(_sym_glLinkProgram, glsym_func_void);
2212 FINDSYM(_sym_glPixelStorei, "glPixelStorei", glsym_func_void);
2213 FALLBAK(_sym_glPixelStorei, glsym_func_void);
2215 FINDSYM(_sym_glPolygonOffset, "glPolygonOffset", glsym_func_void);
2216 FALLBAK(_sym_glPolygonOffset, glsym_func_void);
2218 FINDSYM(_sym_glReadPixels, "glReadPixels", glsym_func_void);
2219 FALLBAK(_sym_glReadPixels, glsym_func_void);
2221 FINDSYM(_sym_glReleaseShaderCompiler, "glReleaseShaderCompiler", glsym_func_void);
2222 FALLBAK(_sym_glReleaseShaderCompiler, glsym_func_void);
2224 FINDSYM(_sym_glRenderbufferStorage, "glRenderbufferStorage", glsym_func_void);
2225 FALLBAK(_sym_glRenderbufferStorage, glsym_func_void);
2227 FINDSYM(_sym_glSampleCoverage, "glSampleCoverage", glsym_func_void);
2228 FALLBAK(_sym_glSampleCoverage, glsym_func_void);
2230 FINDSYM(_sym_glScissor, "glScissor", glsym_func_void);
2231 FALLBAK(_sym_glScissor, glsym_func_void);
2233 FINDSYM(_sym_glShaderBinary, "glShaderBinary", glsym_func_void);
2234 FALLBAK(_sym_glShaderBinary, glsym_func_void);
2236 FINDSYM(_sym_glShaderSource, "glShaderSource", glsym_func_void);
2237 FALLBAK(_sym_glShaderSource, glsym_func_void);
2239 FINDSYM(_sym_glStencilFunc, "glStencilFunc", glsym_func_void);
2240 FALLBAK(_sym_glStencilFunc, glsym_func_void);
2242 FINDSYM(_sym_glStencilFuncSeparate, "glStencilFuncSeparate", glsym_func_void);
2243 FALLBAK(_sym_glStencilFuncSeparate, glsym_func_void);
2245 FINDSYM(_sym_glStencilMask, "glStencilMask", glsym_func_void);
2246 FALLBAK(_sym_glStencilMask, glsym_func_void);
2248 FINDSYM(_sym_glStencilMaskSeparate, "glStencilMaskSeparate", glsym_func_void);
2249 FALLBAK(_sym_glStencilMaskSeparate, glsym_func_void);
2251 FINDSYM(_sym_glStencilOp, "glStencilOp", glsym_func_void);
2252 FALLBAK(_sym_glStencilOp, glsym_func_void);
2254 FINDSYM(_sym_glStencilOpSeparate, "glStencilOpSeparate", glsym_func_void);
2255 FALLBAK(_sym_glStencilOpSeparate, glsym_func_void);
2257 FINDSYM(_sym_glTexImage2D, "glTexImage2D", glsym_func_void);
2258 FALLBAK(_sym_glTexImage2D, glsym_func_void);
2260 FINDSYM(_sym_glTexParameterf, "glTexParameterf", glsym_func_void);
2261 FALLBAK(_sym_glTexParameterf, glsym_func_void);
2263 FINDSYM(_sym_glTexParameterfv, "glTexParameterfv", glsym_func_void);
2264 FALLBAK(_sym_glTexParameterfv, glsym_func_void);
2266 FINDSYM(_sym_glTexParameteri, "glTexParameteri", glsym_func_void);
2267 FALLBAK(_sym_glTexParameteri, glsym_func_void);
2269 FINDSYM(_sym_glTexParameteriv, "glTexParameteriv", glsym_func_void);
2270 FALLBAK(_sym_glTexParameteriv, glsym_func_void);
2272 FINDSYM(_sym_glTexSubImage2D, "glTexSubImage2D", glsym_func_void);
2273 FALLBAK(_sym_glTexSubImage2D, glsym_func_void);
2275 FINDSYM(_sym_glUniform1f, "glUniform1f", glsym_func_void);
2276 FALLBAK(_sym_glUniform1f, glsym_func_void);
2278 FINDSYM(_sym_glUniform1fv, "glUniform1fv", glsym_func_void);
2279 FALLBAK(_sym_glUniform1fv, glsym_func_void);
2281 FINDSYM(_sym_glUniform1i, "glUniform1i", glsym_func_void);
2282 FALLBAK(_sym_glUniform1i, glsym_func_void);
2284 FINDSYM(_sym_glUniform1iv, "glUniform1iv", glsym_func_void);
2285 FALLBAK(_sym_glUniform1iv, glsym_func_void);
2287 FINDSYM(_sym_glUniform2f, "glUniform2f", glsym_func_void);
2288 FALLBAK(_sym_glUniform2f, glsym_func_void);
2290 FINDSYM(_sym_glUniform2fv, "glUniform2fv", glsym_func_void);
2291 FALLBAK(_sym_glUniform2fv, glsym_func_void);
2293 FINDSYM(_sym_glUniform2i, "glUniform2i", glsym_func_void);
2294 FALLBAK(_sym_glUniform2i, glsym_func_void);
2296 FINDSYM(_sym_glUniform2iv, "glUniform2iv", glsym_func_void);
2297 FALLBAK(_sym_glUniform2iv, glsym_func_void);
2299 FINDSYM(_sym_glUniform3f, "glUniform3f", glsym_func_void);
2300 FALLBAK(_sym_glUniform3f, glsym_func_void);
2302 FINDSYM(_sym_glUniform3fv, "glUniform3fv", glsym_func_void);
2303 FALLBAK(_sym_glUniform3fv, glsym_func_void);
2305 FINDSYM(_sym_glUniform3i, "glUniform3i", glsym_func_void);
2306 FALLBAK(_sym_glUniform3i, glsym_func_void);
2308 FINDSYM(_sym_glUniform3iv, "glUniform3iv", glsym_func_void);
2309 FALLBAK(_sym_glUniform3iv, glsym_func_void);
2311 FINDSYM(_sym_glUniform4f, "glUniform4f", glsym_func_void);
2312 FALLBAK(_sym_glUniform4f, glsym_func_void);
2314 FINDSYM(_sym_glUniform4fv, "glUniform4fv", glsym_func_void);
2315 FALLBAK(_sym_glUniform4fv, glsym_func_void);
2317 FINDSYM(_sym_glUniform4i, "glUniform4i", glsym_func_void);
2318 FALLBAK(_sym_glUniform4i, glsym_func_void);
2320 FINDSYM(_sym_glUniform4iv, "glUniform4iv", glsym_func_void);
2321 FALLBAK(_sym_glUniform4iv, glsym_func_void);
2323 FINDSYM(_sym_glUniformMatrix2fv, "glUniformMatrix2fv", glsym_func_void);
2324 FALLBAK(_sym_glUniformMatrix2fv, glsym_func_void);
2326 FINDSYM(_sym_glUniformMatrix3fv, "glUniformMatrix3fv", glsym_func_void);
2327 FALLBAK(_sym_glUniformMatrix3fv, glsym_func_void);
2329 FINDSYM(_sym_glUniformMatrix4fv, "glUniformMatrix4fv", glsym_func_void);
2330 FALLBAK(_sym_glUniformMatrix4fv, glsym_func_void);
2332 FINDSYM(_sym_glUseProgram, "glUseProgram", glsym_func_void);
2333 FALLBAK(_sym_glUseProgram, glsym_func_void);
2335 FINDSYM(_sym_glValidateProgram, "glValidateProgram", glsym_func_void);
2336 FALLBAK(_sym_glValidateProgram, glsym_func_void);
2338 FINDSYM(_sym_glVertexAttrib1f, "glVertexAttrib1f", glsym_func_void);
2339 FALLBAK(_sym_glVertexAttrib1f, glsym_func_void);
2341 FINDSYM(_sym_glVertexAttrib1fv, "glVertexAttrib1fv", glsym_func_void);
2342 FALLBAK(_sym_glVertexAttrib1fv, glsym_func_void);
2344 FINDSYM(_sym_glVertexAttrib2f, "glVertexAttrib2f", glsym_func_void);
2345 FALLBAK(_sym_glVertexAttrib2f, glsym_func_void);
2347 FINDSYM(_sym_glVertexAttrib2fv, "glVertexAttrib2fv", glsym_func_void);
2348 FALLBAK(_sym_glVertexAttrib2fv, glsym_func_void);
2350 FINDSYM(_sym_glVertexAttrib3f, "glVertexAttrib3f", glsym_func_void);
2351 FALLBAK(_sym_glVertexAttrib3f, glsym_func_void);
2353 FINDSYM(_sym_glVertexAttrib3fv, "glVertexAttrib3fv", glsym_func_void);
2354 FALLBAK(_sym_glVertexAttrib3fv, glsym_func_void);
2356 FINDSYM(_sym_glVertexAttrib4f, "glVertexAttrib4f", glsym_func_void);
2357 FALLBAK(_sym_glVertexAttrib4f, glsym_func_void);
2359 FINDSYM(_sym_glVertexAttrib4fv, "glVertexAttrib4fv", glsym_func_void);
2360 FALLBAK(_sym_glVertexAttrib4fv, glsym_func_void);
2362 FINDSYM(_sym_glVertexAttribPointer, "glVertexAttribPointer", glsym_func_void);
2363 FALLBAK(_sym_glVertexAttribPointer, glsym_func_void);
2365 FINDSYM(_sym_glViewport, "glViewport", glsym_func_void);
2366 FALLBAK(_sym_glViewport, glsym_func_void);
2371 // Checking to see if this function exists is a poor but reasonable way to
2372 // check if it's gles but it works for now
2373 if (_sym_glGetShaderPrecisionFormat != (typeof(_sym_glGetShaderPrecisionFormat))sym_missing )
2375 DBG("GL Library is GLES.");
2382 //--------------------------------------------------------------//
2383 // Wrapped GL APIs to handle desktop compatibility
2385 // Stripping precision code from GLES shader for desktop compatibility
2386 // Code adopted from Meego GL code. Temporary Fix.
2388 opengl_strtok(const char *s, int *n, char **saveptr, char *prevbuf)
2394 static const char *delim = " \t\n\r/";
2396 if (prevbuf) free(prevbuf);
2399 *saveptr = (char *)s;
2402 if (!(*saveptr) || !(*n))
2407 for (; *n && strchr(delim, *s); s++, (*n)--)
2409 if (*s == '/' && *n > 1)
2417 while (*n > 1 && s[1] != '\n' && s[1] != '\r');
2419 else if (s[1] == '*')
2425 while (*n > 2 && (s[1] != '*' || s[2] != '/'));
2432 for (; *n && *s && !strchr(delim, *s); s++, (*n)--);
2433 if (*n > 0) s++, (*n)--;
2435 *saveptr = (char *)s;
2438 ret = malloc(retlen + 1);
2443 if (*start == '/' && retlen > 1)
2445 if (start[1] == '/')
2451 while (retlen > 1 && start[1] != '\n' && start[1] != '\r');
2455 else if (start[1] == '*')
2461 while (retlen > 2 && (start[1] != '*' || start[2] != '/'));
2462 start += 3, retlen -= 3;
2466 *(p++) = *(start++), retlen--;
2474 patch_gles_shader(const char *source, int length, int *patched_len)
2476 char *saveptr = NULL;
2480 if (!length) length = strlen(source);
2483 int patched_size = length;
2484 char *patched = malloc(patched_size + 1);
2486 if (!patched) return NULL;
2488 p = (char *)opengl_strtok(source, &length, &saveptr, NULL);
2489 for (; p; p = (char *)opengl_strtok(0, &length, &saveptr, p))
2491 if (!strncmp(p, "lowp", 4) || !strncmp(p, "mediump", 7) || !strncmp(p, "highp", 5))
2495 else if (!strncmp(p, "precision", 9))
2497 while ((p = (char *)opengl_strtok(0, &length, &saveptr, p)) && !strchr(p, ';'));
2501 if (!strncmp(p, "gl_MaxVertexUniformVectors", 26))
2503 p = "(gl_MaxVertexUniformComponents / 4)";
2505 else if (!strncmp(p, "gl_MaxFragmentUniformVectors", 28))
2507 p = "(gl_MaxFragmentUniformComponents / 4)";
2509 else if (!strncmp(p, "gl_MaxVaryingVectors", 20))
2511 p = "(gl_MaxVaryingFloats / 4)";
2514 int new_len = strlen(p);
2515 if (*patched_len + new_len > patched_size)
2518 patched = realloc(patched, patched_size + 1);
2524 memcpy(patched + *patched_len, p, new_len);
2525 *patched_len += new_len;
2529 patched[*patched_len] = 0;
2530 /* check that we don't leave dummy preprocessor lines */
2531 for (sp = patched; *sp;)
2533 for (; *sp == ' ' || *sp == '\t'; sp++);
2534 if (!strncmp(sp, "#define", 7))
2536 for (p = sp + 7; *p == ' ' || *p == '\t'; p++);
2537 if (*p == '\n' || *p == '\r' || *p == '/')
2539 memset(sp, 0x20, 7);
2542 for (; *sp && *sp != '\n' && *sp != '\r'; sp++);
2543 for (; *sp == '\n' || *sp == '\r'; sp++);
2549 evgl_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
2553 char **s = malloc(count * sizeof(char*));
2554 GLint *l = malloc(count * sizeof(GLint));
2556 memset(s, 0, count * sizeof(char*));
2557 memset(l, 0, count * sizeof(GLint));
2559 for (i = 0; i < count; ++i)
2565 len = string[i] ? strlen(string[i]) : 0;
2568 len = string[i] ? strlen(string[i]) : 0;
2572 s[i] = patch_gles_shader(string[i], len, &l[i]);
2580 DBG("Patching Shader Failed.");
2591 _sym_glShaderSource(shader, count, (const char **)s, l);
2601 evgl_glGetShaderPrecisionFormat(GLenum shadertype __UNUSED__, GLenum precisiontype __UNUSED__, GLint* range, GLint* precision)
2605 range[0] = -126; // floor(log2(FLT_MIN))
2606 range[1] = 127; // floor(log2(FLT_MAX))
2610 precision[0] = 24; // floor(-log2((1.0/16777218.0)));
2616 evgl_glReleaseShaderCompiler(void)
2618 DBG("Not supported in Desktop GL");
2623 evgl_glShaderBinary(GLsizei n __UNUSED__, const GLuint* shaders __UNUSED__, GLenum binaryformat __UNUSED__, const void* binary __UNUSED__, GLsizei length __UNUSED__)
2625 // FIXME: need to dlsym/getprocaddress for this
2626 DBG("Not supported in Desktop GL");
2628 //n = binaryformat = length = 0;
2629 //shaders = binary = 0;
2632 //--------------------------------------------------------------//
2637 override_gl_apis(Evas_GL_API *api)
2640 api->version = EVAS_GL_API_VERSION;
2642 #define ORD(f) EVAS_API_OVERRIDE(f, api, _sym_)
2644 ORD(glActiveTexture);
2645 ORD(glAttachShader);
2646 ORD(glBindAttribLocation);
2648 ORD(glBindFramebuffer);
2649 ORD(glBindRenderbuffer);
2652 ORD(glBlendEquation);
2653 ORD(glBlendEquationSeparate);
2655 ORD(glBlendFuncSeparate);
2657 ORD(glBufferSubData);
2658 ORD(glCheckFramebufferStatus);
2662 ORD(glClearStencil);
2664 ORD(glCompileShader);
2665 ORD(glCompressedTexImage2D);
2666 ORD(glCompressedTexSubImage2D);
2667 ORD(glCopyTexImage2D);
2668 ORD(glCopyTexSubImage2D);
2669 ORD(glCreateProgram);
2670 ORD(glCreateShader);
2672 ORD(glDeleteBuffers);
2673 ORD(glDeleteFramebuffers);
2674 ORD(glDeleteProgram);
2675 ORD(glDeleteRenderbuffers);
2676 ORD(glDeleteShader);
2677 ORD(glDeleteTextures);
2681 ORD(glDetachShader);
2683 ORD(glDisableVertexAttribArray);
2685 ORD(glDrawElements);
2687 ORD(glEnableVertexAttribArray);
2690 ORD(glFramebufferRenderbuffer);
2691 ORD(glFramebufferTexture2D);
2694 ORD(glGenerateMipmap);
2695 ORD(glGenFramebuffers);
2696 ORD(glGenRenderbuffers);
2698 ORD(glGetActiveAttrib);
2699 ORD(glGetActiveUniform);
2700 ORD(glGetAttachedShaders);
2701 ORD(glGetAttribLocation);
2703 ORD(glGetBufferParameteriv);
2706 ORD(glGetFramebufferAttachmentParameteriv);
2708 ORD(glGetProgramiv);
2709 ORD(glGetProgramInfoLog);
2710 ORD(glGetRenderbufferParameteriv);
2712 ORD(glGetShaderInfoLog);
2713 ORD(glGetShaderPrecisionFormat);
2714 ORD(glGetShaderSource);
2715 ORD(glGetString); // FIXME
2716 ORD(glGetTexParameterfv);
2717 ORD(glGetTexParameteriv);
2718 ORD(glGetUniformfv);
2719 ORD(glGetUniformiv);
2720 ORD(glGetUniformLocation);
2721 ORD(glGetVertexAttribfv);
2722 ORD(glGetVertexAttribiv);
2723 ORD(glGetVertexAttribPointerv);
2727 ORD(glIsFramebuffer);
2729 ORD(glIsRenderbuffer);
2735 ORD(glPolygonOffset);
2737 ORD(glReleaseShaderCompiler);
2738 ORD(glRenderbufferStorage);
2739 ORD(glSampleCoverage);
2741 ORD(glShaderBinary);
2742 ORD(glShaderSource);
2744 ORD(glStencilFuncSeparate);
2746 ORD(glStencilMaskSeparate);
2748 ORD(glStencilOpSeparate);
2750 ORD(glTexParameterf);
2751 ORD(glTexParameterfv);
2752 ORD(glTexParameteri);
2753 ORD(glTexParameteriv);
2754 ORD(glTexSubImage2D);
2771 ORD(glUniformMatrix2fv);
2772 ORD(glUniformMatrix3fv);
2773 ORD(glUniformMatrix4fv);
2775 ORD(glValidateProgram);
2776 ORD(glVertexAttrib1f);
2777 ORD(glVertexAttrib1fv);
2778 ORD(glVertexAttrib2f);
2779 ORD(glVertexAttrib2fv);
2780 ORD(glVertexAttrib3f);
2781 ORD(glVertexAttrib3fv);
2782 ORD(glVertexAttrib4f);
2783 ORD(glVertexAttrib4fv);
2784 ORD(glVertexAttribPointer);
2788 #define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, evgl_)
2789 if (!gl_lib_is_gles)
2791 // Override functions wrapped by Evas_GL
2792 // GLES2.0 API compat on top of desktop gl
2793 ORD(glGetShaderPrecisionFormat);
2794 ORD(glReleaseShaderCompiler);
2795 ORD(glShaderBinary);
2798 ORD(glShaderSource); // Do precision stripping in both cases
2803 //-------------------------------------------//
2809 gl_lib_handle = dlopen("libOSMesa.so.1", RTLD_NOW);
2810 if (!gl_lib_handle) gl_lib_handle = dlopen("libOSMesa.so", RTLD_NOW);
2813 DBG("Unable to open libOSMesa: %s", dlerror());
2817 //------------------------------------------------//
2818 if (!glue_sym_init()) return 0;
2819 if (!gl_sym_init()) return 0;
2821 override_gl_apis(&gl_funcs);
2833 DBG("Initializing Software OpenGL APIs...\n");
2836 DBG("Unable to support EvasGL in this engine module. Install OSMesa to get it running");
2839 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
2840 ORD(gl_surface_create);
2841 ORD(gl_surface_destroy);
2842 ORD(gl_context_create);
2843 ORD(gl_context_destroy);
2844 ORD(gl_make_current);
2845 ORD(gl_string_query); // FIXME: Need to implement
2846 ORD(gl_proc_address_get); // FIXME: Need to implement
2847 ORD(gl_native_surface_get);
2857 ** MODULE ACCESSIBLE API API
2863 module_open(Evas_Module *em)
2866 _evas_soft_gen_log_dom = eina_log_domain_register
2867 ("evas-software_generic", EVAS_DEFAULT_LOG_COLOR);
2868 if(_evas_soft_gen_log_dom<0)
2870 EINA_LOG_ERR("Can not create a module log domain.");
2876 em->functions = (void *)(&func);
2877 cpunum = eina_cpu_count();
2882 module_close(Evas_Module *em __UNUSED__)
2884 eina_log_domain_unregister(_evas_soft_gen_log_dom);
2887 static Evas_Module_Api evas_modapi =
2889 EVAS_MODULE_API_VERSION,
2898 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_generic);
2900 #ifndef EVAS_STATIC_BUILD_SOFTWARE_GENERIC
2901 EVAS_EINA_MODULE_DEFINE(engine, software_generic);