From 61906631202af855d0742586956ff9f34522a525 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 30 Sep 2009 15:34:45 +0800 Subject: egl: Rework error checking in eglGetCurrentSurface. Signed-off-by: Chia-I Wu --- src/egl/main/eglapi.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index d86ef9ce56..1512c0a14e 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -568,8 +568,26 @@ eglGetCurrentContext(void) EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) { - _EGLSurface *s = _eglGetCurrentSurface(readdraw); - return _eglGetSurfaceHandle(s); + _EGLContext *ctx = _eglGetCurrentContext(); + _EGLSurface *surf; + + if (!ctx) + return EGL_NO_SURFACE; + + switch (readdraw) { + case EGL_DRAW: + surf = ctx->DrawSurface; + break; + case EGL_READ: + surf = ctx->ReadSurface; + break; + default: + _eglError(EGL_BAD_PARAMETER, __FUNCTION__); + surf = NULL; + break; + } + + return _eglGetSurfaceHandle(surf); } -- cgit v1.2.3