diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-04-04 12:18:47 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-04-07 01:19:09 +0000 |
commit | 33626c484c0b7dc3dfbf3dd1856e5d9482a7522f (patch) | |
tree | d10c7628346c2d084af9615dff5348e6844ab76c | |
parent | de839e3ecc017d2713681b6e940ec8001e91eb49 (diff) |
Don't blit individual rects of region when when scrolling backingstore
The QPlatformBackingStore::scroll() API takes a QRegion as input, but
we have no guarantee that the individual source and destination rects
of the region will not overlap each other when applying the scroll offset,
so we can't naively iterate the rects and call qt_scrollRectInImage for
each one.
The reason this didn't cause any issues in practice was that the QWidget
repaint manager was always passing in a single rect as the region.
On the other hand, the client has requested a scroll of the given
region, so it might assume any other part of the backing store is
preserved as is. Scrolling the bounding rect of the region violates
this assumption.
Amends 19ef76b0606621f189d3bc56549d200f2f5ebb25.
Change-Id: I27934dd6685311c0b53ea2adb60fa5997e360f6c
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit 04837c16873e80ff02801a73126121040a6540ec)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
4 files changed, 8 insertions, 8 deletions
diff --git a/src/gui/painting/qrasterbackingstore.cpp b/src/gui/painting/qrasterbackingstore.cpp index 49dbeae774..c1738ddcab 100644 --- a/src/gui/painting/qrasterbackingstore.cpp +++ b/src/gui/painting/qrasterbackingstore.cpp @@ -90,8 +90,8 @@ bool QRasterBackingStore::scroll(const QRegion ®ion, int dx, int dy) const qreal devicePixelRatio = m_image.devicePixelRatio(); const QPoint delta(dx * devicePixelRatio, dy * devicePixelRatio); - for (const QRect &rect : region) - qt_scrollRectInImage(m_image, QRect(rect.topLeft() * devicePixelRatio, rect.size() * devicePixelRatio), delta); + const QRect rect = region.boundingRect(); + qt_scrollRectInImage(m_image, QRect(rect.topLeft() * devicePixelRatio, rect.size() * devicePixelRatio), delta); return true; } diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.cpp b/src/plugins/platforms/offscreen/qoffscreencommon.cpp index 33b98cfa1b..d8da2fbac0 100644 --- a/src/plugins/platforms/offscreen/qoffscreencommon.cpp +++ b/src/plugins/platforms/offscreen/qoffscreencommon.cpp @@ -189,8 +189,8 @@ bool QOffscreenBackingStore::scroll(const QRegion &area, int dx, int dy) if (m_image.isNull()) return false; - for (const QRect &rect : area) - qt_scrollRectInImage(m_image, rect, QPoint(dx, dy)); + const QRect rect = area.boundingRect(); + qt_scrollRectInImage(m_image, rect, QPoint(dx, dy)); return true; } diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp index e42237db13..3274c8548e 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp +++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp @@ -182,8 +182,8 @@ bool QWindowsBackingStore::scroll(const QRegion &area, int dx, int dy) return false; const QPoint offset(dx, dy); - for (const QRect &rect : area) - qt_scrollRectInImage(m_image->image(), rect, offset); + const QRect rect = area.boundingRect(); + qt_scrollRectInImage(m_image->image(), rect, offset); return true; } diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 94edd87eb7..08be139a6e 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -488,8 +488,8 @@ bool QXcbBackingStoreImage::scroll(const QRegion &area, int dx, int dy) if (hasShm()) preparePaint(destinationRegion); - for (const QRect &rect : scrollArea) - qt_scrollRectInImage(m_qimage, rect, delta); + const QRect rect = scrollArea.boundingRect(); + qt_scrollRectInImage(m_qimage, rect, delta); } else { ensureGC(m_xcb_pixmap); |