Make Qt on WASM correctly draw windows with QT_SCALE_FACTOR

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
Pick-to: 6.4
Change-Id: I75ac8d85c14230207379b789834256de4254811b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Mikolaj Boc 2022-10-24 13:34:29 +02:00
parent 739fb98233
commit d553ec049d

View File

@ -126,7 +126,7 @@ void QWasmBackingStore::beginPaint(const QRegion &region)
{ {
m_dirty |= region; m_dirty |= region;
// Keep backing store device pixel ratio in sync with window // 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()); resize(backingStore()->size(), backingStore()->staticContents());
QPainter painter(&m_image); 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 format = window()->format().hasAlpha() ?
QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
m_image = QImage(size * window()->devicePixelRatio(), format); const auto platformScreenDPR = window()->handle()->devicePixelRatio();
m_image.setDevicePixelRatio(window()->devicePixelRatio()); m_image = QImage(size * platformScreenDPR, format);
m_image.setDevicePixelRatio(platformScreenDPR);
m_recreateTexture = true; m_recreateTexture = true;
} }