summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/painting
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/painting')
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp35
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp14
2 files changed, 48 insertions, 1 deletions
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 9dd9ab05e8..1ce7e797fc 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -33,6 +33,7 @@
#include <qcolor.h>
#include <qdebug.h>
+#include <private/qcolorprofile_p.h>
#include <private/qdrawingprimitive_sse2_p.h>
#include <qrgba64.h>
@@ -107,6 +108,9 @@ private slots:
void qrgba64Premultiply();
void qrgba64Equivalence();
+ void qcolorprofile_data();
+ void qcolorprofile();
+
#if 0 // Used to be included in Qt4 for Q_WS_X11
void setallowX11ColorNames();
#endif
@@ -1587,5 +1591,36 @@ void tst_QColor::qrgba64Equivalence()
}
}
+void tst_QColor::qcolorprofile_data()
+{
+ QTest::addColumn<qreal>("gammaC");
+ QTest::addColumn<int>("tolerance");
+
+ QTest::newRow("gamma=1.0") << qreal(1.0) << 0;
+ QTest::newRow("gamma=1.5") << qreal(1.5) << 1;
+ QTest::newRow("gamma=1.7") << qreal(1.7) << 2;
+ QTest::newRow("gamma=2.0") << qreal(2.0) << 8;
+ QTest::newRow("gamma=2.31") << qreal(2.31) << 33;
+ QTest::newRow("SRgb") << qreal(0.0) << 7;
+}
+
+void tst_QColor::qcolorprofile()
+{
+ QFETCH(qreal, gammaC);
+ QFETCH(int, tolerance);
+ QColorProfile *cp = (gammaC == 0) ? QColorProfile::fromSRgb(): QColorProfile::fromGamma(gammaC);
+
+ // Test we are accurate for most values after converting through gamma-correction.
+ int error = 0;
+ for (uint i = 0; i < 256; i++) {
+ QRgb cin = qRgb(i, i, i);
+ QRgba64 tmp = cp->toLinear64(cin);
+ QRgb cout = cp->fromLinear64(tmp);
+ error += qAbs(qRed(cin) - qRed(cout));
+ }
+ QVERIFY(error <= tolerance);
+ delete cp;
+}
+
QTEST_MAIN(tst_QColor)
#include "tst_qcolor.moc"
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index cf4979e291..3562bc63f4 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -4843,6 +4843,18 @@ void tst_QPainter::blendARGBonRGB_data()
<< QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 127;
QTest::newRow("ARGB_PM source-in RGBx8888") << QImage::Format_RGBX8888 << QImage::Format_ARGB32_Premultiplied
<< QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB over RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 127;
+ QTest::newRow("ARGB_PM over RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceOver << qRgba(127, 0, 0, 127) << 127;
+ QTest::newRow("ARGB source RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 127) << 255;
+ QTest::newRow("ARGB_PM source RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(127, 0, 0, 127) << 255;
+ QTest::newRow("ARGB source-in RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 255;
+ QTest::newRow("ARGB_PM source-in RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 255;
QTest::newRow("ARGB over RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32
<< QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 123;
QTest::newRow("ARGB_PM over RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32_Premultiplied
@@ -4905,7 +4917,7 @@ void tst_QPainter::blendARGBonRGB()
painter.drawImage(0, 0, imageArgb);
painter.end();
- QCOMPARE(qRed(imageRgb.pixel(0,0)), expected_red);
+ QCOMPARE(imageRgb.pixelColor(0,0).red(), expected_red);
}
enum CosmeticStrokerPaint