Mesa (master): egl: Make _eglBindContextToSurfaces more readable.

Chia-I Wu olv at kemper.freedesktop.org
Sat Mar 27 19:37:39 UTC 2010


Module: Mesa
Branch: master
Commit: 0a82fadcdd0b6ebbc345c7c302da0e0efce40a98
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a82fadcdd0b6ebbc345c7c302da0e0efce40a98

Author: Chia-I Wu <olv at lunarg.com>
Date:   Sun Mar 28 03:04:38 2010 +0800

egl: Make _eglBindContextToSurfaces more readable.

There is no effective changes given how the function is called.  It is
still not trivial, but it should be more readable and resemble
_eglBindContextToThread a lot.

---

 src/egl/main/eglcontext.c |   36 +++++++++++++++++++++++++-----------
 1 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
index 710752f..5e831aa 100644
--- a/src/egl/main/eglcontext.c
+++ b/src/egl/main/eglcontext.c
@@ -212,21 +212,35 @@ _eglBindContextToSurfaces(_EGLContext *ctx,
                           _EGLSurface **draw, _EGLSurface **read)
 {
    _EGLSurface *newDraw = *draw, *newRead = *read;
+   _EGLContext *oldCtx;
 
-   if (newDraw->CurrentContext)
-      newDraw->CurrentContext->DrawSurface = NULL;
-   newDraw->CurrentContext = ctx;
+   oldCtx = newDraw->CurrentContext;
+   if (ctx != oldCtx) {
+      if (oldCtx) {
+         assert(*draw == oldCtx->DrawSurface);
+         oldCtx->DrawSurface = NULL;
+      }
+      if (ctx) {
+         *draw = ctx->DrawSurface;
+         ctx->DrawSurface = newDraw;
+      }
 
-   if (newRead->CurrentContext)
-      newRead->CurrentContext->ReadSurface = NULL;
-   newRead->CurrentContext = ctx;
+      newDraw->CurrentContext = ctx;
+   }
 
-   if (ctx) {
-      *draw = ctx->DrawSurface;
-      ctx->DrawSurface = newDraw;
+   if (newRead != newDraw)
+      oldCtx = newRead->CurrentContext;
+   if (ctx != oldCtx) {
+      if (oldCtx) {
+         assert(*read == oldCtx->ReadSurface);
+         oldCtx->ReadSurface = NULL;
+      }
+      if (ctx) {
+         *read = ctx->ReadSurface;
+         ctx->ReadSurface = newRead;
+      }
 
-      *read = ctx->ReadSurface;
-      ctx->ReadSurface = newRead;
+      newRead->CurrentContext = ctx;
    }
 }
 




More information about the mesa-commit mailing list