summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/framebuffer.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-02-09 07:55:08 -0700
committerBrian Paul <[email protected]>2009-02-09 07:55:08 -0700
commit49002698193784dacffcbf993de26fcdd42c523e (patch)
treeb0bfb6eb31616c3262d37b1eba520b1af0295410 /src/mesa/main/framebuffer.c
parent5199774dc6a2a65d24ac26fe15715654f2568a02 (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/mesa/main/framebuffer.c')
-rw-r--r--src/mesa/main/framebuffer.c45
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);
}