aboutsummaryrefslogtreecommitdiffstats
path: root/src/particles/qquickparticlesystem_p.h
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2016-03-03 14:18:52 +0100
committerErik Verbruggen <erik.verbruggen@theqtcompany.com>2016-03-04 10:43:03 +0000
commit62ecfe55f414d0d04a4344bc6934b4b01408190f (patch)
treeb86869e2a938c4cacda2b627479479d319cd2873 /src/particles/qquickparticlesystem_p.h
parent13c8aecdfccc9d15c367a9d45ec575f1542a90fd (diff)
Particles: code clean-up.
Replace QHash<int, QQuickParticleGroupData*> groupData with a QVarLengthArray, and make sure that those integers (== indices) are continuous, re-used, and start at zero. That way a whole bunch of qhash calls, hash node creatrion/deletion, and other overhead is removed. Change-Id: Ie74fab8a3e3c7b6efa15b7b9ceff1d1a3e9820e9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'src/particles/qquickparticlesystem_p.h')
-rw-r--r--src/particles/qquickparticlesystem_p.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/particles/qquickparticlesystem_p.h b/src/particles/qquickparticlesystem_p.h
index 5a1ab5022d..7805f87094 100644
--- a/src/particles/qquickparticlesystem_p.h
+++ b/src/particles/qquickparticlesystem_p.h
@@ -111,7 +111,7 @@ private:
class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleGroupData {
public:
- QQuickParticleGroupData(int id, QQuickParticleSystem* sys);
+ QQuickParticleGroupData(const QString &name, QQuickParticleSystem* sys);
~QQuickParticleGroupData();
int size();
@@ -119,7 +119,7 @@ public:
void setSize(int newSize);
- int index;
+ const int index;
QSet<QQuickParticlePainter*> painters;//TODO: What if they are dynamically removed?
//TODO: Refactor particle data list out into a separate class
@@ -317,10 +317,13 @@ public:
//Data members here for ease of related class and auto-test usage. Not "public" API. TODO: d_ptrize
QSet<QQuickParticleData*> needsReset;
QVector<QQuickParticleData*> bySysIdx; //Another reference to the data (data owned by group), but by sysIdx
- QHash<QString, int> groupIds;
- QHash<int, QQuickParticleGroupData*> groupData;
QQuickStochasticEngine* stateEngine;
+ QHash<QString, int> groupIds;
+ QVarLengthArray<QQuickParticleGroupData*, 32> groupData;
+ int nextFreeGroupId;
+ int registerParticleGroupData(const QString &name, QQuickParticleGroupData *pgd);
+
//Also only here for auto-test usage
void updateCurrentTime( int currentTime );
QQuickParticleSystemAnimation* m_animation;
@@ -349,6 +352,9 @@ public:
}
private:
+ void searchNextFreeGroupId();
+
+private:
void initializeSystem();
void initGroups();
QList<QPointer<QQuickParticleEmitter> > m_emitters;
@@ -356,7 +362,6 @@ private:
QList<QPointer<QQuickParticlePainter> > m_painters;
QList<QPointer<QQuickParticlePainter> > m_syncList;
QList<QQuickParticleGroup*> m_groups;
- int m_nextGroupId;
int m_nextIndex;
QSet<int> m_reusableIndexes;
bool m_componentComplete;