1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
Description: make QPainterTest pass with Qt 5.15.9
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.
Author: Dmitry Shachnev <mitya57@debian.org>
Forwarded: https://github.com/OpenOrienteering/mapper/pull/2156
Last-Update: 2023-07-09
--- 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:
--- 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);
|