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:
parent
16d154ca5f
commit
b2edef557c
@ -58,8 +58,10 @@ QWidgetBaselineTest::QWidgetBaselineTest()
|
|||||||
QDataStream appearanceStream(&appearanceBytes, QIODevice::WriteOnly);
|
QDataStream appearanceStream(&appearanceBytes, QIODevice::WriteOnly);
|
||||||
appearanceStream << palette << font;
|
appearanceStream << palette << font;
|
||||||
const qreal screenDpr = QApplication::primaryScreen()->devicePixelRatio();
|
const qreal screenDpr = QApplication::primaryScreen()->devicePixelRatio();
|
||||||
if (screenDpr != 1.0)
|
if (screenDpr != 1.0) {
|
||||||
qWarning() << "DPR is" << screenDpr << "- images will be scaled";
|
qWarning() << "DPR is" << screenDpr << "- images will not be compared to 1.0 baseline!";
|
||||||
|
appearanceStream << screenDpr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
const quint16 appearanceId = qChecksum(appearanceBytes, appearanceBytes.size());
|
const quint16 appearanceId = qChecksum(appearanceBytes, appearanceBytes.size());
|
||||||
@ -123,17 +125,13 @@ void QWidgetBaselineTest::makeVisible()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Always return images scaled to a DPR of 1.0.
|
Grabs the test window and returns the resulting QImage, without
|
||||||
|
compensating for DPR differences.
|
||||||
This might produce some fuzzy differences, but lets us
|
|
||||||
compare those.
|
|
||||||
*/
|
*/
|
||||||
QImage QWidgetBaselineTest::takeSnapshot()
|
QImage QWidgetBaselineTest::takeSnapshot()
|
||||||
{
|
{
|
||||||
QGuiApplication::processEvents();
|
QGuiApplication::processEvents();
|
||||||
QPixmap pm = window->grab();
|
return window->grab().toImage();
|
||||||
QTransform scaleTransform = QTransform::fromScale(1.0 / pm.devicePixelRatioF(), 1.0 / pm.devicePixelRatioF());
|
|
||||||
return pm.toImage().transformed(scaleTransform, Qt::SmoothTransformation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user