From 96269ecc7763c0f192aa29203f28649a6fcd84ea Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 10 Feb 2021 15:49:11 +0100 Subject: Draw extended RGB solid colors Pass extended RGB colors through the paint engine. Change-Id: I2e212cd4c76aaa65439746352c0da2b9db4a506d Reviewed-by: Eirik Aavitsland --- tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests/auto/gui/painting') 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" -- cgit v1.2.3