aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaj Grönholm <kaj.gronholm@qt.io>2021-05-17 10:01:06 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-19 05:56:14 +0000
commitf542e2bd35767e97ce6b328a23e21791a4ccbed9 (patch)
tree5ef8f6c199337405216f22f81bd7b51baf62b1b6 /src
parentf47535cea6da4c6313a240b9cf41c87ca54bc0ef (diff)
Switch from QFlatSet to QSet in particles
Based on testing, when the amount of particles increases, Qt 6 QSet seems to perform better in this use case than the QFlatSet. Task-number: QTBUG-92977 Change-Id: I442a8fb7a0496f6ee7e5c4fc37348f549f81a686 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit 6f1ed8b46abed1a2190c12f8d7b272b075efa0e8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/particles/CMakeLists.txt1
-rw-r--r--src/particles/qquickparticleaffector_p.h3
-rw-r--r--src/particles/qquickparticleflatset_p.h156
-rw-r--r--src/particles/qquickparticlesystem_p.h3
4 files changed, 2 insertions, 161 deletions
diff --git a/src/particles/CMakeLists.txt b/src/particles/CMakeLists.txt
index 9ffa6564c2..e801d0b936 100644
--- a/src/particles/CMakeLists.txt
+++ b/src/particles/CMakeLists.txt
@@ -24,7 +24,6 @@ qt_internal_add_module(QuickParticles
qquickparticleaffector.cpp qquickparticleaffector_p.h
qquickparticleemitter.cpp qquickparticleemitter_p.h
qquickparticleextruder.cpp qquickparticleextruder_p.h
- qquickparticleflatset_p.h
qquickparticlegroup.cpp qquickparticlegroup_p.h
qquickparticlepainter.cpp qquickparticlepainter_p.h
qquickparticlesmodule.cpp qquickparticlesmodule_p.h
diff --git a/src/particles/qquickparticleaffector_p.h b/src/particles/qquickparticleaffector_p.h
index 4f60389e04..79446a23a1 100644
--- a/src/particles/qquickparticleaffector_p.h
+++ b/src/particles/qquickparticleaffector_p.h
@@ -55,7 +55,6 @@
#include "qquickparticlesystem_p.h"
#include "qquickparticleextruder_p.h"
#include "qtquickparticlesglobal_p.h"
-#include "qquickparticleflatset_p.h"
QT_BEGIN_NAMESPACE
@@ -197,7 +196,7 @@ protected:
static const qreal simulationCutoff;
QPointF m_offset;
- QtQuickParticlesPrivate::QFlatSet<QPair<int, int>> m_onceOffed;
+ QSet<QPair<int, int>> m_onceOffed;
private:
QSet<int> m_groupIds;
bool m_updateIntSet;
diff --git a/src/particles/qquickparticleflatset_p.h b/src/particles/qquickparticleflatset_p.h
deleted file mode 100644
index 6d0650a12b..0000000000
--- a/src/particles/qquickparticleflatset_p.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQuick module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKPARTICLEFLATSET_P_H
-#define QQUICKPARTICLEFLATSET_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGlobal>
-
-#include <vector>
-#include <algorithm>
-#include <iterator>
-
-QT_BEGIN_NAMESPACE
-
-// Minimal API, just for the consumption of Qt Quick Particles.
-// For extra safety, it's in a private namespace
-
-namespace QtQuickParticlesPrivate {
-
-template <typename T>
-class QFlatSet
-{
-public:
- using iterator = typename std::vector<T>::iterator;
- using const_iterator = typename std::vector<T>::const_iterator;
- using value_type = typename std::vector<T>::value_type;
- using size_type = int;
-
- iterator find(const T &t)
- {
- return std::find(begin(), end(), t);
- }
-
- const_iterator find(const T &t) const
- {
- return std::find(begin(), end(), t);
- }
-
- bool contains(const T &t) const
- {
- return find(t) != end();
- }
-
- void clear()
- {
- m_data.clear();
- }
-
- void reserve(int capacity)
- {
- m_data.reserve(capacity);
- }
-
- iterator insert(const T &t)
- {
- auto i = find(t);
- if (i != end())
- return i;
- T copy = t;
- m_data.push_back(std::move(copy));
- return std::prev(m_data.end());
- }
-
- iterator insert(T &&t)
- {
- auto i = find(t);
- if (i != end())
- return i;
- m_data.push_back(std::move(t));
- return std::prev(m_data.end());
- }
-
- size_type remove(const T &t)
- {
- auto i = std::find(m_data.begin(), m_data.end(), t);
- if (i != m_data.end()) {
- m_data.erase(i);
- return 1;
- }
- return 0;
- }
-
- iterator operator<<(const T &t)
- {
- return insert(t);
- }
-
- iterator operator<<(T &&t)
- {
- return insert(std::move(t));
- }
-
- iterator begin() { return m_data.begin(); }
- const_iterator begin() const { return m_data.begin(); }
- const_iterator cbegin() const { return m_data.cbegin(); }
-
- iterator end() { return m_data.end(); }
- const_iterator end() const { return m_data.end(); }
- const_iterator cend() const { return m_data.cend(); }
-
-private:
- std::vector<T> m_data;
-};
-
-} // namespace QtQuickParticlesPrivate
-
-QT_END_NAMESPACE
-
-#endif // QQUICKPARTICLEFLATSET_P_H
diff --git a/src/particles/qquickparticlesystem_p.h b/src/particles/qquickparticlesystem_p.h
index 2f2e10d264..0ae2a5f345 100644
--- a/src/particles/qquickparticlesystem_p.h
+++ b/src/particles/qquickparticlesystem_p.h
@@ -63,7 +63,6 @@
#include <private/qv4global_p.h>
#include <private/qv4staticvalue_p.h>
#include "qtquickparticlesglobal_p.h"
-#include "qquickparticleflatset_p.h"
QT_BEGIN_NAMESPACE
@@ -412,7 +411,7 @@ public:
int systemSync(QQuickParticlePainter* p);
//Data members here for ease of related class and auto-test usage. Not "public" API. TODO: d_ptrize
- QtQuickParticlesPrivate::QFlatSet<QQuickParticleData*> needsReset;
+ QSet<QQuickParticleData*> needsReset;
QVector<QQuickParticleData*> bySysIdx; //Another reference to the data (data owned by group), but by sysIdx
QQuickStochasticEngine* stateEngine;