From 49002698193784dacffcbf993de26fcdd42c523e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 9 Feb 2009 07:55:08 -0700 Subject: [PATCH] mesa: rework _mesa_reference_framebuffer() to look like _mesa_reference_renderbuffer() _mesa_unreference_framebuffer() is deprecated since _mesa_reference_framebuffer(ptr, NULL) can be used instead. --- src/mesa/main/framebuffer.c | 45 ++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 52fd3c9d819..351bf6959af 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -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); } -- 2.30.2