make QPainterTest pass with Qt 5.15.9
authorDmitry Shachnev <mitya57@debian.org>
Sun, 9 Jul 2023 20:48:02 +0000 (21:48 +0100)
committerDmitry Shachnev <mitya57@debian.org>
Sun, 9 Jul 2023 20:48:02 +0000 (21:48 +0100)
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
test/qpainter_t.cpp

index 1dfe2f51b4933bfad2cc2b177c451366a9cda0e2..8bd9307441d395cb5e94e87d809f113fbe4e14c0 100644 (file)
@@ -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:
index 85b971c03ab37810f50e693dbbdc6f4c5cbdbc93..a9172b1c8a2f9c98568878ad157d3abc27c1474a 100644 (file)
@@ -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);