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 <eirik.aavitsland@qt.io>
This commit is contained in:
Volker Hilsheimer 2022-03-14 10:29:18 +01:00
parent 16d154ca5f
commit b2edef557c

View File

@ -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();
}
/*!