summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2016-01-21 11:00:41 -0800
committerEric Anholt <eric@anholt.net>2016-01-21 18:31:59 -0800
commitad9acdcdf3174f150c872e736e2f387c172d6eb8 (patch)
tree9fe4aed73f46bb5cc857c30053e982ffdfc024aa
parent1c3889555b27b4e3ed8cc5d5eb84f66f9cfbe0df (diff)
squash: glamor: Fix Render blending for alpha-to-red.glamor-core-profile
Signed-off-by: Eric Anholt <eric@anholt.net>
-rw-r--r--glamor/glamor_render.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index c36b3458f..51718d1c7 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -215,8 +215,8 @@ glamor_create_composite_fs(struct shader_key *key)
"out vec4 color1;\n"
"void main()\n"
"{\n"
- " color0 = get_source() * get_mask();\n"
- " color1 = get_source().a * get_mask();\n"
+ " color0 = dest_swizzle(get_source() * get_mask());\n"
+ " color1 = dest_swizzle(get_source().a * get_mask());\n"
"}\n";
const char *header_ca_dual_blend =
"#version 130\n";
@@ -422,11 +422,29 @@ glamor_lookup_composite_shader(ScreenPtr screen, struct
return shader;
}
+static GLenum
+glamor_translate_blend_alpha_to_red(GLenum blend)
+{
+ switch (blend) {
+ case GL_SRC_ALPHA:
+ return GL_SRC_COLOR;
+ case GL_DST_ALPHA:
+ return GL_DST_COLOR;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ return GL_ONE_MINUS_SRC_COLOR;
+ case GL_ONE_MINUS_DST_ALPHA:
+ return GL_ONE_MINUS_DST_COLOR;
+ default:
+ return blend;
+ }
+}
+
static Bool
glamor_set_composite_op(ScreenPtr screen,
CARD8 op, struct blendinfo *op_info_result,
PicturePtr dest, PicturePtr mask,
- enum ca_state ca_state)
+ enum ca_state ca_state,
+ struct shader_key *key)
{
GLenum source_blend, dest_blend;
struct blendinfo *op_info;
@@ -473,6 +491,14 @@ glamor_set_composite_op(ScreenPtr screen,
}
}
+ /* If we're outputting our alpha to the red channel, then any
+ * reads of alpha for blending need to come from the red channel.
+ */
+ if (key->dest_swizzle == SHADER_DEST_SWIZZLE_ALPHA_TO_RED) {
+ source_blend = glamor_translate_blend_alpha_to_red(source_blend);
+ dest_blend = glamor_translate_blend_alpha_to_red(dest_blend);
+ }
+
op_info_result->source_blend = source_blend;
op_info_result->dest_blend = dest_blend;
op_info_result->source_alpha = op_info->source_alpha;
@@ -1006,8 +1032,10 @@ glamor_composite_choose_shader(CARD8 op,
goto fail;
}
- if (!glamor_set_composite_op(screen, op, op_info, dest, mask, ca_state))
+ if (!glamor_set_composite_op(screen, op, op_info, dest, mask, ca_state,
+ &key)) {
goto fail;
+ }
*shader = glamor_lookup_composite_shader(screen, &key);
if ((*shader)->prog == 0) {