aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickanimatorjob.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-04-12 18:15:52 +0200
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-04-13 09:19:18 +0200
commit6e6079031cf44149be4ca1f05547b4c03e505290 (patch)
treed16fb11a3cdb50f367fea645359538523ab83620 /src/quick/util/qquickanimatorjob.cpp
parent38d2d6ede6722b0fb86ee6723bbfbb2b063c4d6b (diff)
parent8ca22ca7eb5216513410651411fd2e0f07e50f34 (diff)
Merge remote-tracking branch 'origin/dev' into wip/scenegraphng
Diffstat (limited to 'src/quick/util/qquickanimatorjob.cpp')
-rw-r--r--src/quick/util/qquickanimatorjob.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp
index 3502a28301..f0ecb8150a 100644
--- a/src/quick/util/qquickanimatorjob.cpp
+++ b/src/quick/util/qquickanimatorjob.cpp
@@ -239,6 +239,10 @@ void QQuickAnimatorJob::debugAnimation(QDebug d) const
<< "target:" << m_target << "value:" << m_value;
}
+qreal QQuickAnimatorJob::progress(int time) const
+{
+ return m_easing.valueForProgress((m_duration == 0) ? qreal(1) : qreal(time) / qreal(m_duration));
+}
qreal QQuickAnimatorJob::value() const
{
qreal v;
@@ -388,7 +392,7 @@ void QQuickXAnimatorJob::updateCurrentTime(int time)
if (!m_controller)
return;
- m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration);
+ m_value = m_from + (m_to - m_from) * progress(time);
m_helper->dx = m_value;
m_helper->wasChanged = true;
}
@@ -404,7 +408,7 @@ void QQuickYAnimatorJob::updateCurrentTime(int time)
if (!m_controller)
return;
- m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration);
+ m_value = m_from + (m_to - m_from) * progress(time);
m_helper->dy = m_value;
m_helper->wasChanged = true;
}
@@ -473,7 +477,7 @@ void QQuickOpacityAnimatorJob::updateCurrentTime(int time)
if (!m_controller || !m_opacityNode)
return;
- m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration);
+ m_value = m_from + (m_to - m_from) * progress(time);
m_opacityNode->setOpacity(m_value);
}
@@ -488,7 +492,7 @@ void QQuickScaleAnimatorJob::updateCurrentTime(int time)
if (!m_controller)
return;
- m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration);
+ m_value = m_from + (m_to - m_from) * progress(time);
m_helper->scale = m_value;
m_helper->wasChanged = true;
}
@@ -507,7 +511,8 @@ void QQuickRotationAnimatorJob::updateCurrentTime(int time)
if (!m_controller)
return;
- float t = m_easing.valueForProgress(time / (qreal) m_duration);
+ float t = progress(time);
+
switch (m_direction) {
case QQuickRotationAnimator::Clockwise:
m_value = _q_interpolateClockwiseRotation(m_from, m_to, t).toFloat();
@@ -590,7 +595,7 @@ void QQuickUniformAnimatorJob::updateCurrentTime(int time)
if (!m_node || m_uniformIndex == -1 || m_uniformType == -1)
return;
- m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration);
+ m_value = m_from + (m_to - m_from) * progress(time);
QQuickShaderEffectMaterial *material =
static_cast<QQuickShaderEffectMaterial *>(m_node->material());