From a744d308269066e2b9b0ee5f2615e739ac7be688 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 4 Dec 2023 16:26:44 +0100 Subject: 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 Reviewed-by: Andy Nichols --- src/gui/painting/qbackingstoredefaultcompositor.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/gui/painting') 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(); } -- cgit v1.2.3