summaryrefslogtreecommitdiff
path: root/src/location
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@theqtcompany.com>2016-09-15 23:12:42 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2016-10-05 11:30:12 +0000
commit218e208bbf1c3112d2ea5781debc605fc76db80a (patch)
tree34812fb7c66e401bc288d4916ec6fed58d443022 /src/location
parenta65d9b7acf62fdafd670b40c01425cedff61106c (diff)
downloadqtlocation-218e208bbf1c3112d2ea5781debc605fc76db80a.tar.gz
Fix cache mixing with high-dpi and low-dpi osm providers
This cache fixes the cache mixing problem that has been introduced with the osm high dpi tiles support. high dpi providers fall back to low dpi ones and ultimately to hardcoded providers (also low dpi), and can also be enabled/disabled via plugin parameter, thus leaving the cache for a given map id dirty for the next run. With this patch high dpi tiles are named differently from low dpi ones. If high-dpi providers are selected, but become not available, the cache can also change the tileset to load at runtime Change-Id: I229692da07c1fc61c58fb0b6fae6ec5af16e43a7 Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
Diffstat (limited to 'src/location')
-rw-r--r--src/location/location.pro3
-rw-r--r--src/location/maps/qcache3q_p.h11
-rw-r--r--src/location/maps/qgeocameratiles.cpp5
-rw-r--r--src/location/maps/qgeocameratiles_p.h1
-rw-r--r--src/location/maps/qgeofiletilecache_p.h3
-rw-r--r--src/location/maps/qgeotiledmap.cpp19
-rw-r--r--src/location/maps/qgeotiledmap_p.h3
-rw-r--r--src/location/maps/qgeotiledmap_p_p.h2
-rw-r--r--src/location/maps/qgeotiledmapscene.cpp18
-rw-r--r--src/location/maps/qgeotilefetcher.cpp20
-rw-r--r--src/location/maps/qgeotilefetcher_p.h6
-rw-r--r--src/location/maps/qgeotilefetcher_p_p.h5
-rw-r--r--src/location/qlocationglobal_p.h63
13 files changed, 146 insertions, 13 deletions
diff --git a/src/location/location.pro b/src/location/location.pro
index c47c411b..225df556 100644
--- a/src/location/location.pro
+++ b/src/location/location.pro
@@ -16,6 +16,9 @@ PUBLIC_HEADERS += \
qlocation.h \
qlocationglobal.h
+PRIVATE_HEADERS += \
+ qlocationglobal_p.h
+
SOURCES += \
qlocation.cpp
diff --git a/src/location/maps/qcache3q_p.h b/src/location/maps/qcache3q_p.h
index debce5d1..4348e14b 100644
--- a/src/location/maps/qcache3q_p.h
+++ b/src/location/maps/qcache3q_p.h
@@ -162,7 +162,7 @@ public:
QSharedPointer<T> operator[](const Key &key) const;
void remove(const Key &key);
-
+ QList<Key> keys() const;
void printStats();
// Copy data directly into a queue. Designed for single use after construction
@@ -425,6 +425,15 @@ void QCache3Q<Key,T,EvPolicy>::remove(const Key &key)
}
template <class Key, class T, class EvPolicy>
+QList<Key> QCache3Q<Key,T,EvPolicy>::keys() const
+{
+ QList<Key> keys;
+ for (auto i = lookup_.constBegin(); i != lookup_.constEnd(); ++i)
+ keys.append(i.key());
+ return keys;
+}
+
+template <class Key, class T, class EvPolicy>
QSharedPointer<T> QCache3Q<Key,T,EvPolicy>::object(const Key &key) const
{
if (!lookup_.contains(key)) {
diff --git a/src/location/maps/qgeocameratiles.cpp b/src/location/maps/qgeocameratiles.cpp
index 5eae7c0b..f3a36adf 100644
--- a/src/location/maps/qgeocameratiles.cpp
+++ b/src/location/maps/qgeocameratiles.cpp
@@ -169,6 +169,11 @@ void QGeoCameraTiles::setMapType(const QGeoMapType &mapType)
d_ptr->m_mapType = mapType;
}
+QGeoMapType QGeoCameraTiles::activeMapType() const
+{
+ return d_ptr->m_mapType;
+}
+
void QGeoCameraTiles::setMapVersion(int mapVersion)
{
if (d_ptr->m_mapVersion == mapVersion)
diff --git a/src/location/maps/qgeocameratiles_p.h b/src/location/maps/qgeocameratiles_p.h
index d10895f8..8a26f28a 100644
--- a/src/location/maps/qgeocameratiles_p.h
+++ b/src/location/maps/qgeocameratiles_p.h
@@ -71,6 +71,7 @@ public:
void setViewExpansion(double viewExpansion);
void setPluginString(const QString &pluginString);
void setMapType(const QGeoMapType &mapType);
+ QGeoMapType activeMapType() const;
void setMapVersion(int mapVersion);
const QSet<QGeoTileSpec>& createTiles();
diff --git a/src/location/maps/qgeofiletilecache_p.h b/src/location/maps/qgeofiletilecache_p.h
index b6d4919f..fc023bc7 100644
--- a/src/location/maps/qgeofiletilecache_p.h
+++ b/src/location/maps/qgeofiletilecache_p.h
@@ -48,6 +48,7 @@
//
#include <QtLocation/qlocationglobal.h>
+#include <QtLocation/private/qlocationglobal_p.h>
#include <QObject>
#include <QCache>
@@ -88,7 +89,7 @@ public:
/* Custom eviction policy for the disk cache, to avoid deleting all the files
* when the application closes */
-class QCache3QTileEvictionPolicy : public QCache3QDefaultEvictionPolicy<QGeoTileSpec,QGeoCachedTileDisk>
+class Q_LOCATION_PRIVATE_EXPORT QCache3QTileEvictionPolicy : public QCache3QDefaultEvictionPolicy<QGeoTileSpec,QGeoCachedTileDisk>
{
protected:
void aboutToBeRemoved(const QGeoTileSpec &key, QSharedPointer<QGeoCachedTileDisk> obj);
diff --git a/src/location/maps/qgeotiledmap.cpp b/src/location/maps/qgeotiledmap.cpp
index f59417f7..fedaecbc 100644
--- a/src/location/maps/qgeotiledmap.cpp
+++ b/src/location/maps/qgeotiledmap.cpp
@@ -116,6 +116,13 @@ void QGeoTiledMap::clearData()
d->m_mapScene->clearTexturedTiles();
}
+void QGeoTiledMap::clearScene(int mapId)
+{
+ Q_D(QGeoTiledMap);
+ if (activeMapType().mapId() == mapId)
+ d->clearScene();
+}
+
void QGeoTiledMap::handleTileVersionChanged()
{
Q_D(QGeoTiledMap);
@@ -293,6 +300,11 @@ void QGeoTiledMapPrivate::prefetchTiles()
}
}
+QGeoMapType QGeoTiledMapPrivate::activeMapType()
+{
+ return m_visibleTiles->activeMapType();
+}
+
void QGeoTiledMapPrivate::changeCameraData(const QGeoCameraData &cameraData)
{
Q_Q(QGeoTiledMap);
@@ -356,6 +368,13 @@ void QGeoTiledMapPrivate::changeTileVersion(int version)
updateScene();
}
+void QGeoTiledMapPrivate::clearScene()
+{
+ m_mapScene->clearTexturedTiles();
+ m_mapScene->setVisibleTiles(QSet<QGeoTileSpec>());
+ updateScene();
+}
+
void QGeoTiledMapPrivate::changeMapSize(const QSize& size)
{
Q_Q(QGeoTiledMap);
diff --git a/src/location/maps/qgeotiledmap_p.h b/src/location/maps/qgeotiledmap_p.h
index 220d422f..791384c7 100644
--- a/src/location/maps/qgeotiledmap_p.h
+++ b/src/location/maps/qgeotiledmap_p.h
@@ -96,6 +96,9 @@ public:
void prefetchData() Q_DECL_OVERRIDE;
void clearData() Q_DECL_OVERRIDE;
+public Q_SLOTS:
+ virtual void clearScene(int mapId);
+
protected:
QSGNode *updateSceneGraph(QSGNode *, QQuickWindow *window) Q_DECL_OVERRIDE;
virtual void evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles);
diff --git a/src/location/maps/qgeotiledmap_p_p.h b/src/location/maps/qgeotiledmap_p_p.h
index c1b190bf..ab36f6f7 100644
--- a/src/location/maps/qgeotiledmap_p_p.h
+++ b/src/location/maps/qgeotiledmap_p_p.h
@@ -80,12 +80,14 @@ public:
void updateTile(const QGeoTileSpec &spec);
void prefetchTiles();
+ QGeoMapType activeMapType();
protected:
void changeMapSize(const QSize& size) Q_DECL_OVERRIDE;
void changeCameraData(const QGeoCameraData &cameraData) Q_DECL_OVERRIDE;
void changeActiveMapType(const QGeoMapType mapType) Q_DECL_OVERRIDE;
void changeTileVersion(int version);
+ void clearScene();
private:
void updateScene();
diff --git a/src/location/maps/qgeotiledmapscene.cpp b/src/location/maps/qgeotiledmapscene.cpp
index 3896a51e..d859c2af 100644
--- a/src/location/maps/qgeotiledmapscene.cpp
+++ b/src/location/maps/qgeotiledmapscene.cpp
@@ -101,6 +101,8 @@ public:
bool m_verticalLock;
bool m_linearScaling;
+ bool m_dropTextures;
+
void addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture);
QDoubleVector2D itemPositionToMercator(const QDoubleVector2D &pos) const;
@@ -200,6 +202,7 @@ void QGeoTiledMapScene::clearTexturedTiles()
{
Q_D(QGeoTiledMapScene);
d->m_textures.clear();
+ d->m_dropTextures = true;
}
QGeoTiledMapScenePrivate::QGeoTiledMapScenePrivate()
@@ -223,7 +226,8 @@ QGeoTiledMapScenePrivate::QGeoTiledMapScenePrivate()
m_screenHeight(0.0),
m_useVerticalLock(false),
m_verticalLock(false),
- m_linearScaling(false)
+ m_linearScaling(false),
+ m_dropTextures(false)
{
}
@@ -718,6 +722,18 @@ QSGNode *QGeoTiledMapScene::updateSceneGraph(QSGNode *oldNode, QQuickWindow *win
itemSpaceMatrix.scale(1, -1);
mapRoot->root->setMatrix(itemSpaceMatrix);
+ if (d->m_dropTextures) {
+ foreach (const QGeoTileSpec &s, mapRoot->tiles->tiles.keys())
+ delete mapRoot->tiles->tiles.take(s);
+ foreach (const QGeoTileSpec &s, mapRoot->wrapLeft->tiles.keys())
+ delete mapRoot->wrapLeft->tiles.take(s);
+ foreach (const QGeoTileSpec &s, mapRoot->wrapRight->tiles.keys())
+ delete mapRoot->wrapRight->tiles.take(s);
+ foreach (const QGeoTileSpec &spec, mapRoot->textures.keys())
+ mapRoot->textures.take(spec)->deleteLater();
+ d->m_dropTextures = false;
+ }
+
QSet<QGeoTileSpec> textures = QSet<QGeoTileSpec>::fromList(mapRoot->textures.keys());
QSet<QGeoTileSpec> toRemove = textures - d->m_visibleTiles;
QSet<QGeoTileSpec> toAdd = d->m_visibleTiles - textures;
diff --git a/src/location/maps/qgeotilefetcher.cpp b/src/location/maps/qgeotilefetcher.cpp
index 955839cb..34bf686c 100644
--- a/src/location/maps/qgeotilefetcher.cpp
+++ b/src/location/maps/qgeotilefetcher.cpp
@@ -46,20 +46,28 @@
QT_BEGIN_NAMESPACE
QGeoTileFetcher::QGeoTileFetcher(QObject *parent)
-: QObject(parent), d_ptr(new QGeoTileFetcherPrivate)
+: QObject(*new QGeoTileFetcherPrivate(), parent)
{
Q_D(QGeoTileFetcher);
d->enabled_ = true;
- if (!d->queue_.isEmpty())
- d->timer_.start(0, this);
+// if (!d->queue_.isEmpty())
+// d->timer_.start(0, this);
}
-QGeoTileFetcher::~QGeoTileFetcher()
+QGeoTileFetcher::QGeoTileFetcher(QGeoTileFetcherPrivate &dd, QObject *parent)
+: QObject(dd,parent)
{
+ Q_D(QGeoTileFetcher);
+ d->enabled_ = true;
- delete d_ptr;
+// if (!d->queue_.isEmpty())
+// d->timer_.start(0, this);
+}
+
+QGeoTileFetcher::~QGeoTileFetcher()
+{
}
void QGeoTileFetcher::updateTileRequests(const QSet<QGeoTileSpec> &tilesAdded,
@@ -194,7 +202,7 @@ void QGeoTileFetcher::handleReply(QGeoTiledMapReply *reply, const QGeoTileSpec &
*******************************************************************************/
QGeoTileFetcherPrivate::QGeoTileFetcherPrivate()
-: enabled_(false)
+: QObjectPrivate(), enabled_(false)
{
}
diff --git a/src/location/maps/qgeotilefetcher_p.h b/src/location/maps/qgeotilefetcher_p.h
index cbd8b995..e3621d3d 100644
--- a/src/location/maps/qgeotilefetcher_p.h
+++ b/src/location/maps/qgeotilefetcher_p.h
@@ -65,6 +65,7 @@ class QGeoTileSpec;
class Q_LOCATION_EXPORT QGeoTileFetcher : public QObject
{
Q_OBJECT
+ Q_DECLARE_PRIVATE(QGeoTileFetcher)
public:
QGeoTileFetcher(QObject *parent = 0);
@@ -83,19 +84,18 @@ Q_SIGNALS:
void tileError(const QGeoTileSpec &spec, const QString &errorString);
protected:
+ QGeoTileFetcher(QGeoTileFetcherPrivate &dd, QObject *parent = 0);
+
void timerEvent(QTimerEvent *event);
QGeoTiledMappingManagerEngine::CacheAreas cacheHint() const;
virtual bool initialized() const;
private:
- QGeoTileFetcherPrivate *d_ptr;
virtual QGeoTiledMapReply *getTileImage(const QGeoTileSpec &spec) = 0;
void handleReply(QGeoTiledMapReply *reply, const QGeoTileSpec &spec);
- Q_DECLARE_PRIVATE(QGeoTileFetcher)
Q_DISABLE_COPY(QGeoTileFetcher)
-
friend class QGeoTiledMappingManagerEngine;
};
diff --git a/src/location/maps/qgeotilefetcher_p_p.h b/src/location/maps/qgeotilefetcher_p_p.h
index acd7288e..7e9db527 100644
--- a/src/location/maps/qgeotilefetcher_p_p.h
+++ b/src/location/maps/qgeotilefetcher_p_p.h
@@ -48,6 +48,8 @@
// We mean it.
//
+#include <QtCore/private/qobject_p.h>
+#include <QtLocation/private/qlocationglobal_p.h>
#include <QSize>
#include <QList>
#include <QMap>
@@ -64,8 +66,9 @@ class QGeoTileSpec;
class QGeoTiledMapReply;
class QGeoTiledMappingManagerEngine;
-class QGeoTileFetcherPrivate
+class Q_LOCATION_PRIVATE_EXPORT QGeoTileFetcherPrivate : public QObjectPrivate
{
+ Q_DECLARE_PUBLIC(QGeoTileFetcher)
public:
QGeoTileFetcherPrivate();
virtual ~QGeoTileFetcherPrivate();
diff --git a/src/location/qlocationglobal_p.h b/src/location/qlocationglobal_p.h
new file mode 100644
index 00000000..afc0760b
--- /dev/null
+++ b/src/location/qlocationglobal_p.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtPositioning 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 QLOCATIONGLOBAL_P_H
+#define QLOCATIONGLOBAL_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 "qlocationglobal.h"
+
+QT_BEGIN_NAMESPACE
+
+#define Q_LOCATION_PRIVATE_EXPORT Q_LOCATION_EXPORT
+
+QT_END_NAMESPACE
+
+
+#endif // QLOCATIONGLOBAL_P_H