aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/blend.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-04-08 08:20:47 +0200
committermarha <marha@users.sourceforge.net>2013-04-08 08:20:47 +0200
commita4505330e3469b6956348812ff2d6c24f812a8ba (patch)
treecf2b88c771188580ab585f763d2e7a0309ecab26 /mesalib/src/mesa/main/blend.c
parent44fb3db38c5148666f62c78e10fc37bb20ed5c5c (diff)
parent95fb19d661154ba8cfc6c793a0daa25657294b3b (diff)
downloadvcxsrv-a4505330e3469b6956348812ff2d6c24f812a8ba.tar.gz
vcxsrv-a4505330e3469b6956348812ff2d6c24f812a8ba.tar.bz2
vcxsrv-a4505330e3469b6956348812ff2d6c24f812a8ba.zip
Merge remote-tracking branch 'origin/released'
* origin/released: fontconfig libXau mesa xserver xkeyboard-config git update 8 Apr 2013
Diffstat (limited to 'mesalib/src/mesa/main/blend.c')
-rw-r--r--mesalib/src/mesa/main/blend.c82
1 files changed, 77 insertions, 5 deletions
diff --git a/mesalib/src/mesa/main/blend.c b/mesalib/src/mesa/main/blend.c
index 309f1d538..09a1c9ae8 100644
--- a/mesalib/src/mesa/main/blend.c
+++ b/mesalib/src/mesa/main/blend.c
@@ -765,24 +765,96 @@ _mesa_ClampColor(GLenum target, GLenum clamp)
switch (target) {
case GL_CLAMP_VERTEX_COLOR_ARB:
+ if (ctx->API == API_OPENGL_CORE &&
+ !ctx->Extensions.ARB_color_buffer_float) {
+ goto invalid_enum;
+ }
FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.ClampVertexColor = clamp;
+ _mesa_update_clamp_vertex_color(ctx);
break;
case GL_CLAMP_FRAGMENT_COLOR_ARB:
+ if (ctx->API == API_OPENGL_CORE &&
+ !ctx->Extensions.ARB_color_buffer_float) {
+ goto invalid_enum;
+ }
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);
ctx->Color.ClampReadColor = clamp;
break;
default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glClampColorARB(target)");
- return;
+ goto invalid_enum;
}
+ return;
+
+invalid_enum:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glClampColor(%s)",
+ _mesa_lookup_enum_by_nr(target));
+}
+
+static GLboolean
+get_clamp_color(const struct gl_framebuffer *fb, GLenum clamp)
+{
+ if (clamp == GL_TRUE || clamp == GL_FALSE)
+ return clamp;
+
+ ASSERT(clamp == GL_FIXED_ONLY);
+ if (!fb)
+ return GL_TRUE;
+
+ return fb->_AllColorBuffersFixedPoint;
+}
+
+GLboolean
+_mesa_get_clamp_fragment_color(const struct gl_context *ctx)
+{
+ return get_clamp_color(ctx->DrawBuffer,
+ ctx->Color.ClampFragmentColor);
+}
+
+GLboolean
+_mesa_get_clamp_vertex_color(const struct gl_context *ctx)
+{
+ return get_clamp_color(ctx->DrawBuffer, ctx->Light.ClampVertexColor);
+}
+
+GLboolean
+_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);
+}
/**********************************************************************/
@@ -832,10 +904,10 @@ void _mesa_init_color( struct gl_context * ctx )
ctx->Color.DrawBuffer[0] = GL_FRONT;
}
- ctx->Color.ClampFragmentColor = GL_FIXED_ONLY_ARB;
- ctx->Color._ClampFragmentColor = GL_TRUE;
+ ctx->Color.ClampFragmentColor = ctx->API == API_OPENGL_COMPAT ?
+ GL_FIXED_ONLY_ARB : GL_FALSE;
+ ctx->Color._ClampFragmentColor = GL_FALSE;
ctx->Color.ClampReadColor = GL_FIXED_ONLY_ARB;
- ctx->Color._ClampReadColor = GL_TRUE;
if (ctx->API == API_OPENGLES2) {
/* GLES 3 behaves as though GL_FRAMEBUFFER_SRGB is always enabled. */