1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Cache the open file descriptors between successive raster loads

This commit is contained in:
Martin Tůma 2021-07-19 22:51:00 +02:00
parent 2ea16eaaab
commit 3f3ccb6856

View File

@ -1,5 +1,6 @@
#include <QFont> #include <QFont>
#include <QPainter> #include <QPainter>
#include <QCache>
#include "map/imgmap.h" #include "map/imgmap.h"
#include "map/textpathitem.h" #include "map/textpathitem.h"
#include "map/textpointitem.h" #include "map/textpointitem.h"
@ -195,6 +196,8 @@ void RasterTile::ll2xy(QList<MapData::Point> &points)
void RasterTile::drawPolygons(QPainter *painter) void RasterTile::drawPolygons(QPainter *painter)
{ {
QCache<const LBLFile *, SubFile::Handle> hc(16);
for (int n = 0; n < _style->drawOrder().size(); n++) { for (int n = 0; n < _style->drawOrder().size(); n++) {
for (int i = 0; i < _polygons.size(); i++) { for (int i = 0; i < _polygons.size(); i++) {
const MapData::Poly &poly = _polygons.at(i); const MapData::Poly &poly = _polygons.at(i);
@ -207,8 +210,15 @@ void RasterTile::drawPolygons(QPainter *painter)
QPointF br(_map->ll2xy(r.bottomRight())); QPointF br(_map->ll2xy(r.bottomRight()));
QSizeF size(QRectF(tl, br).size()); QSizeF size(QRectF(tl, br).size());
SubFile::Handle hdl(poly.raster.lbl()); bool insert = false;
QPixmap pm(poly.raster.lbl()->image(hdl, poly.raster.id())); SubFile::Handle *hdl = hc.object(poly.raster.lbl());
if (!hdl) {
hdl = new SubFile::Handle(poly.raster.lbl());
insert = true;
}
QPixmap pm(poly.raster.lbl()->image(*hdl, poly.raster.id()));
if (insert)
hc.insert(poly.raster.lbl(), hdl);
qreal sx = size.width() / (qreal)pm.width(); qreal sx = size.width() / (qreal)pm.width();
qreal sy = size.height() / (qreal)pm.height(); qreal sy = size.height() / (qreal)pm.height();