egl: Rework error checking in eglGetCurrentSurface.
authorChia-I Wu <olvaffe@gmail.com>
Wed, 30 Sep 2009 07:34:45 +0000 (15:34 +0800)
committerBrian Paul <brianp@vmware.com>
Thu, 15 Oct 2009 18:53:57 +0000 (12:53 -0600)
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
src/egl/main/eglapi.c

index d86ef9ce562d278ae03a399a5722f5cfe6fbc58e..1512c0a14ea0e028289ee42c4045a2428efef6d7 100644 (file)
@@ -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);
 }