summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-04-27 21:36:32 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-04-27 21:36:32 +0200
commit1c8451bdbbd6ca909dfc5b96a24be909810522fc (patch)
tree9cc69a4794e23f7224d75fc2323fc70e294a9454 /tests/auto/gui
parent7ebec0fa848de299d4cdee06ccc611ee46494fbf (diff)
parent0635b1a69dd666f5eed4b096895bd80b1a9420ff (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/tools/qdoc/tree.cpp tests/auto/gui/painting/qcolor/tst_qcolor.cpp Change-Id: Iaa78f601a63191fa643aabf853520f913f2f0fdc
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp51
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp19
2 files changed, 70 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 525d5b33a0..5691a654d7 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -155,6 +155,9 @@ private slots:
void inplaceMirrored_data();
void inplaceMirrored();
+ void inplaceMirroredOdd_data();
+ void inplaceMirroredOdd();
+
void inplaceRgbMirrored();
void inplaceConversion_data();
@@ -2471,6 +2474,54 @@ void tst_QImage::inplaceMirrored()
#endif
}
+void tst_QImage::inplaceMirroredOdd_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+ QTest::addColumn<bool>("swap_vertical");
+ QTest::addColumn<bool>("swap_horizontal");
+
+ QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false;
+ QTest::newRow("Format_RGB888, vertical") << QImage::Format_RGB888 << true << false;
+ QTest::newRow("Format_RGB16, vertical") << QImage::Format_RGB16 << true << false;
+
+ QTest::newRow("Format_ARGB32, horizontal") << QImage::Format_ARGB32 << false << true;
+ QTest::newRow("Format_RGB888, horizontal") << QImage::Format_RGB888 << false << true;
+ QTest::newRow("Format_RGB16, horizontal") << QImage::Format_RGB16 << false << true;
+
+ QTest::newRow("Format_ARGB32, horizontal+vertical") << QImage::Format_ARGB32 << true << true;
+ QTest::newRow("Format_RGB888, horizontal+vertical") << QImage::Format_RGB888 << true << true;
+ QTest::newRow("Format_RGB16, horizontal+vertical") << QImage::Format_RGB16 << true << true;
+}
+
+void tst_QImage::inplaceMirroredOdd()
+{
+#if defined(Q_COMPILER_REF_QUALIFIERS)
+ QFETCH(QImage::Format, format);
+ QFETCH(bool, swap_vertical);
+ QFETCH(bool, swap_horizontal);
+
+ QImage image(15, 15, format);
+
+ for (int i = 0; i < image.height(); ++i)
+ for (int j = 0; j < image.width(); ++j)
+ image.setPixel(j, i, qRgb(j*16, i*16, 0));
+
+ const uchar* originalPtr = image.constScanLine(0);
+
+ QImage imageMirrored = std::move(image).mirrored(swap_horizontal, swap_vertical);
+ for (int i = 0; i < imageMirrored.height(); ++i) {
+ int mirroredI = swap_vertical ? (imageMirrored.height() - i - 1) : i;
+ for (int j = 0; j < imageMirrored.width(); ++j) {
+ int mirroredJ = swap_horizontal ? (imageMirrored.width() - j - 1) : j;
+ QRgb mirroredColor = imageMirrored.pixel(mirroredJ, mirroredI);
+ QCOMPARE(qRed(mirroredColor) & 0xF8, j * 16);
+ QCOMPARE(qGreen(mirroredColor) & 0xF8, i * 16);
+ }
+ }
+ QCOMPARE(imageMirrored.constScanLine(0), originalPtr);
+#endif
+}
+
void tst_QImage::inplaceRgbMirrored()
{
#if defined(Q_COMPILER_REF_QUALIFIERS)
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index ca9f6cb9f4..cf0d82f3f7 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -38,6 +38,7 @@
#include <qcolor.h>
#include <qdebug.h>
+#include <private/qdrawingprimitive_sse2_p.h>
#include <qrgba64.h>
class tst_QColor : public QObject
@@ -104,6 +105,7 @@ private slots:
void achromaticHslHue();
void premultiply();
+ void unpremultiply_sse4();
void qrgba64();
void qrgba64Premultiply();
void qrgba64Equivalence();
@@ -1449,6 +1451,23 @@ void tst_QColor::premultiply()
}
}
+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)) {
+ 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));
+ }
+ }
+ return;
+ }
+#endif
+ QSKIP("SSE4 not supported on this CPU.");
+}
+
void tst_QColor::qrgba64()
{
QRgba64 rgb64 = QRgba64::fromRgba(0x22, 0x33, 0x44, 0xff);