diff options
author | Brian <[email protected]> | 2007-03-06 10:07:59 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2007-03-06 10:07:59 -0700 |
commit | a510bc3ee1a696da120c09ee4ec33dc033f671ac (patch) | |
tree | c4c594f5f39f060f507dc13fc5e9383956bce909 /src/mesa/main/context.c | |
parent | 593802c0b0f451299ac2598c6de61e884fb44830 (diff) |
Fix/improve framebuffer object reference counting.
Use _mesa_reference_framebuffer() and _mesa_unreference_framebuffer() functions
to be sure reference counting is done correctly. Additional assertions are
done too. Note _mesa_dereference_framebuffer() renamed to "unreference" as
that's more accurate.
Diffstat (limited to 'src/mesa/main/context.c')
-rw-r--r-- | src/mesa/main/context.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 1245c10cc2c..135c814c0a6 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1408,6 +1408,13 @@ _mesa_free_context_data( GLcontext *ctx ) if (ctx == _mesa_get_current_context()) { _mesa_make_current(NULL, NULL, NULL); } + else { + /* unreference WinSysDraw/Read buffers */ + _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer); + _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer); + _mesa_unreference_framebuffer(&ctx->DrawBuffer); + _mesa_unreference_framebuffer(&ctx->ReadBuffer); + } _mesa_free_lighting_data( ctx ); _mesa_free_eval_data( ctx ); @@ -1694,12 +1701,8 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, ASSERT(_mesa_get_current_context() == newCtx); if (oldCtx) { - if (oldCtx->WinSysDrawBuffer) { - _mesa_dereference_framebuffer(&oldCtx->WinSysDrawBuffer); - } - if (oldCtx->WinSysReadBuffer) { - _mesa_dereference_framebuffer(&oldCtx->WinSysReadBuffer); - } + _mesa_unreference_framebuffer(&oldCtx->WinSysDrawBuffer); + _mesa_unreference_framebuffer(&oldCtx->WinSysReadBuffer); } if (!newCtx) { @@ -1713,20 +1716,18 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, ASSERT(drawBuffer->Name == 0); ASSERT(readBuffer->Name == 0); - newCtx->WinSysDrawBuffer = drawBuffer; - newCtx->WinSysReadBuffer = readBuffer; - drawBuffer->RefCount++; - readBuffer->RefCount++; + _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer); + _mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer); /* * Only set the context's Draw/ReadBuffer fields if they're NULL * or not bound to a user-created FBO. */ if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { - newCtx->DrawBuffer = drawBuffer; + _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); } if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { - newCtx->ReadBuffer = readBuffer; + _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); } newCtx->NewState |= _NEW_BUFFERS; |