2 * Copyright (C) 2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import QtGraphicalEffects 1.0
23 property alias source: shaderEffectSource.sourceItem
24 property alias saturation: desaturateEffect.saturationValue
25 property alias blurRadius: fastBlur.radius
27 readonly property alias ready: shaderEffectSource.ready
33 property real saturationValue: 1
35 property variant source: ShaderEffectSource {
36 id: shaderEffectSource
37 hideSource: root.visible
39 property bool ready: false;
46 onScheduledUpdateCompleted: ready = true;
50 varying highp vec2 qt_TexCoord0;
51 uniform sampler2D source;
52 uniform lowp float saturationValue;
55 highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
56 highp vec4 scaledColor = sourceColor * vec4(0.3, 0.59, 0.11, 1.0);
57 lowp float luminance = scaledColor.r + scaledColor.g + scaledColor.b ;
58 gl_FragColor = mix(vec4(luminance, luminance, luminance, sourceColor.a), sourceColor, saturationValue);
65 source: desaturateEffect