mesa: move freeing of software renderbuffers into swrast
authorBrian Paul <brianp@vmware.com>
Mon, 16 Jan 2012 19:15:40 +0000 (12:15 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 24 Jan 2012 21:12:25 +0000 (14:12 -0700)
src/mesa/main/renderbuffer.c
src/mesa/swrast/s_renderbuffer.c

index 2f0b28934b673553533c190268aa6052e54b7f06..4bc4165fb9eddbbf945758260d877a114b2bacf0 100644 (file)
@@ -55,8 +55,6 @@ _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
    rb->InternalFormat = GL_RGBA;
    rb->Format = MESA_FORMAT_NONE;
 
-   rb->Data = NULL;
-
    /* Point back to ourself so that we don't have to check for Wrapped==NULL
     * all over the drivers.
     */
@@ -86,10 +84,7 @@ _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name)
 void
 _mesa_delete_renderbuffer(struct gl_renderbuffer *rb)
 {
-   if (rb->Data) {
-      free(rb->Data);
-   }
-   free(rb);
+   /* no-op */
 }
 
 
index a78c6a191b97fe8cc9e7dea3aa1dd5fa1d84dd3d..825214c95df739ba9fede5c3f7f4571a07db65dd 100644 (file)
@@ -156,6 +156,20 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
 }
 
 
+/**
+ * Called via gl_renderbuffer::Delete()
+ */
+static void
+soft_renderbuffer_delete(struct gl_renderbuffer *rb)
+{
+   if (rb->Data) {
+      free(rb->Data);
+      rb->Data = NULL;
+   }
+   free(rb);
+}
+
+
 void
 _swrast_map_soft_renderbuffer(struct gl_context *ctx,
                               struct gl_renderbuffer *rb,
@@ -198,6 +212,7 @@ _swrast_new_soft_renderbuffer(struct gl_context *ctx, GLuint name)
    struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name);
    if (rb) {
       rb->AllocStorage = soft_renderbuffer_storage;
+      rb->Delete = soft_renderbuffer_delete;
    }
    return rb;
 }