path: root/src/gui/painting/qbackingstore.cpp
diff options
authorMorten Johan Sørvig <>2016-07-26 13:16:53 +0200
committerMorten Johan Sørvig <>2016-07-27 08:54:35 +0000
commita2157df28b8aaa0c6fc02a35a2b24fa82cb77230 (patch)
tree89e3040bfed978af1ed3fa4b0ab36d465c2d2da2 /src/gui/painting/qbackingstore.cpp
parent97318a3d5fc3a2e9b97c7dd5a49ad0e09acbeaaa (diff)
HighDPI: Disable scrolling for non-integer deltas
Disable the scrolling optimization in QBackingStore and fall back to repainting for non-integer deltas. The existing rendered pixels are not re-usable in this case. The test is made on the delta, and not on the scale factor. This means that user code can cooperate and generate (logical delta, scale factor) combinations that result in integer pixel deltas (which _can_ be scrolled). Change-Id: I36eb5d9e00449428bc9095edd8732782b996db16 Task-number: QTBUG-52452 Reviewed-by: Friedemann Kleint <>
Diffstat (limited to 'src/gui/painting/qbackingstore.cpp')
1 files changed, 10 insertions, 5 deletions
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index c39675b0b6..aca246e9bf 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -230,11 +230,16 @@ QSize QBackingStore::size() const
bool QBackingStore::scroll(const QRegion &area, int dx, int dy)
- Q_UNUSED(area);
- Q_UNUSED(dx);
- Q_UNUSED(dy);
- return d_ptr->platformBackingStore->scroll(QHighDpi::toNativeLocalRegion(area, d_ptr->window), QHighDpi::toNativePixels(dx, d_ptr->window), QHighDpi::toNativePixels(dy, d_ptr->window));
+ // Disable scrolling for non-integer scroll deltas. For this case
+ // the the existing rendered pixels can't be re-used, and we return
+ // false to signal that a repaint is needed.
+ const qreal nativeDx = QHighDpi::toNativePixels(qreal(dx), d_ptr->window);
+ const qreal nativeDy = QHighDpi::toNativePixels(qreal(dy), d_ptr->window);
+ if (qFloor(nativeDx) != nativeDx || qFloor(nativeDy) != nativeDy)
+ return false;
+ return d_ptr->platformBackingStore->scroll(QHighDpi::toNativeLocalRegion(area, d_ptr->window),
+ nativeDx, nativeDy);