summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2004-11-27 22:47:59 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2004-11-27 22:47:59 +0000
commit65a66f5bc37383c00423c21baf8ba9d6771e0259 (patch)
tree0d98e004b457adde579dd27b9fe32182d54268b6 /src/mesa/main
parent118a8bad73bda88fc54f802b2beeb687c8ddb45a (diff)
Remove _mesa_ResizeBuffersMESA() call from _mesa_set_viewport().
Now, the driver's Viewport routine should call _mesa_ResizeBuffersMESA() if necessary. Cleaned up code related to GLframebuffer width/height initialization. Set initial viewport/scissor params in _mesa_make_current2(), instead of in the drivers' MakeCurrent functions.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/context.c56
-rw-r--r--src/mesa/main/matrix.c17
-rw-r--r--src/mesa/main/mtypes.h2
3 files changed, 31 insertions, 44 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 6248016d21..2423b68ddc 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1606,6 +1606,10 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_delete_buffer_object(ctx, ctx->Array.NullBufferObj);
#endif
+ /* free dispatch tables */
+ _mesa_free(ctx->Exec);
+ _mesa_free(ctx->Save);
+
/* Shared context state (display lists, textures, etc) */
_glthread_LOCK_MUTEX(ctx->Shared->Mutex);
ctx->Shared->RefCount--;
@@ -1618,9 +1622,6 @@ _mesa_free_context_data( GLcontext *ctx )
if (ctx->Extensions.String)
FREE((void *) ctx->Extensions.String);
-
- FREE(ctx->Exec);
- FREE(ctx->Save);
}
@@ -1877,41 +1878,36 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
newCtx->NewState |= _NEW_BUFFERS;
#if _HAVE_FULL_GL
- if (drawBuffer->Width == 0 && drawBuffer->Height == 0) {
+ if (!drawBuffer->Initialized) {
/* get initial window size */
GLuint bufWidth, bufHeight;
-
- /* ask device driver for size of output buffer */
- (*newCtx->Driver.GetBufferSize)( drawBuffer, &bufWidth, &bufHeight );
-
- if (drawBuffer->Width != bufWidth ||
- drawBuffer->Height != bufHeight) {
-
- drawBuffer->Width = bufWidth;
- drawBuffer->Height = bufHeight;
-
- newCtx->Driver.ResizeBuffers( drawBuffer );
- }
+ /* ask device driver for size of the buffer */
+ (*newCtx->Driver.GetBufferSize)(drawBuffer, &bufWidth, &bufHeight);
+ /* set initial buffer size */
+ drawBuffer->Width = bufWidth;
+ drawBuffer->Height = bufHeight;
+ newCtx->Driver.ResizeBuffers( drawBuffer );
+ drawBuffer->Initialized = GL_TRUE;
}
- if (readBuffer != drawBuffer &&
- readBuffer->Width == 0 && readBuffer->Height == 0) {
+ if (readBuffer != drawBuffer && !readBuffer->Initialized) {
/* get initial window size */
GLuint bufWidth, bufHeight;
-
- /* ask device driver for size of output buffer */
- (*newCtx->Driver.GetBufferSize)( readBuffer, &bufWidth, &bufHeight );
-
- if (readBuffer->Width != bufWidth ||
- readBuffer->Height != bufHeight) {
-
- readBuffer->Width = bufWidth;
- readBuffer->Height = bufHeight;
-
- newCtx->Driver.ResizeBuffers( readBuffer );
- }
+ /* ask device driver for size of the buffer */
+ (*newCtx->Driver.GetBufferSize)(readBuffer, &bufWidth, &bufHeight);
+ /* set initial buffer size */
+ readBuffer->Width = bufWidth;
+ readBuffer->Height = bufHeight;
+ newCtx->Driver.ResizeBuffers( readBuffer );
+ readBuffer->Initialized = GL_TRUE;
}
#endif
+ if (newCtx->FirstTimeCurrent) {
+ /* set initial viewport and scissor size now */
+ _mesa_set_viewport(newCtx, 0, 0, drawBuffer->Width, drawBuffer->Height);
+ newCtx->Scissor.Width = drawBuffer->Width;
+ newCtx->Scissor.Height = drawBuffer->Height;
+ }
}
/* Alert the driver - usually passed on to the sw t&l module,
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 3a4bfe3096..82ea37508d 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -35,7 +35,6 @@
#include "glheader.h"
#include "imports.h"
-#include "buffers.h"
#include "context.h"
#include "enums.h"
#include "macros.h"
@@ -556,11 +555,6 @@ _mesa_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
* Set new viewport parameters and update derived state (the _WindowMap
* matrix). Usually called from _mesa_Viewport().
*
- * \note We also call _mesa_ResizeBuffersMESA() because this is a good
- * time to check if the window has been resized. Many device drivers
- * can't get direct notification from the window system of size changes
- * so this is an ad-hoc solution to that problem.
- *
* \param ctx GL context.
* \param x, y coordinates of the lower left corner of the viewport rectangle.
* \param width width of the viewport rectangle.
@@ -618,15 +612,10 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y,
ctx->Viewport._WindowMap.type = MATRIX_3D_NO_ROT;
ctx->NewState |= _NEW_VIEWPORT;
- /* Check if window/buffer has been resized and if so, reallocate the
- * ancillary buffers. This is an ad-hoc solution to detecting window
- * size changes. 99% of all GL apps call glViewport when a window is
- * resized so this is a good time to check for new window dims and
- * reallocate color buffers and ancilliary buffers.
- */
- _mesa_ResizeBuffersMESA();
-
if (ctx->Driver.Viewport) {
+ /* Many drivers will use this call to check for window size changes
+ * and reallocate the z/stencil/accum/etc buffers if needed.
+ */
(*ctx->Driver.Viewport)( ctx, x, y, width, height );
}
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5586e68510..a53fb12753 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1869,6 +1869,8 @@ struct gl_frame_buffer
GLuint Width, Height; /**< size of frame buffer in pixels */
+ GLboolean Initialized;
+
GLboolean UseSoftwareDepthBuffer;
GLboolean UseSoftwareAccumBuffer;
GLboolean UseSoftwareStencilBuffer;