浏览代码

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.
tags/mesa_20090313
Brian Paul 16 年前
父节点
当前提交
4900269819
共有 1 个文件被更改,包括 24 次插入21 次删除
  1. 24
    21
      src/mesa/main/framebuffer.c

+ 24
- 21
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);
}



正在加载...
取消
保存