[PATCH weston v2] compositor: Address blending for XRGB surfaces with alpha < 1.0.

Scott Moreau oreaus at gmail.com
Tue May 22 09:18:50 PDT 2012


---

Thanks Kristian, your suggestion works great.

 src/compositor.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index ab4c970..a16830c 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -839,6 +839,7 @@ WL_EXPORT void
 weston_surface_draw(struct weston_surface *es, struct weston_output *output,
 		    pixman_region32_t *damage)
 {
+	GLfloat surface_rect[4] = { 0.0, 1.0, 0.0, 1.0 };
 	struct weston_compositor *ec = es->compositor;
 	GLfloat *v;
 	pixman_region32_t repaint;
@@ -854,7 +855,7 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output,
 		goto out;
 
 	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-	if (es->blend)
+	if (es->blend || es->alpha < 1.0)
 		glEnable(GL_BLEND);
 	else
 		glDisable(GL_BLEND);
@@ -873,7 +874,10 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output,
 	glUniform1f(es->shader->saturation_uniform, es->saturation);
 	glUniform1f(es->shader->texwidth_uniform,
 		    (GLfloat)es->geometry.width / es->pitch);
-	glUniform4fv(es->shader->opaque_uniform, 1, es->opaque_rect);
+	if (es->blend)
+		glUniform4fv(es->shader->opaque_uniform, 1, es->opaque_rect);
+	else
+		glUniform4fv(es->shader->opaque_uniform, 1, surface_rect);
 
 	if (es->transform.enabled || output->zoom.active)
 		filter = GL_LINEAR;
@@ -2419,10 +2423,8 @@ weston_shader_init(struct weston_shader *shader,
 	shader->brightness_uniform = glGetUniformLocation(shader->program, "bright");
 	shader->saturation_uniform = glGetUniformLocation(shader->program, "saturation");
 	shader->color_uniform = glGetUniformLocation(shader->program, "color");
-	shader->texwidth_uniform = glGetUniformLocation(shader->program,
-							"texwidth");
-	shader->opaque_uniform =
-		glGetUniformLocation(shader->program, "opaque");
+	shader->texwidth_uniform = glGetUniformLocation(shader->program, "texwidth");
+	shader->opaque_uniform = glGetUniformLocation(shader->program, "opaque");
 
 	return 0;
 }
-- 
1.7.7.6



More information about the wayland-devel mailing list