summaryrefslogtreecommitdiff
path: root/src/location/labs/qsg
diff options
context:
space:
mode:
Diffstat (limited to 'src/location/labs/qsg')
-rw-r--r--src/location/labs/qsg/qgeomapobjectqsgsupport.cpp224
-rw-r--r--src/location/labs/qsg/qgeomapobjectqsgsupport_p.h92
-rw-r--r--src/location/labs/qsg/qmapcircleobjectqsg.cpp10
-rw-r--r--src/location/labs/qsg/qmapcircleobjectqsg_p_p.h5
-rw-r--r--src/location/labs/qsg/qmapiconobjectqsg.cpp25
-rw-r--r--src/location/labs/qsg/qmapiconobjectqsg_p_p.h5
-rw-r--r--src/location/labs/qsg/qmappolygonobjectqsg.cpp10
-rw-r--r--src/location/labs/qsg/qmappolygonobjectqsg_p_p.h5
-rw-r--r--src/location/labs/qsg/qmappolylineobjectqsg.cpp10
-rw-r--r--src/location/labs/qsg/qmappolylineobjectqsg_p_p.h5
-rw-r--r--src/location/labs/qsg/qmaprouteobjectqsg.cpp10
-rw-r--r--src/location/labs/qsg/qmaprouteobjectqsg_p_p.h5
-rw-r--r--src/location/labs/qsg/qqsgmapobject.cpp6
-rw-r--r--src/location/labs/qsg/qqsgmapobject_p.h8
14 files changed, 389 insertions, 31 deletions
diff --git a/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
new file mode 100644
index 00000000..e0e3a6d7
--- /dev/null
+++ b/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
@@ -0,0 +1,224 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgeomapobjectqsgsupport_p.h"
+#include <QtLocation/private/qgeomap_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static int findMapObject(QGeoMapObject *o, const QList<MapObject> &list)
+{
+ for (int i = 0; i < list.size(); ++i)
+ {
+ if (list.at(i).object.data() == o)
+ return i;
+ }
+ return -1;
+}
+
+bool QGeoMapObjectQSGSupport::createMapObjectImplementation(QGeoMapObject *obj, QGeoMapPrivate *d)
+{
+ QExplicitlySharedDataPointer<QGeoMapObjectPrivate> pimpl =
+ QExplicitlySharedDataPointer<QGeoMapObjectPrivate>(d->createMapObjectImplementation(obj));
+ if (pimpl.constData()) {
+ bool res = obj->setImplementation(pimpl);
+ if (res)
+ emit m_map->sgNodeChanged();
+ return res;
+ }
+ return false;
+}
+
+QGeoMapObjectPrivate *QGeoMapObjectQSGSupport::createMapObjectImplementationPrivate(QGeoMapObject *obj)
+{
+ QGeoMapObjectPrivate *res = nullptr;
+
+ {
+ QQSGMapObject *sgo = nullptr;
+ switch (obj->type()) {
+ case QGeoMapObject::PolylineType: {
+ QMapPolylineObjectPrivate &oldImpl = static_cast<QMapPolylineObjectPrivate &>(*obj->implementation());
+ QMapPolylineObjectPrivateQSG *pimpl =
+ new QMapPolylineObjectPrivateQSG(oldImpl);
+ sgo = pimpl;
+ res = pimpl;
+ break;
+ }
+ case QGeoMapObject::PolygonType: {
+ QMapPolygonObjectPrivate &oldImpl = static_cast<QMapPolygonObjectPrivate &>(*obj->implementation());
+ QMapPolygonObjectPrivateQSG *pimpl =
+ new QMapPolygonObjectPrivateQSG(oldImpl);
+ sgo = pimpl;
+ res = pimpl;
+ break;
+ }
+ case QGeoMapObject::CircleType: {
+ QMapCircleObjectPrivate &oldImpl = static_cast<QMapCircleObjectPrivate &>(*obj->implementation());
+ QMapCircleObjectPrivateQSG *pimpl =
+ new QMapCircleObjectPrivateQSG(oldImpl);
+ sgo = pimpl;
+ res = pimpl;
+ break;
+ }
+ case QGeoMapObject::RouteType: {
+ QMapRouteObjectPrivate &oldImpl = static_cast<QMapRouteObjectPrivate &>(*obj->implementation());
+ QMapRouteObjectPrivateQSG *pimpl =
+ new QMapRouteObjectPrivateQSG(oldImpl);
+ sgo = pimpl;
+ res = pimpl;
+ break;
+ }
+ case QGeoMapObject::IconType: {
+ QMapIconObjectPrivate &oldImpl = static_cast<QMapIconObjectPrivate &>(*obj->implementation());
+ QMapIconObjectPrivateQSG *pimpl =
+ new QMapIconObjectPrivateQSG(oldImpl);
+ sgo = pimpl;
+ res = pimpl;
+ break;
+ }
+ default:
+ // Use the following warning only for debugging purposes.
+ // qWarning() << "QGeoMapObjectQSGSupport::createMapObjectImplementationPrivate: not instantiating pimpl for unsupported object type " << obj->type();
+ break;
+ }
+
+ if (res) {
+ QPointer<QGeoMapObject> p(obj);
+ MapObject mo(p, sgo);
+ m_pendingMapObjects << mo;
+ }
+ }
+ return res;
+}
+
+QList<QGeoMapObject *> QGeoMapObjectQSGSupport::mapObjects() const
+{
+ return QList<QGeoMapObject *>();
+}
+
+void QGeoMapObjectQSGSupport::removeMapObject(QGeoMapObject *obj)
+{
+ int idx = findMapObject(obj, m_mapObjects);
+ if (idx >= 0) {
+ const MapObject &mo = m_mapObjects.takeAt(idx);
+ obj->disconnect(m_map);
+ m_removedMapObjects << mo;
+ emit m_map->sgNodeChanged();
+ } else {
+ idx = findMapObject(obj, m_pendingMapObjects);
+ if (idx >= 0) {
+ m_pendingMapObjects.removeAt(idx);
+ obj->disconnect(m_map);
+ } else {
+ // obj not here.
+ }
+ }
+}
+
+void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *window)
+{
+ for (int i = 0; i < m_removedMapObjects.size(); ++i) {
+ MapObject mo = m_removedMapObjects[i];
+ if (mo.qsgNode) {
+ root->removeChildNode(mo.qsgNode);
+ delete mo.qsgNode;
+ mo.qsgNode = nullptr;
+ // mo.sgObject is now invalid as it is destroyed right after appending
+ // mo to m_removedMapObjects
+ }
+ }
+ m_removedMapObjects.clear();
+
+ for (int i = 0; i < m_mapObjects.size(); ++i) {
+ // already added as node
+ if (Q_UNLIKELY(!m_mapObjects.at(i).object)) {
+ qWarning() << "unexpected NULL pointer in m_mapObjects at "<<i;
+ continue;
+ }
+
+ MapObject &mo = m_mapObjects[i];
+ QQSGMapObject *sgo = mo.sgObject;
+ QSGNode *oldNode = mo.qsgNode;
+ mo.qsgNode = sgo->updateMapObjectNode(oldNode, &mo.visibleNode, root, window);
+ if (Q_UNLIKELY(!mo.qsgNode)) {
+ qWarning() << "updateMapObjectNode for "<<mo.object->type() << " returned NULL";
+ } else if (mo.visibleNode && (mo.visibleNode->visible() != mo.object->visible())) {
+ mo.visibleNode->setVisible(mo.object->visible());
+ mo.qsgNode->markDirty(QSGNode::DirtySubtreeBlocked);
+ }
+ }
+
+ QList<int> toRemove;
+ for (int i = 0; i < m_pendingMapObjects.size(); ++i) {
+ // already added as node
+ MapObject &mo = m_pendingMapObjects[i];
+ QQSGMapObject *sgo = mo.sgObject;
+ QSGNode *oldNode = mo.qsgNode;
+ sgo->updateGeometry(); // or subtree will be blocked
+ mo.qsgNode = sgo->updateMapObjectNode(oldNode, &mo.visibleNode, root, window);
+ if (mo.qsgNode) {
+ if (mo.visibleNode && (mo.visibleNode->visible() != mo.object->visible())) {
+ mo.visibleNode->setVisible(mo.object->visible());
+ mo.qsgNode->markDirty(QSGNode::DirtySubtreeBlocked);
+ }
+ m_mapObjects << mo;
+ toRemove.push_front(i);
+ QObject::connect(mo.object, SIGNAL(visibleChanged()), m_map, SIGNAL(sgNodeChanged()));
+ } else {
+ // leave it to be processed, don't spit warnings
+ }
+ }
+
+ for (int i: qAsConst(toRemove))
+ m_pendingMapObjects.removeAt(i);
+}
+
+void QGeoMapObjectQSGSupport::updateObjectsGeometry()
+{
+ for (int i = 0; i < m_mapObjects.size(); ++i) {
+ // already added as node
+ if (Q_UNLIKELY(!m_mapObjects.at(i).object)) {
+ qWarning() << "unexpected NULL pointer in m_mapObjects at "<<i;
+ continue;
+ }
+
+ QQSGMapObject *sgo = m_mapObjects.at(i).sgObject;
+ sgo->updateGeometry();
+ }
+ emit m_map->sgNodeChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/src/location/labs/qsg/qgeomapobjectqsgsupport_p.h b/src/location/labs/qsg/qgeomapobjectqsgsupport_p.h
new file mode 100644
index 00000000..bb0477c5
--- /dev/null
+++ b/src/location/labs/qsg/qgeomapobjectqsgsupport_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGEOMAPOBJECTQSGSUPPORT_P_H
+#define QGEOMAPOBJECTQSGSUPPORT_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 <QtLocation/private/qlocationglobal_p.h>
+#include <QtLocation/private/qgeomapobject_p.h>
+#include <QtLocation/private/qgeomapobject_p_p.h>
+#include <QtLocation/private/qmappolylineobjectqsg_p_p.h>
+#include <QtLocation/private/qmappolygonobjectqsg_p_p.h>
+#include <QtLocation/private/qmapcircleobjectqsg_p_p.h>
+#include <QtLocation/private/qmaprouteobjectqsg_p_p.h>
+#include <QtLocation/private/qmapiconobjectqsg_p_p.h>
+#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
+#include <QtCore/qpointer.h>
+
+QT_BEGIN_NAMESPACE
+
+struct Q_LOCATION_PRIVATE_EXPORT MapObject {
+ MapObject(QPointer<QGeoMapObject> &o, QQSGMapObject *sgo)
+ : object(o), sgObject(sgo) {}
+
+ QPointer<QGeoMapObject> object;
+ QQSGMapObject *sgObject = nullptr; // this is a QMap*ObjectPrivateQSG. it becomes invalid when the pimpl is destroyed
+ VisibleNode *visibleNode = nullptr; // This is a Map*Node (like a MapPolygonNode) that is a QSGNode. This doesn't disappear by itself
+ QSGNode *qsgNode = nullptr;
+};
+
+class Q_LOCATION_PRIVATE_EXPORT QGeoMapObjectQSGSupport
+{
+public:
+ bool createMapObjectImplementation(QGeoMapObject *obj, QGeoMapPrivate *d);
+ QGeoMapObjectPrivate *createMapObjectImplementationPrivate(QGeoMapObject *obj);
+ QList<QGeoMapObject *> mapObjects() const;
+ void removeMapObject(QGeoMapObject *obj);
+ void updateMapObjects(QSGNode *root, QQuickWindow *window);
+ void updateObjectsGeometry();
+
+ QList<MapObject> m_mapObjects;
+ QList<MapObject> m_pendingMapObjects;
+ QList<MapObject> m_removedMapObjects;
+ QGeoMap *m_map = nullptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QGEOMAPOBJECTQSGSUPPORT_P_H
diff --git a/src/location/labs/qsg/qmapcircleobjectqsg.cpp b/src/location/labs/qsg/qmapcircleobjectqsg.cpp
index 9fe3ee0a..775016b9 100644
--- a/src/location/labs/qsg/qmapcircleobjectqsg.cpp
+++ b/src/location/labs/qsg/qmapcircleobjectqsg.cpp
@@ -60,7 +60,8 @@ QMapCircleObjectPrivateQSG::QMapCircleObjectPrivateQSG(const QMapCircleObjectPri
QMapCircleObjectPrivateQSG::~QMapCircleObjectPrivateQSG()
{
-
+ if (m_map)
+ m_map->removeMapObject(q);
}
void QMapCircleObjectPrivateQSG::updateCirclePath()
@@ -147,13 +148,18 @@ QGeoMapObjectPrivate *QMapCircleObjectPrivateQSG::clone()
return new QMapCircleObjectPrivateQSG(static_cast<QMapCircleObjectPrivate &>(*this));
}
-QSGNode *QMapCircleObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow * /*window*/)
+QSGNode *QMapCircleObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **visibleNode,
+ QSGNode *root,
+ QQuickWindow * /*window*/)
{
+// Q_UNUSED(visibleNode) // coz of -Werror=unused-but-set-parameter
MapPolygonNode *node = static_cast<MapPolygonNode *>(oldNode);
bool created = false;
if (!node) {
node = new MapPolygonNode();
+ *visibleNode = static_cast<VisibleNode *>(node);
created = true;
}
diff --git a/src/location/labs/qsg/qmapcircleobjectqsg_p_p.h b/src/location/labs/qsg/qmapcircleobjectqsg_p_p.h
index 17d8568a..4e8162fa 100644
--- a/src/location/labs/qsg/qmapcircleobjectqsg_p_p.h
+++ b/src/location/labs/qsg/qmapcircleobjectqsg_p_p.h
@@ -72,7 +72,10 @@ public:
// QQSGMapObject
void updateGeometry() override;
- QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window) override;
+ QSGNode *updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **visibleNode,
+ QSGNode *root,
+ QQuickWindow *window) override;
// QGeoMapCirclePrivate interface
void setCenter(const QGeoCoordinate &center) override;
diff --git a/src/location/labs/qsg/qmapiconobjectqsg.cpp b/src/location/labs/qsg/qmapiconobjectqsg.cpp
index 53d16179..47c39695 100644
--- a/src/location/labs/qsg/qmapiconobjectqsg.cpp
+++ b/src/location/labs/qsg/qmapiconobjectqsg.cpp
@@ -43,26 +43,19 @@
#include <QtQml/qqmlengine.h>
#include <QtQml/qqml.h>
#include <QtNetwork/qnetworkaccessmanager.h>
+#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
QT_BEGIN_NAMESPACE
-class RootNode : public QSGTransformNode
+class RootNode : public QSGTransformNode, public VisibleNode
{
public:
- RootNode() : QSGTransformNode()
- { }
+ RootNode() { }
bool isSubtreeBlocked() const override
{
- return m_blocked;
+ return subtreeBlocked();
}
-
- void setSubtreeBlocked(bool blocked)
- {
- m_blocked = blocked;
- }
-
- bool m_blocked = false;
};
QMapIconObjectPrivateQSG::QMapIconObjectPrivateQSG(QGeoMapObject *q)
@@ -80,7 +73,8 @@ QMapIconObjectPrivateQSG::QMapIconObjectPrivateQSG(const QMapIconObjectPrivate &
QMapIconObjectPrivateQSG::~QMapIconObjectPrivateQSG()
{
-
+ if (m_map)
+ m_map->removeMapObject(q);
}
void QMapIconObjectPrivateQSG::updateGeometry()
@@ -100,8 +94,12 @@ void QMapIconObjectPrivateQSG::updateGeometry()
// TODO: support and test for zoomLevel
}
-QSGNode *QMapIconObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, QSGNode * root, QQuickWindow *window)
+QSGNode *QMapIconObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **visibleNode,
+ QSGNode *root,
+ QQuickWindow *window)
{
+ Q_UNUSED(visibleNode)
bool created = false;
RootNode *node = static_cast<RootNode *>(oldNode);
if (!node) {
@@ -109,6 +107,7 @@ QSGNode *QMapIconObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, QSGNode
m_imageNode = window->createImageNode();
m_imageNode->setOwnsTexture(true);
node->appendChildNode(m_imageNode);
+ *visibleNode = static_cast<VisibleNode *>(node);
created = true;
}
diff --git a/src/location/labs/qsg/qmapiconobjectqsg_p_p.h b/src/location/labs/qsg/qmapiconobjectqsg_p_p.h
index a2f7cf40..c57828af 100644
--- a/src/location/labs/qsg/qmapiconobjectqsg_p_p.h
+++ b/src/location/labs/qsg/qmapiconobjectqsg_p_p.h
@@ -69,7 +69,10 @@ public:
// QQSGMapObject
void updateGeometry() override;
- QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window) override;
+ QSGNode *updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **visibleNode,
+ QSGNode *root,
+ QQuickWindow *window) override;
// QGeoMapIconPrivate interface
void setCoordinate(const QGeoCoordinate &coordinate) override;
diff --git a/src/location/labs/qsg/qmappolygonobjectqsg.cpp b/src/location/labs/qsg/qmappolygonobjectqsg.cpp
index 27dcc80f..b9602a3a 100644
--- a/src/location/labs/qsg/qmappolygonobjectqsg.cpp
+++ b/src/location/labs/qsg/qmappolygonobjectqsg.cpp
@@ -57,7 +57,8 @@ QMapPolygonObjectPrivateQSG::QMapPolygonObjectPrivateQSG(const QMapPolygonObject
QMapPolygonObjectPrivateQSG::~QMapPolygonObjectPrivateQSG()
{
-
+ if (m_map)
+ m_map->removeMapObject(q);
}
QList<QDoubleVector2D> QMapPolygonObjectPrivateQSG::projectPath()
@@ -74,13 +75,18 @@ QList<QDoubleVector2D> QMapPolygonObjectPrivateQSG::projectPath()
return geopathProjected_;
}
-QSGNode *QMapPolygonObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow * /*window*/)
+QSGNode *QMapPolygonObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **visibleNode,
+ QSGNode *root,
+ QQuickWindow */*window*/)
{
+ Q_UNUSED(visibleNode)
MapPolygonNode *node = static_cast<MapPolygonNode *>(oldNode);
bool created = false;
if (!node) {
node = new MapPolygonNode();
+ *visibleNode = static_cast<VisibleNode *>(node);
created = true;
}
diff --git a/src/location/labs/qsg/qmappolygonobjectqsg_p_p.h b/src/location/labs/qsg/qmappolygonobjectqsg_p_p.h
index bd5efcff..b288528a 100644
--- a/src/location/labs/qsg/qmappolygonobjectqsg_p_p.h
+++ b/src/location/labs/qsg/qmappolygonobjectqsg_p_p.h
@@ -68,7 +68,10 @@ public:
// QQSGMapObject
void updateGeometry() override;
- QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window) override;
+ QSGNode *updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **visibleNode,
+ QSGNode *root,
+ QQuickWindow *window) override;
// QGeoMapPolylinePrivate interface
QList<QGeoCoordinate> path() const override;
diff --git a/src/location/labs/qsg/qmappolylineobjectqsg.cpp b/src/location/labs/qsg/qmappolylineobjectqsg.cpp
index c0c3854e..6b782c77 100644
--- a/src/location/labs/qsg/qmappolylineobjectqsg.cpp
+++ b/src/location/labs/qsg/qmappolylineobjectqsg.cpp
@@ -61,7 +61,8 @@ QMapPolylineObjectPrivateQSG::QMapPolylineObjectPrivateQSG(const QMapPolylineObj
QMapPolylineObjectPrivateQSG::~QMapPolylineObjectPrivateQSG()
{
-
+ if (m_map)
+ m_map->removeMapObject(q);
}
QList<QDoubleVector2D> QMapPolylineObjectPrivateQSG::projectPath()
@@ -96,13 +97,18 @@ void QMapPolylineObjectPrivateQSG::updateGeometry()
m_geometry.translate(origin - m_geometry.firstPointOffset());
}
-QSGNode *QMapPolylineObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow * /*window*/)
+QSGNode *QMapPolylineObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **visibleNode,
+ QSGNode *root,
+ QQuickWindow */*window*/)
{
+ Q_UNUSED(visibleNode)
MapPolylineNode *node = static_cast<MapPolylineNode *>(oldNode);
bool created = false;
if (!node) {
node = new MapPolylineNode();
+ *visibleNode = static_cast<VisibleNode *>(node);
created = true;
}
diff --git a/src/location/labs/qsg/qmappolylineobjectqsg_p_p.h b/src/location/labs/qsg/qmappolylineobjectqsg_p_p.h
index 52b5e89a..792413e5 100644
--- a/src/location/labs/qsg/qmappolylineobjectqsg_p_p.h
+++ b/src/location/labs/qsg/qmappolylineobjectqsg_p_p.h
@@ -68,7 +68,10 @@ public:
// QQSGMapObject
void updateGeometry() override;
- QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window) override;
+ QSGNode *updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **visibleNode,
+ QSGNode *root,
+ QQuickWindow *window) override;
// QGeoMapPolylinePrivate interface
QList<QGeoCoordinate> path() const override;
diff --git a/src/location/labs/qsg/qmaprouteobjectqsg.cpp b/src/location/labs/qsg/qmaprouteobjectqsg.cpp
index a8728e08..eaea64f3 100644
--- a/src/location/labs/qsg/qmaprouteobjectqsg.cpp
+++ b/src/location/labs/qsg/qmaprouteobjectqsg.cpp
@@ -57,7 +57,8 @@ QMapRouteObjectPrivateQSG::QMapRouteObjectPrivateQSG(const QMapRouteObjectPrivat
QMapRouteObjectPrivateQSG::~QMapRouteObjectPrivateQSG()
{
-
+ if (m_map)
+ m_map->removeMapObject(q);
}
void QMapRouteObjectPrivateQSG::updateGeometry()
@@ -65,9 +66,12 @@ void QMapRouteObjectPrivateQSG::updateGeometry()
m_polyline->updateGeometry();
}
-QSGNode *QMapRouteObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow * window)
+QSGNode *QMapRouteObjectPrivateQSG::updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **visibleNode,
+ QSGNode *root,
+ QQuickWindow *window)
{
- return m_polyline->updateMapObjectNode(oldNode, root, window);
+ return m_polyline->updateMapObjectNode(oldNode, visibleNode, root, window);
}
void QMapRouteObjectPrivateQSG::setRoute(const QDeclarativeGeoRoute *route)
diff --git a/src/location/labs/qsg/qmaprouteobjectqsg_p_p.h b/src/location/labs/qsg/qmaprouteobjectqsg_p_p.h
index 1c612532..0c946259 100644
--- a/src/location/labs/qsg/qmaprouteobjectqsg_p_p.h
+++ b/src/location/labs/qsg/qmaprouteobjectqsg_p_p.h
@@ -68,7 +68,10 @@ public:
// QQSGMapObject
void updateGeometry() override;
- QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window) override;
+ QSGNode *updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **visibleNode,
+ QSGNode *root,
+ QQuickWindow *window) override;
// QMapRouteObjectPrivate interface
void setRoute(const QDeclarativeGeoRoute *route) override;
diff --git a/src/location/labs/qsg/qqsgmapobject.cpp b/src/location/labs/qsg/qqsgmapobject.cpp
index 5b4f7dbf..ccda12d8 100644
--- a/src/location/labs/qsg/qqsgmapobject.cpp
+++ b/src/location/labs/qsg/qqsgmapobject.cpp
@@ -35,6 +35,7 @@
****************************************************************************/
#include "qqsgmapobject_p.h"
+#include <QDebug>
QT_BEGIN_NAMESPACE
@@ -48,7 +49,10 @@ QQSGMapObject::~QQSGMapObject()
}
-QSGNode *QQSGMapObject::updateMapObjectNode(QSGNode *oldNode, QSGNode * /*root*/, QQuickWindow * /*window*/)
+QSGNode *QQSGMapObject::updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **/*visibleNode*/,
+ QSGNode * /*root*/,
+ QQuickWindow * /*window*/)
{
delete oldNode;
return 0;
diff --git a/src/location/labs/qsg/qqsgmapobject_p.h b/src/location/labs/qsg/qqsgmapobject_p.h
index d3e54a68..1aecc990 100644
--- a/src/location/labs/qsg/qqsgmapobject_p.h
+++ b/src/location/labs/qsg/qqsgmapobject_p.h
@@ -40,6 +40,7 @@
#include <QtLocation/private/qlocationglobal_p.h>
#include <QtQuick/QSGOpacityNode>
#include <QtLocation/private/qgeomapobject_p.h>
+#include <QtLocation/private/qdeclarativepolylinemapitem_p.h>
QT_BEGIN_NAMESPACE
@@ -50,10 +51,11 @@ public:
QQSGMapObject();
virtual ~QQSGMapObject();
- virtual QSGNode *updateMapObjectNode(QSGNode *oldNode, QSGNode *root, QQuickWindow *window);
+ virtual QSGNode *updateMapObjectNode(QSGNode *oldNode,
+ VisibleNode **visibleNode,
+ QSGNode *root,
+ QQuickWindow *window);
virtual void updateGeometry();
-
- QSGNode *node = nullptr;
};
QT_END_NAMESPACE