use new _mesa_dereference_frame/renderbuffer() functions
authorBrian Paul <brian.paul@tungstengraphics.com>
Sat, 20 May 2006 15:08:25 +0000 (15:08 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Sat, 20 May 2006 15:08:25 +0000 (15:08 +0000)
src/mesa/main/fbobject.c

index 807fac0a393fa8a8af728c3af65a46a60070f902..b6a59336cb8103ef349905d2205e8a42e710e7a9 100644 (file)
@@ -595,10 +595,7 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
 
    oldRb = ctx->CurrentRenderbuffer;
    if (oldRb) {
-      oldRb->RefCount--;
-      if (oldRb->RefCount == 0) {
-         oldRb->Delete(oldRb);
-      }
+      _mesa_dereference_renderbuffer(&oldRb);
    }
 
    ASSERT(newRb != &DummyRenderbuffer);
@@ -635,10 +632,7 @@ _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers)
                /* But the object will not be freed until it's no longer
                 * bound in any context.
                 */
-               rb->RefCount--;
-               if (rb->RefCount == 0) {
-                  rb->Delete(rb);
-               }
+               _mesa_dereference_renderbuffer(&rb);
            }
         }
       }
@@ -1019,12 +1013,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
    if (bindReadBuf) {
       oldFb = ctx->ReadBuffer;
       if (oldFb && oldFb->Name != 0) {
-         _glthread_LOCK_MUTEX(oldFb->Mutex);
-         oldFb->RefCount--;
-         _glthread_UNLOCK_MUTEX(oldFb->Mutex);
-         if (oldFb->RefCount == 0) {
-            oldFb->Delete(oldFb);
-         }
+         _mesa_dereference_framebuffer(&oldFb);
       }
       ctx->ReadBuffer = newFb;
    }
@@ -1035,12 +1024,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
          /* check if old FB had any texture attachments */
          check_end_texture_render(ctx, oldFb);
          /* check if time to delete this framebuffer */
-         _glthread_LOCK_MUTEX(oldFb->Mutex);
-         oldFb->RefCount--;
-         if (oldFb->RefCount == 0) {
-            oldFb->Delete(oldFb);
-         }
-         _glthread_UNLOCK_MUTEX(oldFb->Mutex);
+         _mesa_dereference_framebuffer(&oldFb);
       }
       ctx->DrawBuffer = newFb;
       if (newFb->Name != 0) {
@@ -1085,12 +1069,7 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers)
                /* But the object will not be freed until it's no longer
                 * bound in any context.
                 */
-               _glthread_LOCK_MUTEX(fb->Mutex);
-               fb->RefCount--;
-               _glthread_UNLOCK_MUTEX(fb->Mutex);
-               if (fb->RefCount == 0) {
-                  fb->Delete(fb);
-               }
+               _mesa_dereference_framebuffer(&fb);
            }
         }
       }