Mesa (master): mesa: refactor, create _mesa_update_draw_buffers() helper

Brian Paul brianp at kemper.freedesktop.org
Thu Jun 16 13:32:29 UTC 2011


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

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Jun 16 07:31:58 2011 -0600

mesa: refactor, create _mesa_update_draw_buffers() helper

Move this code out of _mesa_make_current() and put it into a
helper function.

---

 src/mesa/main/buffers.c |   21 +++++++++++++++++++++
 src/mesa/main/buffers.h |    4 ++++
 src/mesa/main/context.c |   13 ++-----------
 3 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 63f53e2..a75c9c2 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -462,6 +462,27 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
 
 
 /**
+ * Update the current drawbuffer's _ColorDrawBufferIndex[] list, etc.
+ * from the context's Color.DrawBuffer[] state.
+ * Use when changing contexts.
+ */
+void
+_mesa_update_draw_buffers(struct gl_context *ctx)
+{
+   GLenum buffers[MAX_DRAW_BUFFERS];
+   GLuint i;
+
+   /* should be a window system FBO */
+   assert(ctx->DrawBuffer->Name == 0);
+
+   for (i = 0; i < ctx->Const.MaxDrawBuffers; i++)
+      buffers[i] = ctx->Color.DrawBuffer[i];
+
+   _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, buffers, NULL);
+}
+
+
+/**
  * Like \sa _mesa_drawbuffers(), this is a helper function for setting
  * GL_READ_BUFFER state in the context and current FBO.
  * \param ctx  the rendering context
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index 1404112..8083bc3 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -50,6 +50,10 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
 extern void
 _mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex);
 
+extern void
+_mesa_update_draw_buffers(struct gl_context *ctx);
+
+
 extern void GLAPIENTRY
 _mesa_ReadBuffer( GLenum mode );
 
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index ef79f1f..b83a5d6 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1456,21 +1456,12 @@ _mesa_make_current( struct gl_context *newCtx,
           * or not bound to a user-created FBO.
           */
          if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
+            _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer);
             /* Update the FBO's list of drawbuffers/renderbuffers.
              * For winsys FBOs this comes from the GL state (which may have
              * changed since the last time this FBO was bound).
              */
-            unsigned int i;
-            GLenum buffers[MAX_DRAW_BUFFERS];
-
-            _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer);
-
-            for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) {
-               buffers[i] = newCtx->Color.DrawBuffer[i];
-            }
-
-            _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers,
-                              buffers, NULL);
+            _mesa_update_draw_buffers(newCtx);
          }
          if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) {
             _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);




More information about the mesa-commit mailing list