70 lines
3.1 KiB
Diff
70 lines
3.1 KiB
Diff
From 65cf9f2585b696b2819db928fb8b0f13a997113b Mon Sep 17 00:00:00 2001
|
|
From: Dmitry Shachnev <mitya57@gmail.com>
|
|
Date: Wed, 17 May 2023 11:26:12 +0300
|
|
Subject: [PATCH] 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.
|
|
---
|
|
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 1dfe2f51b..8bd930744 100644
|
|
--- a/src/core/image_transparency_fixup.h
|
|
+++ b/src/core/image_transparency_fixup.h
|
|
@@ -57,6 +57,9 @@ class ImageTransparencyFixup
|
|
*
|
|
* 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 @@ class ImageTransparencyFixup
|
|
*/
|
|
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 85b971c03..a9172b1c8 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);
|