summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-02-10 15:49:11 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-01-12 18:28:24 +0100
commit96269ecc7763c0f192aa29203f28649a6fcd84ea (patch)
treea0a1866dbffdd1e57989e435fa9a1886f189d446 /tests/auto/gui/painting/qpainter/tst_qpainter.cpp
parent996061a1c0d5cd8413ffb6a97cb25b8da9ed811b (diff)
Draw extended RGB solid colors
Pass extended RGB colors through the paint engine. Change-Id: I2e212cd4c76aaa65439746352c0da2b9db4a506d Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'tests/auto/gui/painting/qpainter/tst_qpainter.cpp')
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 45490ef815..cfcaf5b67e 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -301,6 +301,9 @@ private slots:
void drawImageAtPointF();
void scaledDashes();
+#if QT_CONFIG(raster_fp)
+ void hdrColors();
+#endif
private:
void fillData();
@@ -5393,6 +5396,48 @@ void tst_QPainter::scaledDashes()
QVERIFY(backFound);
}
+#if QT_CONFIG(raster_fp)
+void tst_QPainter::hdrColors()
+{
+ QImage img(10, 10, QImage::Format_RGBA32FPx4_Premultiplied);
+ img.fill(Qt::transparent);
+
+ QColor color = QColor::fromRgbF(2.0f, -0.25f, 1.5f);
+ img.setPixelColor(2, 2, color);
+ QCOMPARE(img.pixelColor(2, 2), color);
+
+ {
+ QPainterPath path;
+ path.addEllipse(4, 4, 2, 2);
+ QPainter p(&img);
+ p.fillPath(path, color);
+ p.end();
+ }
+ QCOMPARE(img.pixelColor(4, 4), color);
+
+ img.fill(color);
+ QCOMPARE(img.pixelColor(8, 8), color);
+
+ QColor color2 = QColor::fromRgbF(0.0f, 1.25f, 2.5f);
+ {
+ QPainter p(&img);
+ p.fillRect(0, 0, 3, 3, color2);
+ p.end();
+ }
+ QCOMPARE(img.pixelColor(1, 1), color2);
+ QCOMPARE(img.pixelColor(4, 4), color);
+
+ QImage img2(10, 10, QImage::Format_RGBX32FPx4);
+ {
+ QPainter p(&img2);
+ p.drawImage(0, 0, img);
+ p.end();
+ }
+ QCOMPARE(img2.pixelColor(2, 2), color2);
+ QCOMPARE(img2.pixelColor(5, 5), color);
+}
+#endif
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"