summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/painting
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-01-29 12:25:06 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-02-09 11:36:49 +0000
commit38aafe1a17c5d3be81edf798dd4dbe745727f4fd (patch)
tree7e742aae377ddd5aef9d53bdcbf500721d2f43f2 /tests/auto/gui/painting
parent868201155fd677dbc6d14346f5ea61e82ebce27b (diff)
Optimize unpremultiply on SSE4.1
Adds an SSE4.1 optimized version of qUnpremultiply and uses it in the most drawing conversions methods. This gives a speed-up of little over 2x. Change-Id: Ieb858a94ada1eb86d7af715ac1a100f1587f360d Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'tests/auto/gui/painting')
-rw-r--r--tests/auto/gui/painting/qcolor/qcolor.pro2
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp32
2 files changed, 33 insertions, 1 deletions
diff --git a/tests/auto/gui/painting/qcolor/qcolor.pro b/tests/auto/gui/painting/qcolor/qcolor.pro
index f7439c243c..44d65bb50b 100644
--- a/tests/auto/gui/painting/qcolor/qcolor.pro
+++ b/tests/auto/gui/painting/qcolor/qcolor.pro
@@ -2,4 +2,4 @@ CONFIG += testcase
CONFIG += parallel_test
TARGET = tst_qcolor
SOURCES += tst_qcolor.cpp
-QT += testlib
+QT += testlib gui-private core-private
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 3b3334ba1f..95f1da1354 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>
class tst_QColor : public QObject
{
@@ -102,6 +103,9 @@ private slots:
void achromaticHslHue();
+ void premultiply();
+ void unpremultiply_sse4();
+
#ifdef Q_DEAD_CODE_FROM_QT4_X11
void setallowX11ColorNames();
#endif
@@ -1432,5 +1436,33 @@ void tst_QColor::setallowX11ColorNames()
}
#endif
+void tst_QColor::premultiply()
+{
+ // Tests that qPremultiply(qUnpremultiply(x)) returns x.
+ for (uint a = 0; a < 256; a++) {
+ for (uint c = 0; c <= a; c++) {
+ QRgb p = qRgba(c, a-c, c, a);
+ QCOMPARE(p, qPremultiply(qUnpremultiply(p)));
+ }
+ }
+}
+
+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.");
+}
+
QTEST_MAIN(tst_QColor)
#include "tst_qcolor.moc"