diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-07-18 16:52:08 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-07-19 09:53:00 +0000 |
commit | 5138fada0b9ce3968b23ec11df5f0d4e67544c43 (patch) | |
tree | ee7aae8533d80852420565837f5c9a9ab0135732 /src/gui/kernel | |
parent | a9dfdbd06acc6a11a03f298a794e290da1028992 (diff) |
Fix QHighDpi::fromNativeLocalExposedRegion rounding errors
Calling bottom/right/bottomRight on a QRect is discouraged, as it does
not give the true bottom-right corner of the rectangle, instead giving
a point one unit to the left and top of the true bottom right.
Dividing this point by a scale factor of e.g. 2, and then using qCeil
on the bottom right x and y coordinates would result in a pointRegion
that was 1x1 * scaleFactor larger than it should, manifesting as
rendering issues at later stages.
We can get away from the whole problem by initially converting the
QRect to a QRectF, and basing the pointRegion's rect on the scaled
size instead of bottom-right coordinates.
Change-Id: I4d4895660655cfa8749c93c7d2573ae79cd7898b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qhighdpiscaling_p.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 32c8f07dc0..0a060a2d2c 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -398,11 +398,11 @@ inline QRegion fromNativeLocalExposedRegion(const QRegion &pixelRegion, const QW const qreal scaleFactor = QHighDpiScaling::factor(window); QRegion pointRegion; - for (const QRect &rect : pixelRegion) { - const QPointF topLeftP = QPointF(rect.topLeft()) / scaleFactor; - const QPointF bottomRightP = QPointF(rect.bottomRight()) / scaleFactor; + for (const QRectF &rect : pixelRegion) { + const QPointF topLeftP = rect.topLeft() / scaleFactor; + const QSizeF sizeP = rect.size() / scaleFactor; pointRegion += QRect(QPoint(qFloor(topLeftP.x()), qFloor(topLeftP.y())), - QPoint(qCeil(bottomRightP.x()), qCeil(bottomRightP.y()))); + QSize(qCeil(sizeP.width()), qCeil(sizeP.height()))); } return pointRegion; } |