summaryrefslogtreecommitdiff
path: root/src/mesa/main/texstate.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-02-24 17:16:57 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-02-24 17:16:57 +0000
commit228d4a6de74fa7ca5d1b7a70b9186a89cd61e06d (patch)
tree7b5af28251e3ea24f68b80a0cfb72b841d652e05 /src/mesa/main/texstate.c
parent1aad408b5a0f4b7253790d437b7e8d8ad4c80131 (diff)
Fix _mesa_copy_texture_state() so that we copy texture object bindings,
not the actual contents of texture objects. This makes glXCopyContext() work properly.
Diffstat (limited to 'src/mesa/main/texstate.c')
-rw-r--r--src/mesa/main/texstate.c53
1 files changed, 41 insertions, 12 deletions
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index dce8c362da..428d0a0d01 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* Version: 6.5
*
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -63,6 +63,35 @@ static const struct gl_tex_env_combine_state default_combine_state = {
};
+/**
+ * Copy a texture binding. Helper used by _mesa_copy_texture_state().
+ */
+static void
+copy_texture_binding(const GLcontext *ctx,
+ struct gl_texture_object **dst,
+ struct gl_texture_object *src)
+{
+ /* only copy if names differ (per OpenGL SI) */
+ if ((*dst)->Name != src->Name) {
+ /* unbind/delete dest binding which we're changing */
+ (*dst)->RefCount--;
+ if ((*dst)->RefCount == 0) {
+ /* time to delete this texture object */
+ ASSERT((*dst)->Name != 0);
+ ASSERT(ctx->Driver.DeleteTexture);
+ /* XXX cast-away const, unfortunately */
+ (*ctx->Driver.DeleteTexture)((GLcontext *) ctx, *dst);
+ }
+ /* make new binding, incrementing ref count */
+ *dst = src;
+ src->RefCount++;
+ }
+}
+
+
+/**
+ * Used by glXCopyContext to copy texture state from one context to another.
+ */
void
_mesa_copy_texture_state( const GLcontext *src, GLcontext *dst )
{
@@ -112,17 +141,17 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst )
dst->Texture.Unit[i].Combine.ScaleShiftRGB = src->Texture.Unit[i].Combine.ScaleShiftRGB;
dst->Texture.Unit[i].Combine.ScaleShiftA = src->Texture.Unit[i].Combine.ScaleShiftA;
- /* texture object state */
- _mesa_copy_texture_object(dst->Texture.Unit[i].Current1D,
- src->Texture.Unit[i].Current1D);
- _mesa_copy_texture_object(dst->Texture.Unit[i].Current2D,
- src->Texture.Unit[i].Current2D);
- _mesa_copy_texture_object(dst->Texture.Unit[i].Current3D,
- src->Texture.Unit[i].Current3D);
- _mesa_copy_texture_object(dst->Texture.Unit[i].CurrentCubeMap,
- src->Texture.Unit[i].CurrentCubeMap);
- _mesa_copy_texture_object(dst->Texture.Unit[i].CurrentRect,
- src->Texture.Unit[i].CurrentRect);
+ /* copy texture object bindings, not contents of texture objects */
+ copy_texture_binding(src, &dst->Texture.Unit[i].Current1D,
+ src->Texture.Unit[i].Current1D);
+ copy_texture_binding(src, &dst->Texture.Unit[i].Current2D,
+ src->Texture.Unit[i].Current2D);
+ copy_texture_binding(src, &dst->Texture.Unit[i].Current3D,
+ src->Texture.Unit[i].Current3D);
+ copy_texture_binding(src, &dst->Texture.Unit[i].CurrentCubeMap,
+ src->Texture.Unit[i].CurrentCubeMap);
+ copy_texture_binding(src, &dst->Texture.Unit[i].CurrentRect,
+ src->Texture.Unit[i].CurrentRect);
}
}