From: Chia-I Wu Date: Wed, 30 Sep 2009 07:34:45 +0000 (+0800) Subject: egl: Rework error checking in eglGetCurrentSurface. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=61906631202af855d0742586956ff9f34522a525;p=mesa.git egl: Rework error checking in eglGetCurrentSurface. Signed-off-by: Chia-I Wu --- diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index d86ef9ce562..1512c0a14ea 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); }