added _mesa_share_state()
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 15 Apr 2005 17:25:07 +0000 (17:25 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 15 Apr 2005 17:25:07 +0000 (17:25 +0000)
src/mesa/main/context.c
src/mesa/main/context.h

index a1e40e9..acf5cc7 100644 (file)
@@ -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.
  * 
index daab59c..4b041ed 100644 (file)
@@ -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);