summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2005-04-15 17:25:07 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2005-04-15 17:25:07 +0000
commit635ee2df37898fe408be565d189c2fb4dc5f61b1 (patch)
tree3c45245c5386b681e978c0fad3d1765e7512e9ca
parent509710cfd7c45a21bf03c3746d78c0f155b8418b (diff)
added _mesa_share_state()
-rw-r--r--src/mesa/main/context.c26
-rw-r--r--src/mesa/main/context.h2
2 files changed, 28 insertions, 0 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index a1e40e94af..acf5cc7d8b 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -2000,6 +2000,32 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
}
}
+
+/**
+ * Make context 'ctx' share the display lists, textures and programs
+ * that are associated with 'ctxToShare'.
+ * Any display lists, textures or programs associated with 'ctx' will
+ * be deleted if nobody else is sharing them.
+ */
+GLboolean
+_mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare)
+{
+ if (ctx && ctxToShare && ctx->Shared && ctxToShare->Shared) {
+ ctx->Shared->RefCount--;
+ if (ctx->Shared->RefCount == 0) {
+ free_shared_state(ctx, ctx->Shared);
+ }
+ ctx->Shared = ctxToShare->Shared;
+ ctx->Shared->RefCount++;
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
+ }
+}
+
+
+
/**
* Get current context for the calling thread.
*
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index daab59ce6b..4b041edc6d 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -162,6 +162,8 @@ extern void
_mesa_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer,
GLframebuffer *readBuffer );
+extern GLboolean
+_mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare);
extern GLcontext *
_mesa_get_current_context(void);