1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +01:00

Fixed broken zoom 0 on HiDPI displays

This commit is contained in:
Martin Tůma 2022-09-14 00:21:50 +02:00
parent de63009edd
commit 6768647070

View File

@ -98,15 +98,17 @@ qreal OnlineMap::tileSize() const
void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
{
qreal scale = OSM::zoom2scale(_zoom, _tileSize);
QRectF b(bounds());
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
-rect.topLeft().y() * scale) * coordinatesRatio(), _zoom);
QPointF tl(floor(rect.left() / tileSize())
* tileSize(), floor(rect.top() / tileSize()) * tileSize());
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
int width = _zoom ? qCeil(s.width() / tileSize()) : 1;
int height = _zoom ? qCeil(s.height() / tileSize()) : 1;
QSizeF s(qMin(rect.right() - tl.x(), b.width()),
qMin(rect.bottom() - tl.y(), b.height()));
int width = ceil(s.width() / tileSize());
int height = ceil(s.height() / tileSize());
QVector<FetchTile> tiles;
tiles.reserve(width * height);
@ -122,10 +124,9 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
for (int i = 0; i < tiles.count(); i++) {
FetchTile &t = tiles[i];
QPointF tp = _zoom ? QPointF(tl.x() + (t.xy().x() - tile.x())
* tileSize(), tl.y() + ((_invertY ? (1<<_zoom) - t.xy().y() - 1 :
t.xy().y()) - tile.y()) * tileSize())
: QPointF(-_tileSize/2, -_tileSize/2);
QPointF tp(qMax(tl.x(), b.left()) + (t.xy().x() - tile.x()) * tileSize(),
qMax(tl.y(), b.top()) + ((_invertY ? (1<<_zoom) - t.xy().y() - 1 :
t.xy().y()) - tile.y()) * tileSize());
if (!t.pixmap().isNull()) {
t.pixmap().setDevicePixelRatio(imageRatio());