aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickbehavior.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-09-18 20:16:16 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-21 22:23:13 +0200
commita0f8be4021caa9bb5055923f0eea3bee0e345235 (patch)
treecf33dd92e8284f5692e65b1a574749d50da4a3f0 /src/quick/util/qquickbehavior.cpp
parent0fc040ef70513ccaeb9e96f7ca05a3df4d6c7879 (diff)
Animators - Render thread animation system
This introduces 6 new QML types for animating state in the scene graph when the UI thread is blocked. The QObject property being animated is updated after the animation completes. It works also with the "windows" and "basic" render loops, but offer litte benefit then compared to in the "threaded" case. Change-Id: Ic19e47c898c0b8bd53e457db922b3c9c457c8147 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/quick/util/qquickbehavior.cpp')
-rw-r--r--src/quick/util/qquickbehavior.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp
index 2d765dc5ee..855e99e5a9 100644
--- a/src/quick/util/qquickbehavior.cpp
+++ b/src/quick/util/qquickbehavior.cpp
@@ -49,6 +49,8 @@
#include <private/qabstractanimationjob_p.h>
#include <private/qquicktransition_p.h>
+#include <private/qquickanimatorjob_p.h>
+
#include <private/qobject_p.h>
QT_BEGIN_NAMESPACE
@@ -186,14 +188,18 @@ void QQuickBehavior::write(const QVariant &value)
if (d->animation->isRunning() && value == d->targetValue)
return;
- const QVariant &currentValue = d->property.read();
d->targetValue = value;
- if (d->animationInstance && d->animationInstance->duration() != -1
+ if (d->animationInstance
+ && (d->animationInstance->duration() != -1
+ || d->animationInstance->isRenderThreadProxy())
&& !d->animationInstance->isStopped()) {
d->blockRunningChanged = true;
d->animationInstance->stop();
}
+ // Render thread animations use "stop" to synchronize the property back
+ // to the item, so we need to read the value after.
+ const QVariant &currentValue = d->property.read();
QQuickStateOperation::ActionList actions;
QQuickAction action;
@@ -205,6 +211,10 @@ void QQuickBehavior::write(const QVariant &value)
QList<QQmlProperty> after;
QAbstractAnimationJob *prev = d->animationInstance;
d->animationInstance = d->animation->transition(actions, after, QQuickAbstractAnimation::Forward);
+
+ if (d->animationInstance && d->animation->threadingModel() == QQuickAbstractAnimation::RenderThread)
+ d->animationInstance = new QQuickAnimatorProxyJob(d->animationInstance, d->animation);
+
if (prev && prev != d->animationInstance)
delete prev;