summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lowe <thomas.lowe@nokia.com>2012-05-03 14:55:53 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-09 03:55:25 +0200
commit98aa648725b6599a523bbeed33a134b3bfcbf19e (patch)
tree10f791296a82dba9e69bc649282288b3c4773d01 /src
parent6e63524d0c175fd1ef7c8ccfd047041622198fda (diff)
downloadqtlocation-98aa648725b6599a523bbeed33a134b3bfcbf19e.tar.gz
Files renamed and cache only accessed through engine
This isn't completely what was requested on the ticket, but it makes the cache more separate, so easier to pull in/out. Mainly this is a slight reworking of the caching to make it a bit simpler for future prefetching. In particular: mapGeometry renamed to mapScene mapImages renames to tileRequestManager and mapImages::setVisible is now tileRequestManager::requestTiles The data flow has been simplified so the requestManager speaks directly to the tiledMappingManagerEngine and this engine takes care of inspecting the single cache. Task-number: QTBUG-25560 Change-Id: I31b2e26c45f7a7ac56fe138cf1a8906a228a93d3 Reviewed-by: Alex Wilson <alex.wilson@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/location/maps/maps.pri9
-rw-r--r--src/location/maps/qgeomap.cpp4
-rw-r--r--src/location/maps/qgeomapdata.cpp4
-rw-r--r--src/location/maps/qgeomapdata_p.h2
-rw-r--r--src/location/maps/qgeomapscene.cpp (renamed from src/location/maps/qgeomapgeometry.cpp)102
-rw-r--r--src/location/maps/qgeomapscene_p.h (renamed from src/location/maps/qgeomapgeometry_p.h)20
-rw-r--r--src/location/maps/qgeotilecache.cpp2
-rw-r--r--src/location/maps/qgeotiledmapdata.cpp67
-rw-r--r--src/location/maps/qgeotiledmapdata_p.h10
-rw-r--r--src/location/maps/qgeotiledmapdata_p_p.h13
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine.cpp38
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine.h5
-rw-r--r--src/location/maps/qgeotiledmappingmanagerengine_p.h2
-rw-r--r--src/location/maps/qgeotilerequestmanager.cpp (renamed from src/location/maps/qgeomapimages.cpp)97
-rw-r--r--src/location/maps/qgeotilerequestmanager_p.h (renamed from src/location/maps/qgeomapimages_p.h)26
15 files changed, 193 insertions, 208 deletions
diff --git a/src/location/maps/maps.pri b/src/location/maps/maps.pri
index 42086e38..fa427f2f 100644
--- a/src/location/maps/maps.pri
+++ b/src/location/maps/maps.pri
@@ -36,8 +36,8 @@ PRIVATE_HEADERS += \
maps/qgeocoordinateinterpolator_p.h \
maps/qgeomaneuver_p.h \
maps/qgeomapcontroller_p.h \
- maps/qgeomapgeometry_p.h \
- maps/qgeomapimages_p.h \
+ maps/qgeomapscene_p.h \
+ maps/qgeotilerequestmanager_p.h \
maps/qgeomap_p.h \
maps/qgeomapdata_p.h \
maps/qgeomapdata_p_p.h \
@@ -73,8 +73,8 @@ SOURCES += \
maps/qgeocoordinateinterpolator.cpp \
maps/qgeomaneuver.cpp \
maps/qgeomapcontroller.cpp \
- maps/qgeomapgeometry.cpp \
- maps/qgeomapimages.cpp \
+ maps/qgeomapscene.cpp \
+ maps/qgeotilerequestmanager.cpp \
maps/qgeomap.cpp \
maps/qgeomapdata.cpp \
maps/qgeotiledmapdata.cpp \
@@ -96,3 +96,4 @@ SOURCES += \
maps/qgeotiledmapreply.cpp \
maps/qgeotilespec.cpp
+
diff --git a/src/location/maps/qgeomap.cpp b/src/location/maps/qgeomap.cpp
index 420dbab1..b4ed8b18 100644
--- a/src/location/maps/qgeomap.cpp
+++ b/src/location/maps/qgeomap.cpp
@@ -51,8 +51,8 @@
#include "qdoublevector3d_p.h"
#include "qgeocameratiles_p.h"
-#include "qgeomapimages_p.h"
-#include "qgeomapgeometry_p.h"
+#include "qgeotilerequestmanager_p.h"
+#include "qgeomapscene_p.h"
#include "qgeomappingmanager.h"
diff --git a/src/location/maps/qgeomapdata.cpp b/src/location/maps/qgeomapdata.cpp
index 97eb2715..fde4a1f9 100644
--- a/src/location/maps/qgeomapdata.cpp
+++ b/src/location/maps/qgeomapdata.cpp
@@ -51,8 +51,8 @@
#include "qdoublevector3d_p.h"
#include "qgeocameratiles_p.h"
-#include "qgeomapimages_p.h"
-#include "qgeomapgeometry_p.h"
+#include "qgeotilerequestmanager_p.h"
+#include "qgeomapscene_p.h"
#include "qgeomappingmanager.h"
diff --git a/src/location/maps/qgeomapdata_p.h b/src/location/maps/qgeomapdata_p.h
index aa38880f..3a0ba8ce 100644
--- a/src/location/maps/qgeomapdata_p.h
+++ b/src/location/maps/qgeomapdata_p.h
@@ -105,10 +105,10 @@ public:
QString pluginString();
QGeoCameraCapabilities cameraCapabilities();
+ QGeoMappingManagerEngine *engine();
protected:
void setCoordinateInterpolator(QSharedPointer<QGeoCoordinateInterpolator> interpolator);
- QGeoMappingManagerEngine *engine();
virtual void mapResized(int width, int height) = 0;
virtual void changeCameraData(const QGeoCameraData &oldCameraData) = 0;
diff --git a/src/location/maps/qgeomapgeometry.cpp b/src/location/maps/qgeomapscene.cpp
index 3bb17493..c8fb3375 100644
--- a/src/location/maps/qgeomapgeometry.cpp
+++ b/src/location/maps/qgeomapscene.cpp
@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "qgeomapgeometry_p.h"
+#include "qgeomapscene_p.h"
#include "qgeocameradata_p.h"
#include "qgeoprojection_p.h"
@@ -64,10 +64,10 @@
QT_BEGIN_NAMESPACE
-class QGeoMapGeometryPrivate {
+class QGeoMapScenePrivate {
public:
- QGeoMapGeometryPrivate(QGeoMapGeometry *geometry);
- ~QGeoMapGeometryPrivate();
+ QGeoMapScenePrivate(QGeoMapScene *scene);
+ ~QGeoMapScenePrivate();
QSize screenSize_; // in pixels
int tileSize_; // the pixel resolution for each tile
@@ -135,40 +135,40 @@ public:
void paintGL(QGLPainter *painter);
private:
- QGeoMapGeometry *q_ptr;
- Q_DECLARE_PUBLIC(QGeoMapGeometry)
+ QGeoMapScene *q_ptr;
+ Q_DECLARE_PUBLIC(QGeoMapScene)
};
-QGeoMapGeometry::QGeoMapGeometry()
+QGeoMapScene::QGeoMapScene()
: QObject(),
- d_ptr(new QGeoMapGeometryPrivate(this)) {}
+ d_ptr(new QGeoMapScenePrivate(this)) {}
-QGeoMapGeometry::~QGeoMapGeometry()
+QGeoMapScene::~QGeoMapScene()
{
delete d_ptr;
}
-void QGeoMapGeometry::setUseVerticalLock(bool lock)
+void QGeoMapScene::setUseVerticalLock(bool lock)
{
- Q_D(QGeoMapGeometry);
+ Q_D(QGeoMapScene);
d->useVerticalLock_ = lock;
}
-void QGeoMapGeometry::setScreenSize(const QSize &size)
+void QGeoMapScene::setScreenSize(const QSize &size)
{
- Q_D(QGeoMapGeometry);
+ Q_D(QGeoMapScene);
d->screenSize_ = size;
}
-void QGeoMapGeometry::setTileSize(int tileSize)
+void QGeoMapScene::setTileSize(int tileSize)
{
- Q_D(QGeoMapGeometry);
+ Q_D(QGeoMapScene);
d->tileSize_ = tileSize;
}
-void QGeoMapGeometry::setCameraData(const QGeoCameraData &cameraData)
+void QGeoMapScene::setCameraData(const QGeoCameraData &cameraData)
{
- Q_D(QGeoMapGeometry);
+ Q_D(QGeoMapScene);
d->cameraData_ = cameraData;
d->intZoomLevel_ = static_cast<int>(floor(d->cameraData_.zoomLevel()));
float delta = cameraData.zoomLevel() - d->intZoomLevel_;
@@ -182,55 +182,55 @@ void QGeoMapGeometry::setCameraData(const QGeoCameraData &cameraData)
d->sideLength_ = 1 << d->intZoomLevel_;
}
-void QGeoMapGeometry::setVisibleTiles(const QSet<QGeoTileSpec> &tiles)
+void QGeoMapScene::setVisibleTiles(const QSet<QGeoTileSpec> &tiles)
{
- Q_D(QGeoMapGeometry);
+ Q_D(QGeoMapScene);
d->setVisibleTiles(tiles);
}
-void QGeoMapGeometry::addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture)
+void QGeoMapScene::addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture)
{
- Q_D(QGeoMapGeometry);
+ Q_D(QGeoMapScene);
d->addTile(spec, texture);
}
-QDoubleVector2D QGeoMapGeometry::screenPositionToMercator(const QPointF &pos) const
+QDoubleVector2D QGeoMapScene::screenPositionToMercator(const QPointF &pos) const
{
- Q_D(const QGeoMapGeometry);
+ Q_D(const QGeoMapScene);
return d->screenPositionToMercator(pos);
}
-QPointF QGeoMapGeometry::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
+QPointF QGeoMapScene::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
{
- Q_D(const QGeoMapGeometry);
+ Q_D(const QGeoMapScene);
return d->mercatorToScreenPosition(mercator);
}
-QGLCamera* QGeoMapGeometry::camera() const
+QGLCamera* QGeoMapScene::camera() const
{
- Q_D(const QGeoMapGeometry);
+ Q_D(const QGeoMapScene);
return d->camera_;
}
-QGLSceneNode* QGeoMapGeometry::sceneNode() const
+QGLSceneNode* QGeoMapScene::sceneNode() const
{
- Q_D(const QGeoMapGeometry);
+ Q_D(const QGeoMapScene);
return d->sceneNode_;
}
-bool QGeoMapGeometry::verticalLock() const
+bool QGeoMapScene::verticalLock() const
{
- Q_D(const QGeoMapGeometry);
+ Q_D(const QGeoMapScene);
return d->verticalLock_;
}
-void QGeoMapGeometry::paintGL(QGLPainter *painter)
+void QGeoMapScene::paintGL(QGLPainter *painter)
{
- Q_D(QGeoMapGeometry);
+ Q_D(QGeoMapScene);
d->paintGL(painter);
}
-QGeoMapGeometryPrivate::QGeoMapGeometryPrivate(QGeoMapGeometry *geometry)
+QGeoMapScenePrivate::QGeoMapScenePrivate(QGeoMapScene *scene)
: tileSize_(0),
camera_(new QGLCamera()),
sceneNode_(new QGLSceneNode()),
@@ -254,15 +254,15 @@ QGeoMapGeometryPrivate::QGeoMapGeometryPrivate(QGeoMapGeometry *geometry)
useVerticalLock_(false),
verticalLock_(false),
linearScaling_(true),
- q_ptr(geometry) {}
+ q_ptr(scene) {}
-QGeoMapGeometryPrivate::~QGeoMapGeometryPrivate()
+QGeoMapScenePrivate::~QGeoMapScenePrivate()
{
delete sceneNode_;
delete camera_;
}
-QDoubleVector2D QGeoMapGeometryPrivate::screenPositionToMercator(const QPointF &pos) const
+QDoubleVector2D QGeoMapScenePrivate::screenPositionToMercator(const QPointF &pos) const
{
double x = mercatorWidth_ * (((pos.x() - screenOffsetX_) / screenWidth_) - 0.5);
x += mercatorCenterX_;
@@ -281,7 +281,7 @@ QDoubleVector2D QGeoMapGeometryPrivate::screenPositionToMercator(const QPointF &
return QDoubleVector2D(x, y);
}
-QPointF QGeoMapGeometryPrivate::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
+QPointF QGeoMapScenePrivate::mercatorToScreenPosition(const QDoubleVector2D &mercator) const
{
double mx = sideLength_ * mercator.x();
@@ -323,7 +323,7 @@ QPointF QGeoMapGeometryPrivate::mercatorToScreenPosition(const QDoubleVector2D &
return QPointF(x + screenOffsetX_, y + screenOffsetY_);
}
-QGeometryData QGeoMapGeometryPrivate::buildGeometry(const QGeoTileSpec &spec)
+QGeometryData QGeoMapScenePrivate::buildGeometry(const QGeoTileSpec &spec)
{
int x = spec.x();
@@ -374,7 +374,7 @@ QGeometryData QGeoMapGeometryPrivate::buildGeometry(const QGeoTileSpec &spec)
return g;
}
-QGLSceneNode *QGeoMapGeometryPrivate::buildSceneNodeFromGeometry(const QGeometryData &geom)
+QGLSceneNode *QGeoMapScenePrivate::buildSceneNodeFromGeometry(const QGeometryData &geom)
{
QGLBuilder builder;
builder.addQuads(geom);
@@ -382,7 +382,7 @@ QGLSceneNode *QGeoMapGeometryPrivate::buildSceneNodeFromGeometry(const QGeometry
}
-void QGeoMapGeometryPrivate::setScalingOnTextures()
+void QGeoMapScenePrivate::setScalingOnTextures()
{
if (!linearScaling_) {
foreach (const QSharedPointer<QGeoTileTexture> &tex, textures_.values()) {
@@ -397,7 +397,7 @@ void QGeoMapGeometryPrivate::setScalingOnTextures()
}
}
-void QGeoMapGeometryPrivate::addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture)
+void QGeoMapScenePrivate::addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture)
{
if (linearScaling_) {
texture->texture->setBindOptions(texture->texture->bindOptions() |
@@ -435,17 +435,17 @@ void QGeoMapGeometryPrivate::addTile(const QGeoTileSpec &spec, QSharedPointer<QG
}
// return true if new tiles introduced in [tiles]
-void QGeoMapGeometryPrivate::setVisibleTiles(const QSet<QGeoTileSpec> &tiles)
+void QGeoMapScenePrivate::setVisibleTiles(const QSet<QGeoTileSpec> &tiles)
{
- Q_Q(QGeoMapGeometry);
+ Q_Q(QGeoMapScene);
// detect if new tiles introduced
bool newTilesIntroduced = !visibleTiles_.contains(tiles);
- // work out the tile bounds for the new geometry
+ // work out the tile bounds for the new scene
setTileBounds(tiles);
- // set up the gl camera for the new geometry
+ // set up the gl camera for the new scene
setupCamera();
QSet<QGeoTileSpec> toRemove = visibleTiles_ - tiles;
@@ -462,7 +462,7 @@ void QGeoMapGeometryPrivate::setVisibleTiles(const QSet<QGeoTileSpec> &tiles)
emit q->newTilesVisible(visibleTiles_);
}
-void QGeoMapGeometryPrivate::updateTiles(const QSet<QGeoTileSpec> &tiles)
+void QGeoMapScenePrivate::updateTiles(const QSet<QGeoTileSpec> &tiles)
{
typedef QSet<QGeoTileSpec>::const_iterator iter;
iter i = tiles.constBegin();
@@ -498,7 +498,7 @@ void QGeoMapGeometryPrivate::updateTiles(const QSet<QGeoTileSpec> &tiles)
}
}
-void QGeoMapGeometryPrivate::removeTiles(const QSet<QGeoTileSpec> &oldTiles)
+void QGeoMapScenePrivate::removeTiles(const QSet<QGeoTileSpec> &oldTiles)
{
typedef QSet<QGeoTileSpec>::const_iterator iter;
iter i = oldTiles.constBegin();
@@ -517,7 +517,7 @@ void QGeoMapGeometryPrivate::removeTiles(const QSet<QGeoTileSpec> &oldTiles)
}
}
-void QGeoMapGeometryPrivate::setTileBounds(const QSet<QGeoTileSpec> &tiles)
+void QGeoMapScenePrivate::setTileBounds(const QSet<QGeoTileSpec> &tiles)
{
if (tiles.isEmpty()) {
minTileX_ = -1;
@@ -595,7 +595,7 @@ void QGeoMapGeometryPrivate::setTileBounds(const QSet<QGeoTileSpec> &tiles)
}
}
-void QGeoMapGeometryPrivate::setupCamera()
+void QGeoMapScenePrivate::setupCamera()
{
double f = 1.0 * qMin(screenSize_.width(), screenSize_.height());
@@ -711,7 +711,7 @@ void QGeoMapGeometryPrivate::setupCamera()
camera_->setFarPlane(farPlane);
}
-void QGeoMapGeometryPrivate::paintGL(QGLPainter *painter)
+void QGeoMapScenePrivate::paintGL(QGLPainter *painter)
{
// TODO protect with mutex?
diff --git a/src/location/maps/qgeomapgeometry_p.h b/src/location/maps/qgeomapscene_p.h
index fb39e0ad..9ff7969d 100644
--- a/src/location/maps/qgeomapgeometry_p.h
+++ b/src/location/maps/qgeomapscene_p.h
@@ -38,8 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QGEOMAPGEOMETRY_P_H
-#define QGEOMAPGEOMETRY_P_H
+#ifndef QGEOMAPSCENE_P_H
+#define QGEOMAPSCENE_P_H
//
// W A R N I N G
@@ -74,14 +74,14 @@ class QGeoTileTexture;
class QPointF;
-class QGeoMapGeometryPrivate;
+class QGeoMapScenePrivate;
-class Q_LOCATION_EXPORT QGeoMapGeometry : public QObject
+class Q_LOCATION_EXPORT QGeoMapScene : public QObject
{
Q_OBJECT
public:
- QGeoMapGeometry();
- virtual ~QGeoMapGeometry();
+ QGeoMapScene();
+ virtual ~QGeoMapScene();
void setScreenSize(const QSize &size);
void setTileSize(int tileSize);
@@ -106,11 +106,11 @@ Q_SIGNALS:
void newTilesVisible(const QSet<QGeoTileSpec> &newTiles);
private:
- QGeoMapGeometryPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapGeometry)
- Q_DISABLE_COPY(QGeoMapGeometry)
+ QGeoMapScenePrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoMapScene)
+ Q_DISABLE_COPY(QGeoMapScene)
};
QT_END_NAMESPACE
-#endif // QGEOMAPGEOMETRY_P_H
+#endif // QGEOMAPSCENE_P_H
diff --git a/src/location/maps/qgeotilecache.cpp b/src/location/maps/qgeotilecache.cpp
index 0b19b596..671675ba 100644
--- a/src/location/maps/qgeotilecache.cpp
+++ b/src/location/maps/qgeotilecache.cpp
@@ -337,7 +337,7 @@ QSharedPointer<QGeoTileTexture> QGeoTileCache::addToTextureCache(const QGeoTileS
tt->cache = this;
/* Do not bind/cleanImage on the texture here -- it needs to be done
- * in the render thread (by qgeomapgeometry) */
+ * in the render thread (by qgeomapscene) */
int textureCost = pixmap.width() * pixmap.height() * pixmap.depth() / 8;
textureCache_.insert(spec, tt, textureCost);
diff --git a/src/location/maps/qgeotiledmapdata.cpp b/src/location/maps/qgeotiledmapdata.cpp
index 4e9eec29..3fc294de 100644
--- a/src/location/maps/qgeotiledmapdata.cpp
+++ b/src/location/maps/qgeotiledmapdata.cpp
@@ -47,8 +47,8 @@
#include "qgeoprojection_p.h"
#include "qgeocameratiles_p.h"
-#include "qgeomapimages_p.h"
-#include "qgeomapgeometry_p.h"
+#include "qgeotilerequestmanager_p.h"
+#include "qgeomapscene_p.h"
#include "qgeocoordinateinterpolator_p.h"
#include "qgeoprojection_p.h"
#include "qdoublevector2d_p.h"
@@ -143,17 +143,16 @@ QGeoTiledMapData::~QGeoTiledMapData()
d_ptr->engine()->deregisterMap(this);
delete d_ptr;
}
-
-void QGeoTiledMapData::tileFetched(const QGeoTileSpec &spec)
+QGeoTileRequestManager *QGeoTiledMapData::getRequestManager()
{
Q_D(QGeoTiledMapData);
- d->tileFetched(spec);
+ return d->tileRequests_;
}
-void QGeoTiledMapData::tileError(const QGeoTileSpec &spec, const QString &errorString)
+void QGeoTiledMapData::newTileFetched(QSharedPointer<QGeoTileTexture> texture)
{
Q_D(QGeoTiledMapData);
- d->tileError(spec, errorString);
+ d->newTileFetched(texture);
}
QGeoTileCache* QGeoTiledMapData::tileCache()
@@ -222,26 +221,21 @@ QPointF QGeoTiledMapData::coordinateToScreenPosition(const QGeoCoordinate &coord
return pos;
}
-void QGeoTiledMapData::updateTileRequests(const QSet<QGeoTileSpec> &tilesAdded, const QSet<QGeoTileSpec> &tilesRemoved)
-{
- static_cast<QGeoTiledMappingManagerEngine*>(engine())->updateTileRequests(this, tilesAdded, tilesRemoved);
-}
-
QGeoTiledMapDataPrivate::QGeoTiledMapDataPrivate(QGeoTiledMapData *parent, QGeoTiledMappingManagerEngine *engine)
: map_(parent),
cache_(engine->tileCache()),
engine_(engine),
cameraTiles_(new QGeoCameraTiles()),
- mapGeometry_(new QGeoMapGeometry()),
- mapImages_(new QGeoMapImages(parent, engine->tileCache()))
+ mapScene_(new QGeoMapScene()),
+ tileRequests_(new QGeoTileRequestManager(parent))
{
cameraTiles_->setMaximumZoomLevel(static_cast<int>(ceil(engine->cameraCapabilities().maximumZoomLevel())));
cameraTiles_->setTileSize(engine->tileSize().width());
cameraTiles_->setPluginString(map_->pluginString());
- mapGeometry_->setTileSize(engine->tileSize().width());
+ mapScene_->setTileSize(engine->tileSize().width());
- QObject::connect(mapGeometry_,
+ QObject::connect(mapScene_,
SIGNAL(newTilesVisible(const QSet<QGeoTileSpec>&)),
map_,
SLOT(evaluateCopyrights(const QSet<QGeoTileSpec>)));
@@ -251,8 +245,8 @@ QGeoTiledMapDataPrivate::~QGeoTiledMapDataPrivate()
{
// controller_ is a child of map_, don't need to delete it here
- delete mapImages_;
- delete mapGeometry_;
+ delete tileRequests_;
+ delete mapScene_;
delete cameraTiles_;
// TODO map items are not deallocated!
@@ -273,7 +267,7 @@ void QGeoTiledMapDataPrivate::changeCameraData(const QGeoCameraData &oldCameraDa
{
double lat = oldCameraData.center().latitude();
- if (mapGeometry_->verticalLock()) {
+ if (mapScene_->verticalLock()) {
QGeoCoordinate coord = map_->cameraData().center();
coord.setLatitude(lat);
map_->cameraData().setCenter(coord);
@@ -296,17 +290,15 @@ void QGeoTiledMapDataPrivate::changeCameraData(const QGeoCameraData &oldCameraDa
cameraTiles_->setCamera(cam);
visibleTiles_ = cameraTiles_->tiles();
- mapGeometry_->setCameraData(cam);
- mapGeometry_->setVisibleTiles(visibleTiles_);
-
- if (mapImages_) {
- mapImages_->setVisibleTiles(visibleTiles_);
+ mapScene_->setCameraData(cam);
+ mapScene_->setVisibleTiles(visibleTiles_);
+ if (tileRequests_) {
QList<QSharedPointer<QGeoTileTexture> > cachedTiles =
- mapImages_->cachedTiles();
+ tileRequests_->requestTiles(visibleTiles_);
foreach (QSharedPointer<QGeoTileTexture> tex, cachedTiles) {
- mapGeometry_->addTile(tex->spec, tex);
+ mapScene_->addTile(tex->spec, tex);
}
if (!cachedTiles.isEmpty())
@@ -325,8 +317,8 @@ void QGeoTiledMapDataPrivate::resized(int width, int height)
{
if (cameraTiles_)
cameraTiles_->setScreenSize(QSize(width, height));
- if (mapGeometry_)
- mapGeometry_->setScreenSize(QSize(width, height));
+ if (mapScene_)
+ mapScene_->setScreenSize(QSize(width, height));
if (map_)
map_->setCameraData(map_->cameraData());
@@ -345,21 +337,12 @@ void QGeoTiledMapDataPrivate::resized(int width, int height)
}
}
-void QGeoTiledMapDataPrivate::tileFetched(const QGeoTileSpec &spec)
+void QGeoTiledMapDataPrivate::newTileFetched(QSharedPointer<QGeoTileTexture> texture)
{
- QSharedPointer<QGeoTileTexture> tex = cache_->get(spec);
- if (tex) {
- mapGeometry_->addTile(spec, tex);
- }
- mapImages_->tileFetched(spec);
+ mapScene_->addTile(texture->spec, texture);
map_->update();
}
-void QGeoTiledMapDataPrivate::tileError(const QGeoTileSpec &spec, const QString &errorString)
-{
- mapImages_->tileError(spec, errorString);
-}
-
QSet<QGeoTileSpec> QGeoTiledMapDataPrivate::visibleTiles()
{
return visibleTiles_;
@@ -367,18 +350,18 @@ QSet<QGeoTileSpec> QGeoTiledMapDataPrivate::visibleTiles()
void QGeoTiledMapDataPrivate::paintGL(QGLPainter *painter)
{
- mapGeometry_->paintGL(painter);
+ mapScene_->paintGL(painter);
cache_->GLContextAvailable();
}
QGeoCoordinate QGeoTiledMapDataPrivate::screenPositionToCoordinate(const QPointF &pos) const
{
- return QGeoProjection::mercatorToCoord(mapGeometry_->screenPositionToMercator(pos));
+ return QGeoProjection::mercatorToCoord(mapScene_->screenPositionToMercator(pos));
}
QPointF QGeoTiledMapDataPrivate::coordinateToScreenPosition(const QGeoCoordinate &coordinate) const
{
- return mapGeometry_->mercatorToScreenPosition(QGeoProjection::coordToMercator(coordinate));
+ return mapScene_->mercatorToScreenPosition(QGeoProjection::coordToMercator(coordinate));
}
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeotiledmapdata_p.h b/src/location/maps/qgeotiledmapdata_p.h
index 521c5131..e91e1aca 100644
--- a/src/location/maps/qgeotiledmapdata_p.h
+++ b/src/location/maps/qgeotiledmapdata_p.h
@@ -62,10 +62,12 @@
QT_BEGIN_NAMESPACE
class QGeoTileSpec;
+class QGeoTileTexture;
class QGeoTileCache;
class QGeoTiledMapDataPrivate;
class QGeoTiledMappingManagerEngine;
class MapItem;
+class QGeoTileRequestManager;
class QPointF;
@@ -80,14 +82,14 @@ public:
void paintGL(QGLPainter *painter);
- void tileFetched(const QGeoTileSpec &spec);
- void tileError(const QGeoTileSpec &spec, const QString &errorString);
+ void newTileFetched(QSharedPointer<QGeoTileTexture> texture);
QGeoCoordinate screenPositionToCoordinate(const QPointF &pos, bool clipToViewport = true) const;
QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
- void updateTileRequests(const QSet<QGeoTileSpec> &tilesAdded, const QSet<QGeoTileSpec> &tilesRemoved);
-
+ // Alternative to exposing this is to make tileFetched a slot, but then requestManager would
+ // need to be a QObject
+ QGeoTileRequestManager *getRequestManager();
protected:
void mapResized(int width, int height);
void changeCameraData(const QGeoCameraData &oldCameraData);
diff --git a/src/location/maps/qgeotiledmapdata_p_p.h b/src/location/maps/qgeotiledmapdata_p_p.h
index f2091667..cd6d1591 100644
--- a/src/location/maps/qgeotiledmapdata_p_p.h
+++ b/src/location/maps/qgeotiledmapdata_p_p.h
@@ -76,8 +76,8 @@ class QGeoMapController;
class QGeoProjection;
class QGeoCameraTiles;
-class QGeoMapImages;
-class QGeoMapGeometry;
+class QGeoTileRequestManager;
+class QGeoMapScene;
class QGeoTiledMapData;
class QGeoTiledMappingManagerEngine;
class QGLPainter;
@@ -101,8 +101,7 @@ public:
QGeoCoordinate screenPositionToCoordinate(const QPointF &pos) const;
QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
- void tileFetched(const QGeoTileSpec &spec);
- void tileError(const QGeoTileSpec &spec, const QString &errorString);
+ void newTileFetched(QSharedPointer<QGeoTileTexture> texture);
QSet<QGeoTileSpec> visibleTiles();
QGeoTiledMappingManagerEngine *engine() const;
@@ -115,10 +114,10 @@ private:
QSet<QGeoTileSpec> visibleTiles_;
QGeoCameraTiles *cameraTiles_;
- QGeoMapGeometry *mapGeometry_;
- QGeoMapImages *mapImages_;
-
+ QGeoMapScene *mapScene_;
Q_DISABLE_COPY(QGeoTiledMapDataPrivate)
+public:
+ QGeoTileRequestManager *tileRequests_;
};
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeotiledmappingmanagerengine.cpp b/src/location/maps/qgeotiledmappingmanagerengine.cpp
index 1f44d640..b42df8e3 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine.cpp
+++ b/src/location/maps/qgeotiledmappingmanagerengine.cpp
@@ -45,6 +45,7 @@
#include "qgeotiledmapdata_p.h"
+#include "qgeotilerequestmanager_p.h"
#include "qgeotilecache_p.h"
#include "qgeotilespec.h"
@@ -127,22 +128,12 @@ QGeoMap* QGeoTiledMappingManagerEngine::createMap(QObject *parent)
void QGeoTiledMappingManagerEngine::registerMap(QGeoTiledMapData *map)
{
- QSet<QGeoTiledMapData*> maps = d_ptr->caches_.value(tileCache());
- maps.insert(map);
- d_ptr->caches_.insert(tileCache(), maps);
+ d_ptr->tileMaps_.insert(map);
}
void QGeoTiledMappingManagerEngine::deregisterMap(QGeoTiledMapData *map)
{
- QGeoTileCache *cache = map->tileCache();
- QSet<QGeoTiledMapData*> maps = d_ptr->caches_.value(cache);
- maps.remove(map);
- if (maps.isEmpty()) {
- d_ptr->caches_.remove(cache);
- } else {
- d_ptr->caches_.insert(cache, maps);
- }
-
+ d_ptr->tileMaps_.remove(map);
d_ptr->mapHash_.remove(map);
QHash<QGeoTileSpec, QSet<QGeoTiledMapData*> > newTileHash = d_ptr->tileHash_;
@@ -227,8 +218,6 @@ void QGeoTiledMappingManagerEngine::engineTileFinished(const QGeoTileSpec &spec,
{
Q_D(QGeoTiledMappingManagerEngine);
- QSet<QGeoTileCache*> caches;
-
QSet<QGeoTiledMapData*> maps = d->tileHash_.value(spec);
typedef QSet<QGeoTiledMapData*>::const_iterator map_iter;
@@ -236,8 +225,6 @@ void QGeoTiledMappingManagerEngine::engineTileFinished(const QGeoTileSpec &spec,
map_iter map = maps.constBegin();
map_iter mapEnd = maps.constEnd();
for (; map != mapEnd; ++map) {
- caches.insert((*map)->tileCache());
-
QSet<QGeoTileSpec> tileSet = d->mapHash_.value(*map);
tileSet.remove(spec);
if (tileSet.isEmpty())
@@ -250,15 +237,14 @@ void QGeoTiledMappingManagerEngine::engineTileFinished(const QGeoTileSpec &spec,
typedef QSet<QGeoTileCache*>::const_iterator cache_iter;
- cache_iter cache = caches.constBegin();
- cache_iter cacheEnd = caches.constEnd();
- for (; cache != cacheEnd; ++cache) {
- (*cache)->insert(spec, bytes, format, d->cacheHint_);
- }
+ tileCache()->insert(spec, bytes, format, d->cacheHint_);
+
+ QSharedPointer<QGeoTileTexture> tile = tileCache()->get(spec);
map = maps.constBegin();
+ mapEnd = maps.constEnd();
for (; map != mapEnd; ++map) {
- (*map)->tileFetched(spec);
+ (*map)->getRequestManager()->tileFetched(tile);
}
}
@@ -282,7 +268,7 @@ void QGeoTiledMappingManagerEngine::engineTileError(const QGeoTileSpec &spec, co
d->tileHash_.remove(spec);
for (map = maps.constBegin(); map != mapEnd; ++map) {
- (*map)->tileError(spec, errorString);
+ (*map)->getRequestManager()->tileError(spec, errorString);
}
emit tileError(spec, errorString);
@@ -328,6 +314,11 @@ QGeoTileCache *QGeoTiledMappingManagerEngine::tileCache()
return d->tileCache_;
}
+QSharedPointer<QGeoTileTexture> QGeoTiledMappingManagerEngine::getTileTexture(const QGeoTileSpec &spec)
+{
+ return d_ptr->tileCache_->get(spec);
+}
+
/*******************************************************************************
*******************************************************************************/
@@ -347,5 +338,6 @@ QGeoTiledMappingManagerEnginePrivate::~QGeoTiledMappingManagerEnginePrivate()
thread_->quit();
}
+#include "moc_qgeotiledmappingmanagerengine.cpp"
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeotiledmappingmanagerengine.h b/src/location/maps/qgeotiledmappingmanagerengine.h
index 0203a5ca..4d81415d 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine.h
+++ b/src/location/maps/qgeotiledmappingmanagerengine.h
@@ -63,6 +63,7 @@ QT_BEGIN_NAMESPACE
class QGeoTiledMappingManagerEnginePrivate;
class QGeoMapRequestOptions;
class QGeoTileFetcher;
+class QGeoTileTexture;
class QGeoTileSpec;
class QGeoTiledMapData;
@@ -96,7 +97,9 @@ public:
const QSet<QGeoTileSpec> &tilesAdded,
const QSet<QGeoTileSpec> &tilesRemoved);
- QGeoTileCache *tileCache();
+ QGeoTileCache *tileCache(); // TODO: check this is still used
+ QSharedPointer<QGeoTileTexture> getTileTexture(const QGeoTileSpec &spec);
+
QGeoTiledMappingManagerEngine::CacheAreas cacheHint() const;
diff --git a/src/location/maps/qgeotiledmappingmanagerengine_p.h b/src/location/maps/qgeotiledmappingmanagerengine_p.h
index 73cf5f61..7948f203 100644
--- a/src/location/maps/qgeotiledmappingmanagerengine_p.h
+++ b/src/location/maps/qgeotiledmappingmanagerengine_p.h
@@ -76,7 +76,7 @@ public:
QThread *thread_;
QSize tileSize_;
- QHash<QGeoTileCache*, QSet<QGeoTiledMapData*> > caches_;
+ QSet<QGeoTiledMapData*> tileMaps_;
QHash<QGeoTiledMapData*, QSet<QGeoTileSpec> > mapHash_;
QHash<QGeoTileSpec, QSet<QGeoTiledMapData*> > tileHash_;
QGeoTiledMappingManagerEngine::CacheAreas cacheHint_;
diff --git a/src/location/maps/qgeomapimages.cpp b/src/location/maps/qgeotilerequestmanager.cpp
index 3997865a..d63a4f2a 100644
--- a/src/location/maps/qgeomapimages.cpp
+++ b/src/location/maps/qgeotilerequestmanager.cpp
@@ -38,7 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "qgeomapimages_p.h"
+#include "qgeotilerequestmanager_p.h"
#include <QSharedPointer>
#include "qgeotilespec.h"
@@ -50,67 +50,64 @@ QT_BEGIN_NAMESPACE
class RetryFuture;
-class QGeoMapImagesPrivate
+class QGeoTileRequestManagerPrivate
{
public:
- QGeoMapImagesPrivate(QGeoTiledMapData *map, QGeoTileCache *cache);
- ~QGeoMapImagesPrivate();
+ QGeoTileRequestManagerPrivate(QGeoTiledMapData *map);
+ ~QGeoTileRequestManagerPrivate();
QGeoTiledMapData *map_;
QGeoTileCache *cache_;
- void setVisibleTiles(const QSet<QGeoTileSpec> &tiles);
- void tileFetched(const QGeoTileSpec &tile);
+ QList<QSharedPointer<QGeoTileTexture> > requestTiles(const QSet<QGeoTileSpec> &tiles);
void tileError(const QGeoTileSpec &tile, const QString &errorString);
QHash<QGeoTileSpec, int> retries_;
QHash<QGeoTileSpec, QSharedPointer<RetryFuture> > futures_;
QSet<QGeoTileSpec> visible_;
- QList<QSharedPointer<QGeoTileTexture> > cachedTex_;
QSet<QGeoTileSpec> requested_;
+
+ void tileFetched(QSharedPointer<QGeoTileTexture> texture);
};
-QGeoMapImages::QGeoMapImages(QGeoTiledMapData *map, QGeoTileCache *cache)
- : d_ptr(new QGeoMapImagesPrivate(map, cache)) {}
+QGeoTileRequestManager::QGeoTileRequestManager(QGeoTiledMapData *map)
+ : d_ptr(new QGeoTileRequestManagerPrivate(map))
+{
+}
-QGeoMapImages::~QGeoMapImages()
+QGeoTileRequestManager::~QGeoTileRequestManager()
{
delete d_ptr;
}
-void QGeoMapImages::setVisibleTiles(const QSet<QGeoTileSpec> &tiles)
+QList<QSharedPointer<QGeoTileTexture> > QGeoTileRequestManager::requestTiles(const QSet<QGeoTileSpec> &tiles)
{
- Q_D(QGeoMapImages);
- d->setVisibleTiles(tiles);
+ Q_D(QGeoTileRequestManager);
+ return d->requestTiles(tiles);
}
-void QGeoMapImages::tileError(const QGeoTileSpec &tile, const QString &errorString)
+void QGeoTileRequestManager::tileFetched(QSharedPointer<QGeoTileTexture> texture)
{
- Q_D(QGeoMapImages);
- d->tileError(tile, errorString);
+ Q_D(QGeoTileRequestManager);
+ d->tileFetched(texture);
}
-QList<QSharedPointer<QGeoTileTexture> > QGeoMapImages::cachedTiles() const
+void QGeoTileRequestManager::tileError(const QGeoTileSpec &tile, const QString &errorString)
{
- Q_D(const QGeoMapImages);
- return d->cachedTex_;
+ Q_D(QGeoTileRequestManager);
+ d->tileError(tile, errorString);
}
-void QGeoMapImages::tileFetched(const QGeoTileSpec &tile)
+QGeoTileRequestManagerPrivate::QGeoTileRequestManagerPrivate(QGeoTiledMapData *map)
+ : map_(map)
{
- Q_D(QGeoMapImages);
- d->tileFetched(tile);
}
-QGeoMapImagesPrivate::QGeoMapImagesPrivate(QGeoTiledMapData *map, QGeoTileCache *cache)
- : map_(map),
- cache_(cache) {}
-
-QGeoMapImagesPrivate::~QGeoMapImagesPrivate()
+QGeoTileRequestManagerPrivate::~QGeoTileRequestManagerPrivate()
{
}
-void QGeoMapImagesPrivate::setVisibleTiles(const QSet<QGeoTileSpec> &tiles)
+QList<QSharedPointer<QGeoTileTexture> > QGeoTileRequestManagerPrivate::requestTiles(const QSet<QGeoTileSpec> &tiles)
{
QSet<QGeoTileSpec> cancelTiles = requested_ - tiles;
QSet<QGeoTileSpec> requestTiles = tiles - visible_ - requested_;
@@ -118,17 +115,20 @@ void QGeoMapImagesPrivate::setVisibleTiles(const QSet<QGeoTileSpec> &tiles)
typedef QSet<QGeoTileSpec>::const_iterator iter;
- cachedTex_.clear();
+ QList<QSharedPointer<QGeoTileTexture> > cachedTex;
+
+ QGeoTiledMappingManagerEngine *engine = map_ ?
+ static_cast<QGeoTiledMappingManagerEngine*>(map_->engine()) : 0;
// remove tiles in cache from request tiles
- if (cache_) {
+ if (engine){
iter i = requestTiles.constBegin();
iter end = requestTiles.constEnd();
for (; i != end; ++i) {
QGeoTileSpec tile = *i;
- QSharedPointer<QGeoTileTexture> tex = cache_->get(tile);
+ QSharedPointer<QGeoTileTexture> tex = engine->getTileTexture(tile);
if (tex) {
- cachedTex_ << tex;
+ cachedTex << tex;
cached.insert(tile);
}
}
@@ -142,8 +142,8 @@ void QGeoMapImagesPrivate::setVisibleTiles(const QSet<QGeoTileSpec> &tiles)
requested_ += requestTiles;
if (!requestTiles.isEmpty() || !cancelTiles.isEmpty()) {
- if (map_) {
- map_->updateTileRequests(requestTiles, cancelTiles);
+ if (engine) {
+ engine->updateTileRequests(map_, requestTiles, cancelTiles);
// Remove any cancelled tiles from the error retry hash to avoid
// re-using the numbers for a totally different request cycle.
@@ -155,6 +155,16 @@ void QGeoMapImagesPrivate::setVisibleTiles(const QSet<QGeoTileSpec> &tiles)
}
}
}
+
+ return cachedTex;
+}
+
+void QGeoTileRequestManagerPrivate::tileFetched(QSharedPointer<QGeoTileTexture> texture)
+{
+ map_->newTileFetched(texture);
+ requested_.remove(texture->spec);
+ retries_.remove(texture->spec);
+ futures_.remove(texture->spec);
}
// Represents a tile that needs to be retried after a certain period of time
@@ -182,17 +192,21 @@ void RetryFuture::retry()
QSet<QGeoTileSpec> cancelTiles;
requestTiles.insert(tile_);
if (map_)
- map_->updateTileRequests(requestTiles, cancelTiles);
+ {
+ QGeoTiledMappingManagerEngine *engine =
+ static_cast<QGeoTiledMappingManagerEngine*>(map_->engine());
+ engine->updateTileRequests(map_, requestTiles, cancelTiles);
+ }
}
-void QGeoMapImagesPrivate::tileError(const QGeoTileSpec &tile, const QString &errorString)
+void QGeoTileRequestManagerPrivate::tileError(const QGeoTileSpec &tile, const QString &errorString)
{
if (requested_.contains(tile)) {
int count = retries_.value(tile, 0);
retries_.insert(tile, count + 1);
if (count >= 5) {
- qWarning("QGeoMapImages: Failed to fetch tile (%d,%d,%d) 5 times, giving up. "
+ qWarning("QGeoTileRequestManager: Failed to fetch tile (%d,%d,%d) 5 times, giving up. "
"Last error message was: '%s'",
tile.x(), tile.y(), tile.zoom(), qPrintable(errorString));
requested_.remove(tile);
@@ -213,13 +227,6 @@ void QGeoMapImagesPrivate::tileError(const QGeoTileSpec &tile, const QString &er
}
}
-void QGeoMapImagesPrivate::tileFetched(const QGeoTileSpec &tile)
-{
- requested_.remove(tile);
- retries_.remove(tile);
- futures_.remove(tile);
-}
-
-#include "qgeomapimages.moc"
+#include "qgeotilerequestmanager.moc"
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomapimages_p.h b/src/location/maps/qgeotilerequestmanager_p.h
index f5adea20..bc43f37d 100644
--- a/src/location/maps/qgeomapimages_p.h
+++ b/src/location/maps/qgeotilerequestmanager_p.h
@@ -38,8 +38,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QGEOMAPIMAGES_P_H
-#define QGEOMAPIMAGES_P_H
+#ifndef QGEOTILEREQUESTMANAGER_P_H
+#define QGEOTILEREQUESTMANAGER_P_H
//
// W A R N I N G
@@ -65,26 +65,24 @@ class QGeoTileSpec;
class QGeoTileCache;
class QGeoTileTexture;
-class QGeoMapImagesPrivate;
+class QGeoTileRequestManagerPrivate;
-class QGeoMapImages
+class QGeoTileRequestManager
{
public:
- QGeoMapImages(QGeoTiledMapData *map, QGeoTileCache *cache);
- ~QGeoMapImages();
+ QGeoTileRequestManager(QGeoTiledMapData *map);
+ ~QGeoTileRequestManager();
- void setVisibleTiles(const QSet<QGeoTileSpec> &tiles);
- QList<QSharedPointer<QGeoTileTexture> > cachedTiles() const;
+ QList<QSharedPointer<QGeoTileTexture> > requestTiles(const QSet<QGeoTileSpec> &tiles);
- void tileFetched(const QGeoTileSpec &tile);
void tileError(const QGeoTileSpec &tile, const QString &errorString);
-
+ void tileFetched(QSharedPointer<QGeoTileTexture> texture);
private:
- QGeoMapImagesPrivate *d_ptr;
- Q_DECLARE_PRIVATE(QGeoMapImages)
- Q_DISABLE_COPY(QGeoMapImages)
+ QGeoTileRequestManagerPrivate *d_ptr;
+ Q_DECLARE_PRIVATE(QGeoTileRequestManager)
+ Q_DISABLE_COPY(QGeoTileRequestManager)
};
QT_END_NAMESPACE
-#endif // QGEOMAPIMAGES_P_H
+#endif // QGEOTILEREQUESTMANAGER_P_H