diff options
Diffstat (limited to 'tests/auto/gui/painting')
-rw-r--r-- | tests/auto/gui/painting/qbrush/tst_qbrush.cpp | 21 | ||||
-rw-r--r-- | tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 20 | ||||
-rw-r--r-- | tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 63 |
3 files changed, 78 insertions, 26 deletions
diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp index 9098bb0f6e..cd3eaa1478 100644 --- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp +++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp @@ -58,6 +58,7 @@ private slots: void testQGradientCopyConstructor(); void gradientStops(); + void gradientPresets(); void textures(); @@ -326,6 +327,26 @@ void tst_QBrush::gradientStops() QCOMPARE(gradient.stops().at(0).second, QColor()); } +void tst_QBrush::gradientPresets() +{ + QGradient gradient(QGradient::WarmFlame); + QCOMPARE(gradient.type(), QGradient::LinearGradient); + QCOMPARE(gradient.coordinateMode(), QGradient::ObjectMode); + + QLinearGradient *lg = static_cast<QLinearGradient *>(&gradient); + QCOMPARE(lg->start(), QPointF(0, 1)); + QCOMPARE(lg->finalStop(), QPointF(1, 0)); + + QCOMPARE(lg->stops().size(), 3); + QCOMPARE(lg->stops().at(0), QGradientStop(0, QColor(QLatin1Literal("#ff9a9e")))); + QCOMPARE(lg->stops().at(1), QGradientStop(0.99, QColor(QLatin1Literal("#fad0c4")))); + QCOMPARE(lg->stops().at(2), QGradientStop(1, QColor(QLatin1Literal("#fad0c4")))); + + + QGradient invalidPreset(QGradient::Preset(-1)); + QCOMPARE(invalidPreset.type(), QGradient::NoGradient); +} + void fill(QPaintDevice *pd) { QPainter p(pd); diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 67d30d7c9a..ece7a30830 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -1492,10 +1492,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; diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 181c609c6e..9bf9e99bf9 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -31,9 +31,9 @@ #include <qpainter.h> #ifndef QT_NO_WIDGETS #include <qdrawutil.h> -#include <qapplication.h> #include <qwidget.h> #endif +#include <qguiapplication.h> #include <qfontmetrics.h> #include <qbitmap.h> #include <qimage.h> @@ -41,26 +41,18 @@ #include <limits.h> #include <math.h> #include <qpaintengine.h> -#ifndef QT_NO_WIDGETS -#include <qdesktopwidget.h> -#endif #include <qpixmap.h> #include <qrandom.h> #include <private/qdrawhelper_p.h> #include <qpainter.h> - -#ifndef QT_NO_WIDGETS -#include <qlabel.h> -#endif - #include <qqueue.h> +#include <qscreen.h> #ifndef QT_NO_WIDGETS #include <qgraphicsview.h> #include <qgraphicsscene.h> #include <qgraphicsproxywidget.h> -#include <qlayout.h> #endif #include <qfontdatabase.h> @@ -404,7 +396,7 @@ void tst_QPainter::cleanupTestCase() #ifndef QT_NO_WIDGETS void tst_QPainter::drawPixmap_comp_data() { - if (qApp->desktop()->depth() < 24) + if (QGuiApplication::primaryScreen()->depth() < 24) QSKIP("Test only works on 32 bit displays"); QTest::addColumn<uint>("dest"); @@ -1099,6 +1091,7 @@ void tst_QPainter::fillRect_data() QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied; QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied; + QTest::newRow("rgba64pm") << QImage::Format_RGBA64_Premultiplied; } void tst_QPainter::fillRect() @@ -2451,6 +2444,24 @@ void tst_QPainter::setOpacity_data() QTest::newRow("A2RGB30P on RGB30") << QImage::Format_RGB30 << QImage::Format_A2RGB30_Premultiplied; + QTest::newRow("RGBA64P on RGBA64P") << QImage::Format_RGBA64_Premultiplied + << QImage::Format_RGBA64_Premultiplied; + + QTest::newRow("RGBA64 on RGBA64") << QImage::Format_RGBA64 + << QImage::Format_RGBA64; + + QTest::newRow("RGBx64 on RGBx64") << QImage::Format_RGBX64 + << QImage::Format_RGBX64; + + QTest::newRow("RGBA64P on ARGB32P") << QImage::Format_ARGB32_Premultiplied + << QImage::Format_RGBA64_Premultiplied; + + QTest::newRow("RGBx64 on ARGB32P") << QImage::Format_ARGB32_Premultiplied + << QImage::Format_RGBX64; + + QTest::newRow("ARGB32P on RGBA64P") << QImage::Format_RGBA64_Premultiplied + << QImage::Format_ARGB32_Premultiplied; + } void tst_QPainter::setOpacity() @@ -3855,6 +3866,8 @@ void tst_QPainter::gradientPixelFormat_data() QTest::newRow("rgbx8888") << QImage::Format_RGBX8888; QTest::newRow("rgba8888") << QImage::Format_RGBA8888; QTest::newRow("rgba8888_pm") << QImage::Format_RGBA8888_Premultiplied; + QTest::newRow("rgbx64") << QImage::Format_RGBX64; + QTest::newRow("rgba64_pm") << QImage::Format_RGBA64_Premultiplied; } void tst_QPainter::gradientPixelFormat() @@ -4792,7 +4805,19 @@ void tst_QPainter::blendARGBonRGB_data() << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 255 ; QTest::newRow("ARGB_PM source-in ARGB32") << QImage::Format_ARGB32 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 255; - // Only ARGB does inverse premultiply, on the rest over and source gives similar results: + 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; + // Only ARGB32 and RGBA8888 does inverse premultiply, on the rest over and source gives similar results: QTest::newRow("ARGB over RGB32") << QImage::Format_RGB32 << QImage::Format_ARGB32 << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 127; QTest::newRow("ARGB_PM over RGB32") << QImage::Format_RGB32 << QImage::Format_ARGB32_Premultiplied @@ -4829,18 +4854,6 @@ 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 @@ -5011,7 +5024,7 @@ void tst_QPainter::drawPolyline_data() { QTest::addColumn< QVector<QPointF> >("points"); - QTest::newRow("basic") << (QVector<QPointF>() << QPointF(10, 10) << QPointF(20, 10) << QPointF(20, 20) << QPointF(10, 20)); + QTest::newRow("basic") << (QVector<QPointF>() << QPointF(10, 10) << QPointF(20, 10) << QPointF(20, 20)); QTest::newRow("clipped") << (QVector<QPointF>() << QPoint(-10, 100) << QPoint(-1, 100) << QPoint(-1, -2) << QPoint(100, -2) << QPoint(100, 40)); // QTBUG-31579 QTest::newRow("shortsegment") << (QVector<QPointF>() << QPoint(20, 100) << QPoint(20, 99) << QPoint(21, 99) << QPoint(21, 104)); // QTBUG-42398 QTest::newRow("edge") << (QVector<QPointF>() << QPointF(4.5, 121.6) << QPointF(9.4, 150.9) << QPointF(14.2, 184.8) << QPointF(19.1, 130.4)); |