diff options
author | Benjamin Poulain <benjamin.poulain@nokia.com> | 2010-07-07 09:53:45 (GMT) |
---|---|---|
committer | Benjamin Poulain <benjamin.poulain@nokia.com> | 2010-07-07 09:57:10 (GMT) |
commit | 51509e8df8caf9c84312255a0dae41615fda1168 (patch) | |
tree | 8a4d7d8be5eb66c9a8ddff1ce65c9f56f31cb21f /tests/benchmarks/gui | |
parent | 03f325217ab8d896327cb8a31f07df4633e9a485 (diff) | |
download | Qt-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).
Diffstat (limited to 'tests/benchmarks/gui')
-rw-r--r-- | tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp | 64 |
1 files changed, 63 insertions, 1 deletions
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" |