diff options
author | Chia-I Wu <[email protected]> | 2009-09-28 14:12:39 +0800 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-10-15 12:54:00 -0600 |
commit | 6c21c8862bc6edc9cddf3b6eb6f276961099a7a8 (patch) | |
tree | 2a4ead835862bdb82e0894259dff143ae4849975 /src/egl/main/eglapi.c | |
parent | 57da499d7ba074128e8c97b8076805e403a2b9c4 (diff) |
egl: Rework the synchronization primitives.
This adds error checking to the synchronization primitives. And
eglWaitGL is now implemented by eglWaitClient.
Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/egl/main/eglapi.c')
-rw-r--r-- | src/egl/main/eglapi.c | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 5ce04693519..14cc5fa6137 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -558,32 +558,66 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, NativePixmapType target) EGLBoolean EGLAPIENTRY -eglWaitGL(void) +eglWaitClient(void) { - _EGLDisplay *disp = _eglGetCurrentDisplay(); + _EGLContext *ctx = _eglGetCurrentContext(); + _EGLDisplay *disp; _EGLDriver *drv; - if (!disp) + if (!ctx) return EGL_TRUE; + /* let bad current context imply bad current surface */ + if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface)) + return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__); - /* a current display is always initialized */ + /* a valid current context implies an initialized current display */ + disp = ctx->Display; drv = disp->Driver; + assert(drv); + + return drv->API.WaitClient(drv, disp, ctx); +} + - return drv->API.WaitGL(drv, disp); +EGLBoolean EGLAPIENTRY +eglWaitGL(void) +{ +#ifdef EGL_VERSION_1_2 + _EGLThreadInfo *t = _eglGetCurrentThread(); + EGLint api_index = t->CurrentAPIIndex; + EGLint es_index = _eglConvertApiToIndex(EGL_OPENGL_ES_API); + EGLBoolean ret; + + if (api_index != es_index && _eglIsCurrentThreadDummy()) + return _eglError(EGL_BAD_ALLOC, "eglWaitGL"); + + t->CurrentAPIIndex = es_index; + ret = eglWaitClient(); + t->CurrentAPIIndex = api_index; + return ret; +#else + return eglWaitClient(); +#endif } EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) { - _EGLDisplay *disp = _eglGetCurrentDisplay(); + _EGLContext *ctx = _eglGetCurrentContext(); + _EGLDisplay *disp; _EGLDriver *drv; - if (!disp) + if (!ctx) return EGL_TRUE; + /* let bad current context imply bad current surface */ + if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface)) + return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__); - /* a current display is always initialized */ + /* a valid current context implies an initialized current display */ + disp = ctx->Display; drv = disp->Driver; + assert(drv); return drv->API.WaitNative(drv, disp, engine); } @@ -958,20 +992,4 @@ eglReleaseThread(void) } -EGLBoolean -eglWaitClient(void) -{ - _EGLDisplay *disp = _eglGetCurrentDisplay(); - _EGLDriver *drv; - - if (!disp) - return EGL_TRUE; - - /* a current display is always initialized */ - drv = disp->Driver; - - return drv->API.WaitClient(drv, disp); -} - - #endif /* EGL_VERSION_1_2 */ |