From 692147ebf7f09d56a7de1659de2449478da4d1ba Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 7 Sep 2005 23:28:41 +0000 Subject: some clean-up and re-org for renderbuffers --- src/mesa/drivers/x11/xm_dd.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'src/mesa/drivers/x11/xm_dd.c') diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 76dec19f53..fcfe32ed42 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -114,8 +114,8 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height ) _glthread_LOCK_MUTEX(_xmesa_lock); XSync(xmBuffer->xm_visual->display, 0); /* added for Chromium */ - XGetGeometry( xmBuffer->xm_visual->display, xmBuffer->frontxrb->pixmap, &root, - &winx, &winy, &winwidth, &winheight, &bw, &d ); + XGetGeometry( xmBuffer->xm_visual->display, xmBuffer->frontxrb->pixmap, + &root, &winx, &winy, &winwidth, &winheight, &bw, &d ); _glthread_UNLOCK_MUTEX(_xmesa_lock); #endif @@ -1094,6 +1094,34 @@ choose_tex_format( GLcontext *ctx, GLint internalFormat, } +/** + * Get the current drawing (and reading) window's size and update the + * corresponding gl_framebuffer(s) if needed. + */ +static void +update_framebuffer_size(GLcontext *ctx) +{ + struct gl_framebuffer *fb = ctx->WinSysDrawBuffer; + GLuint newWidth, newHeight; + get_buffer_size(fb, &newWidth, &newHeight); + if (newWidth != fb->Width || newHeight != fb->Height) { + xmesa_resize_buffers(ctx, fb, newWidth, newHeight); + ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */ + } + + if (ctx->WinSysReadBuffer != ctx->WinSysDrawBuffer) { + /* Update readbuffer's size */ + struct gl_framebuffer *fb = ctx->WinSysReadBuffer; + GLuint newWidth, newHeight; + get_buffer_size(fb, &newWidth, &newHeight); + if (newWidth != fb->Width || newHeight != fb->Height) { + xmesa_resize_buffers(ctx, fb, newWidth, newHeight); + ctx->NewState |= _NEW_BUFFERS; + } + } +} + + /** * Called by glViewport. * This is a good time for us to poll the current X window size and adjust @@ -1107,26 +1135,7 @@ choose_tex_format( GLcontext *ctx, GLint internalFormat, static void xmesa_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) { -#if 1 - struct gl_framebuffer *fb = ctx->WinSysDrawBuffer; - GLuint newWidth, newHeight; - - /* - printf("%s before %d x %d\n", __FUNCTION__, fb->Width, fb->Height); - */ - - get_buffer_size(fb, &newWidth, &newHeight); - if (newWidth != fb->Width || newHeight != fb->Height) { - xmesa_resize_buffers(ctx, fb, newWidth, newHeight); - ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */ - } - /* - printf("%s after %d x %d\n", __FUNCTION__, fb->Width, fb->Height); - */ -#else - /* This also works: */ - _mesa_ResizeBuffersMESA(); -#endif + update_framebuffer_size(ctx); } -- cgit v1.2.3