From 3c7d4de151d0d87b687644381c5d8aaef06f21b2 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 24 Jun 2020 10:25:01 +0200 Subject: Use QList instead of QVector Task-number: QTBUG-84469 Change-Id: I4dc064b70adb054ca4add2dd662e7227255ff970 Reviewed-by: Sona Kurazyan Reviewed-by: Lars Knoll --- src/datavisualization/utils/meshloader.cpp | 16 +++++----- src/datavisualization/utils/meshloader_p.h | 6 ++-- src/datavisualization/utils/objecthelper.cpp | 6 ++-- src/datavisualization/utils/objecthelper_p.h | 16 +++++----- .../utils/scatterobjectbufferhelper.cpp | 34 +++++++++++----------- .../utils/scatterobjectbufferhelper_p.h | 8 ++--- .../utils/scatterpointbufferhelper.cpp | 6 ++-- .../utils/scatterpointbufferhelper_p.h | 5 ++-- src/datavisualization/utils/surfaceobject.cpp | 14 ++++----- src/datavisualization/utils/surfaceobject_p.h | 8 ++--- src/datavisualization/utils/texturehelper.cpp | 2 +- src/datavisualization/utils/texturehelper_p.h | 2 +- src/datavisualization/utils/vertexindexer.cpp | 11 +++---- src/datavisualization/utils/vertexindexer_p.h | 13 ++++----- 14 files changed, 67 insertions(+), 80 deletions(-) (limited to 'src/datavisualization/utils') diff --git a/src/datavisualization/utils/meshloader.cpp b/src/datavisualization/utils/meshloader.cpp index 29c20210..2069b444 100644 --- a/src/datavisualization/utils/meshloader.cpp +++ b/src/datavisualization/utils/meshloader.cpp @@ -31,22 +31,20 @@ #include #include -#include +#include #include QT_BEGIN_NAMESPACE_DATAVISUALIZATION QString slashTag = QStringLiteral("/"); -bool MeshLoader::loadOBJ(const QString &path, - QVector &out_vertices, - QVector &out_uvs, - QVector &out_normals) +bool MeshLoader::loadOBJ(const QString &path, QList &out_vertices, + QList &out_uvs, QList &out_normals) { - QVector vertexIndices, uvIndices, normalIndices; - QVector temp_vertices; - QVector temp_uvs; - QVector temp_normals; + QList vertexIndices, uvIndices, normalIndices; + QList temp_vertices; + QList temp_uvs; + QList temp_normals; QFile file(path); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { diff --git a/src/datavisualization/utils/meshloader_p.h b/src/datavisualization/utils/meshloader_p.h index 2ecf47f0..e8f60ffc 100644 --- a/src/datavisualization/utils/meshloader_p.h +++ b/src/datavisualization/utils/meshloader_p.h @@ -48,10 +48,8 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION class MeshLoader { public: - static bool loadOBJ(const QString &path, - QVector &out_vertices, - QVector &out_uvs, - QVector &out_normals); + static bool loadOBJ(const QString &path, QList &out_vertices, + QList &out_uvs, QList &out_normals); }; QT_END_NAMESPACE_DATAVISUALIZATION diff --git a/src/datavisualization/utils/objecthelper.cpp b/src/datavisualization/utils/objecthelper.cpp index 38ffe928..410a22d7 100644 --- a/src/datavisualization/utils/objecthelper.cpp +++ b/src/datavisualization/utils/objecthelper.cpp @@ -136,9 +136,9 @@ void ObjectHelper::load() m_normalbuffer = 0; m_elementbuffer = 0; } - QVector vertices; - QVector uvs; - QVector normals; + QList vertices; + QList uvs; + QList normals; bool loadOk = MeshLoader::loadOBJ(m_objectFile, vertices, uvs, normals); if (!loadOk) qFatal("loading failed"); diff --git a/src/datavisualization/utils/objecthelper_p.h b/src/datavisualization/utils/objecthelper_p.h index 10820b52..d1c2ea78 100644 --- a/src/datavisualization/utils/objecthelper_p.h +++ b/src/datavisualization/utils/objecthelper_p.h @@ -59,10 +59,10 @@ public: static void releaseObjectHelper(const Abstract3DRenderer *cacheId, ObjectHelper *&obj); inline const QString &objectFile() { return m_objectFile; } - inline const QVector &indices() const { return m_indices; } - inline const QVector &indexedvertices() const { return m_indexedVertices; } - inline const QVector &indexedUVs() const { return m_indexedUVs; } - inline const QVector &indexedNormals() const { return m_indexedNormals; } + inline const QList &indices() const { return m_indices; } + inline const QList &indexedvertices() const { return m_indexedVertices; } + inline const QList &indexedUVs() const { return m_indexedUVs; } + inline const QList &indexedNormals() const { return m_indexedNormals; } private: static ObjectHelper *getObjectHelper(const Abstract3DRenderer *cacheId, @@ -70,10 +70,10 @@ private: void load(); QString m_objectFile; - QVector m_indices; - QVector m_indexedVertices; - QVector m_indexedUVs; - QVector m_indexedNormals; + QList m_indices; + QList m_indexedVertices; + QList m_indexedUVs; + QList m_indexedNormals; }; QT_END_NAMESPACE_DATAVISUALIZATION diff --git a/src/datavisualization/utils/scatterobjectbufferhelper.cpp b/src/datavisualization/utils/scatterobjectbufferhelper.cpp index 579eff98..8e06617b 100644 --- a/src/datavisualization/utils/scatterobjectbufferhelper.cpp +++ b/src/datavisualization/utils/scatterobjectbufferhelper.cpp @@ -74,10 +74,10 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal } // Index vertices - const QVector indices = dotObj->indices(); - const QVector indexed_vertices = dotObj->indexedvertices(); - const QVector indexed_uvs = dotObj->indexedUVs(); - const QVector indexed_normals = dotObj->indexedNormals(); + const QList indices = dotObj->indices(); + const QList indexed_vertices = dotObj->indexedvertices(); + const QList indexed_uvs = dotObj->indexedUVs(); + const QList indexed_normals = dotObj->indexedNormals(); const int indicesCount = indices.count(); const int verticeCount = indexed_vertices.count(); const int uvsCount = indexed_uvs.count(); @@ -95,15 +95,15 @@ void ScatterObjectBufferHelper::fullLoad(ScatterSeriesRenderCache *cache, qreal } modelMatrix.scale(modelScaler); - QVector scaled_vertices; + QList scaled_vertices; scaled_vertices.resize(verticeCount); for (int i = 0; i < verticeCount; i++) scaled_vertices[i] = indexed_vertices[i] * modelMatrix; - QVector buffered_indices; - QVector buffered_vertices; - QVector buffered_uvs; - QVector buffered_normals; + QList buffered_indices; + QList buffered_vertices; + QList buffered_uvs; + QList buffered_normals; buffered_indices.resize(indicesCount * renderArraySize); buffered_vertices.resize(verticeCount * renderArraySize); @@ -204,14 +204,14 @@ void ScatterObjectBufferHelper::updateUVs(ScatterSeriesRenderCache *cache) if (!updateSize) return; - QVector buffered_uvs; + QList buffered_uvs; buffered_uvs.resize(uvsCount * updateSize); uint itemCount = 0; if (cache->colorStyle() == Q3DTheme::ColorStyleRangeGradient) { itemCount = createRangeGradientUVs(cache, buffered_uvs); } else if (cache->colorStyle() == Q3DTheme::ColorStyleObjectGradient) { - const QVector indexed_vertices = dotObj->indexedvertices(); + const QList indexed_vertices = dotObj->indexedvertices(); itemCount = createObjectGradientUVs(cache, buffered_uvs, indexed_vertices); } @@ -234,7 +234,7 @@ void ScatterObjectBufferHelper::updateUVs(ScatterSeriesRenderCache *cache) } uint ScatterObjectBufferHelper::createRangeGradientUVs(ScatterSeriesRenderCache *cache, - QVector &buffered_uvs) + QList &buffered_uvs) { ObjectHelper *dotObj = cache->object(); const int uvsCount = dotObj->indexedUVs().count(); @@ -276,8 +276,8 @@ uint ScatterObjectBufferHelper::createRangeGradientUVs(ScatterSeriesRenderCache } uint ScatterObjectBufferHelper::createObjectGradientUVs(ScatterSeriesRenderCache *cache, - QVector &buffered_uvs, - const QVector &indexed_vertices) + QList &buffered_uvs, + const QList &indexed_vertices) { ObjectHelper *dotObj = cache->object(); const int uvsCount = dotObj->indexedUVs().count(); @@ -316,7 +316,7 @@ void ScatterObjectBufferHelper::update(ScatterSeriesRenderCache *cache, qreal do return; // Index vertices - const QVector indexed_vertices = dotObj->indexedvertices(); + const QList indexed_vertices = dotObj->indexedvertices(); int verticeCount = indexed_vertices.count(); float itemSize = cache->itemSize() / itemScaler; @@ -331,12 +331,12 @@ void ScatterObjectBufferHelper::update(ScatterSeriesRenderCache *cache, qreal do } modelMatrix.scale(modelScaler); - QVector scaled_vertices; + QList scaled_vertices; scaled_vertices.resize(verticeCount); for (int i = 0; i < verticeCount; i++) scaled_vertices[i] = indexed_vertices[i] * modelMatrix; - QVector buffered_vertices; + QList buffered_vertices; buffered_vertices.resize(verticeCount * updateSize); int itemCount = 0; diff --git a/src/datavisualization/utils/scatterobjectbufferhelper_p.h b/src/datavisualization/utils/scatterobjectbufferhelper_p.h index 48b9ea99..fac5e922 100644 --- a/src/datavisualization/utils/scatterobjectbufferhelper_p.h +++ b/src/datavisualization/utils/scatterobjectbufferhelper_p.h @@ -58,11 +58,9 @@ public: void setScaleY(float scale) { m_scaleY = scale; } private: - uint createRangeGradientUVs(ScatterSeriesRenderCache *cache, - QVector &buffered_uvs); - uint createObjectGradientUVs(ScatterSeriesRenderCache *cache, - QVector &buffered_uvs, - const QVector &indexed_vertices); + uint createRangeGradientUVs(ScatterSeriesRenderCache *cache, QList &buffered_uvs); + uint createObjectGradientUVs(ScatterSeriesRenderCache *cache, QList &buffered_uvs, + const QList &indexed_vertices); float m_scaleY; }; diff --git a/src/datavisualization/utils/scatterpointbufferhelper.cpp b/src/datavisualization/utils/scatterpointbufferhelper.cpp index 860a2b88..d3621423 100644 --- a/src/datavisualization/utils/scatterpointbufferhelper.cpp +++ b/src/datavisualization/utils/scatterpointbufferhelper.cpp @@ -111,7 +111,7 @@ void ScatterPointBufferHelper::load(ScatterSeriesRenderCache *cache) } } - QVector buffered_uvs; + QList buffered_uvs; if (itemsVisible) m_indexCount = renderArraySize; @@ -169,7 +169,7 @@ void ScatterPointBufferHelper::updateUVs(ScatterSeriesRenderCache *cache) // It may be that the buffer hasn't yet been initialized, in case the entire series was // hidden items. No need to update in that case. if (m_indexCount > 0) { - QVector buffered_uvs; + QList buffered_uvs; createRangeGradientUVs(cache, buffered_uvs); if (buffered_uvs.size()) { @@ -196,7 +196,7 @@ void ScatterPointBufferHelper::updateUVs(ScatterSeriesRenderCache *cache) } void ScatterPointBufferHelper::createRangeGradientUVs(ScatterSeriesRenderCache *cache, - QVector &buffered_uvs) + QList &buffered_uvs) { const ScatterRenderItemArray &renderArray = cache->renderArray(); const bool updateAll = (cache->updateIndices().size() == 0); diff --git a/src/datavisualization/utils/scatterpointbufferhelper_p.h b/src/datavisualization/utils/scatterpointbufferhelper_p.h index 2b5ee4cc..d1e8f5b0 100644 --- a/src/datavisualization/utils/scatterpointbufferhelper_p.h +++ b/src/datavisualization/utils/scatterpointbufferhelper_p.h @@ -65,11 +65,10 @@ public: GLuint m_pointbuffer; private: - void createRangeGradientUVs(ScatterSeriesRenderCache *cache, - QVector &buffered_uvs); + void createRangeGradientUVs(ScatterSeriesRenderCache *cache, QList &buffered_uvs); private: - QVector m_bufferedPoints; + QList m_bufferedPoints; int m_oldRemoveIndex; float m_scaleY; }; diff --git a/src/datavisualization/utils/surfaceobject.cpp b/src/datavisualization/utils/surfaceobject.cpp index f9e4181e..96a75422 100644 --- a/src/datavisualization/utils/surfaceobject.cpp +++ b/src/datavisualization/utils/surfaceobject.cpp @@ -77,7 +77,7 @@ void SurfaceObject::setUpSmoothData(const QSurfaceDataArray &dataArray, const QR if (changeGeometry) m_vertices.resize(totalSize); - QVector uvs; + QList uvs; if (changeGeometry) uvs.resize(totalSize); int totalIndex = 0; @@ -315,7 +315,7 @@ void SurfaceObject::smoothUVs(const QSurfaceDataArray &dataArray, const bool zDescending = m_dataDimension.testFlag(SurfaceObject::ZDescending); const bool xDescending = m_dataDimension.testFlag(SurfaceObject::XDescending); - QVector uvs; + QList uvs; uvs.resize(m_rows * m_columns); int index = 0; for (int i = 0; i < m_rows; i++) { @@ -534,7 +534,7 @@ void SurfaceObject::setUpData(const QSurfaceDataArray &dataArray, const QRect &s if (changeGeometry) m_vertices.resize(totalSize); - QVector uvs; + QList uvs; if (changeGeometry) uvs.resize(totalSize); @@ -620,7 +620,7 @@ void SurfaceObject::coarseUVs(const QSurfaceDataArray &dataArray, const bool zDescending = m_dataDimension.testFlag(SurfaceObject::ZDescending); const bool xDescending = m_dataDimension.testFlag(SurfaceObject::XDescending); - QVector uvs; + QList uvs; uvs.resize(m_rows * m_columns * 2); int index = 0; int colLimit = m_columns - 1; @@ -802,12 +802,12 @@ void SurfaceObject::createCoarseGridlineIndices(int x, int y, int endX, int endY void SurfaceObject::uploadBuffers() { - QVector uvs; // Empty dummy + QList uvs; // Empty dummy createBuffers(m_vertices, uvs, m_normals, 0); } -void SurfaceObject::createBuffers(const QVector &vertices, const QVector &uvs, - const QVector &normals, const GLint *indices) +void SurfaceObject::createBuffers(const QList &vertices, const QList &uvs, + const QList &normals, const GLint *indices) { // Move to buffers glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer); diff --git a/src/datavisualization/utils/surfaceobject_p.h b/src/datavisualization/utils/surfaceobject_p.h index 41b6ad5f..532f7692 100644 --- a/src/datavisualization/utils/surfaceobject_p.h +++ b/src/datavisualization/utils/surfaceobject_p.h @@ -104,8 +104,8 @@ private: QVector3D createSmoothNormalBodyLineItem(int x, int y); QVector3D createSmoothNormalUpperLineItem(int x, int y); QVector3D normal(const QVector3D &a, const QVector3D &b, const QVector3D &c); - void createBuffers(const QVector &vertices, const QVector &uvs, - const QVector &normals, const GLint *indices); + void createBuffers(const QList &vertices, const QList &uvs, + const QList &normals, const GLint *indices); void checkDirections(const QSurfaceDataArray &array); inline void getNormalizedVertex(const QSurfaceDataItem &data, QVector3D &vertex, bool polar, bool flipXZ); @@ -116,8 +116,8 @@ private: int m_rows = 0; GLuint m_gridElementbuffer; GLuint m_gridIndexCount = 0; - QVector m_vertices; - QVector m_normals; + QList m_vertices; + QList m_normals; // Caches are not owned AxisRenderCache &m_axisCacheX; AxisRenderCache &m_axisCacheY; diff --git a/src/datavisualization/utils/texturehelper.cpp b/src/datavisualization/utils/texturehelper.cpp index fb7b099a..b1371610 100644 --- a/src/datavisualization/utils/texturehelper.cpp +++ b/src/datavisualization/utils/texturehelper.cpp @@ -108,7 +108,7 @@ GLuint TextureHelper::create2DTexture(const QImage &image, bool useTrilinearFilt return textureId; } -GLuint TextureHelper::create3DTexture(const QVector *data, int width, int height, int depth, +GLuint TextureHelper::create3DTexture(const QList *data, int width, int height, int depth, QImage::Format dataFormat) { if (Utils::isOpenGLES() || !width || !height || !depth) diff --git a/src/datavisualization/utils/texturehelper_p.h b/src/datavisualization/utils/texturehelper_p.h index 962e27e9..fac32a42 100644 --- a/src/datavisualization/utils/texturehelper_p.h +++ b/src/datavisualization/utils/texturehelper_p.h @@ -59,7 +59,7 @@ class TextureHelper : protected QOpenGLFunctions // Ownership of created texture is transferred to caller GLuint create2DTexture(const QImage &image, bool useTrilinearFiltering = false, bool convert = true, bool smoothScale = true, bool clampY = false); - GLuint create3DTexture(const QVector *data, int width, int height, int depth, + GLuint create3DTexture(const QList *data, int width, int height, int depth, QImage::Format dataFormat); GLuint createCubeMapTexture(const QImage &image, bool useTrilinearFiltering = false); // Returns selection texture and inserts generated framebuffers to framebuffer parameters diff --git a/src/datavisualization/utils/vertexindexer.cpp b/src/datavisualization/utils/vertexindexer.cpp index 36d93563..5b770366 100644 --- a/src/datavisualization/utils/vertexindexer.cpp +++ b/src/datavisualization/utils/vertexindexer.cpp @@ -48,13 +48,10 @@ bool VertexIndexer::getSimilarVertexIndex_fast(const PackedVertex &packed, } } -void VertexIndexer::indexVBO(const QVector &in_vertices, - const QVector &in_uvs, - const QVector &in_normals, - QVector &out_indices, - QVector &out_vertices, - QVector &out_uvs, - QVector &out_normals) +void VertexIndexer::indexVBO(const QList &in_vertices, const QList &in_uvs, + const QList &in_normals, QList &out_indices, + QList &out_vertices, QList &out_uvs, + QList &out_normals) { unique_vertices = 0; QMap VertexToOutIndex; diff --git a/src/datavisualization/utils/vertexindexer_p.h b/src/datavisualization/utils/vertexindexer_p.h index 030b781b..42a48465 100644 --- a/src/datavisualization/utils/vertexindexer_p.h +++ b/src/datavisualization/utils/vertexindexer_p.h @@ -42,7 +42,7 @@ #include "datavisualizationglobal_p.h" -#include +#include #include QT_BEGIN_NAMESPACE_DATAVISUALIZATION @@ -59,13 +59,10 @@ public: } }; - static void indexVBO(const QVector &in_vertices, - const QVector &in_uvs, - const QVector &in_normals, - QVector &out_indices, - QVector &out_vertices, - QVector &out_uvs, - QVector &out_normals); + static void indexVBO(const QList &in_vertices, const QList &in_uvs, + const QList &in_normals, QList &out_indices, + QList &out_vertices, QList &out_uvs, + QList &out_normals); private: static bool getSimilarVertexIndex_fast(const PackedVertex &packed, -- cgit v1.2.3