summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@theqtcompany.com>2015-11-17 16:33:16 +0100
committerMichal Klocek <michal.klocek@theqtcompany.com>2015-11-23 14:05:20 +0000
commit7c022af015cbd281521674d20847b619e12e5aaf (patch)
treeed708b547541fec2c7f7b0dfe37cb32f7f33afd7
parent65afb397635191666eb889364260edf0d8cd9024 (diff)
downloadqtlocation-7c022af015cbd281521674d20847b619e12e5aaf.tar.gz
Avoid extra QPixmap convertion when tile fetched
Initialize QGeoTileTexture with QImage instead of converting from QPixmap Change-Id: I69dddda385ebc9ce63cb0dd68fee3d3fa6eed73f Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r--src/location/maps/qgeofiletilecache.cpp18
-rw-r--r--src/location/maps/qgeofiletilecache_p.h2
2 files changed, 10 insertions, 10 deletions
diff --git a/src/location/maps/qgeofiletilecache.cpp b/src/location/maps/qgeofiletilecache.cpp
index 688fdf32..6202f7fb 100644
--- a/src/location/maps/qgeofiletilecache.cpp
+++ b/src/location/maps/qgeofiletilecache.cpp
@@ -269,12 +269,12 @@ QSharedPointer<QGeoTileTexture> QGeoFileTileCache::get(const QGeoTileSpec &spec)
QSharedPointer<QGeoCachedTileMemory> tm = memoryCache_.object(spec);
if (tm) {
- QPixmap pixmap;
- if (!pixmap.loadFromData(tm->bytes)) {
+ QImage image;
+ if (!image.loadFromData(tm->bytes)) {
handleError(spec, QLatin1String("Problem with tile image"));
return QSharedPointer<QGeoTileTexture>(0);
}
- QSharedPointer<QGeoTileTexture> tt = addToTextureCache(spec, pixmap);
+ QSharedPointer<QGeoTileTexture> tt = addToTextureCache(spec, image);
if (tt)
return tt;
}
@@ -287,14 +287,14 @@ QSharedPointer<QGeoTileTexture> QGeoFileTileCache::get(const QGeoTileSpec &spec)
QByteArray bytes = file.readAll();
file.close();
- QPixmap pixmap;
- if (!pixmap.loadFromData(bytes)) {
+ QImage image;
+ if (!image.loadFromData(bytes)) {
handleError(spec, QLatin1String("Problem with tile image"));
return QSharedPointer<QGeoTileTexture>(0);
}
addToMemoryCache(spec, bytes, format);
- QSharedPointer<QGeoTileTexture> tt = addToTextureCache(td->spec, pixmap);
+ QSharedPointer<QGeoTileTexture> tt = addToTextureCache(td->spec, image);
if (tt)
return tt;
}
@@ -365,13 +365,13 @@ QSharedPointer<QGeoCachedTileMemory> QGeoFileTileCache::addToMemoryCache(const Q
return tm;
}
-QSharedPointer<QGeoTileTexture> QGeoFileTileCache::addToTextureCache(const QGeoTileSpec &spec, const QPixmap &pixmap)
+QSharedPointer<QGeoTileTexture> QGeoFileTileCache::addToTextureCache(const QGeoTileSpec &spec, const QImage &image)
{
QSharedPointer<QGeoTileTexture> tt(new QGeoTileTexture);
tt->spec = spec;
- tt->image = pixmap.toImage();
+ tt->image = image;
- int textureCost = tt->image.width() * tt->image.height() * tt->image.depth() / 8;
+ int textureCost = image.width() * image.height() * image.depth() / 8;
textureCache_.insert(spec, tt, textureCost);
return tt;
diff --git a/src/location/maps/qgeofiletilecache_p.h b/src/location/maps/qgeofiletilecache_p.h
index 6bd1ad2b..8afb4c8d 100644
--- a/src/location/maps/qgeofiletilecache_p.h
+++ b/src/location/maps/qgeofiletilecache_p.h
@@ -135,7 +135,7 @@ private:
QSharedPointer<QGeoCachedTileDisk> addToDiskCache(const QGeoTileSpec &spec, const QString &filename);
QSharedPointer<QGeoCachedTileMemory> addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format);
- QSharedPointer<QGeoTileTexture> addToTextureCache(const QGeoTileSpec &spec, const QPixmap &pixmap);
+ QSharedPointer<QGeoTileTexture> addToTextureCache(const QGeoTileSpec &spec, const QImage &image);
static QString tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory);
static QGeoTileSpec filenameToTileSpec(const QString &filename);