summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/image
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-12-14 12:49:36 +0100
committerTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-12-17 01:11:57 +0000
commitd290424f2aad53eec5a94909703d988009fde973 (patch)
tree934d4828404efd8d0e3d6a1a288caac2ee974fda /tests/auto/gui/image
parent3e892e4a972446d17afde178a7b17482ecaced33 (diff)
NEON optimized bilinear sampling
Adds NEON version of interpolate_4_pixels used by smooth upscaling, and bilinear sampling. The SSE2 version is reordered to match the NEON version so they have the same order of operations and a faster version that loads directly into vector registers. Testing is extended so we have a test of smoothness that can catch more possible mistakes. Change-Id: I0de4aecf5cb79468e7c8f19f421aa24b2955547c Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'tests/auto/gui/image')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 26b812715d..1c3e3ade39 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -112,6 +112,7 @@ private slots:
void smoothScale2_data();
void smoothScale2();
void smoothScale3();
+ void smoothScale4();
void smoothScaleBig();
void smoothScaleAlpha();
@@ -1677,6 +1678,30 @@ void tst_QImage::smoothScale2()
QCOMPARE(qBlue(pixel), qBlue(expected));
}
+ // scale x up
+ scaled = img.scaled(QSize(size, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = scaled.pixel(x, y);
+ QCOMPARE(qAlpha(pixel), qAlpha(expected));
+ QCOMPARE(qRed(pixel), qRed(expected));
+ QCOMPARE(qGreen(pixel), qGreen(expected));
+ QCOMPARE(qBlue(pixel), qBlue(expected));
+ }
+ }
+
+ // scale y up
+ scaled = img.scaled(QSize(size * 2, size), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = scaled.pixel(x, y);
+ QCOMPARE(qAlpha(pixel), qAlpha(expected));
+ QCOMPARE(qRed(pixel), qRed(expected));
+ QCOMPARE(qGreen(pixel), qGreen(expected));
+ QCOMPARE(qBlue(pixel), qBlue(expected));
+ }
+ }
+
// scale x up, y up
scaled = img.scaled(QSize(size * 2, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
for (int y = 0; y < scaled.height(); ++y) {
@@ -1742,6 +1767,26 @@ void tst_QImage::smoothScale3()
}
}
+// Tests smooth upscale is smooth
+void tst_QImage::smoothScale4()
+{
+ QImage img(4, 4, QImage::Format_RGB32);
+ for (int y = 0; y < 4; ++y) {
+ for (int x = 0; x < 4; ++x) {
+ img.setPixel(x, y, qRgb(x * 255 / 3, y * 255 / 3, 0));
+ }
+ }
+ QImage scaled = img.scaled(37, 23, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ for (int x = 0; x < scaled.width(); ++x) {
+ if (x > 0)
+ QVERIFY(qRed(scaled.pixel(x, y)) >= qRed(scaled.pixel(x - 1, y)));
+ if (y > 0)
+ QVERIFY(qGreen(scaled.pixel(x, y)) >= qGreen(scaled.pixel(x, y - 1)));
+ }
+ }
+}
+
void tst_QImage::smoothScaleBig()
{
#if defined(Q_OS_WINCE)