From 9e740c7266fb72c3e9dfcfde9912510180b600c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Thu, 9 Nov 2023 14:57:02 +0100 Subject: [PATCH] QPainter: support painting at DPR < 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QPainter was clamping the DPR at 1, which makes Qt paint a blank window when the DPR is less than 1. Fix by not clamping and treating only DPR == 1 as a special case. This is particularly relevant on Qt for WebAssembly where the user can set the page scale to a value less than 100%. Fixes: QTBUG-111787 Change-Id: Iaa1f7a9b7837dd933c28380b5049422dc1ce9657 Reviewed-by: Jøger Hansegård Reviewed-by: Tor Arne Vestbø --- src/gui/painting/qpainter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 5e3842cbcc..70bcd92fdd 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -221,7 +221,7 @@ qreal QPainterPrivate::effectiveDevicePixelRatio() const if (device->devType() == QInternal::Printer) return qreal(1); - return qMax(qreal(1), device->devicePixelRatio()); + return device->devicePixelRatio(); } QTransform QPainterPrivate::hidpiScaleTransform() const @@ -1824,7 +1824,7 @@ bool QPainter::begin(QPaintDevice *pd) Q_ASSERT(d->engine->isActive()); - if (!d->state->redirectionMatrix.isIdentity() || d->effectiveDevicePixelRatio() > 1) + if (!d->state->redirectionMatrix.isIdentity() || !qFuzzyCompare(d->effectiveDevicePixelRatio(), qreal(1.0))) d->updateMatrix(); Q_ASSERT(d->engine->isActive());