1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the Declarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
48 #include "qsgparticlesystem_p.h"
54 QT_MODULE(Declarative)
57 class QSGParticlePainter : public QQuickItem
60 Q_PROPERTY(QSGParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)
61 Q_PROPERTY(QStringList groups READ groups WRITE setGroups NOTIFY groupsChanged)
64 explicit QSGParticlePainter(QQuickItem *parent = 0);
65 //Data Interface to system
66 void load(QSGParticleData*);
67 void reload(QSGParticleData*);
70 void performPendingCommits();//Called from updatePaintNode
71 QSGParticleSystem* system() const
77 QStringList groups() const
84 void systemChanged(QSGParticleSystem* arg);
86 void groupsChanged(QStringList arg);
89 void setSystem(QSGParticleSystem* arg);
91 void setGroups(QStringList arg)
93 if (m_groups != arg) {
95 emit groupsChanged(arg);
99 void calcSystemOffset(bool resetPending = false);
102 /* Reset resets all your internal data structures. But anything attached to a particle should
103 be in attached data. So reset + reloads should have no visible effect.
104 ###Hunt down all cases where we do a complete reset for convenience and be more targeted
106 virtual void reset();
108 virtual void componentComplete();
109 virtual void initialize(int gIdx, int pIdx){//Called from main thread
113 virtual void commit(int gIdx, int pIdx){//Called in Render Thread
114 //###If you need to do something on size changed, check m_data size in this? Or we reset you every time?
119 QSGParticleSystem* m_system;
120 friend class QSGParticleSystem;
122 bool m_pleaseReset;//Used by subclasses, but it's a nice optimization to know when stuff isn't going to matter.
123 QStringList m_groups;
124 QPointF m_systemOffset;
127 QSGParticleData* m_sentinel;
128 QSet<QPair<int,int> > m_pendingCommits;
129 //QVector<QSGParticleData*> m_shadowData;//For when we implement overwrite: false