diff options
author | Morten Sørvig <morten.sorvig@qt.io> | 2023-02-20 20:31:03 +0100 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2023-03-28 09:14:09 +0000 |
commit | 2d76f991d01763f5432fc6ba7ae073393f224557 (patch) | |
tree | 9d4514386ee546908520e14a1d186bf3d46384bf /src/gui/painting | |
parent | f8dba0395f6024d5d6a7b3112b9970693cb55dfd (diff) |
Fix QT_WIDGETS_HIGHDPI_DOWNSCALE
The source rect scaling implemented in 79bead6c was incorrect
for child windows with an offset, and was reverted in commit
d59b2fde, after causing QTBUG-107814.
Scale the window rect by the source device pixel ratio to
get the source rect. This source DPR can be different from
the (target) DPR when HIGHDPI_DOWNSCALE is enabled and
will then be a rounded DPR value.
Pick-to: 6.5
Fixes: QTBUG-111102
Task-number: QTBUG-107814
Change-Id: I59801bc22c47fc83d63ae4d96e509ab7fffeb760
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qbackingstoredefaultcompositor.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gui/painting/qbackingstoredefaultcompositor.cpp b/src/gui/painting/qbackingstoredefaultcompositor.cpp index 383fb651dd..db8e5ddce8 100644 --- a/src/gui/painting/qbackingstoredefaultcompositor.cpp +++ b/src/gui/painting/qbackingstoredefaultcompositor.cpp @@ -522,14 +522,16 @@ QPlatformBackingStore::FlushResult QBackingStoreDefaultCompositor::flush(QPlatfo const qreal dpr = window->devicePixelRatio(); const QRect deviceWindowRect = scaledRect(QRect(QPoint(), window->size()), dpr); - const QPoint deviceWindowOffset = scaledOffset(offset, dpr); const bool invertTargetY = rhi->clipSpaceCorrMatrix().data()[5] < 0.0f; const bool invertSource = rhi->isYUpInFramebuffer() != rhi->isYUpInNDC(); if (m_texture) { - // The backingstore is for the entire tlw. - // In case of native children offset tells the position relative to the tlw. - const QRect srcRect = toBottomLeftRect(deviceWindowRect.translated(deviceWindowOffset), m_texture->pixelSize().height()); + // The backingstore is for the entire tlw. In case of native children, offset tells the position + // relative to the tlw. The window rect is scaled by the source device pixel ratio to get + // the source rect. + const QRect sourceWindowRect = scaledRect(QRect(QPoint(), window->size()), sourceDevicePixelRatio); + const QPoint sourceWindowOffset = scaledOffset(offset, sourceDevicePixelRatio); + const QRect srcRect = toBottomLeftRect(sourceWindowRect.translated(sourceWindowOffset), m_texture->pixelSize().height()); const QMatrix3x3 source = sourceTransform(srcRect, m_texture->pixelSize(), origin); QMatrix4x4 target; // identity if (invertTargetY) |