Commit 5b194b02 authored by Stas Boukarev's avatar Stas Boukarev Committed by Friedrich W. H. Kossebau

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
parent 44019592
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment