From bd1c28a82c2ff955e0d154fac2e2df8d5a110dd7 Mon Sep 17 00:00:00 2001 From: Jonas Karlsson Date: Tue, 23 Jun 2020 13:25:39 +0200 Subject: Reimplement UniformAnimator for ShaderEffect Fixes: QTBUG-83976 Change-Id: I307e96be0d3d2edeb8d9065d100c1ef38c8824c7 Reviewed-by: Laszlo Agocs --- src/quick/util/qquickanimatorjob.cpp | 77 +++++++++--------------------------- 1 file changed, 18 insertions(+), 59 deletions(-) (limited to 'src/quick/util/qquickanimatorjob.cpp') diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index b46e2db258..1c2472dc49 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -43,12 +43,7 @@ #include "qquickanimator_p.h" #include "qquickanimator_p_p.h" #include -#if 0 // QTBUG-83976 -# include -# include -# include -# include -#endif +#include #include #include @@ -595,28 +590,31 @@ void QQuickOpacityAnimatorJob::updateCurrentTime(int time) m_opacityNode->setOpacity(m_value); } - -#if 0 // QTBUG-83976 QQuickUniformAnimatorJob::QQuickUniformAnimatorJob() - : m_node(nullptr) - , m_uniformIndex(-1) - , m_uniformType(-1) { m_isUniform = true; } void QQuickUniformAnimatorJob::setTarget(QQuickItem *target) { - QQuickShaderEffect* effect = qobject_cast(target); - if (effect && effect->isOpenGLShaderEffect()) + // Check target is of expected type + if (qobject_cast(target) != nullptr) m_target = target; } -void QQuickUniformAnimatorJob::invalidate() +void QQuickUniformAnimatorJob::updateCurrentTime(int time) +{ + if (!m_effect) + return; + + m_value = m_from + (m_to - m_from) * progress(time); + m_effect->updateUniformValue(m_uniform, m_value); +} + +void QQuickUniformAnimatorJob::writeBack() { - m_node = nullptr; - m_uniformIndex = -1; - m_uniformType = -1; + if (m_target) + m_target->setProperty(m_uniform, value()); } void QQuickUniformAnimatorJob::postSync() @@ -626,52 +624,13 @@ void QQuickUniformAnimatorJob::postSync() return; } - m_node = static_cast(QQuickItemPrivate::get(m_target)->paintNode); - - if (m_node && m_uniformIndex == -1 && m_uniformType == -1) { - QQuickOpenGLShaderEffectMaterial *material = - static_cast(m_node->material()); - bool found = false; - for (int t=0; !found && t &uniforms = material->uniforms[t]; - for (int i=0; i(m_target); } -void QQuickUniformAnimatorJob::updateCurrentTime(int time) -{ - if (!m_controller) - return; - - if (!m_node || m_uniformIndex == -1 || m_uniformType == -1) - return; - - m_value = m_from + (m_to - m_from) * progress(time); - - QQuickOpenGLShaderEffectMaterial *material = - static_cast(m_node->material()); - material->uniforms[m_uniformType][m_uniformIndex].value = m_value; - // As we're not touching the nodes, we need to explicitly mark it dirty. - // Otherwise, the renderer will abort repainting if this was the only - // change in the graph currently rendering. - m_node->markDirty(QSGNode::DirtyMaterial); -} - -void QQuickUniformAnimatorJob::writeBack() +void QQuickUniformAnimatorJob::invalidate() { - if (m_target) - m_target->setProperty(m_uniform, value()); + m_effect = nullptr; } -#endif QT_END_NAMESPACE -- cgit v1.2.3