From 351bb54f544f1f6d63c469caa8e999473714b2ce Mon Sep 17 00:00:00 2001 From: Matthias Rauter Date: Wed, 8 Feb 2023 09:25:51 +0100 Subject: Remove old code for rendering MapItems and the respecitve switch Pick-to: 6.5 Change-Id: I59311a3b9d32ca9df3a5b66a6352b45448a52cdc Reviewed-by: Volker Hilsheimer --- .../quickmapitems/qdeclarativecirclemapitem.cpp | 91 --------- .../quickmapitems/qdeclarativecirclemapitem_p_p.h | 8 - .../quickmapitems/qdeclarativegeomapitembase_p.h | 4 - .../quickmapitems/qdeclarativepolygonmapitem.cpp | 208 --------------------- .../quickmapitems/qdeclarativepolygonmapitem_p_p.h | 33 ---- .../quickmapitems/qdeclarativepolylinemapitem.cpp | 130 ------------- .../qdeclarativepolylinemapitem_p_p.h | 41 ---- .../quickmapitems/qdeclarativerectanglemapitem.cpp | 74 -------- .../qdeclarativerectanglemapitem_p_p.h | 14 -- src/location/quickmapitems/qgeomapitemgeometry.cpp | 69 ------- src/location/quickmapitems/qgeomapitemgeometry_p.h | 6 - 11 files changed, 678 deletions(-) diff --git a/src/location/quickmapitems/qdeclarativecirclemapitem.cpp b/src/location/quickmapitems/qdeclarativecirclemapitem.cpp index 727e2eb0..0e45d439 100644 --- a/src/location/quickmapitems/qdeclarativecirclemapitem.cpp +++ b/src/location/quickmapitems/qdeclarativecirclemapitem.cpp @@ -455,7 +455,6 @@ QDeclarativeCircleMapItemPrivate::~QDeclarativeCircleMapItemPrivate() QDeclarativeCircleMapItemPrivateCPU::QDeclarativeCircleMapItemPrivateCPU(QDeclarativeCircleMapItem &circle) : QDeclarativeCircleMapItemPrivate(circle) { -#ifdef MAPITEMS_USE_SHAPES m_shape = new QQuickShape(&m_circle); m_shape->setObjectName("_qt_map_item_shape"); m_shape->setZ(-1); @@ -469,14 +468,11 @@ QDeclarativeCircleMapItemPrivateCPU::QDeclarativeCircleMapItemPrivateCPU(QDeclar auto shapePaths = m_shape->data(); shapePaths.append(&shapePaths, m_shapePath); -#endif } QDeclarativeCircleMapItemPrivateCPU::~QDeclarativeCircleMapItemPrivateCPU() { -#ifdef MAPITEMS_USE_SHAPES delete m_shape; -#endif } bool QDeclarativeCircleMapItemPrivate::preserveCircleGeometry (QList &path, @@ -634,11 +630,7 @@ void QDeclarativeCircleMapItemPrivateCPU::updatePolish() m_geometry.clear(); m_circle.setWidth(0); m_circle.setHeight(0); -#ifdef MAPITEMS_USE_SHAPES m_shape->setVisible(false); -#else - m_borderGeometry.clear(); -#endif return; } @@ -666,49 +658,6 @@ void QDeclarativeCircleMapItemPrivateCPU::updatePolish() m_geometry.updateSourcePoints(*m_circle.map(), circlePath); } -#ifndef MAPITEMS_USE_SHAPES - if (!invertedCircle) - m_geometry.updateScreenPoints(*m_circle.map(), m_circle.m_border.width()); - - m_borderGeometry.clear(); - QList geoms; - geoms << &m_geometry; - - if (m_circle.m_border.color() != Qt::transparent && m_circle.m_border.width() > 0) { - QList closedPath = circlePath; - closedPath << closedPath.first(); - - if (invertedCircle) { - closedPath = m_circlePath; - closedPath << closedPath.first(); - std::reverse(closedPath.begin(), closedPath.end()); - } - - m_borderGeometry.setPreserveGeometry(true, m_leftBound); - m_borderGeometry.setPreserveGeometry(preserve, m_leftBound); - - // Use srcOrigin_ from fill geometry after clipping to ensure that - // translateToCommonOrigin won't fail. - const QGeoCoordinate &geometryOrigin = m_geometry.origin(); - - m_borderGeometry.srcPoints_.clear(); - m_borderGeometry.srcPointTypes_.clear(); - - QDoubleVector2D borderLeftBoundWrapped; - QList> clippedPaths = m_borderGeometry.clipPath(*m_circle.map(), - closedPath, borderLeftBoundWrapped); - if (clippedPaths.size()) { - borderLeftBoundWrapped = p.geoToWrappedMapProjection(geometryOrigin); - m_borderGeometry.pathToScreen(*m_circle.map(), clippedPaths, borderLeftBoundWrapped); - m_borderGeometry.updateScreenPoints(*m_circle.map(), m_circle.m_border.width()); - geoms << &m_borderGeometry; - } else { - m_borderGeometry.clear(); - } - } -#endif - -#ifdef MAPITEMS_USE_SHAPES m_circle.setShapeTriangulationScale(m_shape, m_geometry.maxCoord()); const bool hasBorder = m_circle.m_border.color().alpha() != 0 && m_circle.m_border.width() > 0; @@ -731,25 +680,12 @@ void QDeclarativeCircleMapItemPrivateCPU::updatePolish() m_shape->setVisible(true); m_circle.setPositionOnMap(m_geometry.origin(), -1 * bb.topLeft() + QPointF(borderWidth, borderWidth)); -#else - const QRectF combined = QGeoMapItemGeometry::translateToCommonOrigin(geoms); - if (invertedCircle || !preserve) { - m_circle.setWidth(combined.width()); - m_circle.setHeight(combined.height()); - } else { - m_circle.setWidth(combined.width() + 2 * m_circle.m_border.width()); // ToDo: Fix this! - m_circle.setHeight(combined.height() + 2 * m_circle.m_border.width()); - } - // No offsetting here, even in normal case, because first point offset is already translated - m_circle.setPositionOnMap(m_geometry.origin(), m_geometry.firstPointOffset()); -#endif } QSGNode *QDeclarativeCircleMapItemPrivateCPU::updateMapItemPaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data) { Q_UNUSED(data); -#ifdef MAPITEMS_USE_SHAPES delete oldNode; if (m_geometry.isScreenDirty() || m_circle.m_dirtyMaterial) { m_geometry.setPreserveGeometry(false); @@ -757,38 +693,11 @@ QSGNode *QDeclarativeCircleMapItemPrivateCPU::updateMapItemPaintNode(QSGNode *ol m_circle.m_dirtyMaterial = false; } return nullptr; -#else - if (!m_node || !oldNode) { // Apparently the QSG might delete the nodes if they become invisible - m_node = new MapPolygonNode(); - if (oldNode) { - delete oldNode; - oldNode = nullptr; - } - } else { - m_node = static_cast(oldNode); - } - - //TODO: update only material - if (m_geometry.isScreenDirty() || m_borderGeometry.isScreenDirty() || m_circle.m_dirtyMaterial) { - m_node->update(m_circle.m_color, m_circle.m_border.color(), &m_geometry, &m_borderGeometry); - m_geometry.setPreserveGeometry(false); - m_borderGeometry.setPreserveGeometry(false); - m_geometry.markClean(); - m_borderGeometry.markClean(); - m_circle.m_dirtyMaterial = false; - } - - return m_node; -#endif } bool QDeclarativeCircleMapItemPrivateCPU::contains(const QPointF &point) const { -#ifdef MAPITEMS_USE_SHAPES return m_shape->contains(m_circle.mapToItem(m_shape, point)); -#else - return (m_geometry.contains(point) || m_borderGeometry.contains(point)); -#endif } QT_END_NAMESPACE diff --git a/src/location/quickmapitems/qdeclarativecirclemapitem_p_p.h b/src/location/quickmapitems/qdeclarativecirclemapitem_p_p.h index e4e3a59c..03b4f1b7 100644 --- a/src/location/quickmapitems/qdeclarativecirclemapitem_p_p.h +++ b/src/location/quickmapitems/qdeclarativecirclemapitem_p_p.h @@ -98,9 +98,6 @@ public: { // preserveGeometry is cleared in updateMapItemPaintNode m_geometry.markSourceDirty(); -#ifndef MAPITEMS_USE_SHAPES - m_borderGeometry.markSourceDirty(); -#endif m_circle.polishAndUpdate(); } void onMapSet() override @@ -126,14 +123,9 @@ public: bool contains(const QPointF &point) const override; QGeoMapCircleGeometry m_geometry; -#ifdef MAPITEMS_USE_SHAPES QQuickShape *m_shape = nullptr; QQuickShapePath *m_shapePath = nullptr; QDeclarativeGeoMapPainterPath *m_painterPath = nullptr; -#else - QGeoMapPolylineGeometry m_borderGeometry; - MapPolygonNode *m_node = nullptr; -#endif }; QT_END_NAMESPACE diff --git a/src/location/quickmapitems/qdeclarativegeomapitembase_p.h b/src/location/quickmapitems/qdeclarativegeomapitembase_p.h index 18624060..6888596a 100644 --- a/src/location/quickmapitems/qdeclarativegeomapitembase_p.h +++ b/src/location/quickmapitems/qdeclarativegeomapitembase_p.h @@ -27,10 +27,6 @@ #include #include -// Master switch to make rectangle, circle, polygon, and polyline use -// QQuickShape instead of a custom scenegraph node. -#define MAPITEMS_USE_SHAPES - QT_BEGIN_NAMESPACE struct Q_LOCATION_PRIVATE_EXPORT QGeoMapViewportChangeEvent diff --git a/src/location/quickmapitems/qdeclarativepolygonmapitem.cpp b/src/location/quickmapitems/qdeclarativepolygonmapitem.cpp index 897ef22d..1f34d0c1 100644 --- a/src/location/quickmapitems/qdeclarativepolygonmapitem.cpp +++ b/src/location/quickmapitems/qdeclarativepolygonmapitem.cpp @@ -218,79 +218,6 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map, sourceBounds_ = srcPath_.boundingRect(); } -#ifndef MAPITEMS_USE_SHAPES -/*! - \internal -*/ -void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map, qreal strokeWidth) -{ - if (!screenDirty_) - return; - - if (map.viewportWidth() == 0 || map.viewportHeight() == 0) { - clear(); - return; - } - - // The geometry has already been clipped against the visible region projection in wrapped mercator space. - QPainterPath ppi = srcPath_; - clear(); - - // a polygon requires at least 3 points; - if (ppi.elementCount() < 3) - return; - - // translate the path into top-left-centric coordinates - QRectF bb = ppi.boundingRect(); - ppi.translate(-bb.left(), -bb.top()); - firstPointOffset_ = -1 * bb.topLeft(); - - ppi.closeSubpath(); - screenOutline_ = ppi; - - using Coord = double; - using N = uint32_t; - using Point = std::array; - - std::vector> polygon; - polygon.push_back(std::vector()); - std::vector &poly = polygon.front(); - // ... fill polygon structure with actual data - - for (int i = 0; i < ppi.elementCount(); ++i) { - const QPainterPath::Element e = ppi.elementAt(i); - if (e.isMoveTo() || i == ppi.elementCount() - 1 - || (qAbs(e.x - poly.front()[0]) < 0.1 - && qAbs(e.y - poly.front()[1]) < 0.1)) { - Point p = {{ e.x, e.y }}; - poly.push_back( p ); - } else if (e.isLineTo()) { - Point p = {{ e.x, e.y }}; - poly.push_back( p ); - } else { - qWarning("Unhandled element type in polygon painterpath"); - } - } - - if (poly.size() > 2) { - // Run tessellation - // Returns array of indices that refer to the vertices of the input polygon. - // Three subsequent indices form a triangle. - screenVertices_.clear(); - screenIndices_.clear(); - for (const auto &p : poly) - screenVertices_ << QPointF(p[0], p[1]); - std::vector indices = qt_mapbox::earcut(polygon); - for (const auto &i: indices) - screenIndices_ << quint32(i); - } - - screenBounds_ = ppi.boundingRect(); - if (strokeWidth != 0.0) - this->translate(QPointF(strokeWidth, strokeWidth)); -} -#endif - /* * QDeclarativePolygonMapItem Private Implementations */ @@ -302,7 +229,6 @@ QDeclarativePolygonMapItemPrivate::~QDeclarativePolygonMapItemPrivate() QDeclarativePolygonMapItemPrivateCPU::QDeclarativePolygonMapItemPrivateCPU(QDeclarativePolygonMapItem &polygon) : QDeclarativePolygonMapItemPrivate(polygon) { -#ifdef MAPITEMS_USE_SHAPES m_shape = new QQuickShape(&m_poly); m_shape->setObjectName("_qt_map_item_shape"); m_shape->setZ(-1); @@ -316,14 +242,11 @@ QDeclarativePolygonMapItemPrivateCPU::QDeclarativePolygonMapItemPrivateCPU(QDecl auto shapePaths = m_shape->data(); shapePaths.append(&shapePaths, m_shapePath); -#endif } QDeclarativePolygonMapItemPrivateCPU::~QDeclarativePolygonMapItemPrivateCPU() { -#ifdef MAPITEMS_USE_SHAPES delete m_shape; -#endif } void QDeclarativePolygonMapItemPrivateCPU::updatePolish() @@ -332,11 +255,7 @@ void QDeclarativePolygonMapItemPrivateCPU::updatePolish() m_geometry.clear(); m_poly.setWidth(0); m_poly.setHeight(0); -#ifdef MAPITEMS_USE_SHAPES m_shape->setVisible(false); -#else - m_borderGeometry.clear(); -#endif return; } const QGeoMap *map = m_poly.map(); @@ -346,42 +265,8 @@ void QDeclarativePolygonMapItemPrivateCPU::updatePolish() m_geometry.updateSourcePoints(*map, m_geopathProjected); -#ifndef MAPITEMS_USE_SHAPES - m_geometry.updateScreenPoints(*map, borderWidth); - - const QGeoProjectionWebMercator &p = static_cast(map->geoProjection()); - QList geoms; - geoms << &m_geometry; - - m_borderGeometry.clear(); - if (m_poly.m_border.color().alpha() != 0 && borderWidth > 0) { - QList closedPath = m_geopathProjected; - closedPath << closedPath.first(); - - m_borderGeometry.setPreserveGeometry(true, m_poly.m_geopoly.boundingGeoRectangle().topLeft()); - - const QGeoCoordinate &geometryOrigin = m_geometry.origin(); - - m_borderGeometry.srcPoints_.clear(); - m_borderGeometry.srcPointTypes_.clear(); - - QDoubleVector2D borderLeftBoundWrapped; - QList > clippedPaths = m_borderGeometry.clipPath(*map, closedPath, borderLeftBoundWrapped); - if (clippedPaths.size()) { - borderLeftBoundWrapped = p.geoToWrappedMapProjection(geometryOrigin); - m_borderGeometry.pathToScreen(*map, clippedPaths, borderLeftBoundWrapped); - m_borderGeometry.updateScreenPoints(*map, borderWidth); - - geoms << &m_borderGeometry; - } else { - m_borderGeometry.clear(); - } - } -#endif - const QRectF bb = m_geometry.sourceBoundingBox(); -#ifdef MAPITEMS_USE_SHAPES m_poly.setShapeTriangulationScale(m_shape, m_geometry.maxCoord()); const bool hasBorder = m_poly.m_border.color().alpha() != 0 && m_poly.m_border.width() > 0; @@ -398,11 +283,6 @@ void QDeclarativePolygonMapItemPrivateCPU::updatePolish() m_shape->setSize(m_poly.size()); m_shape->setOpacity(m_poly.zoomLevelOpacity()); m_shape->setVisible(true); -#else - const QRectF combined = QGeoMapItemGeometry::translateToCommonOrigin(geoms); - m_poly.setWidth(combined.width() + 2 * borderWidth); - m_poly.setHeight(combined.height() + 2 * borderWidth); -#endif m_poly.setPositionOnMap(m_geometry.origin(), -1 * bb.topLeft() + QPointF(borderWidth, borderWidth)); } @@ -411,7 +291,6 @@ QSGNode *QDeclarativePolygonMapItemPrivateCPU::updateMapItemPaintNode(QSGNode *o QQuickItem::UpdatePaintNodeData *data) { Q_UNUSED(data); -#ifdef MAPITEMS_USE_SHAPES delete oldNode; if (m_geometry.isScreenDirty() || m_poly.m_dirtyMaterial) { m_geometry.setPreserveGeometry(false); @@ -419,44 +298,11 @@ QSGNode *QDeclarativePolygonMapItemPrivateCPU::updateMapItemPaintNode(QSGNode *o m_poly.m_dirtyMaterial = false; } return nullptr; -#else - if (!m_node || !oldNode) { - m_node = new MapPolygonNode(); - if (oldNode) { - delete oldNode; - oldNode = nullptr; - } - } else { - m_node = static_cast(oldNode); - } - - //TODO: update only material - if (m_geometry.isScreenDirty() - || m_borderGeometry.isScreenDirty() - || m_poly.m_dirtyMaterial - || !oldNode) { - m_node->update(m_poly.m_color, - m_poly.m_border.color(), - &m_geometry, - &m_borderGeometry); - m_geometry.setPreserveGeometry(false); - m_borderGeometry.setPreserveGeometry(false); - m_geometry.markClean(); - m_borderGeometry.markClean(); - m_poly.m_dirtyMaterial = false; - } - - return m_node; -#endif } bool QDeclarativePolygonMapItemPrivateCPU::contains(const QPointF &point) const { -#ifdef MAPITEMS_USE_SHAPES return m_shape->contains(m_poly.mapToItem(m_shape, point)); -#else - return (m_geometry.contains(point) || m_borderGeometry.contains(point)); -#endif } /* @@ -699,58 +545,4 @@ void QDeclarativePolygonMapItem::geometryChange(const QRectF &newGeometry, const ////////////////////////////////////////////////////////////////////// -#ifndef MAPITEMS_USE_SHAPES - -MapPolygonNode::MapPolygonNode() - : border_(new MapPolylineNode()), - geometry_(QSGGeometry::defaultAttributes_Point2D(), 0) -{ - geometry_.setDrawingMode(QSGGeometry::DrawTriangles); - QSGGeometryNode::setMaterial(&fill_material_); - QSGGeometryNode::setGeometry(&geometry_); - - appendChildNode(border_); -} - -MapPolygonNode::~MapPolygonNode() -{ -} - -/*! - \internal -*/ -void MapPolygonNode::update(const QColor &fillColor, const QColor &borderColor, - const QGeoMapItemGeometry *fillShape, - const QGeoMapItemGeometry *borderShape) -{ - /* Do the border update first */ - border_->update(borderColor, borderShape); - - /* If we have neither fill nor border with valid points, block the whole - * tree. We can't just block the fill without blocking the border too, so - * we're a little conservative here (maybe at the expense of rendering - * accuracy) */ - if (fillShape->size() == 0 && borderShape->size() == 0) { - setSubtreeBlocked(true); - return; - } - setSubtreeBlocked(false); - - - // TODO: do this only if the geometry has changed!! - // No need to do this every frame. - // Then benchmark the difference! - QSGGeometry *fill = QSGGeometryNode::geometry(); - fillShape->allocateAndFill(fill); - markDirty(DirtyGeometry); - - if (fillColor != fill_material_.color()) { - fill_material_.setColor(fillColor); - setMaterial(&fill_material_); - markDirty(DirtyMaterial); - } -} - -#endif - QT_END_NAMESPACE diff --git a/src/location/quickmapitems/qdeclarativepolygonmapitem_p_p.h b/src/location/quickmapitems/qdeclarativepolygonmapitem_p_p.h index 80f2159c..449a1a1d 100644 --- a/src/location/quickmapitems/qdeclarativepolygonmapitem_p_p.h +++ b/src/location/quickmapitems/qdeclarativepolygonmapitem_p_p.h @@ -45,10 +45,6 @@ public: void updateSourcePoints(const QGeoMap &map, const QList &path); -#ifndef MAPITEMS_USE_SHAPES - void updateScreenPoints(const QGeoMap &map, qreal strokeWidth = 0.0); -#endif - QPainterPath srcPath() const { return srcPath_; } qreal maxCoord() const { return maxCoord_; } @@ -58,24 +54,6 @@ protected: bool assumeSimple_ = false; }; -#ifndef MAPITEMS_USE_SHAPES -class Q_LOCATION_PRIVATE_EXPORT MapPolygonNode : public MapItemGeometryNode -{ - -public: - MapPolygonNode(); - ~MapPolygonNode() override; - - void update(const QColor &fillColor, const QColor &borderColor, - const QGeoMapItemGeometry *fillShape, - const QGeoMapItemGeometry *borderShape); -private: - QSGFlatColorMaterial fill_material_; - MapPolylineNode *border_; - QSGGeometry geometry_; -}; -#endif - class Q_LOCATION_PRIVATE_EXPORT QDeclarativePolygonMapItemPrivate { Q_DISABLE_COPY_MOVE(QDeclarativePolygonMapItemPrivate) @@ -115,9 +93,6 @@ public: { // preserveGeometry is cleared in updateMapItemPaintNode m_geometry.markSourceDirty(); -#ifndef MAPITEMS_USE_SHAPES - m_borderGeometry.markSourceDirty(); -#endif m_poly.polishAndUpdate(); } void regenerateCache() @@ -140,9 +115,6 @@ public: void preserveGeometry() { m_geometry.setPreserveGeometry(true, m_poly.m_geopoly.boundingGeoRectangle().topLeft()); -#ifndef MAPITEMS_USE_SHAPES - m_borderGeometry.setPreserveGeometry(true, m_poly.m_geopoly.boundingGeoRectangle().topLeft()); -#endif } void afterViewportChanged() override { @@ -177,14 +149,9 @@ public: QList m_geopathProjected; QGeoMapPolygonGeometry m_geometry; -#ifdef MAPITEMS_USE_SHAPES QQuickShape *m_shape = nullptr; QQuickShapePath *m_shapePath = nullptr; QDeclarativeGeoMapPainterPath *m_painterPath = nullptr; -#else - QGeoMapPolylineGeometry m_borderGeometry; - MapPolygonNode *m_node = nullptr; -#endif }; QT_END_NAMESPACE diff --git a/src/location/quickmapitems/qdeclarativepolylinemapitem.cpp b/src/location/quickmapitems/qdeclarativepolylinemapitem.cpp index fda978ea..2477a4d8 100644 --- a/src/location/quickmapitems/qdeclarativepolylinemapitem.cpp +++ b/src/location/quickmapitems/qdeclarativepolylinemapitem.cpp @@ -724,7 +724,6 @@ QDeclarativePolylineMapItemPrivate::~QDeclarativePolylineMapItemPrivate() QDeclarativePolylineMapItemPrivateCPU::QDeclarativePolylineMapItemPrivateCPU(QDeclarativePolylineMapItem &poly) : QDeclarativePolylineMapItemPrivate(poly) { -#ifdef MAPITEMS_USE_SHAPES m_shape = new QQuickShape(&m_poly); m_shape->setObjectName("_qt_map_item_shape"); m_shape->setZ(-1); @@ -738,14 +737,11 @@ QDeclarativePolylineMapItemPrivateCPU::QDeclarativePolylineMapItemPrivateCPU(QDe auto shapePaths = m_shape->data(); shapePaths.append(&shapePaths, m_shapePath); -#endif } QDeclarativePolylineMapItemPrivateCPU::~QDeclarativePolylineMapItemPrivateCPU() { -#ifdef MAPITEMS_USE_SHAPES delete m_shape; -#endif } void QDeclarativePolylineMapItemPrivateCPU::regenerateCache() @@ -773,9 +769,7 @@ void QDeclarativePolylineMapItemPrivateCPU::updatePolish() m_geometry.clear(); m_poly.setWidth(0); m_poly.setHeight(0); -#ifdef MAPITEMS_USE_SHAPES m_shape->setVisible(false); -#endif return; } QScopedValueRollback rollback(m_poly.m_updatingGeometry); @@ -794,7 +788,6 @@ void QDeclarativePolylineMapItemPrivateCPU::updatePolish() // it has to be shifted so that the center of the line is on the correct geocoord m_poly.setPositionOnMap(m_geometry.origin(), -1 * bb.topLeft() + QPointF(borderWidth, borderWidth) * 0.5); -#ifdef MAPITEMS_USE_SHAPES m_poly.setShapeTriangulationScale(m_shape, m_geometry.maxCoord_); m_shapePath->setStrokeColor(m_poly.m_line.color()); @@ -808,40 +801,20 @@ void QDeclarativePolylineMapItemPrivateCPU::updatePolish() m_shape->setSize(m_poly.size()); m_shape->setOpacity(m_poly.zoomLevelOpacity()); m_shape->setVisible(true); -#endif } QSGNode *QDeclarativePolylineMapItemPrivateCPU::updateMapItemPaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData * /*data*/) { -#ifdef MAPITEMS_USE_SHAPES delete oldNode; -#else - if (!m_node || !oldNode) { - m_node = new MapPolylineNode(); - if (oldNode) { - delete oldNode; - oldNode = nullptr; - } - } else { - m_node = static_cast(oldNode); - } -#endif //TODO: update only material if (m_geometry.isScreenDirty() || m_poly.m_dirtyMaterial || !oldNode) { -#ifndef MAPITEMS_USE_SHAPES - m_node->update(m_poly.m_line.color(), &m_geometry); -#endif m_geometry.setPreserveGeometry(false); m_geometry.markClean(); m_poly.m_dirtyMaterial = false; } -#ifdef MAPITEMS_USE_SHAPES return nullptr; -#else - return m_node; -#endif } bool QDeclarativePolylineMapItemPrivateCPU::contains(const QPointF &point) const @@ -1179,107 +1152,4 @@ void QDeclarativePolylineMapItem::setGeoShape(const QGeoShape &shape) ////////////////////////////////////////////////////////////////////// -#ifndef MAPITEMS_USE_SHAPES - -/*! - \internal -*/ -VisibleNode::VisibleNode() : m_blocked{true}, m_visible{true} -{ - -} - -VisibleNode::~VisibleNode() -{ - -} - -/*! - \internal -*/ -bool VisibleNode::subtreeBlocked() const -{ - return m_blocked || !m_visible; -} - -/*! - \internal -*/ -void VisibleNode::setSubtreeBlocked(bool blocked) -{ - m_blocked = blocked; -} - -bool VisibleNode::visible() const -{ - return m_visible; -} - -/*! - \internal -*/ -void VisibleNode::setVisible(bool visible) -{ - m_visible = visible; -} - -/*! - \internal -*/ -MapItemGeometryNode::~MapItemGeometryNode() -{ - -} - -bool MapItemGeometryNode::isSubtreeBlocked() const -{ - return subtreeBlocked(); -} - - -/*! - \internal -*/ -MapPolylineNode::MapPolylineNode() : - geometry_(QSGGeometry::defaultAttributes_Point2D(),0) -{ - geometry_.setDrawingMode(QSGGeometry::DrawTriangleStrip); - QSGGeometryNode::setMaterial(&fill_material_); - QSGGeometryNode::setGeometry(&geometry_); -} - - -/*! - \internal -*/ -MapPolylineNode::~MapPolylineNode() -{ -} - -/*! - \internal -*/ -void MapPolylineNode::update(const QColor &fillColor, - const QGeoMapItemGeometry *shape) -{ - if (shape->size() == 0) { - setSubtreeBlocked(true); - return; - } else { - setSubtreeBlocked(false); - } - - QSGGeometry *fill = QSGGeometryNode::geometry(); - shape->allocateAndFill(fill); - markDirty(DirtyGeometry); - - if (fillColor != fill_material_.color()) { - fill_material_.setColor(fillColor); - setMaterial(&fill_material_); - markDirty(DirtyMaterial); - } -} - -#endif - QT_END_NAMESPACE diff --git a/src/location/quickmapitems/qdeclarativepolylinemapitem_p_p.h b/src/location/quickmapitems/qdeclarativepolylinemapitem_p_p.h index 9e8992ad..4ade0fba 100644 --- a/src/location/quickmapitems/qdeclarativepolylinemapitem_p_p.h +++ b/src/location/quickmapitems/qdeclarativepolylinemapitem_p_p.h @@ -74,43 +74,6 @@ public: friend class QDeclarativeRectangleMapItem; }; -#ifndef MAPITEMS_USE_SHAPES -class Q_LOCATION_PRIVATE_EXPORT VisibleNode -{ -public: - VisibleNode(); - virtual ~VisibleNode(); - - bool subtreeBlocked() const; - void setSubtreeBlocked(bool blocked); - bool visible() const; - void setVisible(bool visible); - - bool m_blocked : 1; - bool m_visible : 1; -}; - -class Q_LOCATION_PRIVATE_EXPORT MapItemGeometryNode : public QSGGeometryNode, public VisibleNode -{ -public: - ~MapItemGeometryNode() override; - bool isSubtreeBlocked() const override; -}; - -class Q_LOCATION_PRIVATE_EXPORT MapPolylineNode : public MapItemGeometryNode -{ -public: - MapPolylineNode(); - ~MapPolylineNode() override; - - void update(const QColor &fillColor, const QGeoMapItemGeometry *shape); - -protected: - QSGFlatColorMaterial fill_material_; - QSGGeometry geometry_; -}; -#endif - class Q_LOCATION_PRIVATE_EXPORT QDeclarativePolylineMapItemPrivate { Q_DISABLE_COPY_MOVE(QDeclarativePolylineMapItemPrivate) @@ -190,13 +153,9 @@ public: QList m_geopathProjected; QGeoMapPolylineGeometry m_geometry; -#ifdef MAPITEMS_USE_SHAPES QQuickShape *m_shape = nullptr; QQuickShapePath *m_shapePath = nullptr; QDeclarativeGeoMapPainterPath *m_painterPath = nullptr; -#else - MapPolylineNode *m_node = nullptr; -#endif }; QT_END_NAMESPACE diff --git a/src/location/quickmapitems/qdeclarativerectanglemapitem.cpp b/src/location/quickmapitems/qdeclarativerectanglemapitem.cpp index eae60410..1fbc9215 100644 --- a/src/location/quickmapitems/qdeclarativerectanglemapitem.cpp +++ b/src/location/quickmapitems/qdeclarativerectanglemapitem.cpp @@ -324,7 +324,6 @@ QDeclarativeRectangleMapItemPrivate::~QDeclarativeRectangleMapItemPrivate() QDeclarativeRectangleMapItemPrivateCPU::QDeclarativeRectangleMapItemPrivateCPU(QDeclarativeRectangleMapItem &rect) : QDeclarativeRectangleMapItemPrivate(rect) { -#ifdef MAPITEMS_USE_SHAPES m_shape = new QQuickShape(&m_rect); m_shape->setObjectName("_qt_map_item_shape"); m_shape->setZ(-1); @@ -338,14 +337,11 @@ QDeclarativeRectangleMapItemPrivateCPU::QDeclarativeRectangleMapItemPrivateCPU(Q auto shapePaths = m_shape->data(); shapePaths.append(&shapePaths, m_shapePath); -#endif } QDeclarativeRectangleMapItemPrivateCPU::~QDeclarativeRectangleMapItemPrivateCPU() { -#ifdef MAPITEMS_USE_SHAPES delete m_shape; -#endif } void QDeclarativeRectangleMapItemPrivateCPU::updatePolish() @@ -354,11 +350,7 @@ void QDeclarativeRectangleMapItemPrivateCPU::updatePolish() m_geometry.clear(); m_rect.setWidth(0); m_rect.setHeight(0); -#ifdef MAPITEMS_USE_SHAPES m_shape->setVisible(false); -#else - m_borderGeometry.clear(); -#endif return; } @@ -370,38 +362,6 @@ void QDeclarativeRectangleMapItemPrivateCPU::updatePolish() m_geometry.setPreserveGeometry(true, m_rect.m_rectangle.topLeft()); m_geometry.updateSourcePoints(*m_rect.map(), pathMercator_); -#ifndef MAPITEMS_USE_SHAPES - m_geometry.updateScreenPoints(*m_rect.map(), m_rect.m_border.width()); - - const QGeoProjectionWebMercator &p = static_cast(m_rect.map()->geoProjection()); - QList geoms; - geoms << &m_geometry; - - m_borderGeometry.clear(); - if (m_rect.m_border.color().alpha() != 0 && m_rect.m_border.width() > 0) { - QList closedPath = pathMercator_; - closedPath << closedPath.first(); - - m_borderGeometry.setPreserveGeometry(true, m_rect.m_rectangle.topLeft()); - const QGeoCoordinate &geometryOrigin = m_geometry.origin(); - - m_borderGeometry.srcPoints_.clear(); - m_borderGeometry.srcPointTypes_.clear(); - - QDoubleVector2D borderLeftBoundWrapped; - QList > clippedPaths = m_borderGeometry.clipPath(*m_rect.map(), closedPath, borderLeftBoundWrapped); - if (clippedPaths.size()) { - borderLeftBoundWrapped = p.geoToWrappedMapProjection(geometryOrigin); - m_borderGeometry.pathToScreen(*m_rect.map(), clippedPaths, borderLeftBoundWrapped); - m_borderGeometry.updateScreenPoints(*m_rect.map(), m_rect.m_border.width()); - geoms << &m_borderGeometry; - } else { - m_borderGeometry.clear(); - } - } -#endif - -#ifdef MAPITEMS_USE_SHAPES m_rect.setShapeTriangulationScale(m_shape, m_geometry.maxCoord()); const bool hasBorder = m_rect.m_border.color().alpha() != 0 && m_rect.m_border.width() > 0; @@ -422,19 +382,12 @@ void QDeclarativeRectangleMapItemPrivateCPU::updatePolish() m_shape->setVisible(true); m_rect.setPositionOnMap(m_geometry.origin(), -1 * bb.topLeft() + QPointF(borderWidth, borderWidth)); -#else - const QRectF combined = QGeoMapItemGeometry::translateToCommonOrigin(geoms); - m_rect.setWidth(combined.width() + 2 * m_rect.m_border.width()); // ToDo: fix this! 2 is incorrect - m_rect.setHeight(combined.height() + 2 * m_rect.m_border.width()); - m_rect.setPositionOnMap(m_geometry.origin(), m_geometry.firstPointOffset()); -#endif } QSGNode *QDeclarativeRectangleMapItemPrivateCPU::updateMapItemPaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data) { Q_UNUSED(data); -#ifdef MAPITEMS_USE_SHAPES delete oldNode; if (m_geometry.isScreenDirty() || m_rect.m_dirtyMaterial) { m_geometry.setPreserveGeometry(false); @@ -442,38 +395,11 @@ QSGNode *QDeclarativeRectangleMapItemPrivateCPU::updateMapItemPaintNode(QSGNode m_rect.m_dirtyMaterial = false; } return nullptr; -#else - if (!m_node || !oldNode) { - m_node = new MapPolygonNode(); - if (oldNode) { - delete oldNode; - oldNode = nullptr; - } - } else { - m_node = static_cast(oldNode); - } - - //TODO: update only material - if (m_geometry.isScreenDirty() || m_borderGeometry.isScreenDirty() || m_rect.m_dirtyMaterial) { - m_node->update(m_rect.m_color, m_rect.m_border.color(), &m_geometry, &m_borderGeometry); - m_geometry.setPreserveGeometry(false); - m_borderGeometry.setPreserveGeometry(false); - m_geometry.markClean(); - m_borderGeometry.markClean(); - m_rect.m_dirtyMaterial = false; - } - - return m_node; -#endif } bool QDeclarativeRectangleMapItemPrivateCPU::contains(const QPointF &point) const { -#ifdef MAPITEMS_USE_SHAPES return m_shape->contains(m_rect.mapToItem(m_shape, point)); -#else - return (m_geometry.contains(point) || m_borderGeometry.contains(point)); -#endif } QT_END_NAMESPACE diff --git a/src/location/quickmapitems/qdeclarativerectanglemapitem_p_p.h b/src/location/quickmapitems/qdeclarativerectanglemapitem_p_p.h index e7007a80..3f914dd0 100644 --- a/src/location/quickmapitems/qdeclarativerectanglemapitem_p_p.h +++ b/src/location/quickmapitems/qdeclarativerectanglemapitem_p_p.h @@ -60,9 +60,6 @@ public: void markSourceDirtyAndUpdate() override { m_geometry.markSourceDirty(); -#ifndef MAPITEMS_USE_SHAPES - m_borderGeometry.markSourceDirty(); -#endif m_rect.polishAndUpdate(); } void onMapSet() override @@ -76,17 +73,11 @@ public: void onItemGeometryChanged() override { m_geometry.setPreserveGeometry(true, m_rect.m_rectangle.topLeft()); -#ifndef MAPITEMS_USE_SHAPES - m_borderGeometry.setPreserveGeometry(true, m_rect.m_rectangle.topLeft()); -#endif markSourceDirtyAndUpdate(); } void afterViewportChanged() override { m_geometry.setPreserveGeometry(true, m_rect.m_rectangle.topLeft()); -#ifndef MAPITEMS_USE_SHAPES - m_borderGeometry.setPreserveGeometry(true, m_rect.m_rectangle.topLeft()); -#endif markSourceDirtyAndUpdate(); } void updatePolish() override; @@ -94,14 +85,9 @@ public: bool contains(const QPointF &point) const override; QGeoMapPolygonGeometry m_geometry; -#ifdef MAPITEMS_USE_SHAPES QQuickShape *m_shape = nullptr; QQuickShapePath *m_shapePath = nullptr; QDeclarativeGeoMapPainterPath *m_painterPath = nullptr; -#else - QGeoMapPolylineGeometry m_borderGeometry; - MapPolygonNode *m_node = nullptr; -#endif }; QT_END_NAMESPACE diff --git a/src/location/quickmapitems/qgeomapitemgeometry.cpp b/src/location/quickmapitems/qgeomapitemgeometry.cpp index dda09601..a74fa5de 100644 --- a/src/location/quickmapitems/qgeomapitemgeometry.cpp +++ b/src/location/quickmapitems/qgeomapitemgeometry.cpp @@ -21,73 +21,4 @@ QGeoMapItemGeometry::~QGeoMapItemGeometry() } -#ifndef MAPITEMS_USE_SHAPES -/*! - \internal -*/ -void QGeoMapItemGeometry::translate(const QPointF &offset) -{ - for (qsizetype i = 0; i < screenVertices_.size(); ++i) - screenVertices_[i] += offset; - - firstPointOffset_ += offset; - screenOutline_.translate(offset); - screenBounds_.translate(offset); -} - -/*! - \internal -*/ -void QGeoMapItemGeometry::allocateAndFill(QSGGeometry *geom) const -{ - const QList &vx = screenVertices_; - const QList &ix = screenIndices_; - - if (isIndexed()) { - geom->allocate(vx.size(), ix.size()); - if (geom->indexType() == QSGGeometry::UnsignedShortType) { - quint16 *its = geom->indexDataAsUShort(); - for (qsizetype i = 0; i < ix.size(); ++i) - its[i] = ix[i]; - } else if (geom->indexType() == QSGGeometry::UnsignedIntType) { - quint32 *its = geom->indexDataAsUInt(); - for (qsizetype i = 0; i < ix.size(); ++i) - its[i] = ix[i]; - } - } else { - geom->allocate(vx.size()); - } - - QSGGeometry::Point2D *pts = geom->vertexDataAsPoint2D(); - for (qsizetype i = 0; i < vx.size(); ++i) - pts[i].set(vx[i].x(), vx[i].y()); -} - -/*! - \internal -*/ -QRectF QGeoMapItemGeometry::translateToCommonOrigin(const QList &geoms) -{ - QGeoCoordinate origin = geoms.at(0)->origin(); - - QPainterPath brects; - - // first get max offset - QPointF maxOffset = geoms.at(0)->firstPointOffset(); - for (const QGeoMapItemGeometry *g : geoms) { - QPointF o = g->firstPointOffset(); - maxOffset.setX(qMax(o.x(), maxOffset.x())); - maxOffset.setY(qMax(o.y(), maxOffset.y())); - } - - // then translate everything - for (QGeoMapItemGeometry *g : geoms) { - g->translate(maxOffset - g->firstPointOffset()); - brects.addRect(g->sourceBoundingBox()); - } - - return brects.boundingRect(); -} -#endif - QT_END_NAMESPACE diff --git a/src/location/quickmapitems/qgeomapitemgeometry_p.h b/src/location/quickmapitems/qgeomapitemgeometry_p.h index 4e32315f..c7fd2f57 100644 --- a/src/location/quickmapitems/qgeomapitemgeometry_p.h +++ b/src/location/quickmapitems/qgeomapitemgeometry_p.h @@ -119,12 +119,6 @@ public: inline void clear() { firstPointOffset_ = QPointF(0,0); screenVertices_.clear(); screenIndices_.clear(); } -#ifndef MAPITEMS_USE_SHAPES - void translate(const QPointF &offset); - void allocateAndFill(QSGGeometry *geom) const; - static QRectF translateToCommonOrigin(const QList &geoms); -#endif - mutable bool m_dataChanged = false; private: -- cgit v1.2.1