First public contribution.
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Reference EGL implementation to support EGL sync objects and OpenWF extensions
16 #include "eglprivate.h"
20 #define GET_THREAD_SESSION(s,r) CEglThreadSession* s = CEglThreadSession::Static(); \
26 #define PANIC_NOT_SUPPORTED User::Panic(KEglPanicCategory, EEglPanicNotSupported); \
29 // EGL API entrypoints
31 EXPORT_C EGLDisplay eglGetDisplay(NativeDisplayType display_id)
33 GET_THREAD_SESSION(session, EGL_NO_DISPLAY)
34 return session->EglGetDisplay(display_id);
37 EXPORT_C EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor)
39 GET_THREAD_SESSION(session, EGL_FALSE)
40 return session->EglInitialize(dpy, major, minor);
43 EXPORT_C EGLBoolean eglTerminate(EGLDisplay dpy)
45 GET_THREAD_SESSION(session, EGL_FALSE)
46 return session->EglTerminate(dpy);
49 EXPORT_C EGLBoolean eglReleaseThread(void)
51 // do not call CEglThreadSession::Static() here as it may create thread state if it does not exist
53 CEglThreadSession* session = reinterpret_cast<CEglThreadSession*>(Dll::Tls());
63 EXPORT_C EGLint eglGetError(void)
65 // EGL spec section 3.11: GetError will create thread state object,
66 // it is recommended not to call this API immediately after calling ReleaseThread
68 // If session creation fails, we returns BAD_ALLOC
70 GET_THREAD_SESSION(session, EGL_BAD_ALLOC)
71 return session->EglGetError();
74 EXPORT_C const char* eglQueryString(EGLDisplay dpy, EGLint name)
76 GET_THREAD_SESSION(session, NULL)
77 return session->EglQueryString(dpy, name);
80 EXPORT_C TFuncPtrEglProc eglGetProcAddress (const char *procname)
82 GET_THREAD_SESSION(session, NULL)
83 return session->EglGetProcAddress(procname);
86 // Unsupported EGL APIs
88 EXPORT_C EGLBoolean eglGetConfigs(EGLDisplay /*dpy*/, EGLConfig */*configs*/,
89 EGLint /*config_size*/, EGLint */*num_config*/)
94 EXPORT_C EGLBoolean eglChooseConfig(EGLDisplay /*dpy*/, const EGLint */*attrib_list*/,
95 EGLConfig */*configs*/, EGLint /*config_size*/,
96 EGLint */*num_config*/)
101 EXPORT_C EGLBoolean eglGetConfigAttrib(EGLDisplay /*dpy*/, EGLConfig /*config*/,
102 EGLint /*attribute*/, EGLint */*value*/)
107 EXPORT_C EGLSurface eglCreateWindowSurface(EGLDisplay /*dpy*/, EGLConfig /*config*/,
108 EGLNativeWindowType /*win*/,
109 const EGLint */*attrib_list*/)
114 EXPORT_C EGLSurface eglCreatePbufferSurface(EGLDisplay /*dpy*/, EGLConfig /*config*/,
115 const EGLint */*attrib_list*/)
120 EXPORT_C EGLSurface eglCreatePixmapSurface(EGLDisplay /*dpy*/, EGLConfig /*config*/,
121 EGLNativePixmapType /*pixmap*/,
122 const EGLint */*attrib_list*/)
127 EXPORT_C EGLBoolean eglDestroySurface(EGLDisplay /*dpy*/, EGLSurface /*surface*/)
132 EXPORT_C EGLBoolean eglQuerySurface(EGLDisplay /*dpy*/, EGLSurface /*surface*/,
133 EGLint /*attribute*/, EGLint */*value*/)
138 EXPORT_C EGLBoolean eglBindAPI(EGLenum /*api*/)
143 EXPORT_C EGLenum eglQueryAPI(void)
148 EXPORT_C EGLBoolean eglWaitClient(void)
153 EXPORT_C EGLSurface eglCreatePbufferFromClientBuffer(
154 EGLDisplay /*dpy*/, EGLenum /*buftype*/, EGLClientBuffer /*buffer*/,
155 EGLConfig /*config*/, const EGLint */*attrib_list*/)
160 EXPORT_C EGLBoolean eglSurfaceAttrib(EGLDisplay /*dpy*/, EGLSurface /*surface*/,
161 EGLint /*attribute*/, EGLint /*value*/)
166 EXPORT_C EGLBoolean eglBindTexImage(EGLDisplay /*dpy*/, EGLSurface /*surface*/, EGLint /*buffer*/)
171 EXPORT_C EGLBoolean eglReleaseTexImage(EGLDisplay /*dpy*/, EGLSurface /*surface*/, EGLint /*buffer*/)
176 EXPORT_C EGLBoolean eglSwapInterval(EGLDisplay /*dpy*/, EGLint /*interval*/)
181 EXPORT_C EGLContext eglCreateContext(EGLDisplay /*dpy*/, EGLConfig /*config*/,
182 EGLContext /*share_context*/,
183 const EGLint */*attrib_list*/)
188 EXPORT_C EGLBoolean eglDestroyContext(EGLDisplay /*dpy*/, EGLContext /*ctx*/)
193 EXPORT_C EGLBoolean eglMakeCurrent(EGLDisplay /*dpy*/, EGLSurface /*draw*/,
194 EGLSurface /*read*/, EGLContext /*ctx*/)
199 EXPORT_C EGLContext eglGetCurrentContext(void)
204 EXPORT_C EGLSurface eglGetCurrentSurface(EGLint /*readdraw*/)
209 EXPORT_C EGLDisplay eglGetCurrentDisplay(void)
214 EXPORT_C EGLBoolean eglQueryContext(EGLDisplay /*dpy*/, EGLContext /*ctx*/,
215 EGLint /*attribute*/, EGLint */*value*/)
220 EXPORT_C EGLBoolean eglWaitGL(void)
225 EXPORT_C EGLBoolean eglWaitNative(EGLint /*engine*/)
230 EXPORT_C EGLBoolean eglSwapBuffers(EGLDisplay /*dpy*/, EGLSurface /*surface*/)
235 EXPORT_C EGLBoolean eglCopyBuffers(EGLDisplay /*dpy*/, EGLSurface /*surface*/,
236 EGLNativePixmapType /*target*/)
241 // EGL_KHR_reusable_sync APIs
243 EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
245 GET_THREAD_SESSION(session, EGL_NO_SYNC_KHR)
246 return session->EglCreateSyncKhr(dpy, type, attrib_list);
249 EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
251 GET_THREAD_SESSION(session, EGL_FALSE)
252 return session->EglDestroySyncKhr(dpy, sync);
255 EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
257 GET_THREAD_SESSION(session, EGL_FALSE)
258 return session->EglClientWaitSyncKhr(dpy, sync, flags, timeout);
261 EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)
263 GET_THREAD_SESSION(session, EGL_FALSE)
264 return session->EglSignalSyncKhr(dpy, sync, mode);
267 EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
269 GET_THREAD_SESSION(session, EGL_FALSE)
270 return session->EglGetSyncAttribKhr(dpy, sync, attribute, value);
273 // Private extensions
275 EGLint egl_Private_SignalSyncNOK(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)
277 GET_THREAD_SESSION(session, EGL_BAD_ALLOC)
278 return session->EglSignalSyncInternal(dpy, sync, mode);
285 #define GET_THREAD_SESSION_ASSERT(s) CEglThreadSession* s = CEglThreadSession::Static(); \
286 __ASSERT_DEBUG(s, User::Panic(KEglPanicCategory, EEglPanicInvalidSession));
288 void egliDebugHeapMarkStart()
290 GET_THREAD_SESSION_ASSERT(session)
291 session->EglHeapMarkStart();
294 EGLint egliDebugHeapMarkEnd(EGLint count)
296 GET_THREAD_SESSION_ASSERT(session)
297 return session->EglHeapMarkEnd(count);
300 void egliDebugSetBurstAllocFail(EGLenum type, EGLint rate, EGLint burst)
302 GET_THREAD_SESSION_ASSERT(session)
303 session->EglHeapSetBurstAllocFail(type, rate, burst);