summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <mbrasser@ford.com>2021-01-27 08:34:44 -0600
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-02-06 15:41:06 +0000
commita4102d447600dc4bf43243f7ccdafd41195040ca (patch)
treee58a9432c44c063e4ba9e1283ee3cc880e3ef194
parent2c19ddbaad3f5f5acb5307db2d9a1b428b7f676f (diff)
Do less work when there are no active ImageParticle particles
Don't mark geometry and material as dirty if there is nothing to change. Task-number: QTBUG-41867 Change-Id: I016d2d76f4ebf731f5bfc931ba616ee5d074bc65 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit e3cb305a6a19bf394c1068a7e483e1c95e11c22b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/particles/qquickimageparticle.cpp32
-rw-r--r--src/particles/qquickimageparticle_p.h3
-rw-r--r--src/particles/qquickparticlesystem_p.h2
3 files changed, 29 insertions, 8 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)
diff --git a/src/particles/qquickimageparticle_p.h b/src/particles/qquickimageparticle_p.h
index 320534ca0b..19000f6c9b 100644
--- a/src/particles/qquickimageparticle_p.h
+++ b/src/particles/qquickimageparticle_p.h
@@ -383,7 +383,7 @@ protected:
void commit(int gIdx, int pIdx) override;
QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
- void prepareNextFrame(QSGNode**);
+ bool prepareNextFrame(QSGNode**);
void buildParticleNodes(QSGNode**);
void sceneGraphInvalidated() override;
@@ -483,6 +483,7 @@ private:
QRhi *m_rhi;
bool m_apiChecked;
qreal m_dpr;
+ bool m_previousActive;
};
QT_END_NAMESPACE
diff --git a/src/particles/qquickparticlesystem_p.h b/src/particles/qquickparticlesystem_p.h
index d991257452..2f2e10d264 100644
--- a/src/particles/qquickparticlesystem_p.h
+++ b/src/particles/qquickparticlesystem_p.h
@@ -205,6 +205,8 @@ public:
return m_size;
}
+ bool isActive() { return freeList.count() > 0; }
+
QString name() const;
void setSize(int newSize);