When ever an output is repainted, a random tint color is generated. All the repainted regions are tinted with this color. --- src/compositor.c | 16 ++++++++++++++++ src/compositor.h | 2 ++ 2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c index ab90ded..2082c8f 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -737,6 +737,16 @@ texture_region(struct weston_surface *es, pixman_region32_t *region) return n; } +static void +randomise_tint(GLfloat *c) +{ + GLfloat a = 0.5f; + c[0] = ((random() % 1000) / 2000.0f + 0.4f) * a; + c[1] = ((random() % 1000) / 2000.0f + 0.4f) * a; + c[2] = ((random() % 1000) / 2000.0f + 0.4f) * a; + c[3] = a; +} + WL_EXPORT void weston_surface_draw(struct weston_surface *es, struct weston_output *output) { @@ -782,6 +792,7 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output) glUniform1f(es->shader->alpha_uniform, es->alpha / 255.0); glUniform1f(es->shader->texwidth_uniform, (GLfloat)es->geometry.width / es->pitch); + glUniform4fv(es->shader->tint_uniform, 1, ec->tint_color); if (es->transform.enabled) filter = GL_LINEAR; @@ -972,6 +983,8 @@ weston_output_repaint(struct weston_output *output, int msecs) output->border.top + output->border.bottom; glViewport(0, 0, width, height); + randomise_tint(ec->tint_color); + pixman_region32_init(&new_damage); pixman_region32_init(&opaque); pixman_region32_init(&overlap); @@ -1830,6 +1843,7 @@ static const char texture_fragment_shader[] = "uniform sampler2D tex;\n" "uniform float alpha;\n" "uniform float texwidth;\n" + "uniform vec4 tint;\n" "void main()\n" "{\n" " if (v_texcoord.x < 0.0 || v_texcoord.x > texwidth ||\n" @@ -1837,6 +1851,7 @@ static const char texture_fragment_shader[] = " discard;\n" " gl_FragColor = texture2D(tex, v_texcoord)\n;" " gl_FragColor = alpha * gl_FragColor;\n" + " gl_FragColor.rgb = gl_FragColor.rgb * (1.0 - tint.a) + tint.rgb;\n" "}\n"; static const char solid_fragment_shader[] = @@ -1899,6 +1914,7 @@ weston_shader_init(struct weston_shader *shader, shader->color_uniform = glGetUniformLocation(shader->program, "color"); shader->texwidth_uniform = glGetUniformLocation(shader->program, "texwidth"); + shader->tint_uniform = glGetUniformLocation(shader->program, "tint"); return 0; } diff --git a/src/compositor.h b/src/compositor.h index 966d3f4..975eb53 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -109,6 +109,7 @@ struct weston_shader { GLint alpha_uniform; GLint color_uniform; GLint texwidth_uniform; + GLint tint_uniform; }; struct weston_animation { @@ -183,6 +184,7 @@ struct weston_compositor { /* Repaint state. */ struct timespec previous_swap; struct wl_array vertices, indices; + GLfloat tint_color[4]; struct weston_surface *overlay; struct weston_switcher *switcher; -- 1.7.3.4 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel