QML_RUNTIME_TESTING should be disabled by default.
[profile/ivi/qtdeclarative.git] / tests / auto / quick / qquickitemlayer / data / Visible.qml
1 import QtQuick 2.0
2
3 Item
4 {
5     id: root
6
7     width: 100
8     height: 100
9
10     property bool layerEffect: false;
11     onLayerEffectChanged: root.maybeUse();
12     Component.onCompleted: root.maybeUse();
13
14     property real layerOpacity: 1;
15     property bool layerVisible: true;
16
17     function maybeUse() {
18         if (root.layerEffect)
19             box.layer.effect = shaderEffect
20     }
21
22     Component {
23         id: shaderEffect
24         ShaderEffect {
25             fragmentShader: "
26                 uniform lowp sampler2D source;
27                 uniform lowp float qt_Opacity;
28                 varying highp vec2 qt_TexCoord0;
29                 void main() {
30                     gl_FragColor = texture2D(source, qt_TexCoord0).bgra * qt_Opacity;
31                 }
32             "
33         }
34
35     }
36
37     Rectangle {
38         id: box
39         width: 100
40         height: 100
41
42         color: "#0000ff"
43         visible: parent.layerVisible;
44         opacity: parent.layerOpacity;
45
46         Rectangle {
47             x: 50
48             width: 50
49             height: 100
50             color: "#00ff00"
51         }
52
53         layer.enabled: true
54
55     }
56 }