[PATCH weston] compositor: Fix xwayland surface alpha.

Scott Moreau oreaus at gmail.com
Sat Sep 1 20:58:45 PDT 2012


Re-add the opaque_rect hack back to shaders so xwayland surfaces are not broken. xwm
is the only one that uses weston_surface::opaque_rect, specifically for this reason.
It was removed by 0e5a2d02191 - "compositor: simplify shaders", which simplified them
a bit too much.
---
 src/compositor.c | 6 ++++++
 src/compositor.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 9ce44d4..b19cbaf 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1365,6 +1365,7 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output,
 			   1, GL_FALSE, output->matrix.d);
 	glUniform4fv(es->shader->color_uniform, 1, es->color);
 	glUniform1f(es->shader->alpha_uniform, es->alpha);
+	glUniform4fv(es->shader->opaque_uniform, 1, es->opaque_rect);
 
 	if (es->transform.enabled || output->zoom.active)
 		filter = GL_LINEAR;
@@ -3247,9 +3248,13 @@ static const char texture_fragment_shader_rgba[] =
 	"varying vec2 v_texcoord;\n"
 	"uniform sampler2D tex;\n"
 	"uniform float alpha;\n"
+	"uniform vec4 opaque;\n"
 	"void main()\n"
 	"{\n"
 	"   gl_FragColor = alpha * texture2D(tex, v_texcoord)\n;"
+	"   if (opaque.x <= v_texcoord.x && v_texcoord.x < opaque.y &&\n"
+	"	opaque.z <= v_texcoord.y && v_texcoord.y < opaque.w)\n"
+	"	gl_FragColor.a = alpha;\n"
 	"}\n";
 
 static const char texture_fragment_shader_rgbx[] =
@@ -3375,6 +3380,7 @@ weston_shader_init(struct weston_shader *shader,
 	shader->tex_uniforms[2] = glGetUniformLocation(shader->program, "tex2");
 	shader->alpha_uniform = glGetUniformLocation(shader->program, "alpha");
 	shader->color_uniform = glGetUniformLocation(shader->program, "color");
+	shader->opaque_uniform = glGetUniformLocation(shader->program, "opaque");
 
 	return 0;
 }
diff --git a/src/compositor.h b/src/compositor.h
index 96a0477..13ee804 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -248,6 +248,7 @@ struct weston_shader {
 	GLint tex_uniforms[3];
 	GLint alpha_uniform;
 	GLint color_uniform;
+	GLint opaque_uniform;
 };
 
 enum {
-- 
1.7.11.4



More information about the wayland-devel mailing list