summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/painting/qpainter/tst_qpainter.cpp')
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp86
1 files changed, 77 insertions, 9 deletions
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 4f1213dff9..123f049e34 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -122,10 +122,15 @@ private slots:
void drawRect();
void drawRect2();
+ void fillRect_data();
void fillRect();
+ void fillRect2_data();
void fillRect2();
+ void fillRect3_data() { fillRect2_data(); }
void fillRect3();
+ void fillRect4_data() { fillRect2_data(); }
void fillRect4();
+ void fillRectNonPremul();
void drawEllipse_data();
void drawEllipse();
@@ -1079,9 +1084,19 @@ void tst_QPainter::drawRect2()
}
}
+void tst_QPainter::fillRect_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+
+ QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied;
+}
+
void tst_QPainter::fillRect()
{
- QImage image(100, 100, QImage::Format_ARGB32_Premultiplied);
+ QFETCH(QImage::Format, format);
+
+ QImage image(100, 100, format);
image.fill(QColor(0, 0, 0, 0).rgba());
QPainter p(&image);
@@ -1103,17 +1118,29 @@ void tst_QPainter::fillRect()
QRect(0, 0, 50, 100));
}
+void tst_QPainter::fillRect2_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+
+ QTest::newRow("argb32") << QImage::Format_ARGB32;
+ QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("rgba8888") << QImage::Format_RGBA8888;
+ QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied;
+}
+
void tst_QPainter::fillRect2()
{
+ QFETCH(QImage::Format, format);
+
QRgb background = 0x0;
- QImage img(1, 20, QImage::Format_ARGB32_Premultiplied);
+ QImage img(1, 20, format);
img.fill(background);
QPainter p(&img);
QRectF rect(0, 1, 1.2, 18);
- p.fillRect(rect, Qt::black);
+ p.fillRect(rect, Qt::yellow);
p.end();
@@ -1122,11 +1149,14 @@ void tst_QPainter::fillRect2()
QCOMPARE(img.pixel(0, 1), img.pixel(0, 2));
QCOMPARE(img.pixel(0, img.height() - 2), img.pixel(0, img.height() - 3));
+ QCOMPARE(img.pixel(0, 1), QColor(Qt::yellow).rgba());
}
void tst_QPainter::fillRect3()
{
- QImage img(1, 1, QImage::Format_ARGB32_Premultiplied);
+ QFETCH(QImage::Format, format);
+
+ QImage img(1, 1, format);
img.fill(QColor(Qt::black).rgba());
QPainter p(&img);
@@ -1139,7 +1169,9 @@ void tst_QPainter::fillRect3()
void tst_QPainter::fillRect4()
{
- QImage image(100, 1, QImage::Format_ARGB32_Premultiplied);
+ QFETCH(QImage::Format, format);
+
+ QImage image(100, 1, format);
image.fill(0x0);
QImage expected = image;
@@ -1157,6 +1189,24 @@ void tst_QPainter::fillRect4()
QCOMPARE(image, expected);
}
+void tst_QPainter::fillRectNonPremul()
+{
+ QImage img1(1, 1, QImage::Format_ARGB32);
+ QImage img2(1, 1, QImage::Format_RGBA8888);
+
+ QPainter p1(&img1);
+ QPainter p2(&img2);
+
+ QRectF rect(0, 0, 1, 1);
+ p1.fillRect(rect, qRgba(31, 63, 127, 127));
+ p2.fillRect(rect, qRgba(31, 63, 127, 127));
+
+ p1.end();
+ p2.end();
+
+ QCOMPARE(img1.pixel(0, 0), img2.pixel(0,0));
+}
+
void tst_QPainter::drawPath_data()
{
QTest::addColumn<QPainterPath>("path");
@@ -2265,6 +2315,27 @@ void tst_QPainter::setOpacity_data()
QTest::newRow("RGB444 on RGB444") << QImage::Format_RGB444
<< QImage::Format_RGB444;
+
+ QTest::newRow("RGBA8888P on RGBA8888P") << QImage::Format_RGBA8888_Premultiplied
+ << QImage::Format_RGBA8888_Premultiplied;
+
+ QTest::newRow("RGBA8888 on RGBA8888") << QImage::Format_RGBA8888
+ << QImage::Format_RGBA8888;
+
+ QTest::newRow("RGBx8888 on RGBx8888") << QImage::Format_RGBX8888
+ << QImage::Format_RGBX8888;
+
+ QTest::newRow("RGBA8888P on ARGB32P") << QImage::Format_RGBA8888_Premultiplied
+ << QImage::Format_ARGB32_Premultiplied;
+
+ QTest::newRow("RGBx8888 on ARGB32P") << QImage::Format_RGBX8888
+ << QImage::Format_ARGB32_Premultiplied;
+
+ QTest::newRow("ARGB32P on RGBA8888P") << QImage::Format_ARGB32_Premultiplied
+ << QImage::Format_RGBA8888_Premultiplied;
+
+ QTest::newRow("RGB32 on RGBx8888") << QImage::Format_RGB32
+ << QImage::Format_RGBX8888;
}
void tst_QPainter::setOpacity()
@@ -2490,7 +2561,7 @@ public:
}
uchar data[3];
-} Q_PACKED;
+};
void tst_QPainter::drawhelper_blend_color()
{
@@ -4373,9 +4444,6 @@ void TextDrawerThread::run()
void tst_QPainter::drawTextOutsideGuiThread()
{
- if (!QFontDatabase::supportsThreadedFontRendering())
- QSKIP("No threaded font rendering");
-
QImage referenceRendering(100, 100, QImage::Format_ARGB32_Premultiplied);
referenceRendering.fill(0);
QPainter p(&referenceRendering);