aboutsummaryrefslogtreecommitdiffstats
path: root/src/particles
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-29 10:48:54 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-29 10:48:54 +0100
commit4e33b069c426c975319d91e11223114fd0d8ad40 (patch)
treed73e1251bc313b7303fdb000c0789cdfb4c7bb1f /src/particles
parentd9e70d1a49af347f79db7e64bdd8e2e8083a77b5 (diff)
parent05d8ffb4dff5e693967c8ee7cee6d6158eadccbd (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: src/quick/items/qquickaccessibleattached_p.h src/quick/items/qquickwindow.cpp src/quick/scenegraph/qsgthreadedrenderloop.cpp Change-Id: I8bf07487a75f9d1b0d6efa5914dd06875fc9654d
Diffstat (limited to 'src/particles')
-rw-r--r--src/particles/qquickcustomparticle.cpp3
-rw-r--r--src/particles/qquickimageparticle.cpp23
-rw-r--r--src/particles/qquickimageparticle_p.h9
-rw-r--r--src/particles/qquickparticlesystem.cpp20
-rw-r--r--src/particles/qquickparticlesystem_p.h3
5 files changed, 40 insertions, 18 deletions
diff --git a/src/particles/qquickcustomparticle.cpp b/src/particles/qquickcustomparticle.cpp
index e03acd693a..2ab24175a3 100644
--- a/src/particles/qquickcustomparticle.cpp
+++ b/src/particles/qquickcustomparticle.cpp
@@ -303,6 +303,9 @@ QQuickShaderEffectNode *QQuickCustomParticle::prepareNextFrame(QQuickShaderEffec
QQuickShaderEffectNode* QQuickCustomParticle::buildCustomNodes()
{
+ if (!QOpenGLContext::currentContext())
+ return 0;
+
if (QOpenGLContext::currentContext()->isOpenGLES() && m_count * 4 > 0xffff) {
printf("CustomParticle: Too many particles... \n");
return 0;
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp
index 60a67d55a6..50fa9dbc64 100644
--- a/src/particles/qquickimageparticle.cpp
+++ b/src/particles/qquickimageparticle.cpp
@@ -706,10 +706,6 @@ void fillUniformArrayFromImage(float* array, const QImage& img, int size)
QQuickImageParticle::QQuickImageParticle(QQuickItem* parent)
: QQuickParticlePainter(parent)
- , m_image(0)
- , m_colorTable(0)
- , m_sizeTable(0)
- , m_opacityTable(0)
, m_color_variation(0.0)
, m_material(0)
, m_alphaVariation(0.0)
@@ -742,6 +738,7 @@ QQuickImageParticle::QQuickImageParticle(QQuickItem* parent)
QQuickImageParticle::~QQuickImageParticle()
{
+ clearShadows();
}
QQmlListProperty<QQuickSprite> QQuickImageParticle::sprites()
@@ -759,15 +756,14 @@ void QQuickImageParticle::setImage(const QUrl &image)
{
if (image.isEmpty()){
if (m_image) {
- delete m_image;
- m_image = 0;
+ m_image.reset();
emit imageChanged();
}
return;
}
if (!m_image)
- m_image = new ImageData;
+ m_image.reset(new ImageData);
if (image == m_image->source)
return;
m_image->source = image;
@@ -780,14 +776,14 @@ void QQuickImageParticle::setColortable(const QUrl &table)
{
if (table.isEmpty()){
if (m_colorTable) {
- delete m_colorTable;
+ m_colorTable.reset();
emit colortableChanged();
}
return;
}
if (!m_colorTable)
- m_colorTable = new ImageData;
+ m_colorTable.reset(new ImageData);
if (table == m_colorTable->source)
return;
m_colorTable->source = table;
@@ -799,14 +795,14 @@ void QQuickImageParticle::setSizetable(const QUrl &table)
{
if (table.isEmpty()){
if (m_sizeTable) {
- delete m_sizeTable;
+ m_sizeTable.reset();
emit sizetableChanged();
}
return;
}
if (!m_sizeTable)
- m_sizeTable = new ImageData;
+ m_sizeTable.reset(new ImageData);
if (table == m_sizeTable->source)
return;
m_sizeTable->source = table;
@@ -818,14 +814,14 @@ void QQuickImageParticle::setOpacitytable(const QUrl &table)
{
if (table.isEmpty()){
if (m_opacityTable) {
- delete m_opacityTable;
+ m_opacityTable.reset();
emit opacitytableChanged();
}
return;
}
if (!m_opacityTable)
- m_opacityTable = new ImageData;
+ m_opacityTable.reset(new ImageData);
if (table == m_opacityTable->source)
return;
m_opacityTable->source = table;
@@ -1406,6 +1402,7 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node)
else //Simple
g = new QSGGeometry(SimpleParticle_AttributeSet, count, 0);
+ node->setFlag(QSGNode::OwnsGeometry);
node->setGeometry(g);
if (perfLevel <= Colored){
g->setDrawingMode(GL_POINTS);
diff --git a/src/particles/qquickimageparticle_p.h b/src/particles/qquickimageparticle_p.h
index ac61ceeb10..657d945bca 100644
--- a/src/particles/qquickimageparticle_p.h
+++ b/src/particles/qquickimageparticle_p.h
@@ -352,17 +352,16 @@ private:
QUrl source;
QQuickPixmap pix;
};
- ImageData *m_image;
- ImageData *m_colorTable;
- ImageData *m_sizeTable;
- ImageData *m_opacityTable;
+ QScopedPointer<ImageData> m_image;
+ QScopedPointer<ImageData> m_colorTable;
+ QScopedPointer<ImageData> m_sizeTable;
+ QScopedPointer<ImageData> m_opacityTable;
bool loadingSomething();
QColor m_color;
qreal m_color_variation;
- QSGGeometryNode *m_rootNode;
QHash<int, QSGGeometryNode *> m_nodes;
QHash<int, int> m_idxStarts;//TODO: Proper resizing will lead to needing a spriteEngine per particle - do this after sprite engine gains transparent sharing?
QList<QPair<int, int> > m_startsIdx;//Same data, optimized for alternate retrieval
diff --git a/src/particles/qquickparticlesystem.cpp b/src/particles/qquickparticlesystem.cpp
index f751b0f447..be64851a19 100644
--- a/src/particles/qquickparticlesystem.cpp
+++ b/src/particles/qquickparticlesystem.cpp
@@ -478,6 +478,26 @@ QQuickParticleData::~QQuickParticleData()
delete v8Datum;
}
+QQuickParticleData::QQuickParticleData(const QQuickParticleData &other)
+{
+ *this = other;
+}
+
+QQuickParticleData &QQuickParticleData::operator=(const QQuickParticleData &other)
+{
+ clone(other);
+
+ group = other.group;
+ e = other.e;
+ system = other.system;
+ index = other.index;
+ systemIndex = other.systemIndex;
+ // Lazily initialized
+ v8Datum = 0;
+
+ return *this;
+}
+
void QQuickParticleData::clone(const QQuickParticleData& other)
{
x = other.x;
diff --git a/src/particles/qquickparticlesystem_p.h b/src/particles/qquickparticlesystem_p.h
index 81d78de8ac..4d6c153282 100644
--- a/src/particles/qquickparticlesystem_p.h
+++ b/src/particles/qquickparticlesystem_p.h
@@ -137,6 +137,9 @@ public:
QQuickParticleData(QQuickParticleSystem* sys);
~QQuickParticleData();
+ QQuickParticleData(const QQuickParticleData &other);
+ QQuickParticleData &operator=(const QQuickParticleData &other);
+
//Convenience functions for working backwards, because parameters are from the start of particle life
//If setting multiple parameters at once, doing the conversion yourself will be faster.