Debian Codegraph @

src/LomiriToolkit/privates/shaders/frame-qt5.frag

raw
1 /*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Loïc Molinari <[email protected]>
17 */
18
19 uniform sampler2D texture;
20 uniform lowp float opacity;
21 varying mediump vec2 outerCoord;
22 varying mediump vec2 innerCoord;
23 varying lowp vec4 color;
24
25 void main(void)
26 {
27 lowp float shapeOut = texture2D(texture, outerCoord).r;
28 lowp float shapeIn = texture2D(texture, innerCoord).r;
29 // Fused multiply-add friendly version of (shapeOut * (1.0 - shapeIn))
30 lowp float shape = (shapeOut * -shapeIn) + shapeOut;
31 // shape is squared to make thinner corners (particularly visible at stroke 1).
32 gl_FragColor = vec4(shape * shape * opacity) * color;
33 }