From a2157df28b8aaa0c6fc02a35a2b24fa82cb77230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 26 Jul 2016 13:16:53 +0200 Subject: 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 --- src/gui/painting/qbackingstore.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/gui/painting/qbackingstore.cpp') 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); } /*! -- cgit v1.2.3