From 04eff751897b78c041fed3fbb62538f80e766eae Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Mon, 24 Oct 2022 13:34:29 +0200 Subject: [PATCH] Make Qt on WASM correctly draw windows with QT_SCALE_FACTOR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GUI scale factor was taken into account twice, once in QBackingStore::resize and then again implicitly in QWasmBackingStore::resize, through window()->devicePixelRatio(), which contains it as one of its multipliers. Fixes: QTBUG-80992 Change-Id: I75ac8d85c14230207379b789834256de4254811b Reviewed-by: Morten Johan Sørvig (cherry picked from commit d553ec049d3496240a2af6b04be14cf124cb1a4d) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/wasm/qwasmbackingstore.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmbackingstore.cpp b/src/plugins/platforms/wasm/qwasmbackingstore.cpp index 594dcaa8128..05a5a1bbdbd 100644 --- a/src/plugins/platforms/wasm/qwasmbackingstore.cpp +++ b/src/plugins/platforms/wasm/qwasmbackingstore.cpp @@ -126,7 +126,7 @@ void QWasmBackingStore::beginPaint(const QRegion ®ion) { m_dirty |= region; // Keep backing store device pixel ratio in sync with window - if (m_image.devicePixelRatio() != window()->devicePixelRatio()) + if (m_image.devicePixelRatio() != window()->handle()->devicePixelRatio()) resize(backingStore()->size(), backingStore()->staticContents()); QPainter painter(&m_image); @@ -145,8 +145,9 @@ void QWasmBackingStore::resize(const QSize &size, const QRegion &staticContents) QImage::Format format = window()->format().hasAlpha() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; - m_image = QImage(size * window()->devicePixelRatio(), format); - m_image.setDevicePixelRatio(window()->devicePixelRatio()); + const auto platformScreenDPR = window()->handle()->devicePixelRatio(); + m_image = QImage(size * platformScreenDPR, format); + m_image.setDevicePixelRatio(platformScreenDPR); m_recreateTexture = true; }