diff options
author | Brian Paul <[email protected]> | 2009-02-09 07:55:08 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-02-09 07:55:08 -0700 |
commit | 49002698193784dacffcbf993de26fcdd42c523e (patch) | |
tree | b0bfb6eb31616c3262d37b1eba520b1af0295410 /src | |
parent | 5199774dc6a2a65d24ac26fe15715654f2568a02 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/framebuffer.c | 45 |
1 files 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); } |