i915tex: Clean up resizing of renderbuffers.
authorMichel Dänzer <michel@tungstengraphics.com>
Sun, 8 Apr 2007 12:04:15 +0000 (14:04 +0200)
committerMichel Dänzer <michel@tungstengraphics.com>
Sun, 8 Apr 2007 12:04:15 +0000 (14:04 +0200)
src/mesa/drivers/dri/i915tex/intel_context.c
src/mesa/drivers/dri/i915tex/intel_fbo.c

index a2b0856fde17641bcfec63cb4a96ab14e5d0c668..6a3456e154b176751dbdb2b42467cd9fbb0e8b4f 100644 (file)
@@ -587,10 +587,11 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
       }
 
       /* set GLframebuffer size to match window, if needed */
-      if (driReadPriv != driDrawPriv && readFb->Width != driReadPriv->w) {
-         _mesa_resize_framebuffer(&intel->ctx, readFb,
-                                  driReadPriv->w, driReadPriv->h);
-      }         
+      driUpdateFramebufferSize(&intel->ctx, driDrawPriv);
+
+      if (driReadPriv != driDrawPriv) {
+        driUpdateFramebufferSize(&intel->ctx, driReadPriv);
+      }
 
       _mesa_make_current(&intel->ctx, &intel_fb->Base, readFb);
 
index 9b84faaeb7d4a7fa3a7c84c2a4df0f3f1eab1ef5..87ef22f52f4273c4593a5a5f53ca4970b6b41c67 100644 (file)
@@ -309,27 +309,39 @@ static GLboolean
 intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
                            GLenum internalFormat, GLuint width, GLuint height)
 {
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_framebuffer *intel_fb;
-
    ASSERT(rb->Name == 0);
    rb->Width = width;
    rb->Height = height;
    rb->_ActualFormat = internalFormat;
 
-   if (intel && intel->driDrawable &&
-       (intel_fb = intel->driDrawable->driverPrivate) &&
-       intel_fb->pf_num_pages == 3 &&
-       rb == &intel_fb->color_rb[intel_fb->pf_current_page]->Base &&
-       (rb = &intel_fb->color_rb[(intel_fb->pf_current_page + 2) % 3]->Base)) {
-      rb->Width = width;
-      rb->Height = height;
-      rb->_ActualFormat = internalFormat;
-   }
-
    return GL_TRUE;
 }
 
+static void
+intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
+                    GLuint width, GLuint height)
+{
+   struct intel_framebuffer *intel_fb = (struct intel_framebuffer*)fb;
+   int i;
+
+   _mesa_resize_framebuffer(ctx, fb, width, height);
+
+   fb->Initialized = GL_TRUE; /* XXX remove someday */
+
+   if (fb->Name != 0) {
+      return;
+   }
+
+   /* Make sure all window system renderbuffers are up to date */
+   for (i = 0; i < 3; i++) {
+      struct gl_renderbuffer *rb = &intel_fb->color_rb[i]->Base;
+
+      /* only resize if size is changing */
+      if (rb && (rb->Width != width || rb->Height != height)) {
+        rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height);
+      }
+   }
+}
 
 static GLboolean
 intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
@@ -671,4 +683,5 @@ intel_fbo_init(struct intel_context *intel)
    intel->ctx.Driver.FramebufferRenderbuffer = intel_framebuffer_renderbuffer;
    intel->ctx.Driver.RenderTexture = intel_render_texture;
    intel->ctx.Driver.FinishRenderTexture = intel_finish_render_texture;
+   intel->ctx.Driver.ResizeBuffers = intel_resize_buffers;
 }