[gnome-shell] ScreenShield: blur and desaturate the screenshield background
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] ScreenShield: blur and desaturate the screenshield background
- Date: Tue, 6 Nov 2012 21:52:30 +0000 (UTC)
commit 4fd690333aa3713b48128cded71a3f11234729a9
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Fri Aug 3 18:40:11 2012 +0200
ScreenShield: blur and desaturate the screenshield background
The background is the same as the normal desktop, so we blur and
desaturate it to clearly show that it's not the normal system state.
To do so, we don't use standard ClutterEffects, to avoid the FBO
indirection. Instead, we take advantage of MetaBackgroundActor support
for GLSL code and paint the shaded background texture directly.
https://bugzilla.gnome.org/show_bug.cgi?id=682536
js/ui/screenShield.js | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index 6dcd188..8de06ec 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -49,6 +49,38 @@ const SUMMARY_ICON_SIZE = 48;
const STANDARD_FADE_TIME = 10;
const SHORT_FADE_TIME = 0.3;
+function sample(offx, offy) {
+ return 'texel += texture2D (sampler, tex_coord.st + pixel_step * ' +
+ 'vec2 (' + offx + ',' + offy + ') * 2.0);\n'
+}
+const GLSL_BLUR_EFFECT_DECLARATIONS = ' \
+uniform vec2 pixel_step;\n \
+vec4 apply_blur(in sampler2D sampler, in vec2 tex_coord) {\n \
+ vec4 texel;\n \
+ texel = texture2D (sampler, tex_coord.st);\n'
+ + sample(-1.0, -1.0)
+ + sample( 0.0, -1.0)
+ + sample(+1.0, -1.0)
+ + sample(-1.0, 0.0)
+ + sample( 0.0, 0.0)
+ + sample(+1.0, 0.0)
+ + sample(-1.0, +1.0)
+ + sample( 0.0, +1.0)
+ + sample(+1.0, +1.0) + ' \
+ texel /= 9.0;\n \
+ return texel;\n \
+}\n \
+vec3 desaturate (const vec3 color, const float desaturation)\n \
+{\n \
+ const vec3 gray_conv = vec3 (0.299, 0.587, 0.114);\n \
+ vec3 gray = vec3 (dot (gray_conv, color));\n \
+ return vec3 (mix (color.rgb, gray, desaturation));\n \
+}';
+const GLSL_BLUR_EFFECT_CODE = ' \
+cogl_texel = apply_blur(cogl_sampler, cogl_tex_coord.st);\n \
+cogl_texel.rgb = desaturate(cogl_texel.rgb, 0.6);\n';
+
+
const Clock = new Lang.Class({
Name: 'ScreenShieldClock',
@@ -367,6 +399,11 @@ const ScreenShield = new Lang.Class({
name: 'lockScreenContents' });
this._lockScreenContents.add_constraint(new Layout.MonitorConstraint({ primary: true }));
+ let backgroundActor = Meta.BackgroundActor.new_for_screen(global.screen);
+ backgroundActor.add_glsl_snippet(Meta.SnippetHook.TEXTURE_LOOKUP,
+ GLSL_BLUR_EFFECT_DECLARATIONS,
+ GLSL_BLUR_EFFECT_CODE,
+ true);
this._background = new St.Bin({ style_class: 'screen-shield-background',
child: Meta.BackgroundActor.new_for_screen(global.screen) });
this._lockScreenGroup.add_actor(this._background);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]