diff options
-rw-r--r-- | src/widgets/graphicsview/qgraphicsview.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 705d5a0f4d..1320545748 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -3483,7 +3483,9 @@ void QGraphicsView::paintEvent(QPaintEvent *event) // Recreate the background pixmap, and flag the whole background as // exposed. if (d->mustResizeBackgroundPixmap) { - d->backgroundPixmap = QPixmap(viewport()->size()); + const qreal dpr = d->viewport->devicePixelRatioF(); + d->backgroundPixmap = QPixmap(viewport()->size() * dpr); + d->backgroundPixmap.setDevicePixelRatio(dpr); QBrush bgBrush = viewport()->palette().brush(viewport()->backgroundRole()); if (!bgBrush.isOpaque()) d->backgroundPixmap.fill(Qt::transparent); @@ -3679,14 +3681,20 @@ void QGraphicsView::scrollContentsBy(int dx, int dy) && X11->use_xrender #endif ) { + // Below, QPixmap::scroll() works in device pixels, while the delta values + // and backgroundPixmapExposed are in device independent pixels. + const qreal dpr = d->backgroundPixmap.devicePixelRatio(); + const qreal inverseDpr = qreal(1) / dpr; + // Scroll the background pixmap QRegion exposed; if (!d->backgroundPixmap.isNull()) - d->backgroundPixmap.scroll(dx, dy, d->backgroundPixmap.rect(), &exposed); + d->backgroundPixmap.scroll(dx * dpr, dy * dpr, d->backgroundPixmap.rect(), &exposed); // Invalidate the background pixmap d->backgroundPixmapExposed.translate(dx, dy); - d->backgroundPixmapExposed += exposed; + const QRegion exposedScaled = QTransform::fromScale(inverseDpr, inverseDpr).map(exposed); + d->backgroundPixmapExposed += exposedScaled; } // Always replay on scroll. |