1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
import QtQuick 2.0
import Animators 1.0 as Rt
Rectangle {
id: root
width: 320
height: 480
color: "black"
property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
Timer {
running: true
interval: 2
onTriggered: loader.sourceComponent = com
repeat: false
}
Loader {
id: loader
sourceComponent: undefined
anchors.fill: parent
}
Component {
id: com
Item {
anchors.fill: parent
Rt.ShaderEffect {
id: effect
width: parent.width
height: parent.height / 2
visible: !renderThreadAnimationsDisabled
property variant source: ShaderEffectSource {
sourceItem: Rectangle { width: 100; height: 100; color: "red" }
hideSource: true
}
property real c: 0.0
fragmentShader:
"
varying highp vec2 qt_TexCoord0;
uniform sampler2D source;
uniform highp float c;
uniform highp float qt_Opacity;
void main() {
lowp vec4 color = texture2D(source, qt_TexCoord0);
gl_FragColor = mix(color, vec4(0.4), c) * qt_Opacity;
}
"
Text {
anchors.centerIn: parent
text: "Render thread animation"
smooth: true
color: "white"
font.pixelSize: 20
}
Rt.ParallelAnimation {
id: testAnimation
running: control.running && !renderThreadAnimationsDisabled
paused: control.paused
loops: 10
Rt.NumberAnimation {
loops: 1
target: effect
property: "opacity"
from: 1.0
to: 0.0
duration: 3000
}
Rt.NumberAnimation {
loops: 1
target: effect
property: "c"
from: 0.0
to: 1.0
duration: 1500
}
}
}
ShaderEffect {
id: refeffect
y: parent.height / 2 + 5
width: parent.width
height: parent.height / 2
visible: !mainThreadAnimationsDisabled
property var source: ShaderEffectSource {
sourceItem: Rectangle { width: 100; height: 100; color: "red" }
hideSource: true
}
property real c: 0.0
fragmentShader:
"
varying highp vec2 qt_TexCoord0;
uniform sampler2D source;
uniform highp float c;
uniform highp float qt_Opacity;
void main() {
lowp vec4 color = texture2D(source, qt_TexCoord0);
gl_FragColor = mix(color, vec4(0.4), c) * qt_Opacity;
}
"
Text {
anchors.centerIn: parent
text: "Main thread animation"
smooth: true
color: "white"
font.pixelSize: 20
}
ParallelAnimation {
id: refAnimation
running: control.running && !mainThreadAnimationsDisabled
paused: control.paused
loops: 10
NumberAnimation {
loops: 1
target: refeffect
property: "opacity"
from: 1.0
to: 0.0
duration: 3000
}
NumberAnimation {
loops: 1
target: refeffect
property: "c"
from: 0.0
to: 1.0
duration: 1500
}
}
}
}
}
Control {
id: control
anchors.bottom: parent.bottom
running: true
}
}
|