b8ae00137057608a13c0979edd08429e51afe91e
[platform/core/uifw/coregl.git] / src / coregl_export_egl.c
1 #include "coregl_export.h"
2
3 Mutex init_export_mutex = MUTEX_INITIALIZER;
4
5 #define INIT_EXPORT() \
6         if (unlikely(export_initialized == 0)) \
7         { \
8                 mutex_lock(&init_export_mutex); \
9                 if (export_initialized == 0) \
10                 { \
11                         if (coregl_initialize() != 0) \
12                         { \
13                                 export_initialized = 1; \
14                         } \
15                 } \
16                 mutex_unlock(&init_export_mutex); \
17         }
18
19 EGLint
20 coregl_api_eglGetError(void)
21 {
22         INIT_EXPORT();
23         if (!export_initialized)
24                 return EGL_NOT_INITIALIZED;
25         else
26                 return ovr_eglGetError();
27 }
28
29 EGLDisplay
30 coregl_api_eglGetDisplay(EGLNativeDisplayType display_id)
31 {
32         INIT_EXPORT();
33         if (!export_initialized)
34                 return NULL;
35         else
36                 return ovr_eglGetDisplay(display_id);
37 }
38
39 EGLBoolean
40 coregl_api_eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor)
41 {
42         INIT_EXPORT();
43         if (!export_initialized)
44                 return EGL_FALSE;
45         else
46                 return ovr_eglInitialize(dpy, major, minor);
47 }
48
49 EGLBoolean
50 coregl_api_eglTerminate(EGLDisplay dpy)
51 {
52         INIT_EXPORT();
53         if (!export_initialized)
54                 return EGL_FALSE;
55         else
56                 return ovr_eglTerminate(dpy);
57 }
58
59 EGLBoolean
60 coregl_api_eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
61 {
62         INIT_EXPORT();
63         if (!export_initialized)
64                 return EGL_FALSE;
65         else
66                 return ovr_eglGetConfigs(dpy, configs, config_size, num_config);
67 }
68
69 EGLBoolean
70 coregl_api_eglChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config)
71 {
72         INIT_EXPORT();
73         if (!export_initialized)
74                 return EGL_FALSE;
75         else
76                 return ovr_eglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
77 }
78
79 EGLBoolean
80 coregl_api_eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
81 {
82         INIT_EXPORT();
83         if (!export_initialized)
84                 return EGL_FALSE;
85         else
86                 return ovr_eglGetConfigAttrib(dpy, config, attribute, value);
87 }
88
89
90 EGLSurface
91 coregl_api_eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list)
92 {
93         INIT_EXPORT();
94         if (!export_initialized)
95                 return EGL_NO_SURFACE;
96         else
97                 return ovr_eglCreateWindowSurface(dpy, config, win, attrib_list);
98 }
99
100 EGLSurface
101 coregl_api_eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
102 {
103         INIT_EXPORT();
104         if (!export_initialized)
105                 return EGL_NO_SURFACE;
106         else
107                 return ovr_eglCreatePbufferSurface(dpy, config, attrib_list);
108 }
109
110 EGLSurface
111 coregl_api_eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list)
112 {
113         INIT_EXPORT();
114         if (!export_initialized)
115                 return EGL_NO_SURFACE;
116         else
117                 return ovr_eglCreatePixmapSurface(dpy, config, pixmap, attrib_list);
118 }
119
120 EGLBoolean
121 coregl_api_eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
122 {
123         INIT_EXPORT();
124         if (!export_initialized)
125                 return EGL_FALSE;
126         else
127                 return ovr_eglDestroySurface(dpy, surface);
128 }
129
130 EGLBoolean
131 coregl_api_eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
132 {
133         INIT_EXPORT();
134         if (!export_initialized)
135                 return EGL_FALSE;
136         else
137                 return ovr_eglQuerySurface(dpy, surface, attribute, value);
138 }
139
140 EGLBoolean
141 coregl_api_eglBindAPI(EGLenum api)
142 {
143         INIT_EXPORT();
144         if (!export_initialized)
145                 return EGL_FALSE;
146         else
147                 return ovr_eglBindAPI(api);
148 }
149
150 EGLenum
151 coregl_api_eglQueryAPI(void)
152 {
153         INIT_EXPORT();
154         if (!export_initialized)
155                 return EGL_NONE;
156         else
157                 return ovr_eglQueryAPI();
158 }
159
160 EGLBoolean
161 coregl_api_eglWaitClient(void)
162 {
163         INIT_EXPORT();
164         if (!export_initialized)
165                 return EGL_FALSE;
166         else
167                 return ovr_eglWaitClient();
168 }
169
170 EGLBoolean
171 coregl_api_eglReleaseThread(void)
172 {
173         INIT_EXPORT();
174         if (!export_initialized)
175                 return EGL_FALSE;
176         else
177                 return ovr_eglReleaseThread();
178 }
179
180 EGLSurface
181 coregl_api_eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
182 {
183         INIT_EXPORT();
184         if (!export_initialized)
185                 return EGL_NO_SURFACE;
186         else
187                 return ovr_eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
188 }
189
190 EGLBoolean
191 coregl_api_eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
192 {
193         INIT_EXPORT();
194         if (!export_initialized)
195                 return EGL_FALSE;
196         else
197                 return ovr_eglSurfaceAttrib(dpy, surface, attribute, value);
198 }
199
200 EGLBoolean
201 coregl_api_eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
202 {
203         INIT_EXPORT();
204         if (!export_initialized)
205                 return EGL_FALSE;
206         else
207                 return ovr_eglBindTexImage(dpy, surface, buffer);
208 }
209
210 EGLBoolean
211 coregl_api_eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
212 {
213         INIT_EXPORT();
214         if (!export_initialized)
215                 return EGL_FALSE;
216         else
217                 return ovr_eglReleaseTexImage(dpy, surface, buffer);
218 }
219
220 EGLBoolean
221 coregl_api_eglSwapInterval(EGLDisplay dpy, EGLint interval)
222 {
223         INIT_EXPORT();
224         if (!export_initialized)
225                 EGL_FALSE;
226         else
227                 return ovr_eglSwapInterval(dpy, interval);
228 }
229
230 EGLContext
231 coregl_api_eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list)
232 {
233         INIT_EXPORT();
234         if (!export_initialized)
235                 return EGL_NO_CONTEXT;
236         else
237                 return ovr_eglCreateContext(dpy, config, share_context, attrib_list);
238 }
239
240 EGLBoolean
241 coregl_api_eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
242 {
243         INIT_EXPORT();
244         if (!export_initialized)
245                 return EGL_FALSE;
246         else
247                 return ovr_eglDestroyContext(dpy, ctx);
248 }
249
250 EGLBoolean
251 coregl_api_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
252 {
253         INIT_EXPORT();
254         if (!export_initialized)
255                 return EGL_FALSE;
256         else
257                 return ovr_eglMakeCurrent(dpy, draw, read, ctx);
258 }
259
260 EGLContext
261 coregl_api_eglGetCurrentContext(void)
262 {
263         INIT_EXPORT();
264         if (!export_initialized)
265                 return EGL_NO_CONTEXT;
266         else
267                 return ovr_eglGetCurrentContext();
268 }
269
270 EGLSurface
271 coregl_api_eglGetCurrentSurface(EGLint readdraw)
272 {
273         INIT_EXPORT();
274         if (!export_initialized)
275                 return EGL_NO_SURFACE;
276         else
277                 return ovr_eglGetCurrentSurface(readdraw);
278 }
279
280 EGLDisplay
281 coregl_api_eglGetCurrentDisplay(void)
282 {
283         INIT_EXPORT();
284         if (!export_initialized)
285                 return EGL_NO_DISPLAY;
286         else
287                 return ovr_eglGetCurrentDisplay();
288 }
289
290 EGLBoolean
291 coregl_api_eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
292 {
293         INIT_EXPORT();
294         if (!export_initialized)
295                 return EGL_FALSE;
296         return ovr_eglQueryContext(dpy, ctx, attribute, value);
297 }
298
299 EGLBoolean
300 coregl_api_eglWaitGL(void)
301 {
302         INIT_EXPORT();
303         if (!export_initialized)
304                 return EGL_FALSE;
305         else
306                 return ovr_eglWaitGL();
307 }
308
309 EGLBoolean
310 coregl_api_eglWaitNative(EGLint engine)
311 {
312         INIT_EXPORT();
313         if (!export_initialized)
314                 return EGL_FALSE;
315         else
316                 return ovr_eglWaitNative(engine);
317 }
318
319 EGLBoolean
320 coregl_api_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
321 {
322         INIT_EXPORT();
323         if (!export_initialized)
324                 return EGL_FALSE;
325         else
326                 return ovr_eglSwapBuffers(dpy, surface);
327 }
328
329 EGLBoolean
330 coregl_api_eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
331 {
332         INIT_EXPORT();
333         if (!export_initialized)
334                 return EGL_FALSE;
335         else
336                 return ovr_eglCopyBuffers(dpy, surface, target);
337 }
338
339 _eng_fn
340 coregl_api_eglGetProcAddress(const char* procname)
341 {
342         INIT_EXPORT();
343         if (!export_initialized)
344                 return NULL;
345         else
346                 return ovr_eglGetProcAddress(procname);
347 }
348
349 const char *
350 coregl_api_eglQueryString(EGLDisplay dpy, EGLint name)
351 {
352         INIT_EXPORT();
353         if (!export_initialized)
354                 return NULL;
355         return ovr_eglQueryString(dpy, name);
356 }
357