From e3e655744a61ab56093ef4742b96449ed4a7457c Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Wed, 22 Jun 2022 16:46:59 +0200 Subject: [PATCH] Fix setScaledClipRect autotest for reading SVG format Since setScaledClipRect will actually render only the necessary parts, there may be insignificant differences in rounding/anitaliasing compared to rendering the whole image first and then clipping. Hence this autotest case would always fail. But that would not happen in CI, since it tests qtbase without the qtsvg module, and then the SVG tests are skipped. (For some reason, one ran into this in wayland testing and made an exception for that, but obviously this failure has nothing to do with wayland). Work around the issue by converting the rendered images to 4 bpc format, so the differences in the least significant bits get truncated away. Fixes: QTBUG-100917 Task-number: QTBUG-81044 Change-Id: I1c14e98af22d0ae22a751960b69e692c7a38399b Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Shawn Rutledge (cherry picked from commit 458ec4cb5442315c2c923ba78faf45fdd729a109) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/gui/image/qimagereader/tst_qimagereader.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index b01eb83089d..42a2efe5a8d 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -487,8 +487,11 @@ void tst_QImageReader::setScaledClipRect() QImageReader originalReader(prefix + fileName); originalReader.setScaledSize(QSize(300, 300)); QImage originalImage = originalReader.read(); - if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive) && format.contains("svg")) - QEXPECT_FAIL("", "This fails on Wayland, see QTBUG-100917.", Abort); + if (format.contains("svg")) { + // rendering of subrect may yield slight rounding differences, truncate them away + image.convertTo(QImage::Format_RGB444); + originalImage.convertTo(QImage::Format_RGB444); + } QCOMPARE(originalImage.copy(newRect), image); }