summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview/qgraphicsview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsview.cpp')
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index f79ee41e10..24647dd74c 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -2703,7 +2703,7 @@ void QGraphicsView::updateScene(const QList<QRectF> &rects)
dirtyViewportRects << xrect;
}
- foreach (const QRect &rect, dirtyViewportRects) {
+ for (const QRect &rect : qAsConst(dirtyViewportRects)) {
// Add the exposed rect to the update region. In rect update
// mode, we only count the bounding rect of items.
if (!boundingRectUpdate) {
@@ -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.