diff options
Diffstat (limited to 'src/particles/qquickimageparticle.cpp')
-rw-r--r-- | src/particles/qquickimageparticle.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp index 643194c8d5..884edc3390 100644 --- a/src/particles/qquickimageparticle.cpp +++ b/src/particles/qquickimageparticle.cpp @@ -743,6 +743,7 @@ QQuickImageParticle::QQuickImageParticle(QQuickItem* parent) , m_rhi(nullptr) , m_apiChecked(false) , m_dpr(1.0) + , m_previousActive(false) { setFlag(ItemHasContents); } @@ -1569,11 +1570,13 @@ QSGNode *QQuickImageParticle::updatePaintNode(QSGNode *node, UpdatePaintNodeData } if (m_system && m_system->isRunning() && !m_system->isPaused()){ - prepareNextFrame(&node); + bool dirty = prepareNextFrame(&node); if (node) { update(); - foreach (QSGGeometryNode* n, m_nodes) - n->markDirty(QSGNode::DirtyGeometry); + if (dirty) { + foreach (QSGGeometryNode* n, m_nodes) + n->markDirty(QSGNode::DirtyGeometry); + } } else if (m_startedImageLoading < 2) { update();//To call prepareNextFrame() again from the renderThread } @@ -1587,7 +1590,7 @@ QSGNode *QQuickImageParticle::updatePaintNode(QSGNode *node, UpdatePaintNodeData return node; } -void QQuickImageParticle::prepareNextFrame(QSGNode **node) +bool QQuickImageParticle::prepareNextFrame(QSGNode **node) { if (*node == nullptr){//TODO: Staggered loading (as emitted) buildParticleNodes(node); @@ -1603,7 +1606,7 @@ void QQuickImageParticle::prepareNextFrame(QSGNode **node) qDebug() << "Total count: " << count; } if (*node == nullptr) - return; + return false; } qint64 timeStamp = m_system->systemSync(this); @@ -1625,8 +1628,23 @@ void QQuickImageParticle::prepareNextFrame(QSGNode **node) getState(m_material)->timestamp = time; break; } - foreach (QSGGeometryNode* node, m_nodes) - node->markDirty(QSGNode::DirtyMaterial); + + bool active = false; + for (auto groupId : groupIds()) { + if (m_system->groupData[groupId]->isActive()) { + active = true; + break; + } + } + + const bool dirty = active || m_previousActive; + if (dirty) { + foreach (QSGGeometryNode* node, m_nodes) + node->markDirty(QSGNode::DirtyMaterial); + } + + m_previousActive = active; + return dirty; } void QQuickImageParticle::spritesUpdate(qreal time) |