2 * Copyright (C) 2016 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/>.
21 anchors.fill: sourceItem
22 anchors.margins: -units.gu(2)
23 visible: sourceItem !== null
25 property var sourceItem: null
28 property int maskWidth: 0
29 property int maskHeight: 0
31 property real opacityValue: 1
40 x: root.maskX - root.anchors.margins
41 y: root.maskY - root.anchors.margins
43 height: root.maskHeight
44 opacity: 1 - root.opacityValue
52 property variant source: ShaderEffectSource {
53 id: shaderEffectSource
54 sourceItem: root.sourceItem
55 sourceRect: root.sourceItem ? Qt.rect(sourceItem.x + root.anchors.margins,
56 sourceItem.y + root.anchors.margins,
57 sourceItem.width - root.anchors.margins * 2,
58 sourceItem.height - root.anchors.margins * 2)
63 property var mask: ShaderEffectSource {
64 sourceItem: opacityMask
69 varying highp vec2 qt_TexCoord0;
70 uniform sampler2D source;
71 uniform sampler2D mask;
74 highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
75 highp vec4 maskColor = texture2D(mask, qt_TexCoord0);
77 sourceColor *= 1.0 - maskColor.a;
79 gl_FragColor = sourceColor;