summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2010-06-19 19:56:29 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-06-20 02:30:33 (GMT)
commit0a96503e84b418708712af61497df4a493ed9072 (patch)
treea1b29c6416f0896a3c9fee394c7858a0ec744713 /tests
parentcf5971503ee1f7a5ce96758e33796dfdf48375bf (diff)
downloadQt-0a96503e84b418708712af61497df4a493ed9072.zip
Qt-0a96503e84b418708712af61497df4a493ed9072.tar.gz
Qt-0a96503e84b418708712af61497df4a493ed9072.tar.bz2
Start the implementation of in-place recoding for images
Currently, with the graphics system raster, converting from images to QPixmap often needs to allocate a new image to convert the right format. For example, for an image in ARGB32 of 10 mbytes, we need to allocate a second image of 10 mbytes in ARGB32_PM to convert the source image in the right format for pixmap. This can create a hight peak of memory, and is a bit slower than it should. This patch introduce in-place conversion of images when they are loaded with QPixmap::loadFromData(). The images are loaded in their default format by QImageReader, and are then converted in-place, trying to reduce memory allocations. Reviewed-by: Samuel Rødal
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qpixmap/loadFromData/designer_argb32.pngbin0 -> 4189 bytes
-rw-r--r--tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha.gifbin0 -> 3317 bytes
-rw-r--r--tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha.pngbin0 -> 2431 bytes
-rw-r--r--tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha.gifbin0 -> 2086 bytes
-rw-r--r--tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha.pngbin0 -> 1405 bytes
-rw-r--r--tests/auto/qpixmap/loadFromData/designer_rgb32.jpgbin0 -> 11810 bytes
-rw-r--r--tests/auto/qpixmap/loadFromData/designer_rgb32.pngbin0 -> 4282 bytes
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp37
8 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qpixmap/loadFromData/designer_argb32.png b/tests/auto/qpixmap/loadFromData/designer_argb32.png
new file mode 100644
index 0000000..55d8247
--- /dev/null
+++ b/tests/auto/qpixmap/loadFromData/designer_argb32.png
Binary files differ
diff --git a/tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha.gif b/tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha.gif
new file mode 100644
index 0000000..26a6da3
--- /dev/null
+++ b/tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha.gif
Binary files differ
diff --git a/tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha.png b/tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha.png
new file mode 100644
index 0000000..28cd2f0
--- /dev/null
+++ b/tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha.png
Binary files differ
diff --git a/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha.gif b/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha.gif
new file mode 100644
index 0000000..49ec77b
--- /dev/null
+++ b/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha.gif
Binary files differ
diff --git a/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha.png b/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha.png
new file mode 100644
index 0000000..09735a9
--- /dev/null
+++ b/tests/auto/qpixmap/loadFromData/designer_indexed8_with_alpha.png
Binary files differ
diff --git a/tests/auto/qpixmap/loadFromData/designer_rgb32.jpg b/tests/auto/qpixmap/loadFromData/designer_rgb32.jpg
new file mode 100644
index 0000000..70f39c2
--- /dev/null
+++ b/tests/auto/qpixmap/loadFromData/designer_rgb32.jpg
Binary files differ
diff --git a/tests/auto/qpixmap/loadFromData/designer_rgb32.png b/tests/auto/qpixmap/loadFromData/designer_rgb32.png
new file mode 100644
index 0000000..bca471d
--- /dev/null
+++ b/tests/auto/qpixmap/loadFromData/designer_rgb32.png
Binary files differ
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 49b1e52..179f068 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -172,6 +172,9 @@ private slots:
void fromData();
void loadFromDataNullValues();
+ void loadFromDataImage_data();
+ void loadFromDataImage();
+
void preserveDepth();
void splash_crash();
@@ -1540,6 +1543,40 @@ void tst_QPixmap::loadFromDataNullValues()
}
}
+void tst_QPixmap::loadFromDataImage_data()
+{
+ QTest::addColumn<QString>("imagePath");
+#ifdef Q_OS_SYMBIAN
+ const QString prefix = QLatin1String(SRCDIR) + "loadFromData";
+#else
+ const QString prefix = QLatin1String(SRCDIR) + "/loadFromData";
+#endif
+ QTest::newRow("designer_argb32.png") << prefix + "/designer_argb32.png";
+ QTest::newRow("designer_indexed8_no_alpha.png") << prefix + "/designer_indexed8_no_alpha.png";
+ QTest::newRow("designer_indexed8_with_alpha.png") << prefix + "/designer_indexed8_with_alpha.png";
+ QTest::newRow("designer_rgb32.png") << prefix + "/designer_rgb32.png";
+ QTest::newRow("designer_indexed8_no_alpha.gif") << prefix + "/designer_indexed8_no_alpha.gif";
+ QTest::newRow("designer_indexed8_with_alpha.gif") << prefix + "/designer_indexed8_with_alpha.gif";
+ QTest::newRow("designer_rgb32.jpg") << prefix + "/designer_rgb32.jpg";
+}
+
+void tst_QPixmap::loadFromDataImage()
+{
+ QFETCH(QString, imagePath);
+
+ QImage imageRef(imagePath);
+ QPixmap pixmapWithCopy = QPixmap::fromImage(imageRef);
+
+ QFile file(imagePath);
+ file.open(QIODevice::ReadOnly);
+ QByteArray rawData = file.readAll();
+
+ QPixmap directLoadingPixmap;
+ directLoadingPixmap.loadFromData(rawData);
+
+ QVERIFY(pixmapsAreEqual(&pixmapWithCopy, &directLoadingPixmap));
+}
+
void tst_QPixmap::task_246446()
{
// This crashed without the bugfix in 246446