summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStas Boukarev <stassats@gmail.com>2016-09-20 17:33:20 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-09-20 17:46:48 (GMT)
commit17c73b120bfe418a0e854fd7f2846014ef400b9c (patch)
treee118de9204e19bec99df5a95c997de3d767c1e77
parent900d04b18bebe32efca88f481d22b760aa3383a5 (diff)
Scale pixmap cache of MarbleGraphicsItem
Summary: Use devicePixelRatio to properly scale cached pixmaps on HiDPI screens. Reviewers: nienhueser, #marble, rahn Reviewed By: nienhueser, #marble, rahn Subscribers: kossebau Differential Revision: https://phabricator.kde.org/D2152
-rw-r--r--src/lib/marble/graphicsview/MarbleGraphicsItem.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/lib/marble/graphicsview/MarbleGraphicsItem.cpp b/src/lib/marble/graphicsview/MarbleGraphicsItem.cpp
index 03553f6..adacbde 100644
--- a/src/lib/marble/graphicsview/MarbleGraphicsItem.cpp
+++ b/src/lib/marble/graphicsview/MarbleGraphicsItem.cpp
@@ -57,16 +57,20 @@ bool MarbleGraphicsItem::paintEvent( QPainter *painter, const ViewportParams *vi
if ( ItemCoordinateCache == cacheMode()
|| DeviceCoordinateCache == cacheMode() )
{
- const QSize neededPixmapSize = size().toSize() + QSize( 1, 1 ); // adding a pixel for rounding errors
- if ( p()->m_pixmap.size() != neededPixmapSize ) {
+ const qreal scale = painter->device()->devicePixelRatio();
- if ( p()->m_pixmap.size() != neededPixmapSize ) {
- if ( size().isValid() && !size().isNull() ) {
- p()->m_pixmap = QPixmap( neededPixmapSize );
- }
- else {
- mDebug() << "Warning: Invalid pixmap size suggested: " << d->m_size;
- }
+ const QSize neededPixmapSize = scale * size().toSize() + QSize( 1, 1 ); // adding a pixel for rounding errors
+
+ if ( p()->m_pixmap.size() != neededPixmapSize ||
+ p()->m_pixmap.devicePixelRatio() != scale ) {
+
+
+ if ( size().isValid() && !size().isNull() ) {
+ p()->m_pixmap = QPixmap( neededPixmapSize );
+ p()->m_pixmap.setDevicePixelRatio( scale );
+ }
+ else {
+ mDebug() << "Warning: Invalid pixmap size suggested: " << d->m_size;
}
p()->m_pixmap.fill( Qt::transparent );