diff options
Diffstat (limited to 'src/quick/util/qquickanimatorjob.cpp')
-rw-r--r-- | src/quick/util/qquickanimatorjob.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index d7be237a39..8d5ecadab5 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -238,6 +238,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) return; Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); - 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; } @@ -405,7 +409,7 @@ void QQuickYAnimatorJob::updateCurrentTime(int time) return; Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); - 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; } @@ -475,7 +479,7 @@ void QQuickOpacityAnimatorJob::updateCurrentTime(int time) return; Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); - 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); } @@ -491,7 +495,7 @@ void QQuickScaleAnimatorJob::updateCurrentTime(int time) return; Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); - 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; } @@ -511,7 +515,8 @@ void QQuickRotationAnimatorJob::updateCurrentTime(int time) return; Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); - 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(); @@ -594,7 +599,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()); |