mesa: rework _mesa_reference_framebuffer() to look like _mesa_reference_renderbuffer()
authorBrian Paul <brianp@vmware.com>
Mon, 9 Feb 2009 14:55:08 +0000 (07:55 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 9 Feb 2009 14:55:08 +0000 (07:55 -0700)
_mesa_unreference_framebuffer() is deprecated since _mesa_reference_framebuffer(ptr, NULL)
can be used instead.

src/mesa/main/framebuffer.c

index 52fd3c9d819aa308b3e55fa0e61873ee81f4bfc9..351bf6959af8b911bfd3bad565e864581bff6097 100644 (file)
@@ -223,19 +223,36 @@ _mesa_reference_framebuffer(struct gl_framebuffer **ptr,
       /* no change */
       return;
    }
+
    if (*ptr) {
-      _mesa_unreference_framebuffer(ptr);
+      /* unreference old renderbuffer */
+      GLboolean deleteFlag = GL_FALSE;
+      struct gl_framebuffer *oldFb = *ptr;
+
+      _glthread_LOCK_MUTEX(oldFb->Mutex);
+      ASSERT(oldFb->RefCount > 0);
+      oldFb->RefCount--;
+      deleteFlag = (oldFb->RefCount == 0);
+      _glthread_UNLOCK_MUTEX(oldFb->Mutex);
+      
+      if (deleteFlag)
+         oldFb->Delete(oldFb);
+
+      *ptr = NULL;
    }
    assert(!*ptr);
-   assert(fb);
-   _glthread_LOCK_MUTEX(fb->Mutex);
-   fb->RefCount++;
-   _glthread_UNLOCK_MUTEX(fb->Mutex);
-   *ptr = fb;
+
+   if (fb) {
+      _glthread_LOCK_MUTEX(fb->Mutex);
+      fb->RefCount++;
+      _glthread_UNLOCK_MUTEX(fb->Mutex);
+      *ptr = fb;
+   }
 }
 
 
 /**
+ * XXX this function is deprecated.
  * Undo/remove a reference to a framebuffer object.
  * Decrement the framebuffer object's reference count and delete it when
  * the refcount hits zero.
@@ -244,21 +261,7 @@ _mesa_reference_framebuffer(struct gl_framebuffer **ptr,
 void
 _mesa_unreference_framebuffer(struct gl_framebuffer **fb)
 {
-   assert(fb);
-   if (*fb) {
-      GLboolean deleteFlag = GL_FALSE;
-
-      _glthread_LOCK_MUTEX((*fb)->Mutex);
-      ASSERT((*fb)->RefCount > 0);
-      (*fb)->RefCount--;
-      deleteFlag = ((*fb)->RefCount == 0);
-      _glthread_UNLOCK_MUTEX((*fb)->Mutex);
-      
-      if (deleteFlag)
-         (*fb)->Delete(*fb);
-
-      *fb = NULL;
-   }
+   _mesa_reference_framebuffer(fb, NULL);
 }