summaryrefslogtreecommitdiff
path: root/src/location/maps/qgeotilerequestmanager.cpp
diff options
context:
space:
mode:
authorThomas Lowe <thomas.lowe@nokia.com>2012-05-08 15:40:12 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-16 09:23:55 +0200
commitf9377591312f3c426e8d4bfa45f7554ad7e3e966 (patch)
tree3817480012dd575861dbf1c57d518af75af739e0 /src/location/maps/qgeotilerequestmanager.cpp
parent321e37cb2b04cf075b85399fd97ea77b25f371c1 (diff)
downloadqtlocation-f9377591312f3c426e8d4bfa45f7554ad7e3e966.tar.gz
Simple prefetch scheme
Prefetches larger set of tiles when camera is stopped QTBUG-25136 Prefetch implementation including zoom-level prefetching Two prefetching options- pan buffer, or pan buffer for two nearest zoom levels Code simplified by removing all three visibleTiles lists, so they can't go out of sync Textures not promoted up the cache if they aren't visible when retrieved from server Also: Prefetch on map initialize + optimisation This ensures that the prefetch is called at the end of initialisation Useful if the location is not already in disk cache. And makes no difference if it is already in disk cache. QTBUG-25786 Change-Id: Ife7c1d103f83695659f4534880268fa5afd8f7c7 Reviewed-by: Alex Wilson <alex.wilson@nokia.com>
Diffstat (limited to 'src/location/maps/qgeotilerequestmanager.cpp')
-rw-r--r--src/location/maps/qgeotilerequestmanager.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/location/maps/qgeotilerequestmanager.cpp b/src/location/maps/qgeotilerequestmanager.cpp
index 563df456..431a3c26 100644
--- a/src/location/maps/qgeotilerequestmanager.cpp
+++ b/src/location/maps/qgeotilerequestmanager.cpp
@@ -41,6 +41,7 @@
#include "qgeotilerequestmanager_p.h"
#include <QSharedPointer>
+#include <QDebug>
#include "qgeotilespec.h"
#include "qgeotiledmapdata_p.h"
#include "qgeotiledmappingmanagerengine.h"
@@ -64,10 +65,9 @@ public:
QHash<QGeoTileSpec, int> retries_;
QHash<QGeoTileSpec, QSharedPointer<RetryFuture> > futures_;
- QSet<QGeoTileSpec> visible_;
QSet<QGeoTileSpec> requested_;
- void tileFetched(QSharedPointer<QGeoTileTexture> texture);
+ void tileFetched(const QGeoTileSpec &spec);
};
QGeoTileRequestManager::QGeoTileRequestManager(QGeoTiledMapData *map)
@@ -86,10 +86,10 @@ QList<QSharedPointer<QGeoTileTexture> > QGeoTileRequestManager::requestTiles(con
return d->requestTiles(tiles);
}
-void QGeoTileRequestManager::tileFetched(QSharedPointer<QGeoTileTexture> texture)
+void QGeoTileRequestManager::tileFetched(const QGeoTileSpec &spec)
{
Q_D(QGeoTileRequestManager);
- d->tileFetched(texture);
+ d->tileFetched(spec);
}
void QGeoTileRequestManager::tileError(const QGeoTileSpec &tile, const QString &errorString)
@@ -110,8 +110,10 @@ QGeoTileRequestManagerPrivate::~QGeoTileRequestManagerPrivate()
QList<QSharedPointer<QGeoTileTexture> > QGeoTileRequestManagerPrivate::requestTiles(const QSet<QGeoTileSpec> &tiles)
{
QSet<QGeoTileSpec> cancelTiles = requested_ - tiles;
- QSet<QGeoTileSpec> requestTiles = tiles - visible_ - requested_;
+ QSet<QGeoTileSpec> requestTiles = tiles - requested_;
QSet<QGeoTileSpec> cached;
+// int tileSize = tiles.size();
+// int newTiles = requestTiles.size();
typedef QSet<QGeoTileSpec>::const_iterator iter;
@@ -136,13 +138,14 @@ QList<QSharedPointer<QGeoTileTexture> > QGeoTileRequestManagerPrivate::requestTi
requestTiles -= cached;
- visible_ = tiles;
-
requested_ -= cancelTiles;
requested_ += requestTiles;
+// qDebug() << "required # tiles: " << tileSize << ", new tiles: " << newTiles << ", total server requests: " << requested_.size();
+
if (!requestTiles.isEmpty() || !cancelTiles.isEmpty()) {
if (engine) {
+// qDebug() << "new server requests: " << requestTiles.size() << ", server cancels: " << cancelTiles.size();
engine->updateTileRequests(map_, requestTiles, cancelTiles);
// Remove any cancelled tiles from the error retry hash to avoid
@@ -159,12 +162,12 @@ QList<QSharedPointer<QGeoTileTexture> > QGeoTileRequestManagerPrivate::requestTi
return cachedTex;
}
-void QGeoTileRequestManagerPrivate::tileFetched(QSharedPointer<QGeoTileTexture> texture)
+void QGeoTileRequestManagerPrivate::tileFetched(const QGeoTileSpec &spec)
{
- map_->newTileFetched(texture);
- requested_.remove(texture->spec);
- retries_.remove(texture->spec);
- futures_.remove(texture->spec);
+ map_->newTileFetched(spec);
+ requested_.remove(spec);
+ retries_.remove(spec);
+ futures_.remove(spec);
}
// Represents a tile that needs to be retried after a certain period of time