summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/blend.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-03-28 02:48:17 +0100
committerMarek Olšák <[email protected]>2013-04-06 23:57:09 +0200
commit9d4f67600b0a8f4b37eb2ed45b194e153669d11a (patch)
tree2c3dafb839c1d656950f3fce16d400d883d51601 /src/mesa/main/blend.c
parent755648c37fc7a54ed0b11c868fd4c7fe28b2f861 (diff)
mesa: move updating clamp control derived state out of mesa_update_state_locked
It has 2 dependencies: glClampColor and the framebuffer, we might just as well do the update where those two are changed. v2: cosmetic changes from Brian's email Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/blend.c')
-rw-r--r--src/mesa/main/blend.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 15b0dc759cd..906ff3efdfb 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -767,10 +767,12 @@ _mesa_ClampColor(GLenum target, GLenum clamp)
case GL_CLAMP_VERTEX_COLOR_ARB:
FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.ClampVertexColor = clamp;
+ _mesa_update_clamp_vertex_color(ctx);
break;
case GL_CLAMP_FRAGMENT_COLOR_ARB:
FLUSH_VERTICES(ctx, _NEW_FRAG_CLAMP);
ctx->Color.ClampFragmentColor = clamp;
+ _mesa_update_clamp_fragment_color(ctx);
break;
case GL_CLAMP_READ_COLOR_ARB:
FLUSH_VERTICES(ctx, _NEW_COLOR);
@@ -814,6 +816,34 @@ _mesa_get_clamp_read_color(const struct gl_context *ctx)
return get_clamp_color(ctx->ReadBuffer, ctx->Color.ClampReadColor);
}
+/**
+ * Update the ctx->Color._ClampFragmentColor field
+ */
+void
+_mesa_update_clamp_fragment_color(struct gl_context *ctx)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+
+ /* Don't clamp if:
+ * - there is no colorbuffer
+ * - all colorbuffers are unsigned normalized, so clamping has no effect
+ * - there is an integer colorbuffer
+ */
+ if (!fb || !fb->_HasSNormOrFloatColorBuffer || fb->_IntegerColor)
+ ctx->Color._ClampFragmentColor = GL_FALSE;
+ else
+ ctx->Color._ClampFragmentColor = _mesa_get_clamp_fragment_color(ctx);
+}
+
+/**
+ * Update the ctx->Color._ClampVertexColor field
+ */
+void
+_mesa_update_clamp_vertex_color(struct gl_context *ctx)
+{
+ ctx->Light._ClampVertexColor = _mesa_get_clamp_vertex_color(ctx);
+}
+
/**********************************************************************/
/** \name Initialization */