summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-05-18 17:03:58 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-05-26 18:00:01 +0200
commit93cd9130d6d8d30e901dd3b2f2546dbc63754e2e (patch)
tree3def7382cd1e4edd4ff380587deee775e48a2e4b /tests
parente51831260a759b58cb089cac089c202a795fc584 (diff)
Introduce float QImage formats and rendering
Useful for some HDR representations and HDR rendering. Change-Id: If6e8a661faa3d2afdf17b6ed4d8ff5c5b2aeb30e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp40
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp3
-rw-r--r--tests/auto/other/lancelot/paintcommands.cpp8
-rw-r--r--tests/auto/other/lancelot/tst_lancelot.cpp25
4 files changed, 68 insertions, 8 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index c3096bd47f..57fee0a547 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -323,6 +323,18 @@ static QLatin1String formatToString(QImage::Format format)
return QLatin1String("Grayscale16");
case QImage::Format_BGR888:
return QLatin1String("BGR888");
+ case QImage::Format_RGBX16FPx4:
+ return QLatin1String("RGBx16FPx4");
+ case QImage::Format_RGBA16FPx4:
+ return QLatin1String("RGBA16FPx4");
+ case QImage::Format_RGBA16FPx4_Premultiplied:
+ return QLatin1String("RGBA16FPx4pm");
+ case QImage::Format_RGBX32FPx4:
+ return QLatin1String("RGBx32FPx4");
+ case QImage::Format_RGBA32FPx4:
+ return QLatin1String("RGBA32FPx4");
+ case QImage::Format_RGBA32FPx4_Premultiplied:
+ return QLatin1String("RGBA32FPx4pm");
default:
break;
};
@@ -1765,7 +1777,17 @@ void tst_QImage::smoothScale2_data()
QTest::addColumn<int>("size");
int sizes[] = { 2, 3, 4, 6, 7, 8, 10, 16, 20, 32, 40, 64, 100, 101, 128, 0 };
- QImage::Format formats[] = { QImage::Format_RGB32, QImage::Format_ARGB32_Premultiplied, QImage::Format_RGBX64, QImage::Format_RGBA64_Premultiplied, QImage::Format_Invalid };
+ QImage::Format formats[] = { QImage::Format_RGB32,
+ QImage::Format_ARGB32_Premultiplied,
+#if QT_CONFIG(raster_64bit)
+ QImage::Format_RGBX64,
+ QImage::Format_RGBA64_Premultiplied,
+#endif
+#if QT_CONFIG(raster_fp)
+ QImage::Format_RGBX32FPx4,
+ QImage::Format_RGBA32FPx4_Premultiplied,
+#endif
+ QImage::Format_Invalid };
for (int j = 0; formats[j] != QImage::Format_Invalid; ++j) {
QString formatstr = formatToString(formats[j]);
for (int i = 0; sizes[i] != 0; ++i) {
@@ -1780,11 +1802,9 @@ void tst_QImage::smoothScale2()
QFETCH(QImage::Format, format);
QFETCH(int, size);
- bool opaque = (format == QImage::Format_RGB32 || format == QImage::Format_RGBX64);
-
- QRgb expected = opaque ? qRgb(63, 127, 255) : qRgba(31, 63, 127, 127);
-
QImage img(size, size, format);
+ bool opaque = !img.hasAlphaChannel();
+ QRgb expected = opaque ? qRgb(63, 127, 255) : qRgba(31, 63, 127, 127);
img.fill(expected);
// scale x down, y down
@@ -1929,6 +1949,9 @@ void tst_QImage::smoothScale4_data()
#if QT_CONFIG(raster_64bit)
QTest::newRow("RGBx64") << QImage::Format_RGBX64;
#endif
+#if QT_CONFIG(raster_fp)
+ QTest::newRow("RGBx32FP") << QImage::Format_RGBX32FPx4;
+#endif
}
void tst_QImage::smoothScale4()
@@ -2356,6 +2379,8 @@ void tst_QImage::fillColor_data()
QImage::Format_RGBA8888_Premultiplied,
QImage::Format_BGR30,
QImage::Format_A2RGB30_Premultiplied,
+ QImage::Format_RGBX16FPx4,
+ QImage::Format_RGBA32FPx4_Premultiplied,
};
for (int i=0; names[i] != 0; ++i) {
@@ -2678,7 +2703,6 @@ void tst_QImage::inplaceRgbSwapped_data()
void tst_QImage::inplaceRgbSwapped()
{
-#if defined(Q_COMPILER_REF_QUALIFIERS)
QFETCH(QImage::Format, format);
QImage image(64, 1, format);
@@ -2686,7 +2710,7 @@ void tst_QImage::inplaceRgbSwapped()
QList<QRgb> testColor(image.width());
for (int i = 0; i < image.width(); ++i)
- testColor[i] = qRgb(i * 2, i * 3, 255 - i * 4);
+ testColor[i] = qRgb(i * 2, i * 3, std::min(255 - i * 4, 0));
if (format == QImage::Format_Indexed8) {
for (int i = 0; i < image.width(); ++i) {
@@ -2739,7 +2763,6 @@ void tst_QImage::inplaceRgbSwapped()
QCOMPARE(dataSwapped, orig.rgbSwapped());
}
-#endif
}
@@ -3006,6 +3029,7 @@ void tst_QImage::inplaceRgbConversion_data()
void tst_QImage::inplaceRgbConversion()
{
+ // Test that conversions between RGB formats of the same bitwidth can be done inplace.
QFETCH(QImage::Format, format);
QFETCH(QImage::Format, dest_format);
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 30ce4fcfa8..a028990a16 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -1060,6 +1060,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;
+ QTest::newRow("rgbaFP16pm") << QImage::Format_RGBA16FPx4_Premultiplied;
}
void tst_QPainter::fillRect()
@@ -1558,6 +1559,8 @@ void tst_QPainter::qimageFormats_data()
QTest::newRow("Qimage::Format_BGR888") << QImage::Format_BGR888;
QTest::newRow("Qimage::Format_A2RGB30_Premultiplied") << QImage::Format_A2RGB30_Premultiplied;
QTest::newRow("Qimage::Format_RGB30") << QImage::Format_RGB30;
+ QTest::newRow("QImage::Format_RGBX16FPx4") << QImage::Format_RGBX16FPx4;
+ QTest::newRow("QImage::Format_RGBA32FPx4_Premultiplied") << QImage::Format_RGBA32FPx4_Premultiplied;
}
/*
diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp
index d8157f047f..9344c9a67d 100644
--- a/tests/auto/other/lancelot/paintcommands.cpp
+++ b/tests/auto/other/lancelot/paintcommands.cpp
@@ -182,6 +182,14 @@ const char *PaintCommands::imageFormatTable[] = {
"RGBx64",
"RGBA64",
"RGBA64_Premultiplied",
+ "Grayscale16",
+ "BGR888",
+ "RGBx16FPx4",
+ "RGBA16FPx4",
+ "RGBA16FPx4_Premultiplied",
+ "RGBx32FPx4",
+ "RGBA32FPx4",
+ "RGBA32FPx4_Premultiplied",
};
int PaintCommands::translateEnum(const char *table[], const QString &pattern, int limit)
diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp
index 7a85e9c370..407b14be94 100644
--- a/tests/auto/other/lancelot/tst_lancelot.cpp
+++ b/tests/auto/other/lancelot/tst_lancelot.cpp
@@ -90,6 +90,10 @@ private slots:
void testRasterGrayscale8();
void testRasterRGBA64PM_data();
void testRasterRGBA64PM();
+ void testRasterRGBA16F_data();
+ void testRasterRGBA16F();
+ void testRasterRGBA32FPM_data();
+ void testRasterRGBA32FPM();
#ifndef QT_NO_OPENGL
void testOpenGL_data();
@@ -242,6 +246,27 @@ void tst_Lancelot::testRasterRGBA64PM()
}
+void tst_Lancelot::testRasterRGBA16F_data()
+{
+ setupTestSuite();
+}
+
+void tst_Lancelot::testRasterRGBA16F()
+{
+ runTestSuite(Raster, QImage::Format_RGBA16FPx4);
+}
+
+void tst_Lancelot::testRasterRGBA32FPM_data()
+{
+ setupTestSuite();
+}
+
+void tst_Lancelot::testRasterRGBA32FPM()
+{
+ runTestSuite(Raster, QImage::Format_RGBA32FPx4_Premultiplied);
+}
+
+
#ifndef QT_NO_OPENGL
bool tst_Lancelot::checkSystemGLSupport()
{