diff options
Diffstat (limited to 'tests/auto/gui/painting/qcolor/tst_qcolor.cpp')
-rw-r--r-- | tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 67d30d7c9a..72bad03a6a 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -318,6 +318,9 @@ void tst_QColor::namehex_data() QTest::newRow("global color darkCyan") << "#008080" << QColor(Qt::darkCyan); QTest::newRow("global color darkMagenta") << "#800080" << QColor(Qt::darkMagenta); QTest::newRow("global color darkYellow") << "#808000" << QColor(Qt::darkYellow); + QTest::newRow("#RGB") << "#888" << QColor(0x88, 0x88, 0x88); + QTest::newRow("#RRRGGGBBB") << "#80F80F80F" << QColor(qRgba64(0x80f8, 0x80f8, 0x80f8, 0xffff)); + QTest::newRow("#RRRRGGGGBBBB") << "#808180818081" << QColor(qRgba64(0x8081, 0x8081, 0x8081, 0xffff)); QTest::newRow("transparent red") << "#66ff0000" << QColor(255, 0, 0, 102); QTest::newRow("invalid red") << "#gg0000" << QColor(); QTest::newRow("invalid transparent") << "#gg00ff00" << QColor(); @@ -1492,10 +1495,28 @@ void tst_QColor::unpremultiply_sse4() // Tests that qUnpremultiply_sse4 returns the same as qUnpremultiply. #if QT_COMPILER_SUPPORTS_HERE(SSE4_1) if (qCpuHasFeature(SSE4_1)) { + int minorDifferences = 0; + for (uint a = 0; a < 256; a++) { + for (uint c = 0; c <= a; c++) { + const QRgb p = qRgba(c, a-c, c/2, a); + const uint u = qUnpremultiply(p); + const uint usse4 = qUnpremultiply_sse4(p); + if (u != usse4) { + QCOMPARE(qAlpha(u), qAlpha(usse4)); + QVERIFY(qAbs(qRed(u) - qRed(usse4)) <= 1); + QVERIFY(qAbs(qGreen(u) - qGreen(usse4)) <= 1); + QVERIFY(qAbs(qBlue(u) - qBlue(usse4)) <= 1); + ++minorDifferences; + } + } + } + // Allow a few rounding differences as long as it still obeys + // the qPremultiply(qUnpremultiply(x)) == x invariant + QVERIFY(minorDifferences <= 16 * 255); for (uint a = 0; a < 256; a++) { for (uint c = 0; c <= a; c++) { QRgb p = qRgba(c, a-c, c, a); - QCOMPARE(qUnpremultiply(p), qUnpremultiply_sse4(p)); + QCOMPARE(p, qPremultiply(qUnpremultiply_sse4(p))); } } return; |