summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2010-07-07 09:53:45 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-07-07 09:57:10 (GMT)
commit51509e8df8caf9c84312255a0dae41615fda1168 (patch)
tree8a4d7d8be5eb66c9a8ddff1ce65c9f56f31cb21f
parent03f325217ab8d896327cb8a31f07df4633e9a485 (diff)
downloadQt-51509e8df8caf9c84312255a0dae41615fda1168.zip
Qt-51509e8df8caf9c84312255a0dae41615fda1168.tar.gz
Qt-51509e8df8caf9c84312255a0dae41615fda1168.tar.bz2
Add test and fix style for the SSE2 implementation of ARGB32 conversion
The commit beba018814b35c4bd032e6b9fa948e4bac34c59a introduce conversion from ARGB32 to ARGB32_PM with SSE2. This patch add a benchmark for this type of usage, and change the name to use lowercase for SSE2 (style convention).
-rw-r--r--src/gui/image/qimage.cpp4
-rw-r--r--src/gui/image/qimage_sse2.cpp2
-rw-r--r--tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp64
3 files changed, 66 insertions, 4 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 88a0366..e5930ac 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -3735,8 +3735,8 @@ void qInitImageConversions()
#ifdef QT_HAVE_SSE2
if (features & SSE2) {
- extern bool convert_ARGB_to_ARGB_PM_inplace_SSE2(QImageData *data, Qt::ImageConversionFlags);
- inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_SSE2;
+ extern bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags);
+ inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_sse2;
}
#endif
}
diff --git a/src/gui/image/qimage_sse2.cpp b/src/gui/image/qimage_sse2.cpp
index e2b89b9..82d49a6 100644
--- a/src/gui/image/qimage_sse2.cpp
+++ b/src/gui/image/qimage_sse2.cpp
@@ -49,7 +49,7 @@
QT_BEGIN_NAMESPACE
-bool convert_ARGB_to_ARGB_PM_inplace_SSE2(QImageData *data, Qt::ImageConversionFlags)
+bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags)
{
Q_ASSERT(data->format == QImage::Format_ARGB32);
diff --git a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp
index 8e9de4a..27e5025 100644
--- a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp
@@ -40,9 +40,12 @@
****************************************************************************/
#include <qtest.h>
-#include <QPixmap>
#include <QBitmap>
+#include <QDir>
+#include <QImage>
+#include <QImageReader>
#include <QPainter>
+#include <QPixmap>
#include <private/qpixmap_raster_p.h>
class tst_QPixmap : public QObject
@@ -62,6 +65,9 @@ private slots:
void transformed();
void mask_data();
void mask();
+
+ void fromImageReader_data();
+ void fromImageReader();
};
Q_DECLARE_METATYPE(QImage::Format)
@@ -248,6 +254,62 @@ void tst_QPixmap::mask()
}
}
+void tst_QPixmap::fromImageReader_data()
+{
+ const QString tempDir = QDir::tempPath();
+ QTest::addColumn<QString>("filename");
+
+ QImage image(2000, 2000, QImage::Format_ARGB32);
+ image.fill(0);
+ {
+ // Generate an image with opaque and transparent pixels
+ // with an interesting distribution.
+ QPainter painter(&image);
+
+ QRadialGradient radialGrad(QPointF(1000, 1000), 1000);
+ radialGrad.setColorAt(0, QColor(255, 0, 0, 255));
+ radialGrad.setColorAt(0.5, QColor(0, 255, 0, 255));
+ radialGrad.setColorAt(0.9, QColor(0, 0, 255, 100));
+ radialGrad.setColorAt(1, QColor(0, 0, 0, 0));
+
+ painter.fillRect(image.rect(), radialGrad);
+ }
+ image.save("test.png");
+
+ // RGB32
+ const QString rgb32Path = tempDir + QString::fromLatin1("/rgb32.jpg");
+ image.save(rgb32Path);
+ QTest::newRow("gradient RGB32") << rgb32Path;
+
+ // ARGB32
+ const QString argb32Path = tempDir + QString::fromLatin1("/argb32.png");
+ image.save(argb32Path);
+ QTest::newRow("gradient ARGB32") << argb32Path;
+
+ // Indexed 8
+ const QString indexed8Path = tempDir + QString::fromLatin1("/indexed8.gif");
+ image.save(indexed8Path);
+ QTest::newRow("gradient indexed8") << indexed8Path;
+
+}
+
+void tst_QPixmap::fromImageReader()
+{
+ QFETCH(QString, filename);
+ // warmup
+ {
+ QImageReader imageReader(filename);
+ QPixmap::fromImageReader(&imageReader);
+ }
+
+ QBENCHMARK {
+ QImageReader imageReader(filename);
+ QPixmap::fromImageReader(&imageReader);
+ }
+ QFile::remove(filename);
+}
+
+
QTEST_MAIN(tst_QPixmap)
#include "tst_qpixmap.moc"