From 9ae952a88c33b53b72852eb90e794ccceb9eb8ff Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Sep 2005 00:09:09 +0000 Subject: [PATCH] added driUpdateFramebufferSize() --- src/mesa/drivers/dri/common/drirenderbuffer.c | 26 +++++++++++++++++-- src/mesa/drivers/dri/common/drirenderbuffer.h | 5 ++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.c b/src/mesa/drivers/dri/common/drirenderbuffer.c index df0d27302cc..764dafc7f4f 100644 --- a/src/mesa/drivers/dri/common/drirenderbuffer.c +++ b/src/mesa/drivers/dri/common/drirenderbuffer.c @@ -1,15 +1,19 @@ #include "mtypes.h" #include "drirenderbuffer.h" +#include "framebuffer.h" #include "renderbuffer.h" #include "imports.h" /** - * This will get called when a window is resized. + * This will get called when a window (gl_framebuffer) is resized (probably + * via driUpdateFramebufferSize(), below). * Just update width, height and internal format fields for now. * There's usually no memory allocation above because the present - * DRI drivers use statically-allocated full-screen buffers. + * DRI drivers use statically-allocated full-screen buffers. If that's not + * the case for a DRI driver, a different AllocStorage method should + * be used. */ static GLboolean driRenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *rb, @@ -164,3 +168,21 @@ driFlipRenderbuffers(struct gl_framebuffer *fb, GLboolean flipped) } } } + + +/** + * Check that the gl_framebuffer associated with dPriv is the right size. + * Resize the gl_framebuffer if needed. + * It's expected that the dPriv->driverPrivate member points to a + * gl_framebuffer object. + */ +void +driUpdateFramebufferSize(GLcontext *ctx, const __DRIdrawablePrivate *dPriv) +{ + struct gl_framebuffer *fb = (struct gl_framebuffer *) dPriv->driverPrivate; + if (fb && (dPriv->w != fb->Width || dPriv->h != fb->Height)) { + _mesa_resize_framebuffer(ctx, fb, dPriv->w, dPriv->h); + assert(fb->Width == dPriv->w); + assert(fb->Height == dPriv->h); + } +} diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.h b/src/mesa/drivers/dri/common/drirenderbuffer.h index f2cc357ff9e..cd73b781741 100644 --- a/src/mesa/drivers/dri/common/drirenderbuffer.h +++ b/src/mesa/drivers/dri/common/drirenderbuffer.h @@ -67,4 +67,9 @@ driNewRenderbuffer(GLenum format, GLvoid *addr, extern void driFlipRenderbuffers(struct gl_framebuffer *fb, GLboolean flipped); + +extern void +driUpdateFramebufferSize(GLcontext *ctx, const __DRIdrawablePrivate *dPriv); + + #endif /* DRIRENDERBUFFER_H */ -- 2.30.2