Lomiri
SessionIcon.qml
1 /*
2  * Copyright (C) 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 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 General Public License for more details.
12  *
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/>.
15  */
16 
17 import QtQuick 2.4
18 
19 Image {
20  id: root
21 
22  property color color
23  readonly property string fragColorShader:
24  "
25  varying highp vec2 qt_TexCoord0;
26  uniform sampler2D source;
27  uniform lowp vec4 color;
28  uniform lowp float qt_Opacity;
29 
30  void main()
31  {
32  lowp vec4 sourceColor = texture2D(source, qt_TexCoord0);
33  gl_FragColor = color * sourceColor.a * qt_Opacity;
34  }
35  "
36 
37  fillMode: Image.PreserveAspectFit
38  height: sourceSize.height
39 
40  ShaderEffect {
41  readonly property color color: root.color
42  readonly property Image source: parent
43 
44  height: source.height; width: source.width
45  fragmentShader: fragColorShader
46  }
47 }