summaryrefslogtreecommitdiffstats
path: root/src/egl/main/eglapi.c
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2009-07-17 11:41:02 -0600
committerBrian Paul <[email protected]>2009-07-17 11:41:02 -0600
commit75da80b29556e6dbbba21e5297ca440e475f65cb (patch)
tree8ae922d896d77df1e70768edaace6e12462d9bc4 /src/egl/main/eglapi.c
parent8e92ec9fdd58bdfcdef65a995988974d3266b9ad (diff)
egl: Support per-thread info.
This commit introduces a "current" system to manage per-thread info. It uses TLS, if GLX_USE_TLS is defined, or pthread, if PTHREADS is defined. If none of them are defined, it uses a dummy implementation that is just like before. Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/egl/main/eglapi.c')
-rw-r--r--src/egl/main/eglapi.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 9df938e1887..8f4a489b913 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -321,7 +321,8 @@ eglGetError(void)
{
_EGLThreadInfo *t = _eglGetCurrentThread();
EGLint e = t->LastError;
- t->LastError = EGL_SUCCESS;
+ if (!_eglIsCurrentThreadDummy())
+ t->LastError = EGL_SUCCESS;
return e;
}
@@ -546,6 +547,9 @@ eglBindAPI(EGLenum api)
{
_EGLThreadInfo *t = _eglGetCurrentThread();
+ if (_eglIsCurrentThreadDummy())
+ return _eglError(EGL_BAD_ALLOC, "eglBindAPI");
+
switch (api) {
#ifdef EGL_VERSION_1_4
case EGL_OPENGL_API:
@@ -603,15 +607,19 @@ eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype,
EGLBoolean
eglReleaseThread(void)
{
- _EGLThreadInfo *t = _eglGetCurrentThread();
- EGLDisplay dpy = eglGetCurrentDisplay();
+ EGLDisplay dpy;
+
+ if (_eglIsCurrentThreadDummy())
+ return EGL_TRUE;
+
+ dpy = eglGetCurrentDisplay();
if (dpy) {
_EGLDriver *drv = _eglLookupDriver(dpy);
/* unbind context */
(void) drv->API.MakeCurrent(drv, dpy, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
- _eglDeleteThreadData(t);
+ _eglDestroyCurrentThread();
return EGL_TRUE;
}