aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/context.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-02-26 11:37:37 -0700
committerBrian <[email protected]>2007-02-26 11:37:37 -0700
commite6a9381f78605072cab52447fce35eaa98c1e75c (patch)
tree4f4bd45e59f550e120e31c8924e9c156233cec07 /src/mesa/main/context.c
parent344c3f7379ab4db749e7e8513be9be8fbb9f126c (diff)
Do proper framebuffer refcounting in _mesa_make_current().
Also, added DeletePending field to gl_framebuffer used when a window has been deleted, but there still may be rendering contexts attached to the gl_framebuffer object.
Diffstat (limited to 'src/mesa/main/context.c')
-rw-r--r--src/mesa/main/context.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 9b3759b6c82..1245c10cc2c 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -95,6 +95,7 @@
#include "fbobject.h"
#include "feedback.h"
#include "fog.h"
+#include "framebuffer.h"
#include "get.h"
#include "glthread.h"
#include "glapioffsets.h"
@@ -1666,6 +1667,8 @@ void
_mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
GLframebuffer *readBuffer )
{
+ GET_CURRENT_CONTEXT(oldCtx);
+
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(newCtx, "_mesa_make_current()\n");
@@ -1690,6 +1693,15 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
_glapi_set_context((void *) newCtx);
ASSERT(_mesa_get_current_context() == newCtx);
+ if (oldCtx) {
+ if (oldCtx->WinSysDrawBuffer) {
+ _mesa_dereference_framebuffer(&oldCtx->WinSysDrawBuffer);
+ }
+ if (oldCtx->WinSysReadBuffer) {
+ _mesa_dereference_framebuffer(&oldCtx->WinSysReadBuffer);
+ }
+ }
+
if (!newCtx) {
_glapi_set_dispatch(NULL); /* none current */
}
@@ -1703,6 +1715,8 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
ASSERT(readBuffer->Name == 0);
newCtx->WinSysDrawBuffer = drawBuffer;
newCtx->WinSysReadBuffer = readBuffer;
+ drawBuffer->RefCount++;
+ readBuffer->RefCount++;
/*
* Only set the context's Draw/ReadBuffer fields if they're NULL