From b2edef557cf97ae9251be3675f8179a7d2298faa Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 14 Mar 2022 10:29:18 +0100 Subject: [PATCH] Baseline: don't compensate for DPRs != 1.0 The resulting blurriness is too significant, and it's hard to see where the difference comes from. Better to encode the screen DPR into the appearance ID if it's not 1.0, and warn about the comparison not being done to the baseline images with a 1.0 DPR. Pick-to: 6.3 Change-Id: Iceab7b0a4cc50627145bd1267cff22344f7d8e5b Reviewed-by: Eirik Aavitsland --- tests/baseline/shared/qwidgetbaselinetest.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/baseline/shared/qwidgetbaselinetest.cpp b/tests/baseline/shared/qwidgetbaselinetest.cpp index 0b68b3dfaab..41771cf669a 100644 --- a/tests/baseline/shared/qwidgetbaselinetest.cpp +++ b/tests/baseline/shared/qwidgetbaselinetest.cpp @@ -58,8 +58,10 @@ QWidgetBaselineTest::QWidgetBaselineTest() QDataStream appearanceStream(&appearanceBytes, QIODevice::WriteOnly); appearanceStream << palette << font; const qreal screenDpr = QApplication::primaryScreen()->devicePixelRatio(); - if (screenDpr != 1.0) - qWarning() << "DPR is" << screenDpr << "- images will be scaled"; + if (screenDpr != 1.0) { + qWarning() << "DPR is" << screenDpr << "- images will not be compared to 1.0 baseline!"; + appearanceStream << screenDpr; + } } #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) const quint16 appearanceId = qChecksum(appearanceBytes, appearanceBytes.size()); @@ -123,17 +125,13 @@ void QWidgetBaselineTest::makeVisible() } /* - Always return images scaled to a DPR of 1.0. - - This might produce some fuzzy differences, but lets us - compare those. + Grabs the test window and returns the resulting QImage, without + compensating for DPR differences. */ QImage QWidgetBaselineTest::takeSnapshot() { QGuiApplication::processEvents(); - QPixmap pm = window->grab(); - QTransform scaleTransform = QTransform::fromScale(1.0 / pm.devicePixelRatioF(), 1.0 / pm.devicePixelRatioF()); - return pm.toImage().transformed(scaleTransform, Qt::SmoothTransformation); + return window->grab().toImage(); } /*!