From ffee803f1099f85082a152791a7a3b261947a751 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 24 Jun 2020 11:57:21 +0200 Subject: Use QList instead of QVector Task-number: QTBUG-84469 Change-Id: Iefd2fb627602ef4744d80858eee72a089ef5f4ec Reviewed-by: Lars Knoll --- .../qdeclarativepolylinemapitem.cpp | 83 ++++++++++------------ 1 file changed, 36 insertions(+), 47 deletions(-) (limited to 'src/location/declarativemaps/qdeclarativepolylinemapitem.cpp') diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp index d59704dc..0448d667 100644 --- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp @@ -571,10 +571,8 @@ static inline int clipPointType(qreal x, qreal y, const QRectF &rect) return type; } -static void clipSegmentToRect(qreal x0, qreal y0, qreal x1, qreal y1, - const QRectF &clipRect, - QVector &outPoints, - QVector &outTypes) +static void clipSegmentToRect(qreal x0, qreal y0, qreal x1, qreal y1, const QRectF &clipRect, + QList &outPoints, QList &outTypes) { int type0 = clipPointType(x0, y0, clipRect); int type1 = clipPointType(x1, y1, clipRect); @@ -637,11 +635,9 @@ static void clipSegmentToRect(qreal x0, qreal y0, qreal x1, qreal y1, } } -static void clipPathToRect(const QVector &points, - const QVector &types, - const QRectF &clipRect, - QVector &outPoints, - QVector &outTypes) +static void clipPathToRect(const QList &points, + const QList &types, const QRectF &clipRect, + QList &outPoints, QList &outTypes) { outPoints.clear(); outPoints.reserve(points.size()); @@ -686,8 +682,8 @@ void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map, viewport.adjust(-strokeWidth, -strokeWidth, strokeWidth * 2, strokeWidth * 2); viewport.translate(-1 * origin); - QVector points; - QVector types; + QList points; + QList types; if (clipToViewport_) { // Although the geometry has already been clipped against the visible region in wrapped mercator space. @@ -755,7 +751,7 @@ bool QGeoMapPolylineGeometry::contains(const QPointF &point) const { // screenOutline_.contains(screenPoint) doesn't work, as, it appears, that // screenOutline_ for QGeoMapPolylineGeometry is empty (QRectF(0,0 0x0)) - const QVector &verts = vertices(); + const QList &verts = vertices(); QPolygonF tri; for (int i = 0; i < verts.size(); ++i) { tri << verts[i]; @@ -1625,7 +1621,7 @@ bool QGeoMapPolylineGeometryOpenGL::allocateAndFillEntries(QSGGeometry *geom, return false; } - const QVector &v = *m_screenVertices; + const QList &v = *m_screenVertices; if (v.size() < 2) { geom->allocate(0, 0); return true; @@ -1692,7 +1688,7 @@ void QGeoMapPolylineGeometryOpenGL::allocateAndFillLineStrip(QSGGeometry *geom, // Select LOD. Generate if not present. Assign it to m_screenVertices; Q_UNUSED(lod) - const QVector &vx = *m_screenVertices; + const QList &vx = *m_screenVertices; geom->allocate(vx.size()); QSGGeometry::Point2D *pts = geom->vertexDataAsPoint2D(); @@ -1918,10 +1914,10 @@ const char *MapPolylineShaderExtruded::vertexShaderMiteredSegments() const "}\n"; } -QVector QGeoMapItemLODGeometry::getSimplified( - QVector &wrappedPath, // reference as it gets copied in the nested call - double leftBoundWrapped, - unsigned int zoom) +QList QGeoMapItemLODGeometry::getSimplified( + QList + &wrappedPath, // reference as it gets copied in the nested call + double leftBoundWrapped, unsigned int zoom) { // Try a simplify step QList data; @@ -1932,7 +1928,7 @@ QVector QGeoMapItemLODGeometry::getSimplified zoom); data.clear(); - QVector simple; + QList simple; for (auto e: simplified) simple << e; return simple; @@ -1947,16 +1943,11 @@ bool QGeoMapItemLODGeometry::isLODActive(unsigned int lod) const class PolylineSimplifyTask : public QRunnable { public: - PolylineSimplifyTask(const QSharedPointer > &input, // reference as it gets copied in the nested call - const QSharedPointer > &output, - double leftBound, - unsigned int zoom, - QSharedPointer &working) - : m_zoom(zoom) - , m_leftBound(leftBound) - , m_input(input) - , m_output(output) - , m_working(working) + PolylineSimplifyTask(const QSharedPointer> + &input, // reference as it gets copied in the nested call + const QSharedPointer> &output, + double leftBound, unsigned int zoom, QSharedPointer &working) + : m_zoom(zoom), m_leftBound(leftBound), m_input(input), m_output(output), m_working(working) { Q_ASSERT(!input.isNull()); Q_ASSERT(!output.isNull()); @@ -1969,25 +1960,23 @@ public: // Skip sending notifications for now. Updated data will be picked up eventually. // ToDo: figure out how to connect a signal from here to a slot in the item. *m_working = QGeoMapPolylineGeometryOpenGL::zoomToLOD(m_zoom); - const QVector res = - QGeoMapPolylineGeometryOpenGL::getSimplified( *m_input, - m_leftBound, - QGeoMapPolylineGeometryOpenGL::zoomForLOD(m_zoom)); + const QList res = + QGeoMapPolylineGeometryOpenGL::getSimplified( + *m_input, m_leftBound, QGeoMapPolylineGeometryOpenGL::zoomForLOD(m_zoom)); *m_output = res; *m_working = 0; } unsigned int m_zoom; double m_leftBound; - QSharedPointer > m_input, m_output; + QSharedPointer> m_input, m_output; QSharedPointer m_working; }; -void QGeoMapItemLODGeometry::enqueueSimplificationTask(const QSharedPointer > &input, - const QSharedPointer > &output, - double leftBound, - unsigned int zoom, - QSharedPointer &working) +void QGeoMapItemLODGeometry::enqueueSimplificationTask( + const QSharedPointer> &input, + const QSharedPointer> &output, double leftBound, + unsigned int zoom, QSharedPointer &working) { Q_ASSERT(!input.isNull()); Q_ASSERT(!output.isNull()); @@ -2010,8 +1999,8 @@ void QGeoMapItemLODGeometry::selectLOD(unsigned int zoom, double leftBound, bool // if here, zoomToLOD != 0 and no current working task. // So select the last filled LOD != m_working (lower-bounded by 1, // guaranteed to exist), and enqueue the right one - m_verticesLOD[requestedLod] = QSharedPointer>( - new QVector); + m_verticesLOD[requestedLod] = QSharedPointer>( + new QList); for (unsigned int i = requestedLod - 1; i >= 1; i--) { if (*m_working != i && !m_verticesLOD[i].isNull()) { @@ -2019,8 +2008,8 @@ void QGeoMapItemLODGeometry::selectLOD(unsigned int zoom, double leftBound, bool break; } else if (i == 1) { // get 1 synchronously if not computed already - m_verticesLOD[1] = QSharedPointer>( - new QVector); + m_verticesLOD[1] = QSharedPointer>( + new QList); *m_verticesLOD[1] = getSimplified( *m_verticesLOD[0], leftBound, zoomForLOD(0)); @@ -2044,16 +2033,16 @@ void QGeoMapItemLODGeometry::selectLODOnDataChanged(unsigned int zoom, double le if (lod > 0) { // Generate ZL 1 as fallback for all cases != 0. Do not do if 0 is requested // (= old behavior, LOD disabled) - m_verticesLOD[1] = QSharedPointer>( - new QVector); + m_verticesLOD[1] = QSharedPointer>( + new QList); *m_verticesLOD[1] = getSimplified( *m_verticesLOD[0], leftBound, zoomForLOD(0)); } if (lod > 1) { if (!m_verticesLOD[lod]) - m_verticesLOD[lod] = QSharedPointer>( - new QVector); + m_verticesLOD[lod] = QSharedPointer>( + new QList); enqueueSimplificationTask( m_verticesLOD.at(0), m_verticesLOD[lod], leftBound, -- cgit v1.2.1