aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/context.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/context.c')
-rw-r--r--src/mesa/main/context.c67
1 files changed, 32 insertions, 35 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index cc29f2cb992..f51adb59dad 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1500,23 +1500,36 @@ check_compatible(const GLcontext *ctx, const GLframebuffer *buffer)
/**
- * Bind the given context to the given draw-buffer and read-buffer and
- * make it the current context for this thread.
+ * Do one-time initialization for the given framebuffer. Specifically,
+ * ask the driver for the window's current size and update the framebuffer
+ * object to match.
+ * Really, the device driver should totally take care of this.
+ */
+static void
+initialize_framebuffer_size(GLcontext *ctx, GLframebuffer *fb)
+{
+ GLuint width, height;
+ ASSERT(ctx->Driver.GetBufferSize);
+ ctx->Driver.GetBufferSize(fb, &width, &height);
+ if (ctx->Driver.ResizeBuffers)
+ ctx->Driver.ResizeBuffers(ctx, fb, width, height);
+ fb->Initialized = GL_TRUE;
+}
+
+
+/**
+ * Bind the given context to the given drawBuffer and readBuffer and
+ * make it the current context for the calling thread.
+ * We'll render into the drawBuffer and read pixels from the
+ * readBuffer (i.e. glRead/CopyPixels, glCopyTexImage, etc).
*
- * \param newCtx new GL context. If NULL then there will be no current GL
- * context.
- * \param drawBuffer draw framebuffer.
- * \param readBuffer read framebuffer.
- *
- * Check that the context's and framebuffer's visuals are compatible, returning
- * immediately otherwise. Sets the glapi current context via
- * _glapi_set_context(). If \p newCtx is not NULL, associates \p drawBuffer and
- * \p readBuffer with it and calls dd_function_table::ResizeBuffers if the buffers size has changed.
- * Calls dd_function_table::MakeCurrent callback if defined.
+ * We check that the context's and framebuffer's visuals are compatible
+ * and return immediately if they're not.
*
- * When a context is bound by the first time and the \c MESA_INFO environment
- * variable is set it calls print_info() as an aid for remote user
- * troubleshooting.
+ * \param newCtx the new GL context. If NULL then there will be no current GL
+ * context.
+ * \param drawBuffer the drawing framebuffer
+ * \param readBuffer the reading framebuffer
*/
void
_mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
@@ -1570,32 +1583,16 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
#if _HAVE_FULL_GL
if (!drawBuffer->Initialized) {
- /* get initial window size */
- GLuint bufWidth, bufHeight;
- /* ask device driver for size of the buffer */
- (*newCtx->Driver.GetBufferSize)(drawBuffer, &bufWidth, &bufHeight);
- /* set initial buffer size */
- if (newCtx->Driver.ResizeBuffers)
- newCtx->Driver.ResizeBuffers(newCtx, drawBuffer,
- bufWidth, bufHeight);
- drawBuffer->Initialized = GL_TRUE;
+ initialize_framebuffer_size(newCtx, drawBuffer);
}
-
if (readBuffer != drawBuffer && !readBuffer->Initialized) {
- /* get initial window size */
- GLuint bufWidth, bufHeight;
- /* ask device driver for size of the buffer */
- (*newCtx->Driver.GetBufferSize)(readBuffer, &bufWidth, &bufHeight);
- /* set initial buffer size */
- if (newCtx->Driver.ResizeBuffers)
- newCtx->Driver.ResizeBuffers(newCtx, readBuffer,
- bufWidth, bufHeight);
- readBuffer->Initialized = GL_TRUE;
+ initialize_framebuffer_size(newCtx, readBuffer);
}
#endif
if (newCtx->FirstTimeCurrent) {
/* set initial viewport and scissor size now */
- _mesa_set_viewport(newCtx, 0, 0, drawBuffer->Width, drawBuffer->Height);
+ _mesa_set_viewport(newCtx, 0, 0,
+ drawBuffer->Width, drawBuffer->Height);
newCtx->Scissor.Width = drawBuffer->Width;
newCtx->Scissor.Height = drawBuffer->Height;
}