Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickanimatorjob_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Gunnar Sletta <gunnar@sletta.org>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QQUICKANIMATORJOB_P_H
6#define QQUICKANIMATORJOB_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qabstractanimationjob_p.h>
20#include <private/qquickanimator_p.h>
21#include <private/qtquickglobal_p.h>
22
23#include <QtQuick/qquickitem.h>
24
25#include <QtCore/qeasingcurve.h>
26#include <QtCore/qpointer.h>
27
29
30class QQuickAnimator;
31class QQuickWindow;
32class QQuickItem;
34
36
37class QSGOpacityNode;
38
39class Q_QUICK_EXPORT QQuickAnimatorProxyJob : public QObject, public QAbstractAnimationJob
40{
42
43public:
46
47 int duration() const override { return m_duration; }
48
49 const QSharedPointer<QAbstractAnimationJob> &job() const { return m_job; }
50
51protected:
52 void updateCurrentTime(int) override;
53 void updateLoopCount(int) override;
54 void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override;
55 void debugAnimation(QDebug d) const override;
56
57public Q_SLOTS:
58 void windowChanged(QQuickWindow *window);
59 void sceneGraphInitialized();
60
61private:
62 void syncBackCurrentValues();
63 void readyToAnimate();
64 void setWindow(QQuickWindow *window);
65 static QObject *findAnimationContext(QQuickAbstractAnimation *);
66
67 QPointer<QQuickAnimatorController> m_controller;
68 QSharedPointer<QAbstractAnimationJob> m_job;
69 int m_duration;
70
71 enum InternalState {
72 State_Starting, // Used when it should be running, but no we're still missing the controller.
73 State_Running,
74 State_Paused,
75 State_Stopped
76 };
77
78 InternalState m_internalState;
79};
80
81class Q_QUICK_EXPORT QQuickAnimatorJob : public QAbstractAnimationJob
82{
83public:
84 virtual void setTarget(QQuickItem *target);
85 QQuickItem *target() const { return m_target; }
86
87 void setFrom(qreal from) {
88 m_from = from;
89 boundValue();
90 }
91 qreal from() const { return m_from; }
92
93 void setTo(qreal to) {
94 m_to = to;
95 boundValue();
96 }
97 qreal to() const { return m_to; }
98
99 void setDuration(int duration) { m_duration = duration; }
100 int duration() const override { return m_duration; }
101
102 QEasingCurve easingCurve() const { return m_easing; }
103 void setEasingCurve(const QEasingCurve &curve) { m_easing = curve; }
104
105 // Initialize is called on the GUI thread just before it is started
106 // and taken over on the render thread.
107 virtual void initialize(QQuickAnimatorController *controller);
108
109 // Called on the render thread during SG shutdown.
110 virtual void invalidate() = 0;
111
112 // Called on the GUI thread after a complete render thread animation job
113 // has been completed to write back a given animator's result to the
114 // source item.
115 virtual void writeBack() = 0;
116
117 // Called before the SG sync on the render thread. The GUI thread is
118 // locked during this call.
119 virtual void preSync() { }
120
121 // Called after the SG sync on the render thread. The GUI thread is
122 // locked during this call.
123 virtual void postSync() { }
124
125 // Called after animations have ticked on the render thread. No locks are
126 // held at this time, so synchronization needs to be taken into account
127 // if applicable.
128 virtual void commit() { }
129
130 bool isTransform() const { return m_isTransform; }
131 bool isUniform() const { return m_isUniform; }
132
133 qreal value() const;
134
135 QQuickAnimatorController *controller() const { return m_controller; }
136
137protected:
139 void debugAnimation(QDebug d) const override;
140
141 qreal progress(int time) const;
142 void boundValue();
143
144 QPointer<QQuickItem> m_target;
146
150
152
154
157};
158
160{
161public:
162
163 struct Helper
164 {
166 : ref(1)
167 , node(nullptr)
168 , ox(0)
169 , oy(0)
170 , dx(0)
171 , dy(0)
172 , scale(1)
173 , rotation(0)
176 {
177 }
178
179 void sync();
180 void commit();
181
182 int ref;
185
186 // Origin
187 float ox;
188 float oy;
189
190 float dx;
191 float dy;
192 float scale;
193 float rotation;
194
197 };
198
200
201 void commit() override;
202 void preSync() override;
203
204 void setTarget(QQuickItem *item) override;
205
206protected:
208 void invalidate() override;
209
211};
212
214{
215public:
216 void updateCurrentTime(int time) override;
217 void writeBack() override;
218};
219
221{
222public:
223 void updateCurrentTime(int time) override;
224 void writeBack() override;
225};
226
228{
229public:
230 void updateCurrentTime(int time) override;
231 void writeBack() override;
232};
233
235{
236public:
238
239 void updateCurrentTime(int time) override;
240 void writeBack() override;
241
244
245private:
247};
248
249class Q_QUICK_EXPORT QQuickOpacityAnimatorJob : public QQuickAnimatorJob
250{
251public:
253
254 void invalidate() override;
255 void updateCurrentTime(int time) override;
256 void writeBack() override;
257 void postSync() override;
258
259private:
260 QSGOpacityNode *m_opacityNode;
261};
262
263#if QT_CONFIG(quick_shadereffect)
265
266class Q_QUICK_EXPORT QQuickUniformAnimatorJob : public QQuickAnimatorJob
267{
268public:
269 QQuickUniformAnimatorJob();
270
271 void setTarget(QQuickItem *target) override;
272
273 void setUniform(const QByteArray &uniform) { m_uniform = uniform; }
274 QByteArray uniform() const { return m_uniform; }
275
276 void updateCurrentTime(int time) override;
277 void writeBack() override;
278 void postSync() override;
279
280 void invalidate() override;
281
282private:
283 QByteArray m_uniform;
284 QPointer<QQuickShaderEffect> m_effect;
285};
286#endif
287
289
290#endif // QQUICKANIMATORJOB_P_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
QPointer< QQuickItem > m_target
QQuickItem * target() const
void setFrom(qreal from)
virtual void writeBack()=0
void setDuration(int duration)
virtual void invalidate()=0
QQuickAnimatorController * m_controller
QQuickAnimatorController * controller() const
void setEasingCurve(const QEasingCurve &curve)
QEasingCurve easingCurve() const
int duration() const override
int duration() const override
const QSharedPointer< QAbstractAnimationJob > & job() const
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
QQuickRotationAnimator::RotationDirection direction() const
void setDirection(QQuickRotationAnimator::RotationDirection direction)
void setTarget(QQuickItem *item) override
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
The QSGOpacityNode class is used to change opacity of nodes.
Definition qsgnode.h:276
The QSGTransformNode class implements transformations in the scene graph.
Definition qsgnode.h:241
direction
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
static bool initialize()
Definition qctf.cpp:94
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum target
GLint ref
GLenum GLenum GLenum GLenum GLenum scale
#define Q_OBJECT
#define Q_SLOTS
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
QObject::connect nullptr
QPropertyAnimation animation
[0]
QGraphicsItem * item
aWidget window() -> setWindowTitle("New Window Title")
[2]