summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2013-04-18 09:20:55 -0700
committerEric Anholt <[email protected]>2013-04-30 11:59:23 -0700
commite34c857639380303a43146a50cdd724774f59a2f (patch)
tree919d6ab25240cf3f46ebc452b0d682fa1a4c92e8 /src/mesa/main
parentdb31bc5cfb7c08c1a32067b09d769c880bc4e954 (diff)
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 <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> (v1)
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/blend.c17
-rw-r--r--src/mesa/main/blend.h4
2 files changed, 21 insertions, 0 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 7413b156233..0c28352b236 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 */
diff --git a/src/mesa/main/blend.h b/src/mesa/main/blend.h
index 5b7a0259102..b43b3ccb315 100644
--- a/src/mesa/main/blend.h
+++ b/src/mesa/main/blend.h
@@ -35,6 +35,7 @@
#include "glheader.h"
+#include "formats.h"
struct gl_context;
@@ -115,6 +116,9 @@ _mesa_update_clamp_fragment_color(struct gl_context *ctx);
extern void
_mesa_update_clamp_vertex_color(struct gl_context *ctx);
+extern gl_format
+_mesa_get_render_format(const struct gl_context *ctx, gl_format format);
+
extern void
_mesa_init_color( struct gl_context * ctx );