summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2010-07-23 14:14:49 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-07-26 10:40:00 (GMT)
commit90642dd2b6b14c39cc6178f1161331895809b342 (patch)
tree47cebd733363e9f8560cb2f9909f816dbe8a1def /tests/auto
parent38d8826503385f249cfd4d35382a79252de85873 (diff)
downloadQt-90642dd2b6b14c39cc6178f1161331895809b342.zip
Qt-90642dd2b6b14c39cc6178f1161331895809b342.tar.gz
Qt-90642dd2b6b14c39cc6178f1161331895809b342.tar.bz2
Use SSSE3 to convert from RGB888 to RGB32
Converting from RGB encoded on 24bits to RGB encoded on 32 bits is quite inefficient. This type of conversion is common for some image format. The patch implement the conversion with SSSE3. This reduce by 3 the number of instructions, pushing the bottleneck to memory bandwidth. On Atom N450, the new benchmark is 40% faster for scanlines of 2000 pixels, 30% faster for scanlines of 32 pixels, and 15% slower for small images (3 and 8px). Reviewed-by: Olivier Goffart
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qimage/tst_qimage.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index 5052114..1330d96 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -83,6 +83,8 @@ private slots:
void convertToFormat_data();
void convertToFormat();
+ void convertToFormatRgb888ToRGB32();
+
void createAlphaMask_data();
void createAlphaMask();
#ifndef QT_NO_IMAGE_HEURISTIC_MASK
@@ -799,6 +801,26 @@ void tst_QImage::convertToFormat()
QFile::remove(QLatin1String("expected2.xpm"));
}
+void tst_QImage::convertToFormatRgb888ToRGB32()
+{
+ // 545 so width % 4 != 0. This ensure there is padding at the end of the scanlines
+ const int height = 545;
+ const int width = 545;
+ QImage source(width, height, QImage::Format_RGB888);
+ for (int y = 0; y < height; ++y) {
+ uchar *srcPixels = source.scanLine(y);
+ for (int x = 0; x < width * 3; ++x)
+ srcPixels[x] = x;
+ }
+
+ QImage rgb32Image = source.convertToFormat(QImage::Format_RGB888);
+ QCOMPARE(rgb32Image.format(), QImage::Format_RGB888);
+ for (int x = 0; x < width; ++x) {
+ for (int y = 0; y < height; ++y)
+ QCOMPARE(rgb32Image.pixel(x, y), source.pixel(x, y));
+ }
+}
+
void tst_QImage::createAlphaMask_data()
{
QTest::addColumn<int>("x");