bfb061c89e51e6dc034e902afc59a60068288310
[profile/ivi/evas.git] / src / modules / engines / software_generic / evas_engine.c
1 #include "evas_common.h" /* Also includes international specific stuff */
2 #include "evas_private.h"
3 #ifdef EVAS_CSERVE2
4 #include "evas_cs2_private.h"
5 #endif
6
7 #ifdef HAVE_DLSYM
8 # include <dlfcn.h>      /* dlopen,dlclose,etc */
9
10 # define EVAS_GL 1
11 # define EVAS_GL_NO_GL_H_CHECK 1
12 # include "Evas_GL.h"
13
14 #else
15 # warning software_generic will not be able to have Evas_GL API.
16 #endif
17
18 #ifdef EVAS_GL
19 //----------------------------------//
20 // OSMesa...
21
22 #define OSMESA_MAJOR_VERSION 6
23 #define OSMESA_MINOR_VERSION 5
24 #define OSMESA_PATCH_VERSION 0
25
26 /*
27  * Values for the format parameter of OSMesaCreateContext()
28  * New in version 2.0.
29  */
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
37
38
39 /*
40  * OSMesaPixelStore() parameters:
41  * New in version 2.0.
42  */
43 #define OSMESA_ROW_LENGTH       0x10
44 #define OSMESA_Y_UP             0x11
45
46
47 /*
48  * Accepted by OSMesaGetIntegerv:
49  */
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 */
56
57
58 typedef void (*OSMESAproc)();
59 typedef struct osmesa_context *OSMesaContext;
60 #endif
61
62 typedef struct _Render_Engine_GL_Surface    Render_Engine_GL_Surface;
63 typedef struct _Render_Engine_GL_Context    Render_Engine_GL_Context;
64
65 struct _Render_Engine_GL_Surface
66 {
67    int     initialized;
68    int     w, h;
69
70 #ifdef EVAS_GL
71    GLenum  internal_fmt;
72 #endif
73    int     internal_cpp;   // Component per pixel.  ie. RGB = 3
74
75    int     depth_bits;
76    int     stencil_bits;
77
78    // Data 
79    void   *buffer;
80
81    Render_Engine_GL_Context   *current_ctx;
82 };
83
84 #ifdef EVAS_GL
85 struct _Render_Engine_GL_Context
86 {
87    int            initialized;
88
89    OSMesaContext  context;
90
91    Render_Engine_GL_Context   *share_ctx;
92
93    Render_Engine_GL_Surface   *current_sfc;
94 };
95
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 //------------------------------------------------------//
109
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;
115
116 //------------------------------------------------------//
117 // OSMesa APIS...
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);
123
124
125 //------------------------------------------------------//
126 // GLES 2.0 APIs...
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;
269
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; */
274 #endif
275
276 /*
277  *****
278  **
279  ** ENGINE ROUTINES
280  **
281  *****
282  */
283 static int cpunum = 0;
284 static int _evas_soft_gen_log_dom = -1;
285
286 static void
287 eng_output_dump(void *data __UNUSED__)
288 {
289    evas_common_image_image_all_unload();
290    evas_common_font_font_all_unload();
291 }
292
293 static void *
294 eng_context_new(void *data __UNUSED__)
295 {
296    return evas_common_draw_context_new();
297 }
298
299 static void
300 eng_context_free(void *data __UNUSED__, void *context)
301 {
302    evas_common_draw_context_free(context);
303 }
304
305 static void
306 eng_context_clip_set(void *data __UNUSED__, void *context, int x, int y, int w, int h)
307 {
308    evas_common_draw_context_set_clip(context, x, y, w, h);
309 }
310
311 static void
312 eng_context_clip_clip(void *data __UNUSED__, void *context, int x, int y, int w, int h)
313 {
314    evas_common_draw_context_clip_clip(context, x, y, w, h);
315 }
316
317 static void
318 eng_context_clip_unset(void *data __UNUSED__, void *context)
319 {
320    evas_common_draw_context_unset_clip(context);
321 }
322
323 static int
324 eng_context_clip_get(void *data __UNUSED__, void *context, int *x, int *y, int *w, int *h)
325 {
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;
331 }
332
333 static void
334 eng_context_color_set(void *data __UNUSED__, void *context, int r, int g, int b, int a)
335 {
336    evas_common_draw_context_set_color(context, r, g, b, a);
337 }
338
339 static int
340 eng_context_color_get(void *data __UNUSED__, void *context, int *r, int *g, int *b, int *a)
341 {
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));
346    return 1;
347 }
348
349 static void
350 eng_context_multiplier_set(void *data __UNUSED__, void *context, int r, int g, int b, int a)
351 {
352    evas_common_draw_context_set_multiplier(context, r, g, b, a);
353 }
354
355 static void
356 eng_context_multiplier_unset(void *data __UNUSED__, void *context)
357 {
358    evas_common_draw_context_unset_multiplier(context);
359 }
360
361 static int
362 eng_context_multiplier_get(void *data __UNUSED__, void *context, int *r, int *g, int *b, int *a)
363 {
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;
369 }
370
371 static void
372 eng_context_mask_set(void *data __UNUSED__, void *context, void *mask, int x, int y, int w, int h)
373 {
374    evas_common_draw_context_set_mask(context, mask, x, y, w, h);
375 }
376
377 static void
378 eng_context_mask_unset(void *data __UNUSED__, void *context)
379 {
380    evas_common_draw_context_unset_mask(context);
381 }
382 /*
383 static void *
384 eng_context_mask_get(void *data __UNUSED__, void *context)
385 {
386    return ((RGBA_Draw_Context *)context)->mask.mask;
387 }
388 */
389
390 static void
391 eng_context_cutout_add(void *data __UNUSED__, void *context, int x, int y, int w, int h)
392 {
393    evas_common_draw_context_add_cutout(context, x, y, w, h);
394 }
395
396 static void
397 eng_context_cutout_clear(void *data __UNUSED__, void *context)
398 {
399    evas_common_draw_context_clear_cutouts(context);
400 }
401
402 static void
403 eng_context_anti_alias_set(void *data __UNUSED__, void *context, unsigned char aa)
404 {
405    evas_common_draw_context_set_anti_alias(context, aa);
406 }
407
408 static unsigned char
409 eng_context_anti_alias_get(void *data __UNUSED__, void *context)
410 {
411    return ((RGBA_Draw_Context *)context)->anti_alias;
412 }
413
414 static void
415 eng_context_color_interpolation_set(void *data __UNUSED__, void *context, int color_space)
416 {
417    evas_common_draw_context_set_color_interpolation(context, color_space);
418 }
419
420 static int
421 eng_context_color_interpolation_get(void *data __UNUSED__, void *context)
422 {
423    return ((RGBA_Draw_Context *)context)->interpolation.color_space;
424 }
425
426 static void
427 eng_context_render_op_set(void *data __UNUSED__, void *context, int op)
428 {
429    evas_common_draw_context_set_render_op(context, op);
430 }
431
432 static int
433 eng_context_render_op_get(void *data __UNUSED__, void *context)
434 {
435    return ((RGBA_Draw_Context *)context)->render_op;
436 }
437
438
439
440 static void
441 eng_rectangle_draw(void *data __UNUSED__, void *context, void *surface, int x, int y, int w, int h)
442 {
443 #ifdef BUILD_PIPE_RENDER
444    if ((cpunum > 1))
445      evas_common_pipe_rectangle_draw(surface, context, x, y, w, h);
446    else
447 #endif
448      {
449         evas_common_rectangle_draw(surface, context, x, y, w, h);
450         evas_common_cpu_end_opt();
451      }
452 }
453
454 static void
455 eng_line_draw(void *data __UNUSED__, void *context, void *surface, int x1, int y1, int x2, int y2)
456 {
457 #ifdef BUILD_PIPE_RENDER
458    if ((cpunum > 1))
459     evas_common_pipe_line_draw(surface, context, x1, y1, x2, y2);
460    else
461 #endif   
462      {
463         evas_common_line_draw(surface, context, x1, y1, x2, y2);
464         evas_common_cpu_end_opt();
465      }
466 }
467
468 static void *
469 eng_polygon_point_add(void *data __UNUSED__, void *context __UNUSED__, void *polygon, int x, int y)
470 {
471    return evas_common_polygon_point_add(polygon, x, y);
472 }
473
474 static void *
475 eng_polygon_points_clear(void *data __UNUSED__, void *context __UNUSED__, void *polygon)
476 {
477    return evas_common_polygon_points_clear(polygon);
478 }
479
480 static void
481 eng_polygon_draw(void *data __UNUSED__, void *context, void *surface, void *polygon, int x, int y)
482 {
483 #ifdef BUILD_PIPE_RENDER
484    if ((cpunum > 1))
485      evas_common_pipe_poly_draw(surface, context, polygon, x, y);
486    else
487 #endif
488      {
489         evas_common_polygon_draw(surface, context, polygon, x, y);
490         evas_common_cpu_end_opt();
491      }
492 }
493
494 static int
495 eng_image_alpha_get(void *data __UNUSED__, void *image)
496 {
497    Image_Entry *im;
498
499    if (!image) return 1;
500    im = image;
501    switch (im->space)
502      {
503       case EVAS_COLORSPACE_ARGB8888:
504         if (im->flags.alpha) return 1;
505       default:
506         break;
507      }
508    return 0;
509 }
510
511 static int
512 eng_image_colorspace_get(void *data __UNUSED__, void *image)
513 {
514    Image_Entry *im;
515
516    if (!image) return EVAS_COLORSPACE_ARGB8888;
517    im = image;
518    return im->space;
519 }
520
521 static Eina_Bool
522 eng_image_can_region_get(void *data __UNUSED__, void *image)
523 {
524    Image_Entry *im;
525    if (!image) return EINA_FALSE;
526    im = image;
527    return ((Evas_Image_Load_Func*) im->info.loader)->do_region;
528 }
529
530 static void
531 eng_image_mask_create(void *data __UNUSED__, void *image)
532 {
533    RGBA_Image *im;
534    int sz;
535    uint8_t *dst,*end;
536    uint32_t *src;
537
538    if (!image) return;
539    im = image;
540    if (im->mask.mask && !im->mask.dirty) return;
541
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);
545    dst = im->mask.mask;
546    if (!im->image.data)
547       evas_cache_image_load_data(&im->cache_entry);
548    src = (void*) im->image.data;
549    if (!src) return;
550    for (end = dst + sz ; dst < end ; dst ++, src ++)
551       *dst = *src >> 24;
552    im->mask.dirty = 0;
553 }
554
555
556 static void *
557 eng_image_alpha_set(void *data __UNUSED__, void *image, int has_alpha)
558 {
559    RGBA_Image *im;
560
561    if (!image) return NULL;
562    im = image;
563    if (im->cache_entry.space != EVAS_COLORSPACE_ARGB8888)
564      {
565         im->cache_entry.flags.alpha = 0;
566         return im;
567      }
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);
571    return im;
572 }
573
574 static void *
575 eng_image_border_set(void *data __UNUSED__, void *image, int l __UNUSED__, int r __UNUSED__, int t __UNUSED__, int b __UNUSED__)
576 {
577    RGBA_Image *im;
578
579    im = image;
580    return im;
581 }
582
583 static void
584 eng_image_border_get(void *data __UNUSED__, void *image __UNUSED__, int *l __UNUSED__, int *r __UNUSED__, int *t __UNUSED__, int *b __UNUSED__)
585 {
586 }
587
588 static char *
589 eng_image_comment_get(void *data __UNUSED__, void *image, char *key __UNUSED__)
590 {
591    RGBA_Image *im;
592
593    if (!image) return NULL;
594    im = image;
595    return im->info.comment;
596 }
597
598 static char *
599 eng_image_format_get(void *data __UNUSED__, void *image __UNUSED__)
600 {
601    return NULL;
602 }
603
604 static void
605 eng_image_colorspace_set(void *data __UNUSED__, void *image, int cspace)
606 {
607    Image_Entry *im;
608
609    if (!image) return;
610    im = image;
611    evas_cache_image_colorspace(im, cspace);
612 }
613
614 static void *
615 eng_image_native_set(void *data __UNUSED__, void *image, void *native __UNUSED__)
616 {
617    //return image;
618    Evas_Native_Surface *ns = native;
619    Image_Entry *im = image, *im2 = NULL;
620
621    if (!im)
622      {
623         if ((!ns) && (ns->data.x11.visual))
624           {
625              im = evas_cache_image_data(evas_common_image_cache_get(),
626                                         im->w, im->h,
627                                         ns->data.x11.visual, 1,
628                                         EVAS_COLORSPACE_ARGB8888);
629              return im;
630           }
631         else
632            return NULL;
633      }
634
635    if ((!ns) && (!im)) return im;
636
637    if (!ns) return im;
638
639    im2 = evas_cache_image_data(evas_common_image_cache_get(), 
640                                im->w, im->h, 
641                                ns->data.x11.visual, 1,
642                                EVAS_COLORSPACE_ARGB8888);
643    evas_cache_image_drop(im);
644    im = im2;
645
646    return im;
647
648 }
649
650 static void *
651 eng_image_native_get(void *data __UNUSED__, void *image __UNUSED__)
652 {
653    return NULL;
654 }
655
656 static void *
657 eng_image_load(void *data __UNUSED__, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
658 {
659    *error = EVAS_LOAD_ERROR_NONE;
660 #ifdef EVAS_CSERVE2
661    if (evas_cserve2_use_get())
662      {
663         Image_Entry *ie;
664         ie = evas_cache2_image_open(evas_common_image_cache2_get(),
665                                     file, key, lo, error);
666         if (ie)
667           evas_cache2_image_open_wait(ie);
668
669         return ie;
670      }
671 #endif
672    return evas_common_load_image_from_file(file, key, lo, error);
673 }
674
675 static void *
676 eng_image_new_from_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
677 {
678 #ifdef EVAS_CSERVE2
679    if (evas_cserve2_use_get())
680      {
681         Evas_Cache2 *cache = evas_common_image_cache2_get();
682         return evas_cache2_image_data(cache, w, h, image_data, alpha, cspace);
683      }
684 #endif
685    return evas_cache_image_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
686 }
687
688 static void *
689 eng_image_new_from_copied_data(void *data __UNUSED__, int w, int h, DATA32 *image_data, int alpha, int cspace)
690 {
691 #ifdef EVAS_CSERVE2
692    if (evas_cserve2_use_get())
693      {
694         Evas_Cache2 *cache = evas_common_image_cache2_get();
695         return evas_cache2_image_copied_data(cache, w, h, image_data, alpha,
696                                              cspace);
697      }
698 #endif
699    return evas_cache_image_copied_data(evas_common_image_cache_get(), w, h, image_data, alpha, cspace);
700 }
701
702 static void
703 eng_image_free(void *data __UNUSED__, void *image)
704 {
705 #ifdef EVAS_CSERVE2
706    if (evas_cserve2_use_get())
707      {
708         evas_cache2_image_close(image);
709         return;
710      }
711 #endif
712    evas_cache_image_drop(image);
713 }
714
715 static void
716 eng_image_size_get(void *data __UNUSED__, void *image, int *w, int *h)
717 {
718    Image_Entry *im;
719
720    im = image;
721    if (w) *w = im->w;
722    if (h) *h = im->h;
723 }
724
725 static void *
726 eng_image_size_set(void *data __UNUSED__, void *image, int w, int h)
727 {
728    Image_Entry *im = image;
729    if (!im) return NULL;
730 #ifdef EVAS_CSERVE2
731    if (evas_cserve2_use_get())
732      return evas_cache2_image_size_set(im, w, h);
733 #endif
734    return evas_cache_image_size_set(im, w, h);
735 }
736
737 static void *
738 eng_image_dirty_region(void *data __UNUSED__, void *image, int x, int y, int w, int h)
739 {
740    Image_Entry *im = image;
741    if (!im) return NULL;
742 #ifdef EVAS_CSERVE2
743    if (evas_cserve2_use_get())
744      return evas_cache2_image_dirty(im, x, y, w, h);
745 #endif
746    return evas_cache_image_dirty(im, x, y, w, h);
747 }
748
749 static void *
750 eng_image_data_get(void *data __UNUSED__, void *image, int to_write, DATA32 **image_data, int *err)
751 {
752    RGBA_Image *im;
753    int error = EVAS_LOAD_ERROR_NONE;
754
755    if (!image)
756      {
757         *image_data = NULL;
758         return NULL;
759      }
760    im = image;
761
762 #ifdef EVAS_CSERVE2
763    if (evas_cserve2_use_get())
764      {
765         error = evas_cache2_image_load_data(&im->cache_entry);
766         if (err) *err = error;
767
768         if (to_write)
769           im = (RGBA_Image *)evas_cache2_image_writable(&im->cache_entry);
770
771         *image_data = im->image.data;
772         return im;
773      }
774 #endif
775
776    error = evas_cache_image_load_data(&im->cache_entry);
777    switch (im->cache_entry.space)
778      {
779       case EVAS_COLORSPACE_ARGB8888:
780         if (to_write)
781           im = (RGBA_Image *)evas_cache_image_alone(&im->cache_entry);
782         *image_data = im->image.data;
783         break;
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;
790         break;
791       default:
792         abort();
793         break;
794      }
795    if (err) *err = error;
796    return im;
797 }
798
799 static void *
800 eng_image_data_put(void *data, void *image, DATA32 *image_data)
801 {
802    RGBA_Image *im, *im2;
803
804    if (!image) return NULL;
805    im = image;
806    switch (im->cache_entry.space)
807      {
808       case EVAS_COLORSPACE_ARGB8888:
809         if (image_data != im->image.data)
810           {
811              int w, h;
812
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));
818 #ifdef EVAS_CSERVE2
819              if (evas_cserve2_use_get())
820                {
821                   evas_cache2_image_close(&im->cache_entry);
822                   im = im2;
823                   break;
824                }
825 #endif
826              evas_cache_image_drop(&im->cache_entry);
827              im = im2;
828           }
829         break;
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)
836           {
837              if (im->cs.data)
838                {
839                   if (!im->cs.no_free) free(im->cs.data);
840                }
841              im->cs.data = image_data;
842           }
843         evas_common_image_colorspace_dirty(im);
844         break;
845       default:
846         abort();
847         break;
848      }
849    return im;
850 }
851
852 static void
853 eng_image_data_preload_request(void *data __UNUSED__, void *image, const void *target)
854 {
855    RGBA_Image *im = image;
856    if (!im) return ;
857
858 #ifdef EVAS_CSERVE2
859    if (evas_cserve2_use_get())
860      {
861         evas_cache2_image_preload_data(&im->cache_entry, target);
862         return;
863      }
864 #endif
865    evas_cache_image_preload_data(&im->cache_entry, target);
866 }
867
868 static void
869 eng_image_data_preload_cancel(void *data __UNUSED__, void *image, const void *target)
870 {
871    RGBA_Image *im = image;
872 #ifdef EVAS_CSERVE2
873    if (evas_cserve2_use_get())
874      return;
875 #endif
876
877    if (!im) return ;
878    evas_cache_image_preload_cancel(&im->cache_entry, target);
879 }
880
881 static void
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)
883 {
884    RGBA_Image *im;
885
886    if (!image) return;
887    im = image;
888 #ifdef BUILD_PIPE_RENDER
889    if ((cpunum > 1))
890      {
891 #ifdef EVAS_CSERVE2
892         if (evas_cserve2_use_get())
893           evas_cache2_image_load_data(&im->cache_entry);
894 #endif
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);
899         
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);
903      }
904    else
905 #endif
906      {
907 #if 0
908 #ifdef EVAS_CSERVE2
909         if (evas_cserve2_use_get())
910           {
911              evas_cache2_image_load_data(&im->cache_entry);
912              goto image_loaded;
913           }
914 #endif
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);
918
919 image_loaded:
920 #endif
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);
927 /*        
928         if (smooth)
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);
932         else
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);
936  */
937         evas_common_cpu_end_opt();
938      }
939 }
940
941 static void
942 evas_software_image_map_draw(void *data, void *context, RGBA_Image *surface, RGBA_Image *im, RGBA_Map *m, int smooth, int level, int offset)
943 {
944    if (m->count - offset < 3) return;
945
946    if ((m->pts[0 + offset].x == m->pts[3 + offset].x) &&
947        (m->pts[1 + offset].x == m->pts[2 + offset].x) &&
948        (m->pts[0 + offset].y == m->pts[1 + offset].y) &&
949        (m->pts[3 + offset].y == m->pts[2 + offset].y) &&
950        (m->pts[0 + offset].x <= m->pts[1 + offset].x) &&
951        (m->pts[0 + offset].y <= m->pts[2 + offset].y) &&
952        (m->pts[0 + offset].u == 0) &&
953        (m->pts[0 + offset].v == 0) &&
954        (m->pts[1 + offset].u == (int)(im->cache_entry.w << FP)) &&
955        (m->pts[1 + offset].v == 0) &&
956        (m->pts[2 + offset].u == (int)(im->cache_entry.w << FP)) &&
957        (m->pts[2 + offset].v == (int)(im->cache_entry.h << FP)) &&
958        (m->pts[3 + offset].u == 0) &&
959        (m->pts[3 + offset].v == (int)(im->cache_entry.h << FP)) &&
960        (m->pts[0 + offset].col == 0xffffffff) &&
961        (m->pts[1 + offset].col == 0xffffffff) &&
962        (m->pts[2 + offset].col == 0xffffffff) &&
963        (m->pts[3 + offset].col == 0xffffffff))
964      {
965         int dx, dy, dw, dh;
966
967         dx = m->pts[0 + offset].x >> FP;
968         dy = m->pts[0 + offset].y >> FP;
969         dw = (m->pts[2 + offset].x >> FP) - dx;
970         dh = (m->pts[2 + offset].y >> FP) - dy;
971         eng_image_draw
972           (data, context, surface, im,
973            0, 0, im->cache_entry.w, im->cache_entry.h,
974            dx, dy, dw, dh, smooth);
975      }
976    else
977      {
978 #ifdef BUILD_PIPE_RENDER
979         if ((cpunum > 1))
980           {
981              evas_common_pipe_map_draw(im, surface, context, m, smooth, level);
982              return ;
983           }
984         else
985 #endif
986           {
987              evas_common_map_rgba(im, surface, context, m->count - offset, &m->pts[offset], smooth, level);
988           }
989      }
990    evas_common_cpu_end_opt();
991
992    if (m->count > 4)
993      {
994         evas_software_image_map_draw(data, context, surface, im, m, smooth, level, offset + 2);
995      }
996 }
997
998 static void
999 eng_image_map_draw(void *data, void *context, void *surface, void *image, RGBA_Map *m, int smooth, int level)
1000 {
1001    if (!image) return;
1002    if (m->count < 3) return;
1003
1004    evas_software_image_map_draw(data, context, surface, image, m, smooth, level, 0);
1005 }
1006
1007 static void
1008 eng_image_map_clean(void *data __UNUSED__, RGBA_Map *m)
1009 {
1010    evas_common_map_rgba_clean(m);
1011 }
1012
1013 static void *
1014 eng_image_map_surface_new(void *data __UNUSED__, int w, int h, int alpha)
1015 {
1016    void *surface;
1017 #ifdef EVAS_CSERVE2
1018    if (evas_cserve2_use_get())
1019      {
1020         surface = evas_cache2_image_copied_data(evas_common_image_cache2_get(),
1021                                                 w, h, NULL, alpha,
1022                                                 EVAS_COLORSPACE_ARGB8888);
1023         evas_cache2_image_pixels(surface);
1024         return surface;
1025      }
1026 #endif
1027    surface = evas_cache_image_copied_data(evas_common_image_cache_get(), 
1028                                           w, h, NULL, alpha, 
1029                                           EVAS_COLORSPACE_ARGB8888);
1030    evas_cache_image_pixels(surface);
1031    return surface;
1032 }
1033
1034 static void
1035 eng_image_map_surface_free(void *data __UNUSED__, void *surface)
1036 {
1037 #ifdef EVAS_CSERVE2
1038    if (evas_cserve2_use_get())
1039      {
1040         evas_cache2_image_unload_data(surface);
1041         return;
1042      }
1043 #endif
1044    evas_cache_image_drop(surface);
1045 }
1046
1047 static void
1048 eng_image_scale_hint_set(void *data __UNUSED__, void *image, int hint)
1049 {
1050    Image_Entry *im;
1051
1052    if (!image) return;
1053    im = image;
1054    im->scale_hint = hint;
1055 }
1056
1057 static int
1058 eng_image_scale_hint_get(void *data __UNUSED__, void *image)
1059 {
1060    Image_Entry *im;
1061
1062    if (!image) return EVAS_IMAGE_SCALE_HINT_NONE;
1063    im = image;
1064    return im->scale_hint;
1065 }
1066
1067 static Eina_Bool
1068 eng_image_animated_get(void *data __UNUSED__, void *image)
1069 {
1070    Image_Entry *im;
1071
1072    if (!image) return EINA_FALSE;
1073    im = image;
1074    return im->flags.animated;
1075 }
1076
1077 static int
1078 eng_image_animated_frame_count_get(void *data __UNUSED__, void *image)
1079 {
1080    Image_Entry *im;
1081
1082    if (!image) return -1;
1083    im = image;
1084    if (!im->flags.animated) return -1;
1085    return im->frame_count;
1086 }
1087
1088 static Evas_Image_Animated_Loop_Hint
1089 eng_image_animated_loop_type_get(void *data __UNUSED__, void *image)
1090 {
1091    Image_Entry *im;
1092
1093    if (!image) return EVAS_IMAGE_ANIMATED_HINT_NONE;
1094    im = image;
1095    if (!im->flags.animated) return EVAS_IMAGE_ANIMATED_HINT_NONE;
1096    return im->loop_hint;
1097 }
1098
1099 static int
1100 eng_image_animated_loop_count_get(void *data __UNUSED__, void *image)
1101 {
1102    Image_Entry *im;
1103
1104    if (!image) return -1;
1105    im = image;
1106    if (!im->flags.animated) return -1;
1107    return im->loop_count;
1108 }
1109
1110 static double
1111 eng_image_animated_frame_duration_get(void *data __UNUSED__, void *image, int start_frame, int frame_num)
1112 {
1113    Image_Entry *im;
1114
1115    if (!image) return -1;
1116    im = image;
1117    if (!im->flags.animated) return -1;
1118    return evas_common_load_rgba_image_frame_duration_from_file(im, start_frame, frame_num);
1119 }
1120
1121 static Eina_Bool
1122 eng_image_animated_frame_set(void *data __UNUSED__, void *image, int frame_index)
1123 {
1124    Image_Entry *im;
1125
1126    if (!image) return EINA_FALSE;
1127    im = image;
1128    if (!im->flags.animated) return EINA_FALSE;
1129    if (im->cur_frame == frame_index) return EINA_FALSE;
1130    im->cur_frame = frame_index;
1131    return EINA_TRUE;
1132 }
1133
1134 static void
1135 eng_image_cache_flush(void *data __UNUSED__)
1136 {
1137    int tmp_size;
1138
1139    tmp_size = evas_common_image_get_cache();
1140    evas_common_image_set_cache(0);
1141    evas_common_rgba_image_scalecache_flush();
1142    evas_common_image_set_cache(tmp_size);
1143 }
1144
1145 static void
1146 eng_image_cache_set(void *data __UNUSED__, int bytes)
1147 {
1148    evas_common_image_set_cache(bytes);
1149    evas_common_rgba_image_scalecache_size_set(bytes);
1150 }
1151
1152 static int
1153 eng_image_cache_get(void *data __UNUSED__)
1154 {
1155    return evas_common_image_get_cache();
1156 }
1157
1158 static Evas_Font_Set *
1159 eng_font_load(void *data __UNUSED__, const char *name, int size,
1160       Font_Rend_Flags wanted_rend)
1161 {
1162    return (Evas_Font_Set *) evas_common_font_load(name, size, wanted_rend);
1163 }
1164
1165 static Evas_Font_Set *
1166 eng_font_memory_load(void *data __UNUSED__, const char *source, const char *name, int size, const void *fdata, int fdata_size, Font_Rend_Flags wanted_rend)
1167 {
1168    return (Evas_Font_Set *) evas_common_font_memory_load(source, name, size,
1169          fdata, fdata_size, wanted_rend);
1170 }
1171
1172 static Evas_Font_Set *
1173 eng_font_add(void *data __UNUSED__, Evas_Font_Set *font, const char *name, int size, Font_Rend_Flags wanted_rend)
1174 {
1175    return (Evas_Font_Set *) evas_common_font_add((RGBA_Font *) font, name,
1176          size, wanted_rend);
1177 }
1178
1179 static Evas_Font_Set *
1180 eng_font_memory_add(void *data __UNUSED__, Evas_Font_Set *font, const char *source, const char *name, int size, const void *fdata, int fdata_size, Font_Rend_Flags wanted_rend)
1181 {
1182    return (Evas_Font_Set *) evas_common_font_memory_add((RGBA_Font *) font,
1183          source, name, size, fdata, fdata_size, wanted_rend);
1184 }
1185
1186 static void
1187 eng_font_free(void *data __UNUSED__, Evas_Font_Set *font)
1188 {
1189    evas_common_font_free((RGBA_Font *) font);
1190 }
1191
1192 static int
1193 eng_font_ascent_get(void *data __UNUSED__, Evas_Font_Set *font)
1194 {
1195    return evas_common_font_ascent_get((RGBA_Font *) font);
1196 }
1197
1198 static int
1199 eng_font_descent_get(void *data __UNUSED__, Evas_Font_Set *font)
1200 {
1201    return evas_common_font_descent_get((RGBA_Font *) font);
1202 }
1203
1204 static int
1205 eng_font_max_ascent_get(void *data __UNUSED__, Evas_Font_Set *font)
1206 {
1207    return evas_common_font_max_ascent_get((RGBA_Font *) font);
1208 }
1209
1210 static int
1211 eng_font_max_descent_get(void *data __UNUSED__, Evas_Font_Set *font)
1212 {
1213    return evas_common_font_max_descent_get((RGBA_Font *) font);
1214 }
1215
1216 static void
1217 eng_font_string_size_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props, int *w, int *h)
1218 {
1219    evas_common_font_query_size((RGBA_Font *) font, text_props, w, h);
1220 }
1221
1222 static int
1223 eng_font_inset_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1224 {
1225    return evas_common_font_query_inset((RGBA_Font *) font, text_props);
1226 }
1227
1228 static int
1229 eng_font_right_inset_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1230 {
1231    return evas_common_font_query_right_inset((RGBA_Font *) font, text_props);
1232 }
1233
1234 static int
1235 eng_font_h_advance_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1236 {
1237    int h, v;
1238
1239    evas_common_font_query_advance((RGBA_Font *) font, text_props, &h, &v);
1240    return h;
1241 }
1242
1243 static int
1244 eng_font_v_advance_get(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props)
1245 {
1246    int h, v;
1247
1248    evas_common_font_query_advance((RGBA_Font *) font, text_props, &h, &v);
1249    return v;
1250 }
1251
1252 static int
1253 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)
1254 {
1255    return evas_common_font_query_pen_coords((RGBA_Font *) font, text_props, pos, cpen_x, cy, cadv, ch);
1256 }
1257
1258 static Eina_Bool
1259 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, Evas_Text_Props_Mode mode)
1260 {
1261    return evas_common_text_props_content_create((RGBA_Font_Int *) fi, text,
1262          text_props, par_props, par_pos, len, mode);
1263 }
1264
1265 static int
1266 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)
1267 {
1268    return evas_common_font_query_char_coords((RGBA_Font *) font, text_props, pos, cx, cy, cw, ch);
1269 }
1270
1271 static int
1272 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)
1273 {
1274    return evas_common_font_query_char_at_coords((RGBA_Font *) font, text_props, x, y, cx, cy, cw, ch);
1275 }
1276
1277 static int
1278 eng_font_last_up_to_pos(void *data __UNUSED__, Evas_Font_Set *font, const Evas_Text_Props *text_props, int x, int y)
1279 {
1280    return evas_common_font_query_last_up_to_pos((RGBA_Font *) font, text_props, x, y);
1281 }
1282
1283 static int
1284 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)
1285 {
1286    return evas_common_font_query_run_font_end_get((RGBA_Font *) font,
1287          (RGBA_Font_Int **) script_fi, (RGBA_Font_Int **) cur_fi,
1288          script, text, run_len);
1289 }
1290
1291 static void
1292 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__, Evas_Text_Props *text_props)
1293 {
1294 #ifdef BUILD_PIPE_RENDER
1295    if ((cpunum > 1))
1296      evas_common_pipe_text_draw(surface, context, x, y, text_props);
1297    else
1298 #endif   
1299      {
1300         evas_common_font_draw_prepare(text_props);
1301         evas_common_font_draw(surface, context, x, y, text_props);
1302         evas_common_cpu_end_opt();
1303      }
1304 }
1305
1306 static void
1307 eng_font_cache_flush(void *data __UNUSED__)
1308 {
1309    int tmp_size;
1310
1311    tmp_size = evas_common_font_cache_get();
1312    evas_common_font_cache_set(0);
1313    evas_common_font_flush();
1314    evas_common_font_cache_set(tmp_size);
1315 }
1316
1317 static void
1318 eng_font_cache_set(void *data __UNUSED__, int bytes)
1319 {
1320    evas_common_font_cache_set(bytes);
1321 }
1322
1323 static int
1324 eng_font_cache_get(void *data __UNUSED__)
1325 {
1326    return evas_common_font_cache_get();
1327 }
1328
1329 static void
1330 eng_font_hinting_set(void *data __UNUSED__, Evas_Font_Set *font, int hinting)
1331 {
1332    evas_common_font_hinting_set((RGBA_Font *) font, hinting);
1333 }
1334
1335 static int
1336 eng_font_hinting_can_hint(void *data __UNUSED__, int hinting)
1337 {
1338    return evas_common_hinting_available(hinting);
1339 }
1340
1341 static Eina_Bool
1342 eng_canvas_alpha_get(void *data __UNUSED__, void *info __UNUSED__)
1343 {
1344    return EINA_TRUE;
1345 }
1346
1347
1348 /* Filter API */
1349 #if 0 // filtering disabled
1350 static void
1351 eng_image_draw_filtered(void *data __UNUSED__, void *context __UNUSED__,
1352                         void *surface, void *image, Evas_Filter_Info *filter)
1353 {
1354    Evas_Software_Filter_Fn fn;
1355    RGBA_Image *im = image;
1356
1357    fn = evas_filter_software_get(filter);
1358    if (!fn) return;
1359    if (im->cache_entry.cache) evas_cache_image_load_data(&im->cache_entry);
1360    fn(filter, image, surface);
1361    return;
1362 }
1363
1364 static Filtered_Image *
1365 eng_image_filtered_get(void *image, uint8_t *key, size_t keylen)
1366 {
1367    RGBA_Image *im = image;
1368    Filtered_Image *fi;
1369    Eina_List *l;
1370
1371    for (l = im->filtered ; l ; l = l->next)
1372      {
1373          fi = l->data;
1374          if (fi->keylen != keylen) continue;
1375          if (memcmp(key, fi->key, keylen) != 0) continue;
1376          fi->ref ++;
1377          return fi;
1378      }
1379
1380    return NULL;
1381 }
1382
1383 static Filtered_Image *
1384 eng_image_filtered_save(void *image, void *fimage, uint8_t *key, size_t keylen)
1385 {
1386    RGBA_Image *im = image;
1387    Filtered_Image *fi;
1388    Eina_List *l;
1389
1390    for (l = im->filtered ; l ; l = l->next)
1391      {
1392         fi = l->data;
1393         if (fi->keylen != keylen) continue;
1394         if (memcmp(key, fi->key, keylen) == 0) continue;
1395         evas_cache_image_drop((void *)fi->image);
1396         fi->image = fimage;
1397         return fi;
1398      }
1399
1400    fi = calloc(1,sizeof(Filtered_Image));
1401    if (!fi) return NULL;
1402
1403    fi->keylen = keylen;
1404    fi->key = malloc(keylen);
1405    memcpy(fi->key, key, keylen);
1406    fi->image = fimage;
1407    fi->ref = 1;
1408
1409    im->filtered = eina_list_prepend(im->filtered, fi);
1410
1411    return fi;
1412 }
1413
1414 static void
1415 eng_image_filtered_free(void *image, Filtered_Image *fi)
1416 {
1417    RGBA_Image *im = image;
1418
1419    fi->ref --;
1420    if (fi->ref) return;
1421
1422    free(fi->key);
1423    evas_cache_image_drop(&fi->image->cache_entry);
1424    fi->image = NULL;
1425
1426    im->filtered = eina_list_remove(im->filtered, fi);
1427 }
1428 #endif
1429
1430 static int
1431 eng_image_load_error_get(void *data __UNUSED__, void *image)
1432 {
1433    RGBA_Image *im;
1434    
1435    if (!image) return EVAS_LOAD_ERROR_NONE;
1436    im = image;
1437    return im->cache_entry.load_error;
1438 }
1439
1440 //------------ Evas GL engine code ---------------//
1441 static void *
1442 eng_gl_surface_create(void *data __UNUSED__, void *config, int w, int h)
1443 {
1444 #ifdef EVAS_GL
1445    Render_Engine_GL_Surface *sfc;
1446    Evas_GL_Config *cfg;
1447
1448    sfc = calloc(1, sizeof(Render_Engine_GL_Surface));
1449    if (!sfc) return NULL;
1450
1451    cfg = (Evas_GL_Config *)config;
1452
1453    sfc->initialized  = 0;
1454    sfc->w            = w;
1455    sfc->h            = h;
1456
1457    // Color Format
1458    switch (cfg->color_format)
1459      {
1460
1461       case EVAS_GL_RGB_888:
1462          sfc->internal_fmt = OSMESA_RGB;
1463          sfc->internal_cpp = 3;
1464          break;
1465       case EVAS_GL_RGBA_8888:
1466          sfc->internal_fmt = OSMESA_BGRA;
1467          sfc->internal_cpp = 4;
1468          break;
1469       default:
1470          sfc->internal_fmt = OSMESA_RGBA;
1471          sfc->internal_cpp = 4;
1472          break;
1473      }
1474
1475    // Depth Bits
1476    switch (cfg->depth_bits)
1477      {
1478       case EVAS_GL_DEPTH_BIT_8:
1479          sfc->depth_bits = 8;
1480          break;
1481       case EVAS_GL_DEPTH_BIT_16:
1482          sfc->depth_bits = 16;
1483          break;
1484       case EVAS_GL_DEPTH_BIT_24:
1485          sfc->depth_bits = 24;
1486          break;
1487       case EVAS_GL_DEPTH_BIT_32:
1488          sfc->depth_bits = 32;
1489          break;
1490       case EVAS_GL_DEPTH_NONE:
1491       default:
1492          sfc->depth_bits = 0;
1493          break;
1494      }
1495    
1496    // Stencil Bits
1497    switch (cfg->stencil_bits)
1498      {
1499       case EVAS_GL_STENCIL_BIT_1:
1500          sfc->stencil_bits = 1;
1501          break;
1502       case EVAS_GL_STENCIL_BIT_2:
1503          sfc->stencil_bits = 2;
1504          break;
1505       case EVAS_GL_STENCIL_BIT_4:
1506          sfc->stencil_bits = 4;
1507          break;
1508       case EVAS_GL_STENCIL_BIT_8:
1509          sfc->stencil_bits = 8;
1510          break;
1511       case EVAS_GL_STENCIL_BIT_16:
1512          sfc->stencil_bits = 16;
1513          break;
1514       case EVAS_GL_STENCIL_NONE:
1515       default:
1516          sfc->stencil_bits = 0;
1517          break;
1518      }
1519
1520    sfc->buffer = malloc(sizeof(unsigned char)*sfc->internal_cpp*w*h);
1521
1522    if (!sfc->buffer)
1523      {
1524         free(sfc);
1525         return NULL;
1526      }
1527
1528    return sfc;
1529 #else
1530    (void) config;
1531    (void) w;
1532    (void) h;
1533    return NULL;
1534 #endif
1535 }
1536
1537 static int
1538 eng_gl_surface_destroy(void *data __UNUSED__, void *surface)
1539 {
1540 #ifdef EVAS_GL
1541    Render_Engine_GL_Surface *sfc;
1542
1543    sfc = (Render_Engine_GL_Surface*)surface;
1544
1545    if (!sfc) return 0;
1546
1547    if (sfc->buffer) free(sfc->buffer);
1548
1549    free(sfc);
1550
1551    surface = NULL;
1552
1553    return 1;
1554 #else
1555    (void) surface;
1556    return 1;
1557 #endif
1558 }
1559
1560 static void *
1561 eng_gl_context_create(void *data __UNUSED__, void *share_context)
1562 {
1563 #ifdef EVAS_GL
1564    Render_Engine_GL_Context *ctx;
1565    Render_Engine_GL_Context *share_ctx;
1566
1567    ctx = calloc(1, sizeof(Render_Engine_GL_Context));
1568
1569    if (!ctx) return NULL;
1570
1571    share_ctx = (Render_Engine_GL_Context *)share_context;
1572
1573    ctx->share_ctx = share_ctx;
1574
1575    /*
1576    if (share_ctx)
1577       ctx->context = OSMesaCreateContextExt( OSMESA_RGBA, 8, 0, 0, share_ctx->context );
1578    else
1579       ctx->context = OSMesaCreateContextExt( OSMESA_RGBA, 8, 0, 0, NULL );
1580
1581
1582    if (!ctx->context)
1583      {
1584         ERR("Error creating OSMesa Context.");
1585         free(ctx);
1586         return NULL;
1587      }
1588      */
1589
1590    ctx->initialized = 0;
1591
1592    return ctx;
1593 #else
1594    (void) share_context;
1595    return NULL;
1596 #endif
1597 }
1598
1599 static int
1600 eng_gl_context_destroy(void *data __UNUSED__, void *context)
1601 {
1602 #ifdef EVAS_GL
1603    Render_Engine_GL_Context *ctx;
1604
1605    ctx = (Render_Engine_GL_Context*)context;
1606
1607    if (!ctx) return 0;
1608
1609    _sym_OSMesaDestroyContext(ctx->context);
1610
1611    free(ctx);
1612    context = NULL;
1613
1614    return 1;
1615 #else
1616    (void) context;
1617    return 0;
1618 #endif
1619 }
1620
1621 static int
1622 eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
1623 {
1624 #ifdef EVAS_GL
1625    Render_Engine_GL_Surface *sfc;
1626    Render_Engine_GL_Context *ctx;
1627    OSMesaContext share_ctx;
1628    GLboolean ret;
1629
1630    sfc = (Render_Engine_GL_Surface*)surface;
1631    ctx = (Render_Engine_GL_Context*)context;
1632
1633    // Unset surface/context
1634    if ((!sfc) || (!ctx))
1635      {
1636         if (ctx) ctx->current_sfc = NULL;
1637         if (sfc) sfc->current_ctx = NULL;
1638         return 1;
1639      }
1640
1641    // Initialize Context if it hasn't been.
1642    if (!ctx->initialized)
1643      {
1644         if (ctx->share_ctx)
1645            share_ctx = ctx->share_ctx->context;
1646         else
1647            share_ctx = NULL;
1648
1649         ctx->context =  _sym_OSMesaCreateContextExt(sfc->internal_fmt, 
1650                                                sfc->depth_bits,
1651                                                sfc->stencil_bits, 
1652                                                0,
1653                                                share_ctx);
1654         if (!ctx->context)
1655           {
1656              ERR("Error initializing context.");
1657              return 0;
1658           }
1659
1660         ctx->initialized = 1;
1661      }
1662
1663
1664    // Call MakeCurrent
1665    ret = _sym_OSMesaMakeCurrent(ctx->context, sfc->buffer, GL_UNSIGNED_BYTE, 
1666                            sfc->w, sfc->h);
1667
1668    if (ret == GL_FALSE)
1669      {
1670         ERR("Error doing MakeCurrent.");
1671         return 0;
1672      }
1673
1674    _sym_OSMesaPixelStore(OSMESA_Y_UP, 0);
1675
1676    // Set the current surface/context
1677    ctx->current_sfc = sfc;
1678    sfc->current_ctx = ctx;
1679
1680    return 1;
1681 #else
1682    (void) surface;
1683    (void) context;
1684    return 1;
1685 #endif
1686 }
1687
1688 // FIXME!!! Implement later
1689 static void *
1690 eng_gl_string_query(void *data __UNUSED__, int name __UNUSED__)
1691 {
1692    return NULL;
1693 }
1694
1695 static void *
1696 eng_gl_proc_address_get(void *data __UNUSED__, const char *name)
1697 {
1698 #ifdef EVAS_GL
1699    if (_sym_OSMesaGetProcAddress) return _sym_OSMesaGetProcAddress(name);
1700    return dlsym(RTLD_DEFAULT, name);
1701 #else
1702    (void) name;
1703    return NULL;
1704 #endif
1705 }
1706
1707 static int
1708 eng_gl_native_surface_get(void *data __UNUSED__, void *surface, void *native_surface)
1709 {
1710 #ifdef EVAS_GL
1711    Render_Engine_GL_Surface *sfc;
1712    Evas_Native_Surface *ns;
1713
1714    sfc = (Render_Engine_GL_Surface*)surface;
1715    ns  = (Evas_Native_Surface*)native_surface;
1716
1717    if (!sfc) return 0;
1718
1719    ns->type = EVAS_NATIVE_SURFACE_OPENGL;
1720    ns->version = EVAS_NATIVE_SURFACE_VERSION;
1721    ns->data.x11.visual = sfc->buffer;
1722
1723    return 1;
1724 #else
1725    (void) surface;
1726    (void) native_surface;
1727    return 1;
1728 #endif
1729 }
1730
1731
1732 static void *
1733 eng_gl_api_get(void *data __UNUSED__)
1734 {
1735 #ifdef EVAS_GL
1736    return &gl_funcs;
1737 #else
1738    return NULL;
1739 #endif
1740 }
1741
1742 //------------------------------------------------//
1743
1744
1745 /*
1746  *****
1747  **
1748  ** ENGINE API
1749  **
1750  *****
1751  */
1752
1753 static Evas_Func func =
1754 {
1755    NULL,
1756      NULL,
1757      NULL,
1758      NULL,
1759      NULL,
1760      NULL,
1761      NULL,
1762      NULL,
1763      NULL,
1764      NULL,
1765      NULL,
1766      NULL,
1767      NULL,
1768      eng_output_dump,
1769      /* draw context virtual methods */
1770      eng_context_new,
1771      eng_canvas_alpha_get,
1772      eng_context_free,
1773      eng_context_clip_set,
1774      eng_context_clip_clip,
1775      eng_context_clip_unset,
1776      eng_context_clip_get,
1777      eng_context_mask_set,
1778      eng_context_mask_unset,
1779      eng_context_color_set,
1780      eng_context_color_get,
1781      eng_context_multiplier_set,
1782      eng_context_multiplier_unset,
1783      eng_context_multiplier_get,
1784      eng_context_cutout_add,
1785      eng_context_cutout_clear,
1786      eng_context_anti_alias_set,
1787      eng_context_anti_alias_get,
1788      eng_context_color_interpolation_set,
1789      eng_context_color_interpolation_get,
1790      eng_context_render_op_set,
1791      eng_context_render_op_get,
1792      /* rect draw funcs */
1793      eng_rectangle_draw,
1794      /* line draw funcs */
1795      eng_line_draw,
1796      /* polygon draw funcs */
1797      eng_polygon_point_add,
1798      eng_polygon_points_clear,
1799      eng_polygon_draw,
1800      /* image draw funcs */
1801      eng_image_load,
1802      eng_image_new_from_data,
1803      eng_image_new_from_copied_data,
1804      eng_image_free,
1805      eng_image_size_get,
1806      eng_image_size_set,
1807      NULL,
1808      eng_image_dirty_region,
1809      eng_image_data_get,
1810      eng_image_data_put,
1811      eng_image_data_preload_request,
1812      eng_image_data_preload_cancel,
1813      eng_image_alpha_set,
1814      eng_image_alpha_get,
1815      eng_image_border_set,
1816      eng_image_border_get,
1817      eng_image_draw,
1818      eng_image_comment_get,
1819      eng_image_format_get,
1820      eng_image_colorspace_set,
1821      eng_image_colorspace_get,
1822      eng_image_can_region_get,
1823      eng_image_mask_create,
1824      eng_image_native_set,
1825      eng_image_native_get,
1826      /* image cache funcs */
1827      eng_image_cache_flush,
1828      eng_image_cache_set,
1829      eng_image_cache_get,
1830      /* font draw functions */
1831      eng_font_load,
1832      eng_font_memory_load,
1833      eng_font_add,
1834      eng_font_memory_add,
1835      eng_font_free,
1836      eng_font_ascent_get,
1837      eng_font_descent_get,
1838      eng_font_max_ascent_get,
1839      eng_font_max_descent_get,
1840      eng_font_string_size_get,
1841      eng_font_inset_get,
1842      eng_font_h_advance_get,
1843      eng_font_v_advance_get,
1844      eng_font_char_coords_get,
1845      eng_font_char_at_coords_get,
1846      eng_font_draw,
1847      /* font cache functions */
1848      eng_font_cache_flush,
1849      eng_font_cache_set,
1850      eng_font_cache_get,
1851      /* font hinting functions */
1852      eng_font_hinting_set,
1853      eng_font_hinting_can_hint,
1854      eng_image_scale_hint_set,
1855      eng_image_scale_hint_get,
1856      /* more font draw functions */
1857      eng_font_last_up_to_pos,
1858      eng_image_map_draw,
1859      eng_image_map_surface_new,
1860      eng_image_map_surface_free,
1861      eng_image_map_clean,
1862      NULL, // eng_image_content_hint_set - software doesn't use it
1863      NULL, // eng_image_content_hint_get - software doesn't use it
1864      eng_font_pen_coords_get,
1865      eng_font_text_props_info_create,
1866      eng_font_right_inset_get,
1867 #if 0 // filtering disabled
1868      eng_image_draw_filtered,
1869      eng_image_filtered_get,
1870      eng_image_filtered_save,
1871      eng_image_filtered_free,
1872 #endif   
1873      NULL, // need software mesa for gl rendering <- gl_surface_create
1874      NULL, // need software mesa for gl rendering <- gl_surface_destroy
1875      NULL, // need software mesa for gl rendering <- gl_context_create
1876      NULL, // need software mesa for gl rendering <- gl_context_destroy
1877      NULL, // need software mesa for gl rendering <- gl_make_current
1878      NULL, // need software mesa for gl rendering <- gl_string_query
1879      NULL, // need software mesa for gl rendering <- gl_proc_address_get
1880      NULL, // need software mesa for gl rendering <- gl_native_surface_get
1881      NULL, // need software mesa for gl rendering <- gl_api_get
1882      NULL, // need software mesa for gl rendering <- gl_img_obj_set
1883      eng_image_load_error_get,
1884      eng_font_run_font_end_get,
1885      eng_image_animated_get,
1886      eng_image_animated_frame_count_get,
1887      eng_image_animated_loop_type_get,
1888      eng_image_animated_loop_count_get,
1889      eng_image_animated_frame_duration_get,
1890      eng_image_animated_frame_set,
1891      NULL
1892    /* FUTURE software generic calls go here */
1893 };
1894
1895
1896 //----------------------------------------------------------------//
1897 //                                                                //
1898 //                      Load Symbols                              //
1899 //                                                                //
1900 //----------------------------------------------------------------//
1901 #ifdef EVAS_GL
1902 static void
1903 sym_missing(void)
1904 {
1905    ERR("GL symbols missing!\n");
1906 }
1907
1908 static int
1909 glue_sym_init(void)
1910 {
1911    //------------------------------------------------//
1912    // Use eglGetProcAddress
1913 #define FINDSYM(dst, sym, typ) \
1914    if (!dst) dst = (typeof(dst))dlsym(gl_lib_handle, sym); \
1915    if (!dst)  \
1916      { \
1917         ERR("Symbol not found %s\n", sym); \
1918         return 0; \
1919      }
1920 #define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
1921
1922     //------------------------------------------------------//
1923    // OSMesa APIs...
1924    FINDSYM(_sym_OSMesaCreateContextExt, "OSMesaCreateContextExt", glsym_func_osm_ctx);
1925    FALLBAK(_sym_OSMesaCreateContextExt, glsym_func_void);
1926
1927    FINDSYM(_sym_OSMesaDestroyContext, "OSMesaDestroyContext", glsym_func_void);
1928    FALLBAK(_sym_OSMesaDestroyContext, glsym_func_void);
1929
1930    FINDSYM(_sym_OSMesaMakeCurrent, "OSMesaMakeCurrent", glsym_func_bool);
1931    FALLBAK(_sym_OSMesaMakeCurrent, glsym_func_void);
1932
1933    FINDSYM(_sym_OSMesaPixelStore, "OSMesaPixelStore", glsym_func_void);
1934    FALLBAK(_sym_OSMesaPixelStore, glsym_func_void);
1935
1936    FINDSYM(_sym_OSMesaGetProcAddress, "OSMesaGetProcAddress", glsym_func_eng_fn);
1937    FALLBAK(_sym_OSMesaGetProcAddress, glsym_func_void);
1938
1939 #undef FINDSYM
1940 #undef FALLBAK
1941
1942    return 1;
1943 }
1944
1945 static int
1946 gl_sym_init(void)
1947 {
1948    //------------------------------------------------//
1949 #define FINDSYM(dst, sym, typ) \
1950    if (!dst) dst = (typeof(dst))dlsym(gl_lib_handle, sym); \
1951    if (!dst) DBG("Symbol not found %s\n", sym);
1952 #define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
1953
1954
1955    //------------------------------------------------------//
1956    // GLES 2.0 APIs...
1957    FINDSYM(_sym_glActiveTexture, "glActiveTexture", glsym_func_void);
1958    FALLBAK(_sym_glActiveTexture, glsym_func_void);
1959
1960    FINDSYM(_sym_glAttachShader, "glAttachShader", glsym_func_void);
1961    FALLBAK(_sym_glAttachShader, glsym_func_void);
1962
1963    FINDSYM(_sym_glBindAttribLocation, "glBindAttribLocation", glsym_func_void);
1964    FALLBAK(_sym_glBindAttribLocation, glsym_func_void);
1965
1966    FINDSYM(_sym_glBindBuffer, "glBindBuffer", glsym_func_void);
1967    FALLBAK(_sym_glBindBuffer, glsym_func_void);
1968
1969    FINDSYM(_sym_glBindFramebuffer, "glBindFramebuffer", glsym_func_void);
1970    FALLBAK(_sym_glBindFramebuffer, glsym_func_void);
1971
1972    FINDSYM(_sym_glBindRenderbuffer, "glBindRenderbuffer", glsym_func_void);
1973    FALLBAK(_sym_glBindRenderbuffer, glsym_func_void);
1974
1975    FINDSYM(_sym_glBindTexture, "glBindTexture", glsym_func_void);
1976    FALLBAK(_sym_glBindTexture, glsym_func_void);
1977
1978    FINDSYM(_sym_glBlendColor, "glBlendColor", glsym_func_void);
1979    FALLBAK(_sym_glBlendColor, glsym_func_void);
1980
1981    FINDSYM(_sym_glBlendEquation, "glBlendEquation", glsym_func_void);
1982    FALLBAK(_sym_glBlendEquation, glsym_func_void);
1983
1984    FINDSYM(_sym_glBlendEquationSeparate, "glBlendEquationSeparate", glsym_func_void);
1985    FALLBAK(_sym_glBlendEquationSeparate, glsym_func_void);
1986
1987    FINDSYM(_sym_glBlendFunc, "glBlendFunc", glsym_func_void);
1988    FALLBAK(_sym_glBlendFunc, glsym_func_void);
1989
1990    FINDSYM(_sym_glBlendFuncSeparate, "glBlendFuncSeparate", glsym_func_void);
1991    FALLBAK(_sym_glBlendFuncSeparate, glsym_func_void);
1992
1993    FINDSYM(_sym_glBufferData, "glBufferData", glsym_func_void);
1994    FALLBAK(_sym_glBufferData, glsym_func_void);
1995
1996    FINDSYM(_sym_glBufferSubData, "glBufferSubData", glsym_func_void);
1997    FALLBAK(_sym_glBufferSubData, glsym_func_void);
1998
1999    FINDSYM(_sym_glCheckFramebufferStatus, "glCheckFramebufferStatus", glsym_func_uint);
2000    FALLBAK(_sym_glCheckFramebufferStatus, glsym_func_uint);
2001
2002    FINDSYM(_sym_glClear, "glClear", glsym_func_void);
2003    FALLBAK(_sym_glClear, glsym_func_void);
2004
2005    FINDSYM(_sym_glClearColor, "glClearColor", glsym_func_void);
2006    FALLBAK(_sym_glClearColor, glsym_func_void);
2007
2008    FINDSYM(_sym_glClearDepthf, "glClearDepthf", glsym_func_void);
2009    FINDSYM(_sym_glClearDepthf, "glClearDepth", glsym_func_void);
2010    FALLBAK(_sym_glClearDepthf, glsym_func_void);
2011
2012    FINDSYM(_sym_glClearStencil, "glClearStencil", glsym_func_void);
2013    FALLBAK(_sym_glClearStencil, glsym_func_void);
2014
2015    FINDSYM(_sym_glColorMask, "glColorMask", glsym_func_void);
2016    FALLBAK(_sym_glColorMask, glsym_func_void);
2017
2018    FINDSYM(_sym_glCompileShader, "glCompileShader", glsym_func_void);
2019    FALLBAK(_sym_glCompileShader, glsym_func_void);
2020
2021    FINDSYM(_sym_glCompressedTexImage2D, "glCompressedTexImage2D", glsym_func_void);
2022    FALLBAK(_sym_glCompressedTexImage2D, glsym_func_void);
2023
2024    FINDSYM(_sym_glCompressedTexSubImage2D, "glCompressedTexSubImage2D", glsym_func_void);
2025    FALLBAK(_sym_glCompressedTexSubImage2D, glsym_func_void);
2026
2027    FINDSYM(_sym_glCopyTexImage2D, "glCopyTexImage2D", glsym_func_void);
2028    FALLBAK(_sym_glCopyTexImage2D, glsym_func_void);
2029
2030    FINDSYM(_sym_glCopyTexSubImage2D, "glCopyTexSubImage2D", glsym_func_void);
2031    FALLBAK(_sym_glCopyTexSubImage2D, glsym_func_void);
2032
2033    FINDSYM(_sym_glCreateProgram, "glCreateProgram", glsym_func_uint);
2034    FALLBAK(_sym_glCreateProgram, glsym_func_uint);
2035
2036    FINDSYM(_sym_glCreateShader, "glCreateShader", glsym_func_uint);
2037    FALLBAK(_sym_glCreateShader, glsym_func_uint);
2038
2039    FINDSYM(_sym_glCullFace, "glCullFace", glsym_func_void);
2040    FALLBAK(_sym_glCullFace, glsym_func_void);
2041
2042    FINDSYM(_sym_glDeleteBuffers, "glDeleteBuffers", glsym_func_void);
2043    FALLBAK(_sym_glDeleteBuffers, glsym_func_void);
2044
2045    FINDSYM(_sym_glDeleteFramebuffers, "glDeleteFramebuffers", glsym_func_void);
2046    FALLBAK(_sym_glDeleteFramebuffers, glsym_func_void);
2047
2048    FINDSYM(_sym_glDeleteProgram, "glDeleteProgram", glsym_func_void);
2049    FALLBAK(_sym_glDeleteProgram, glsym_func_void);
2050
2051    FINDSYM(_sym_glDeleteRenderbuffers, "glDeleteRenderbuffers", glsym_func_void);
2052    FALLBAK(_sym_glDeleteRenderbuffers, glsym_func_void);
2053
2054    FINDSYM(_sym_glDeleteShader, "glDeleteShader", glsym_func_void);
2055    FALLBAK(_sym_glDeleteShader, glsym_func_void);
2056
2057    FINDSYM(_sym_glDeleteTextures, "glDeleteTextures", glsym_func_void);
2058    FALLBAK(_sym_glDeleteTextures, glsym_func_void);
2059
2060    FINDSYM(_sym_glDepthFunc, "glDepthFunc", glsym_func_void);
2061    FALLBAK(_sym_glDepthFunc, glsym_func_void);
2062
2063    FINDSYM(_sym_glDepthMask, "glDepthMask", glsym_func_void);
2064    FALLBAK(_sym_glDepthMask, glsym_func_void);
2065
2066    FINDSYM(_sym_glDepthRangef, "glDepthRangef", glsym_func_void);
2067    FINDSYM(_sym_glDepthRangef, "glDepthRange", glsym_func_void);
2068    FALLBAK(_sym_glDepthRangef, glsym_func_void);
2069
2070    FINDSYM(_sym_glDetachShader, "glDetachShader", glsym_func_void);
2071    FALLBAK(_sym_glDetachShader, glsym_func_void);
2072
2073    FINDSYM(_sym_glDisable, "glDisable", glsym_func_void);
2074    FALLBAK(_sym_glDisable, glsym_func_void);
2075
2076    FINDSYM(_sym_glDisableVertexAttribArray, "glDisableVertexAttribArray", glsym_func_void);
2077    FALLBAK(_sym_glDisableVertexAttribArray, glsym_func_void);
2078
2079    FINDSYM(_sym_glDrawArrays, "glDrawArrays", glsym_func_void);
2080    FALLBAK(_sym_glDrawArrays, glsym_func_void);
2081
2082    FINDSYM(_sym_glDrawElements, "glDrawElements", glsym_func_void);
2083    FALLBAK(_sym_glDrawElements, glsym_func_void);
2084
2085    FINDSYM(_sym_glEnable, "glEnable", glsym_func_void);
2086    FALLBAK(_sym_glEnable, glsym_func_void);
2087
2088    FINDSYM(_sym_glEnableVertexAttribArray, "glEnableVertexAttribArray", glsym_func_void);
2089    FALLBAK(_sym_glEnableVertexAttribArray, glsym_func_void);
2090
2091    FINDSYM(_sym_glFinish, "glFinish", glsym_func_void);
2092    FALLBAK(_sym_glFinish, glsym_func_void);
2093
2094    FINDSYM(_sym_glFlush, "glFlush", glsym_func_void);
2095    FALLBAK(_sym_glFlush, glsym_func_void);
2096
2097    FINDSYM(_sym_glFramebufferRenderbuffer, "glFramebufferRenderbuffer", glsym_func_void);
2098    FALLBAK(_sym_glFramebufferRenderbuffer, glsym_func_void);
2099
2100    FINDSYM(_sym_glFramebufferTexture2D, "glFramebufferTexture2D", glsym_func_void);
2101    FALLBAK(_sym_glFramebufferTexture2D, glsym_func_void);
2102
2103    FINDSYM(_sym_glFrontFace, "glFrontFace", glsym_func_void);
2104    FALLBAK(_sym_glFrontFace, glsym_func_void);
2105
2106    FINDSYM(_sym_glGenBuffers, "glGenBuffers", glsym_func_void);
2107    FALLBAK(_sym_glGenBuffers, glsym_func_void);
2108
2109    FINDSYM(_sym_glGenerateMipmap, "glGenerateMipmap", glsym_func_void);
2110    FALLBAK(_sym_glGenerateMipmap, glsym_func_void);
2111
2112    FINDSYM(_sym_glGenFramebuffers, "glGenFramebuffers", glsym_func_void);
2113    FALLBAK(_sym_glGenFramebuffers, glsym_func_void);
2114
2115    FINDSYM(_sym_glGenRenderbuffers, "glGenRenderbuffers", glsym_func_void);
2116    FALLBAK(_sym_glGenRenderbuffers, glsym_func_void);
2117
2118    FINDSYM(_sym_glGenTextures, "glGenTextures", glsym_func_void);
2119    FALLBAK(_sym_glGenTextures, glsym_func_void);
2120
2121    FINDSYM(_sym_glGetActiveAttrib, "glGetActiveAttrib", glsym_func_void);
2122    FALLBAK(_sym_glGetActiveAttrib, glsym_func_void);
2123
2124    FINDSYM(_sym_glGetActiveUniform, "glGetActiveUniform", glsym_func_void);
2125    FALLBAK(_sym_glGetActiveUniform, glsym_func_void);
2126
2127    FINDSYM(_sym_glGetAttachedShaders, "glGetAttachedShaders", glsym_func_void);
2128    FALLBAK(_sym_glGetAttachedShaders, glsym_func_void);
2129
2130    FINDSYM(_sym_glGetAttribLocation, "glGetAttribLocation", glsym_func_int);
2131    FALLBAK(_sym_glGetAttribLocation, glsym_func_int);
2132
2133    FINDSYM(_sym_glGetBooleanv, "glGetBooleanv", glsym_func_void);
2134    FALLBAK(_sym_glGetBooleanv, glsym_func_void);
2135
2136    FINDSYM(_sym_glGetBufferParameteriv, "glGetBufferParameteriv", glsym_func_void);
2137    FALLBAK(_sym_glGetBufferParameteriv, glsym_func_void);
2138
2139    FINDSYM(_sym_glGetError, "glGetError", glsym_func_uint);
2140    FALLBAK(_sym_glGetError, glsym_func_uint);
2141
2142    FINDSYM(_sym_glGetFloatv, "glGetFloatv", glsym_func_void);
2143    FALLBAK(_sym_glGetFloatv, glsym_func_void);
2144
2145    FINDSYM(_sym_glGetFramebufferAttachmentParameteriv, "glGetFramebufferAttachmentParameteriv", glsym_func_void);
2146    FALLBAK(_sym_glGetFramebufferAttachmentParameteriv, glsym_func_void);
2147
2148    FINDSYM(_sym_glGetIntegerv, "glGetIntegerv", glsym_func_void);
2149    FALLBAK(_sym_glGetIntegerv, glsym_func_void);
2150
2151    FINDSYM(_sym_glGetProgramiv, "glGetProgramiv", glsym_func_void);
2152    FALLBAK(_sym_glGetProgramiv, glsym_func_void);
2153
2154    FINDSYM(_sym_glGetProgramInfoLog, "glGetProgramInfoLog", glsym_func_void);
2155    FALLBAK(_sym_glGetProgramInfoLog, glsym_func_void);
2156
2157    FINDSYM(_sym_glGetRenderbufferParameteriv, "glGetRenderbufferParameteriv", glsym_func_void);
2158    FALLBAK(_sym_glGetRenderbufferParameteriv, glsym_func_void);
2159
2160    FINDSYM(_sym_glGetShaderiv, "glGetShaderiv", glsym_func_void);
2161    FALLBAK(_sym_glGetShaderiv, glsym_func_void);
2162
2163    FINDSYM(_sym_glGetShaderInfoLog, "glGetShaderInfoLog", glsym_func_void);
2164    FALLBAK(_sym_glGetShaderInfoLog, glsym_func_void);
2165
2166    FINDSYM(_sym_glGetShaderPrecisionFormat, "glGetShaderPrecisionFormat", glsym_func_void);
2167    FALLBAK(_sym_glGetShaderPrecisionFormat, glsym_func_void);
2168
2169    FINDSYM(_sym_glGetShaderSource, "glGetShaderSource", glsym_func_void);
2170    FALLBAK(_sym_glGetShaderSource, glsym_func_void);
2171
2172    FINDSYM(_sym_glGetString, "glGetString", glsym_func_uchar_ptr);
2173    FALLBAK(_sym_glGetString, glsym_func_const_uchar_ptr);
2174
2175    FINDSYM(_sym_glGetTexParameterfv, "glGetTexParameterfv", glsym_func_void);
2176    FALLBAK(_sym_glGetTexParameterfv, glsym_func_void);
2177
2178    FINDSYM(_sym_glGetTexParameteriv, "glGetTexParameteriv", glsym_func_void);
2179    FALLBAK(_sym_glGetTexParameteriv, glsym_func_void);
2180
2181    FINDSYM(_sym_glGetUniformfv, "glGetUniformfv", glsym_func_void);
2182    FALLBAK(_sym_glGetUniformfv, glsym_func_void);
2183
2184    FINDSYM(_sym_glGetUniformiv, "glGetUniformiv", glsym_func_void);
2185    FALLBAK(_sym_glGetUniformiv, glsym_func_void);
2186
2187    FINDSYM(_sym_glGetUniformLocation, "glGetUniformLocation", glsym_func_int);
2188    FALLBAK(_sym_glGetUniformLocation, glsym_func_int);
2189
2190    FINDSYM(_sym_glGetVertexAttribfv, "glGetVertexAttribfv", glsym_func_void);
2191    FALLBAK(_sym_glGetVertexAttribfv, glsym_func_void);
2192
2193    FINDSYM(_sym_glGetVertexAttribiv, "glGetVertexAttribiv", glsym_func_void);
2194    FALLBAK(_sym_glGetVertexAttribiv, glsym_func_void);
2195
2196    FINDSYM(_sym_glGetVertexAttribPointerv, "glGetVertexAttribPointerv", glsym_func_void);
2197    FALLBAK(_sym_glGetVertexAttribPointerv, glsym_func_void);
2198
2199    FINDSYM(_sym_glHint, "glHint", glsym_func_void);
2200    FALLBAK(_sym_glHint, glsym_func_void);
2201
2202    FINDSYM(_sym_glIsBuffer, "glIsBuffer", glsym_func_uchar);
2203    FALLBAK(_sym_glIsBuffer, glsym_func_uchar);
2204
2205    FINDSYM(_sym_glIsEnabled, "glIsEnabled", glsym_func_uchar);
2206    FALLBAK(_sym_glIsEnabled, glsym_func_uchar);
2207
2208    FINDSYM(_sym_glIsFramebuffer, "glIsFramebuffer", glsym_func_uchar);
2209    FALLBAK(_sym_glIsFramebuffer, glsym_func_uchar);
2210
2211    FINDSYM(_sym_glIsProgram, "glIsProgram", glsym_func_uchar);
2212    FALLBAK(_sym_glIsProgram, glsym_func_uchar);
2213
2214    FINDSYM(_sym_glIsRenderbuffer, "glIsRenderbuffer", glsym_func_uchar);
2215    FALLBAK(_sym_glIsRenderbuffer, glsym_func_uchar);
2216
2217    FINDSYM(_sym_glIsShader, "glIsShader", glsym_func_uchar);
2218    FALLBAK(_sym_glIsShader, glsym_func_uchar);
2219
2220    FINDSYM(_sym_glIsTexture, "glIsTexture", glsym_func_uchar);
2221    FALLBAK(_sym_glIsTexture, glsym_func_uchar);
2222
2223    FINDSYM(_sym_glLineWidth, "glLineWidth", glsym_func_void);
2224    FALLBAK(_sym_glLineWidth, glsym_func_void);
2225
2226    FINDSYM(_sym_glLinkProgram, "glLinkProgram", glsym_func_void);
2227    FALLBAK(_sym_glLinkProgram, glsym_func_void);
2228
2229    FINDSYM(_sym_glPixelStorei, "glPixelStorei", glsym_func_void);
2230    FALLBAK(_sym_glPixelStorei, glsym_func_void);
2231
2232    FINDSYM(_sym_glPolygonOffset, "glPolygonOffset", glsym_func_void);
2233    FALLBAK(_sym_glPolygonOffset, glsym_func_void);
2234
2235    FINDSYM(_sym_glReadPixels, "glReadPixels", glsym_func_void);
2236    FALLBAK(_sym_glReadPixels, glsym_func_void);
2237
2238    FINDSYM(_sym_glReleaseShaderCompiler, "glReleaseShaderCompiler", glsym_func_void);
2239    FALLBAK(_sym_glReleaseShaderCompiler, glsym_func_void);
2240
2241    FINDSYM(_sym_glRenderbufferStorage, "glRenderbufferStorage", glsym_func_void);
2242    FALLBAK(_sym_glRenderbufferStorage, glsym_func_void);
2243
2244    FINDSYM(_sym_glSampleCoverage, "glSampleCoverage", glsym_func_void);
2245    FALLBAK(_sym_glSampleCoverage, glsym_func_void);
2246
2247    FINDSYM(_sym_glScissor, "glScissor", glsym_func_void);
2248    FALLBAK(_sym_glScissor, glsym_func_void);
2249
2250    FINDSYM(_sym_glShaderBinary, "glShaderBinary", glsym_func_void);
2251    FALLBAK(_sym_glShaderBinary, glsym_func_void);
2252
2253    FINDSYM(_sym_glShaderSource, "glShaderSource", glsym_func_void);
2254    FALLBAK(_sym_glShaderSource, glsym_func_void);
2255
2256    FINDSYM(_sym_glStencilFunc, "glStencilFunc", glsym_func_void);
2257    FALLBAK(_sym_glStencilFunc, glsym_func_void);
2258
2259    FINDSYM(_sym_glStencilFuncSeparate, "glStencilFuncSeparate", glsym_func_void);
2260    FALLBAK(_sym_glStencilFuncSeparate, glsym_func_void);
2261
2262    FINDSYM(_sym_glStencilMask, "glStencilMask", glsym_func_void);
2263    FALLBAK(_sym_glStencilMask, glsym_func_void);
2264
2265    FINDSYM(_sym_glStencilMaskSeparate, "glStencilMaskSeparate", glsym_func_void);
2266    FALLBAK(_sym_glStencilMaskSeparate, glsym_func_void);
2267
2268    FINDSYM(_sym_glStencilOp, "glStencilOp", glsym_func_void);
2269    FALLBAK(_sym_glStencilOp, glsym_func_void);
2270
2271    FINDSYM(_sym_glStencilOpSeparate, "glStencilOpSeparate", glsym_func_void);
2272    FALLBAK(_sym_glStencilOpSeparate, glsym_func_void);
2273
2274    FINDSYM(_sym_glTexImage2D, "glTexImage2D", glsym_func_void);
2275    FALLBAK(_sym_glTexImage2D, glsym_func_void);
2276
2277    FINDSYM(_sym_glTexParameterf, "glTexParameterf", glsym_func_void);
2278    FALLBAK(_sym_glTexParameterf, glsym_func_void);
2279
2280    FINDSYM(_sym_glTexParameterfv, "glTexParameterfv", glsym_func_void);
2281    FALLBAK(_sym_glTexParameterfv, glsym_func_void);
2282
2283    FINDSYM(_sym_glTexParameteri, "glTexParameteri", glsym_func_void);
2284    FALLBAK(_sym_glTexParameteri, glsym_func_void);
2285
2286    FINDSYM(_sym_glTexParameteriv, "glTexParameteriv", glsym_func_void);
2287    FALLBAK(_sym_glTexParameteriv, glsym_func_void);
2288
2289    FINDSYM(_sym_glTexSubImage2D, "glTexSubImage2D", glsym_func_void);
2290    FALLBAK(_sym_glTexSubImage2D, glsym_func_void);
2291
2292    FINDSYM(_sym_glUniform1f, "glUniform1f", glsym_func_void);
2293    FALLBAK(_sym_glUniform1f, glsym_func_void);
2294
2295    FINDSYM(_sym_glUniform1fv, "glUniform1fv", glsym_func_void);
2296    FALLBAK(_sym_glUniform1fv, glsym_func_void);
2297
2298    FINDSYM(_sym_glUniform1i, "glUniform1i", glsym_func_void);
2299    FALLBAK(_sym_glUniform1i, glsym_func_void);
2300
2301    FINDSYM(_sym_glUniform1iv, "glUniform1iv", glsym_func_void);
2302    FALLBAK(_sym_glUniform1iv, glsym_func_void);
2303
2304    FINDSYM(_sym_glUniform2f, "glUniform2f", glsym_func_void);
2305    FALLBAK(_sym_glUniform2f, glsym_func_void);
2306
2307    FINDSYM(_sym_glUniform2fv, "glUniform2fv", glsym_func_void);
2308    FALLBAK(_sym_glUniform2fv, glsym_func_void);
2309
2310    FINDSYM(_sym_glUniform2i, "glUniform2i", glsym_func_void);
2311    FALLBAK(_sym_glUniform2i, glsym_func_void);
2312
2313    FINDSYM(_sym_glUniform2iv, "glUniform2iv", glsym_func_void);
2314    FALLBAK(_sym_glUniform2iv, glsym_func_void);
2315
2316    FINDSYM(_sym_glUniform3f, "glUniform3f", glsym_func_void);
2317    FALLBAK(_sym_glUniform3f, glsym_func_void);
2318
2319    FINDSYM(_sym_glUniform3fv, "glUniform3fv", glsym_func_void);
2320    FALLBAK(_sym_glUniform3fv, glsym_func_void);
2321
2322    FINDSYM(_sym_glUniform3i, "glUniform3i", glsym_func_void);
2323    FALLBAK(_sym_glUniform3i, glsym_func_void);
2324
2325    FINDSYM(_sym_glUniform3iv, "glUniform3iv", glsym_func_void);
2326    FALLBAK(_sym_glUniform3iv, glsym_func_void);
2327
2328    FINDSYM(_sym_glUniform4f, "glUniform4f", glsym_func_void);
2329    FALLBAK(_sym_glUniform4f, glsym_func_void);
2330
2331    FINDSYM(_sym_glUniform4fv, "glUniform4fv", glsym_func_void);
2332    FALLBAK(_sym_glUniform4fv, glsym_func_void);
2333
2334    FINDSYM(_sym_glUniform4i, "glUniform4i", glsym_func_void);
2335    FALLBAK(_sym_glUniform4i, glsym_func_void);
2336
2337    FINDSYM(_sym_glUniform4iv, "glUniform4iv", glsym_func_void);
2338    FALLBAK(_sym_glUniform4iv, glsym_func_void);
2339
2340    FINDSYM(_sym_glUniformMatrix2fv, "glUniformMatrix2fv", glsym_func_void);
2341    FALLBAK(_sym_glUniformMatrix2fv, glsym_func_void);
2342
2343    FINDSYM(_sym_glUniformMatrix3fv, "glUniformMatrix3fv", glsym_func_void);
2344    FALLBAK(_sym_glUniformMatrix3fv, glsym_func_void);
2345
2346    FINDSYM(_sym_glUniformMatrix4fv, "glUniformMatrix4fv", glsym_func_void);
2347    FALLBAK(_sym_glUniformMatrix4fv, glsym_func_void);
2348
2349    FINDSYM(_sym_glUseProgram, "glUseProgram", glsym_func_void);
2350    FALLBAK(_sym_glUseProgram, glsym_func_void);
2351
2352    FINDSYM(_sym_glValidateProgram, "glValidateProgram", glsym_func_void);
2353    FALLBAK(_sym_glValidateProgram, glsym_func_void);
2354
2355    FINDSYM(_sym_glVertexAttrib1f, "glVertexAttrib1f", glsym_func_void);
2356    FALLBAK(_sym_glVertexAttrib1f, glsym_func_void);
2357
2358    FINDSYM(_sym_glVertexAttrib1fv, "glVertexAttrib1fv", glsym_func_void);
2359    FALLBAK(_sym_glVertexAttrib1fv, glsym_func_void);
2360
2361    FINDSYM(_sym_glVertexAttrib2f, "glVertexAttrib2f", glsym_func_void);
2362    FALLBAK(_sym_glVertexAttrib2f, glsym_func_void);
2363
2364    FINDSYM(_sym_glVertexAttrib2fv, "glVertexAttrib2fv", glsym_func_void);
2365    FALLBAK(_sym_glVertexAttrib2fv, glsym_func_void);
2366
2367    FINDSYM(_sym_glVertexAttrib3f, "glVertexAttrib3f", glsym_func_void);
2368    FALLBAK(_sym_glVertexAttrib3f, glsym_func_void);
2369
2370    FINDSYM(_sym_glVertexAttrib3fv, "glVertexAttrib3fv", glsym_func_void);
2371    FALLBAK(_sym_glVertexAttrib3fv, glsym_func_void);
2372
2373    FINDSYM(_sym_glVertexAttrib4f, "glVertexAttrib4f", glsym_func_void);
2374    FALLBAK(_sym_glVertexAttrib4f, glsym_func_void);
2375
2376    FINDSYM(_sym_glVertexAttrib4fv, "glVertexAttrib4fv", glsym_func_void);
2377    FALLBAK(_sym_glVertexAttrib4fv, glsym_func_void);
2378
2379    FINDSYM(_sym_glVertexAttribPointer, "glVertexAttribPointer", glsym_func_void);
2380    FALLBAK(_sym_glVertexAttribPointer, glsym_func_void);
2381
2382    FINDSYM(_sym_glViewport, "glViewport", glsym_func_void);
2383    FALLBAK(_sym_glViewport, glsym_func_void);
2384
2385 #undef FINDSYM
2386 #undef FALLBAK
2387
2388    // Checking to see if this function exists is a poor but reasonable way to 
2389    // check if it's gles but it works for now
2390    if (_sym_glGetShaderPrecisionFormat != (typeof(_sym_glGetShaderPrecisionFormat))sym_missing ) 
2391      {
2392         DBG("GL Library is GLES.");
2393         gl_lib_is_gles = 1;
2394      }
2395
2396    return 1;
2397 }
2398
2399 //--------------------------------------------------------------//
2400 // Wrapped GL APIs to handle desktop compatibility
2401
2402 // Stripping precision code from GLES shader for desktop compatibility
2403 // Code adopted from Meego GL code. Temporary Fix.  
2404 static const char *
2405 opengl_strtok(const char *s, int *n, char **saveptr, char *prevbuf)
2406 {
2407    char *start;
2408    char *ret;
2409    char *p;
2410    int retlen;
2411    static const char *delim = " \t\n\r/";
2412
2413    if (prevbuf) free(prevbuf);
2414
2415    if (s) 
2416       *saveptr = (char *)s;
2417    else 
2418      {
2419         if (!(*saveptr) || !(*n))
2420            return NULL;
2421         s = *saveptr;
2422      }
2423
2424    for (; *n && strchr(delim, *s); s++, (*n)--) 
2425      {
2426         if (*s == '/' && *n > 1) 
2427           {
2428              if (s[1] == '/') 
2429                {
2430                   do 
2431                     {
2432                        s++, (*n)--;
2433                     } 
2434                   while (*n > 1 && s[1] != '\n' && s[1] != '\r');
2435                } 
2436              else if (s[1] == '*') 
2437                {
2438                   do 
2439                     {
2440                        s++, (*n)--;
2441                     } 
2442                   while (*n > 2 && (s[1] != '*' || s[2] != '/'));
2443                   s++, (*n)--;
2444                }
2445           }
2446      }
2447
2448    start = (char *)s;
2449    for (; *n && *s && !strchr(delim, *s); s++, (*n)--);
2450    if (*n > 0) s++, (*n)--;
2451
2452    *saveptr = (char *)s;
2453
2454    retlen = s - start;
2455    ret = malloc(retlen + 1);
2456    p = ret;
2457
2458    while (retlen > 0) 
2459      {
2460         if (*start == '/' && retlen > 1) 
2461           {
2462              if (start[1] == '/') 
2463                {
2464                   do 
2465                     {
2466                        start++, retlen--;
2467                     } 
2468                   while (retlen > 1 && start[1] != '\n' && start[1] != '\r');
2469                   start++, retlen--;
2470                   continue;
2471                } 
2472              else if (start[1] == '*') 
2473                {
2474                   do 
2475                     {
2476                        start++, retlen--;
2477                     } 
2478                   while (retlen > 2 && (start[1] != '*' || start[2] != '/'));
2479                   start += 3, retlen -= 3;
2480                   continue;
2481                }
2482           }
2483         *(p++) = *(start++), retlen--;
2484      }
2485
2486    *p = 0;
2487    return ret;
2488 }       
2489
2490 static char *
2491 patch_gles_shader(const char *source, int length, int *patched_len)
2492 {
2493    char *saveptr = NULL;
2494    char *sp;
2495    char *p = NULL;
2496
2497    if (!length) length = strlen(source);
2498
2499    *patched_len = 0;
2500    int patched_size = length;
2501    char *patched = malloc(patched_size + 1);
2502
2503    if (!patched) return NULL;
2504
2505    p = (char *)opengl_strtok(source, &length, &saveptr, NULL);
2506    for (; p; p = (char *)opengl_strtok(0, &length, &saveptr, p)) 
2507      {
2508         if (!strncmp(p, "lowp", 4) || !strncmp(p, "mediump", 7) || !strncmp(p, "highp", 5)) 
2509           {
2510              continue;
2511           } 
2512         else if (!strncmp(p, "precision", 9)) 
2513           {
2514              while ((p = (char *)opengl_strtok(0, &length, &saveptr, p)) && !strchr(p, ';'));
2515           } 
2516         else 
2517           {
2518              if (!strncmp(p, "gl_MaxVertexUniformVectors", 26)) 
2519                {
2520                   p = "(gl_MaxVertexUniformComponents / 4)";
2521                } 
2522              else if (!strncmp(p, "gl_MaxFragmentUniformVectors", 28)) 
2523                {
2524                   p = "(gl_MaxFragmentUniformComponents / 4)";
2525                } 
2526              else if (!strncmp(p, "gl_MaxVaryingVectors", 20)) 
2527                {
2528                   p = "(gl_MaxVaryingFloats / 4)";
2529                }
2530
2531              int new_len = strlen(p);
2532              if (*patched_len + new_len > patched_size) 
2533                {
2534                   patched_size *= 2;
2535                   patched = realloc(patched, patched_size + 1);
2536
2537                   if (!patched) 
2538                      return NULL;
2539                }
2540
2541              memcpy(patched + *patched_len, p, new_len);
2542              *patched_len += new_len;
2543           }     
2544      }
2545
2546    patched[*patched_len] = 0;
2547    /* check that we don't leave dummy preprocessor lines */
2548    for (sp = patched; *sp;) 
2549      {
2550         for (; *sp == ' ' || *sp == '\t'; sp++);
2551         if (!strncmp(sp, "#define", 7)) 
2552           {
2553              for (p = sp + 7; *p == ' ' || *p == '\t'; p++);
2554              if (*p == '\n' || *p == '\r' || *p == '/') 
2555                {
2556                   memset(sp, 0x20, 7);
2557                }
2558           }
2559         for (; *sp && *sp != '\n' && *sp != '\r'; sp++);
2560         for (; *sp == '\n' || *sp == '\r'; sp++);
2561      }
2562    return patched;
2563 }
2564
2565 static void
2566 evgl_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
2567 {
2568    int i = 0, len = 0;
2569
2570    char **s = malloc(count * sizeof(char*));
2571    GLint *l = malloc(count * sizeof(GLint));
2572
2573    memset(s, 0, count * sizeof(char*));
2574    memset(l, 0, count * sizeof(GLint));
2575
2576    for (i = 0; i < count; ++i) 
2577      {
2578         if (length) 
2579           {
2580              len = length[i];
2581              if (len < 0) 
2582                 len = string[i] ? strlen(string[i]) : 0;
2583           }
2584         else
2585            len = string[i] ? strlen(string[i]) : 0;
2586
2587         if (string[i]) 
2588           {
2589              s[i] = patch_gles_shader(string[i], len, &l[i]);
2590              if (!s[i]) 
2591                {
2592                   while(i)
2593                      free(s[--i]);
2594                   free(l);
2595                   free(s);
2596
2597                   DBG("Patching Shader Failed.");
2598                   return;
2599                }
2600           } 
2601         else 
2602           {
2603              s[i] = NULL;
2604              l[i] = 0;
2605           }
2606      }
2607
2608    _sym_glShaderSource(shader, count, (const char **)s, l);
2609
2610    while(i)
2611       free(s[--i]);
2612    free(l);
2613    free(s);
2614 }
2615
2616
2617 static void
2618 evgl_glGetShaderPrecisionFormat(GLenum shadertype __UNUSED__, GLenum precisiontype __UNUSED__, GLint* range, GLint* precision)
2619 {
2620    if (range)
2621      {
2622         range[0] = -126; // floor(log2(FLT_MIN))
2623         range[1] = 127; // floor(log2(FLT_MAX))
2624      }
2625    if (precision)
2626      {
2627         precision[0] = 24; // floor(-log2((1.0/16777218.0)));
2628      }
2629    return;
2630 }
2631
2632 static void
2633 evgl_glReleaseShaderCompiler(void)
2634 {
2635    DBG("Not supported in Desktop GL");
2636    return;
2637 }
2638
2639 static void
2640 evgl_glShaderBinary(GLsizei n __UNUSED__, const GLuint* shaders __UNUSED__, GLenum binaryformat __UNUSED__, const void* binary __UNUSED__, GLsizei length __UNUSED__)
2641 {
2642    // FIXME: need to dlsym/getprocaddress for this
2643    DBG("Not supported in Desktop GL");
2644    return;
2645    //n = binaryformat = length = 0;
2646    //shaders = binary = 0;
2647 }
2648 #endif
2649 //--------------------------------------------------------------//
2650
2651
2652 #ifdef EVAS_GL
2653 static void
2654 override_gl_apis(Evas_GL_API *api)
2655 {
2656
2657    api->version = EVAS_GL_API_VERSION;
2658
2659 #define ORD(f) EVAS_API_OVERRIDE(f, api, _sym_)
2660    // GLES 2.0
2661    ORD(glActiveTexture);
2662    ORD(glAttachShader);
2663    ORD(glBindAttribLocation);
2664    ORD(glBindBuffer);
2665    ORD(glBindFramebuffer);
2666    ORD(glBindRenderbuffer);
2667    ORD(glBindTexture);
2668    ORD(glBlendColor);
2669    ORD(glBlendEquation);
2670    ORD(glBlendEquationSeparate);
2671    ORD(glBlendFunc);
2672    ORD(glBlendFuncSeparate);
2673    ORD(glBufferData);
2674    ORD(glBufferSubData);
2675    ORD(glCheckFramebufferStatus);
2676    ORD(glClear);
2677    ORD(glClearColor);
2678    ORD(glClearDepthf);     
2679    ORD(glClearStencil);
2680    ORD(glColorMask);
2681    ORD(glCompileShader);
2682    ORD(glCompressedTexImage2D);
2683    ORD(glCompressedTexSubImage2D);
2684    ORD(glCopyTexImage2D);
2685    ORD(glCopyTexSubImage2D);
2686    ORD(glCreateProgram);
2687    ORD(glCreateShader);
2688    ORD(glCullFace);
2689    ORD(glDeleteBuffers);
2690    ORD(glDeleteFramebuffers);
2691    ORD(glDeleteProgram);
2692    ORD(glDeleteRenderbuffers);
2693    ORD(glDeleteShader);
2694    ORD(glDeleteTextures);
2695    ORD(glDepthFunc);
2696    ORD(glDepthMask);
2697    ORD(glDepthRangef);     
2698    ORD(glDetachShader);
2699    ORD(glDisable);
2700    ORD(glDisableVertexAttribArray);
2701    ORD(glDrawArrays);
2702    ORD(glDrawElements);
2703    ORD(glEnable);
2704    ORD(glEnableVertexAttribArray);
2705    ORD(glFinish);
2706    ORD(glFlush);
2707    ORD(glFramebufferRenderbuffer);
2708    ORD(glFramebufferTexture2D);
2709    ORD(glFrontFace);
2710    ORD(glGenBuffers);
2711    ORD(glGenerateMipmap);
2712    ORD(glGenFramebuffers);
2713    ORD(glGenRenderbuffers);
2714    ORD(glGenTextures);
2715    ORD(glGetActiveAttrib);
2716    ORD(glGetActiveUniform);
2717    ORD(glGetAttachedShaders);
2718    ORD(glGetAttribLocation);
2719    ORD(glGetBooleanv);
2720    ORD(glGetBufferParameteriv);
2721    ORD(glGetError);
2722    ORD(glGetFloatv);
2723    ORD(glGetFramebufferAttachmentParameteriv);
2724    ORD(glGetIntegerv);
2725    ORD(glGetProgramiv);
2726    ORD(glGetProgramInfoLog);
2727    ORD(glGetRenderbufferParameteriv);
2728    ORD(glGetShaderiv);
2729    ORD(glGetShaderInfoLog);
2730    ORD(glGetShaderPrecisionFormat);  
2731    ORD(glGetShaderSource);
2732    ORD(glGetString);             // FIXME
2733    ORD(glGetTexParameterfv);
2734    ORD(glGetTexParameteriv);
2735    ORD(glGetUniformfv);
2736    ORD(glGetUniformiv);
2737    ORD(glGetUniformLocation);
2738    ORD(glGetVertexAttribfv);
2739    ORD(glGetVertexAttribiv);
2740    ORD(glGetVertexAttribPointerv);
2741    ORD(glHint);
2742    ORD(glIsBuffer);
2743    ORD(glIsEnabled);
2744    ORD(glIsFramebuffer);
2745    ORD(glIsProgram);
2746    ORD(glIsRenderbuffer);
2747    ORD(glIsShader);
2748    ORD(glIsTexture);
2749    ORD(glLineWidth);
2750    ORD(glLinkProgram);
2751    ORD(glPixelStorei);
2752    ORD(glPolygonOffset);
2753    ORD(glReadPixels);
2754    ORD(glReleaseShaderCompiler); 
2755    ORD(glRenderbufferStorage);
2756    ORD(glSampleCoverage);
2757    ORD(glScissor);
2758    ORD(glShaderBinary); 
2759    ORD(glShaderSource);
2760    ORD(glStencilFunc);
2761    ORD(glStencilFuncSeparate);
2762    ORD(glStencilMask);
2763    ORD(glStencilMaskSeparate);
2764    ORD(glStencilOp);
2765    ORD(glStencilOpSeparate);
2766    ORD(glTexImage2D);
2767    ORD(glTexParameterf);
2768    ORD(glTexParameterfv);
2769    ORD(glTexParameteri);
2770    ORD(glTexParameteriv);
2771    ORD(glTexSubImage2D);
2772    ORD(glUniform1f);
2773    ORD(glUniform1fv);
2774    ORD(glUniform1i);
2775    ORD(glUniform1iv);
2776    ORD(glUniform2f);
2777    ORD(glUniform2fv);
2778    ORD(glUniform2i);
2779    ORD(glUniform2iv);
2780    ORD(glUniform3f);
2781    ORD(glUniform3fv);
2782    ORD(glUniform3i);
2783    ORD(glUniform3iv);
2784    ORD(glUniform4f);
2785    ORD(glUniform4fv);
2786    ORD(glUniform4i);
2787    ORD(glUniform4iv);
2788    ORD(glUniformMatrix2fv);
2789    ORD(glUniformMatrix3fv);
2790    ORD(glUniformMatrix4fv);
2791    ORD(glUseProgram);
2792    ORD(glValidateProgram);
2793    ORD(glVertexAttrib1f);
2794    ORD(glVertexAttrib1fv);
2795    ORD(glVertexAttrib2f);
2796    ORD(glVertexAttrib2fv);
2797    ORD(glVertexAttrib3f);
2798    ORD(glVertexAttrib3fv);
2799    ORD(glVertexAttrib4f);
2800    ORD(glVertexAttrib4fv);
2801    ORD(glVertexAttribPointer);
2802    ORD(glViewport);
2803 #undef ORD
2804
2805 #define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, evgl_)
2806    if (!gl_lib_is_gles)
2807      {
2808         // Override functions wrapped by Evas_GL
2809         // GLES2.0 API compat on top of desktop gl
2810         ORD(glGetShaderPrecisionFormat);
2811         ORD(glReleaseShaderCompiler);
2812         ORD(glShaderBinary);
2813      }
2814
2815    ORD(glShaderSource);    // Do precision stripping in both cases
2816 #undef ORD
2817 }
2818 #endif
2819
2820 //-------------------------------------------//
2821 static int
2822 gl_lib_init(void)
2823 {
2824 #ifdef EVAS_GL
2825    // dlopen OSMesa 
2826    gl_lib_handle = dlopen("libOSMesa.so.1", RTLD_NOW);
2827    if (!gl_lib_handle) gl_lib_handle = dlopen("libOSMesa.so", RTLD_NOW);
2828    if (!gl_lib_handle)
2829      {
2830         DBG("Unable to open libOSMesa:  %s", dlerror());
2831         return 0;
2832      }
2833
2834    //------------------------------------------------//
2835    if (!glue_sym_init()) return 0;
2836    if (!gl_sym_init()) return 0;
2837
2838    override_gl_apis(&gl_funcs);
2839
2840    return 1;
2841 #else
2842    return 0;
2843 #endif
2844 }
2845
2846
2847 static void
2848 init_gl(void)
2849 {
2850    DBG("Initializing Software OpenGL APIs...\n");
2851
2852    if (!gl_lib_init())
2853       DBG("Unable to support EvasGL in this engine module. Install OSMesa to get it running");
2854    else
2855      {
2856 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
2857         ORD(gl_surface_create);
2858         ORD(gl_surface_destroy);
2859         ORD(gl_context_create);
2860         ORD(gl_context_destroy);
2861         ORD(gl_make_current);
2862         ORD(gl_string_query);           // FIXME: Need to implement
2863         ORD(gl_proc_address_get);       // FIXME: Need to implement
2864         ORD(gl_native_surface_get);
2865         ORD(gl_api_get);
2866 #undef ORD
2867      }
2868 }
2869
2870
2871 /*
2872  *****
2873  **
2874  ** MODULE ACCESSIBLE API API
2875  **
2876  *****
2877  */
2878
2879 static int
2880 module_open(Evas_Module *em)
2881 {
2882    if (!em) return 0;
2883    _evas_soft_gen_log_dom = eina_log_domain_register
2884      ("evas-software_generic", EVAS_DEFAULT_LOG_COLOR);
2885    if(_evas_soft_gen_log_dom<0)
2886      {
2887         EINA_LOG_ERR("Can not create a module log domain.");
2888         return 0;
2889      }
2890
2891    init_gl();
2892    evas_common_pipe_init();
2893
2894    em->functions = (void *)(&func);
2895    cpunum = eina_cpu_count();
2896    return 1;
2897 }
2898
2899 static void
2900 module_close(Evas_Module *em __UNUSED__)
2901 {
2902   eina_log_domain_unregister(_evas_soft_gen_log_dom);
2903 }
2904
2905 static Evas_Module_Api evas_modapi =
2906 {
2907    EVAS_MODULE_API_VERSION,
2908    "software_generic",
2909    "none",
2910    {
2911      module_open,
2912      module_close
2913    }
2914 };
2915
2916 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_generic);
2917
2918 #ifndef EVAS_STATIC_BUILD_SOFTWARE_GENERIC
2919 EVAS_EINA_MODULE_DEFINE(engine, software_generic);
2920 #endif