+GLboolean
+_mesa_get_clamp_read_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *readFb)
+{
+ return get_clamp_color(readFb, ctx->Color.ClampReadColor);
+}
+
+/**
+ * Update the ctx->Color._ClampFragmentColor field
+ */
+void
+_mesa_update_clamp_fragment_color(struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb)
+{
+ /* Don't clamp if:
+ * - there is no colorbuffer
+ * - all colorbuffers are unsigned normalized, so clamping has no effect
+ * - there is an integer colorbuffer
+ */
+ if (!drawFb || !drawFb->_HasSNormOrFloatColorBuffer ||
+ drawFb->_IntegerBuffers)
+ ctx->Color._ClampFragmentColor = GL_FALSE;
+ else
+ ctx->Color._ClampFragmentColor =
+ _mesa_get_clamp_fragment_color(ctx, drawFb);
+}
+
+/**
+ * Update the ctx->Color._ClampVertexColor field
+ */
+void
+_mesa_update_clamp_vertex_color(struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb)
+{
+ ctx->Light._ClampVertexColor =
+ _mesa_get_clamp_vertex_color(ctx, drawFb);
+}
+
+/**
+ * Returns an appropriate mesa_format for color rendering based on the
+ * GL_FRAMEBUFFER_SRGB state.
+ *
+ * Some drivers implement GL_FRAMEBUFFER_SRGB using a flag on the blend state
+ * (which GL_FRAMEBUFFER_SRGB maps to reasonably), but some have to do so by
+ * overriding the format of the surface. This is a helper for doing the
+ * surface format override variant.
+ */
+mesa_format
+_mesa_get_render_format(const struct gl_context *ctx, mesa_format format)
+{
+ if (ctx->Color.sRGBEnabled)
+ return format;
+ else
+ return _mesa_get_srgb_format_linear(format);
+}