From 518ec4193dcd3eee3826f15a42ca0dce70256b8e Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Sun, 9 Jul 2023 21:48:02 +0100 Subject: [PATCH] make QPainterTest pass with Qt 5.15.9 Forwarded: https://github.com/OpenOrienteering/mapper/pull/2156 Last-Update: 2023-07-09 https://bugreports.qt.io/browse/QTBUG-100327 was fixed in 5.15.9, so now we have a good result from the beginning and don't need ImageTransparencyFixup. Gbp-Pq: Name qt-5.15.9.patch --- src/core/image_transparency_fixup.h | 5 +++++ test/qpainter_t.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/image_transparency_fixup.h b/src/core/image_transparency_fixup.h index 1dfe2f5..8bd9307 100644 --- a/src/core/image_transparency_fixup.h +++ b/src/core/image_transparency_fixup.h @@ -57,6 +57,9 @@ public: * * The image must be of QImage::Format_ARGB32_Premultiplied. * It may be null. + * + * This fixup is needed for Qt5 < 5.15.9 and Qt6 < 6.2.4 which are + * affected by https://bugreports.qt.io/browse/QTBUG-100327. */ inline ImageTransparencyFixup(QImage* image) : dest(0), dest_end(0) @@ -81,11 +84,13 @@ public: */ inline void operator()() const { +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 9) || (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 2, 4)) for (QRgb* px = dest; px < dest_end; px++) { if (*px == 0x01000000) /* qRgba(0, 0, 0, 1) */ *px = 0x00000000; /* qRgba(0, 0, 0, 0) */ } +#endif } protected: diff --git a/test/qpainter_t.cpp b/test/qpainter_t.cpp index 85b971c..a9172b1 100644 --- a/test/qpainter_t.cpp +++ b/test/qpainter_t.cpp @@ -80,9 +80,10 @@ void QPainterTest::multiplyComposition() QCOMPARE(compose(white_img, white_img, multiply).pixel(0,0), qRgba(255, 255, 255, 255)); QCOMPARE(compose(black_img, black_img, multiply).pixel(0,0), qRgba(0, 0, 0, 255)); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 9) || (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 2, 4)) QEXPECT_FAIL("", "CompositionMode_Multiply incorrectly composes full transparency.", Continue); +#endif QCOMPARE(compose(trans_img, trans_img, multiply).pixel(0,0), qRgba(0, 0, 0, 0)); - QCOMPARE(compose(trans_img, trans_img, multiply).pixel(0,0), qRgba(0, 0, 0, 1)); // This should fail! // ImageTransparencyFixup fixes the particular issue. QImage result = compose(trans_img, trans_img, multiply); @@ -107,9 +108,10 @@ void QPainterTest::darkenComposition() QCOMPARE(compose(white_img, white_img, darken).pixel(0,0), qRgba(255, 255, 255, 255)); QCOMPARE(compose(black_img, black_img, darken).pixel(0,0), qRgba(0, 0, 0, 255)); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 9) || (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 2, 4)) QEXPECT_FAIL("", "CompositionMode_Darken incorrectly composes full transparency.", Continue); +#endif QCOMPARE(compose(trans_img, trans_img, darken).pixel(0,0), qRgba(0, 0, 0, 0)); - QCOMPARE(compose(trans_img, trans_img, darken).pixel(0,0), qRgba(0, 0, 0, 1)); // This should fail! // ImageTransparencyFixup fixes the particular issue. QImage result = compose(trans_img, trans_img, darken); -- 2.30.2