summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@live.com>2012-12-07 22:15:49 -0600
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-11 21:24:23 +0100
commitf156e578d7f4b05f44a6e84b2173f1e69b856442 (patch)
tree9e47c7d240bc52236391c3e51c4b6c6f71124209 /tests
parent9fa5191b6eca7fc96b4720d9b892b0e2a8ff1469 (diff)
Ensure raster pixmap cache key is the same as that of pixmap.toImage()
This is done to support texture uploads in an image provider. It ensures we can load the texture using QImage in the image provider, and when it is later painted as a pixmap, the cacheKey will be identical (assuming no format conversion was required). Change-Id: I54229511ed91ce5430cc478af5aff0d96685a2da Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index 576519e2ca..e204da059d 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -114,6 +114,7 @@ private slots:
void convertFromImageNoDetach();
void convertFromImageDetach();
+ void convertFromImageCacheKey();
#if defined(Q_OS_WIN)
void toWinHBITMAP_data();
@@ -779,6 +780,28 @@ void tst_QPixmap::convertFromImageDetach()
QVERIFY(copy.isDetached());
}
+void tst_QPixmap::convertFromImageCacheKey()
+{
+ QPixmap randomPixmap(10, 10);
+ if (randomPixmap.handle()->classId() != QPlatformPixmap::RasterClass)
+ QSKIP("Test only valid for raster pixmaps");
+
+ //first get the screen format
+ QImage::Format screenFormat = randomPixmap.toImage().format();
+ QVERIFY(screenFormat != QImage::Format_Invalid);
+
+ QImage orig(100,100, screenFormat);
+ orig.fill(0);
+
+ QPixmap pix = QPixmap::fromImage(orig);
+ QImage copy = pix.toImage();
+
+ QVERIFY(copy.format() == screenFormat);
+
+ QCOMPARE(orig.cacheKey(), pix.cacheKey());
+ QCOMPARE(copy.cacheKey(), pix.cacheKey());
+}
+
#if defined(Q_OS_WIN)
QT_BEGIN_NAMESPACE