summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/blend.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2013-04-18 09:20:55 -0700
committerEric Anholt <eric@anholt.net>2013-04-30 11:59:23 -0700
commite34c857639380303a43146a50cdd724774f59a2f (patch)
tree919d6ab25240cf3f46ebc452b0d682fa1a4c92e8 /src/mesa/main/blend.c
parentdb31bc5cfb7c08c1a32067b09d769c880bc4e954 (diff)
downloadexternal_mesa3d-e34c857639380303a43146a50cdd724774f59a2f.zip
external_mesa3d-e34c857639380303a43146a50cdd724774f59a2f.tar.gz
external_mesa3d-e34c857639380303a43146a50cdd724774f59a2f.tar.bz2
mesa: Make a Mesa core function for sRGB render encoding handling.
v2: const-qualify ctx, and add a comment about the function (recommended by Brian and Kenneth). Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
Diffstat (limited to 'src/mesa/main/blend.c')
-rw-r--r--src/mesa/main/blend.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 7413b15..0c28352 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -856,6 +856,23 @@ _mesa_update_clamp_vertex_color(struct gl_context *ctx)
ctx->Light._ClampVertexColor = _mesa_get_clamp_vertex_color(ctx);
}
+/**
+ * Returns an appropriate gl_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.
+ */
+gl_format
+_mesa_get_render_format(const struct gl_context *ctx, gl_format format)
+{
+ if (ctx->Color.sRGBEnabled)
+ return format;
+ else
+ return _mesa_get_srgb_format_linear(format);
+}
/**********************************************************************/
/** \name Initialization */