mesa: change gl_format to mesa_format
[mesa.git] / src / mesa / main / renderbuffer.c
index bb8f46d11eb4ab8312a9351271a0151900579c88..2ff96e548ebcd595dce9db13db6acfe6c4759a13 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
  *
  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  */
 
 
 #include "renderbuffer.h"
 
 
-/**
- * Default GetPointer routine.  Always return NULL to indicate that
- * direct buffer access is not supported.
- */
-static void *
-nop_get_pointer(struct gl_context *ctx, struct gl_renderbuffer *rb, GLint x, GLint y)
-{
-   return NULL;
-}
-
-
 /**
  * Initialize the fields of a gl_renderbuffer to default values.
  */
@@ -63,22 +52,9 @@ _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
 
    rb->Width = 0;
    rb->Height = 0;
+   rb->Depth = 0;
    rb->InternalFormat = GL_RGBA;
    rb->Format = MESA_FORMAT_NONE;
-
-   rb->DataType = GL_NONE;
-   rb->Data = NULL;
-
-   /* Point back to ourself so that we don't have to check for Wrapped==NULL
-    * all over the drivers.
-    */
-   rb->Wrapped = rb;
-
-   rb->GetPointer = nop_get_pointer;
-   rb->GetRow = NULL;
-   rb->GetValues = NULL;
-   rb->PutRow = NULL;
-   rb->PutValues = NULL;
 }
 
 
@@ -100,13 +76,15 @@ _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name)
 /**
  * Delete a gl_framebuffer.
  * This is the default function for renderbuffer->Delete().
+ * Drivers which subclass gl_renderbuffer should probably implement their
+ * own delete function.  But the driver might also call this function to
+ * free the object in the end.
  */
 void
-_mesa_delete_renderbuffer(struct gl_renderbuffer *rb)
+_mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
 {
-   if (rb->Data) {
-      free(rb->Data);
-   }
+   _glthread_DESTROY_MUTEX(rb->Mutex);
+   free(rb->Label);
    free(rb);
 }
 
@@ -132,7 +110,7 @@ _mesa_add_renderbuffer(struct gl_framebuffer *fb,
           fb->Attachment[bufferName].Renderbuffer == NULL);
 
    /* winsys vs. user-created buffer cross check */
-   if (fb->Name) {
+   if (_mesa_is_user_fbo(fb)) {
       assert(rb->Name);
    }
    else {
@@ -183,7 +161,8 @@ _mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr,
       _glthread_UNLOCK_MUTEX(oldRb->Mutex);
 
       if (deleteFlag) {
-         oldRb->Delete(oldRb);
+         GET_CURRENT_CONTEXT(ctx);
+         oldRb->Delete(ctx, oldRb);
       }
 
       *ptr = NULL;