1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 14:53:21 +02:00

Run the parallel computation only for tiles to be (newly) rendered

This commit is contained in:
Martin Tůma 2018-11-06 01:30:29 +01:00
parent 16c95334a0
commit efc773d04b

View File

@ -30,11 +30,10 @@ public:
#define META_TYPE(type) static_cast<QMetaType::Type>(type) #define META_TYPE(type) static_cast<QMetaType::Type>(type)
static void render(MBTile &tile) static void render(MBTile *tile)
{ {
if (tile.pixmap.isNull()) tile->pixmap.loadFromData(tile->data, QString::number(tile->zoom)
tile.pixmap.loadFromData(tile.data, QString::number(tile.zoom) .toLatin1());
.toLatin1());
} }
static double index2mercator(int index, int zoom) static double index2mercator(int index, int zoom)
@ -250,6 +249,7 @@ void MBTilesMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
int width = ceil(s.width() / tileSize()); int width = ceil(s.width() / tileSize());
int height = ceil(s.height() / tileSize()); int height = ceil(s.height() / tileSize());
QList<MBTile*> jobs;
QVector<MBTile> tiles; QVector<MBTile> tiles;
tiles.reserve(width * height); tiles.reserve(width * height);
@ -265,11 +265,12 @@ void MBTilesMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
mt.data = tileData(_zoom, t); mt.data = tileData(_zoom, t);
mt.key = key; mt.key = key;
mt.zoom = _zoom; mt.zoom = _zoom;
jobs.append(&mt);
} }
} }
} }
QFuture<void> future = QtConcurrent::map(tiles, render); QFuture<void> future = QtConcurrent::map(jobs, render);
future.waitForFinished(); future.waitForFinished();
for (int i = 0; i < tiles.size(); i++) { for (int i = 0; i < tiles.size(); i++) {