summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2023-12-04 16:26:44 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2023-12-06 18:01:20 +0000
commita744d308269066e2b9b0ee5f2615e739ac7be688 (patch)
treee03f553f7726a3261f7e3439a2134312593e8e8c /src/gui/painting
parent459be7030ef1524160d60a3712e7161ecc55896e (diff)
Use linear filtering with downscaling also with QOpenGLWidget
Amends 9505305c403423f58e70471aaf55994bb734a0bd Fixes: QTBUG-119444 Pick-to: 6.6 6.5 Change-Id: I88c31bcdf42ac4ffef122e49f088cc764db8c384 Reviewed-by: Ilya Fedin <fedin-ilja2010@ya.ru> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qbackingstoredefaultcompositor.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/gui/painting/qbackingstoredefaultcompositor.cpp b/src/gui/painting/qbackingstoredefaultcompositor.cpp
index 77ab79d30c..c1452ca768 100644
--- a/src/gui/painting/qbackingstoredefaultcompositor.cpp
+++ b/src/gui/painting/qbackingstoredefaultcompositor.cpp
@@ -535,6 +535,12 @@ QPlatformBackingStore::FlushResult QBackingStoreDefaultCompositor::flush(QPlatfo
const qreal dpr = window->devicePixelRatio();
const QRect deviceWindowRect = scaledRect(QRect(QPoint(), window->size()), dpr);
+ const QRect sourceWindowRect = scaledRect(QRect(QPoint(), window->size()), sourceDevicePixelRatio);
+ // If sourceWindowRect is larger than deviceWindowRect, we are doing high
+ // DPI downscaling. In that case Linear filtering is a must, whereas for the
+ // 1:1 case Nearest must be used for Qt 5 visual compatibility.
+ const bool needsLinearSampler = sourceWindowRect.width() > deviceWindowRect.width()
+ && sourceWindowRect.height() > deviceWindowRect.height();
const bool invertTargetY = !rhi->isYUpInNDC();
const bool invertSource = !rhi->isYUpInFramebuffer();
@@ -543,7 +549,6 @@ QPlatformBackingStore::FlushResult QBackingStoreDefaultCompositor::flush(QPlatfo
// 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);
@@ -551,16 +556,8 @@ QPlatformBackingStore::FlushResult QBackingStoreDefaultCompositor::flush(QPlatfo
if (invertTargetY)
target.data()[5] = -1.0f;
updateUniforms(&m_widgetQuadData, resourceUpdates, target, source, uniformOptions);
-
- // If sourceWindowRect is larger than deviceWindowRect, we are doing
- // high DPI downscaling. In that case Linear filtering is a must,
- // whereas for the 1:1 case Nearest must be used for Qt 5 visual
- // compatibility.
- if (sourceWindowRect.width() > deviceWindowRect.width()
- && sourceWindowRect.height() > deviceWindowRect.height())
- {
+ if (needsLinearSampler)
updatePerQuadData(&m_widgetQuadData, m_texture.get(), nullptr, NeedsLinearFiltering);
- }
}
const int textureWidgetCount = textures->count();
@@ -591,6 +588,8 @@ QPlatformBackingStore::FlushResult QBackingStoreDefaultCompositor::flush(QPlatfo
else
updatePerQuadData(&m_textureQuadData[i], t, tExtra);
updateUniforms(&m_textureQuadData[i], resourceUpdates, target, source);
+ if (needsLinearSampler)
+ updatePerQuadData(&m_textureQuadData[i], t, tExtra, NeedsLinearFiltering);
} else {
m_textureQuadData[i].reset();
}