summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpixmap
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-04-27 13:02:32 (GMT)
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-04-27 13:43:31 (GMT)
commitd45ec470519d1075ebf299b74cbb846a0c7d99af (patch)
tree8c20e535f97ed669e0553e7aa2f9cb4a03965a82 /tests/auto/qpixmap
parent4a1ae3d1b4e8e032b1c978fcc7e1812e37e1f047 (diff)
downloadQt-d45ec470519d1075ebf299b74cbb846a0c7d99af.zip
Qt-d45ec470519d1075ebf299b74cbb846a0c7d99af.tar.gz
Qt-d45ec470519d1075ebf299b74cbb846a0c7d99af.tar.bz2
Upload VGImage data when drawing pixmaps that are being painted into.
When a painter is open on a pixmap's underlying QVolatileImage, it is better to upload the VGImage content every time the pixmap is drawn on the screen, in order to enable showing animations that are created by continously rendering into the same pixmap and keeping the same painter open. Task-number: QT-4002 Reviewed-by: Jason Barron
Diffstat (limited to 'tests/auto/qpixmap')
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 0b5c30b..d103cb7 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -194,6 +194,8 @@ private slots:
#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG)
void vgImageReadBack();
#endif
+
+ void drawPixmapWhilePainterOpen();
};
static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
@@ -1881,5 +1883,49 @@ void tst_QPixmap::vgImageReadBack()
}
#endif // Symbian & OpenVG
+class PixmapWidget : public QWidget
+{
+public:
+ PixmapWidget(QPixmap &pixmap) : QWidget(0), m_pixmap(pixmap)
+ {
+ resize(pixmap.width(), pixmap.height());
+ }
+
+protected:
+ void paintEvent(QPaintEvent *)
+ {
+ QPainter p(this);
+ p.drawPixmap(0, 0, m_pixmap);
+ }
+
+private:
+ QPixmap &m_pixmap;
+};
+
+void tst_QPixmap::drawPixmapWhilePainterOpen()
+{
+ int size = 100;
+ QPixmap pix(size, size);
+ pix.fill(Qt::red);
+
+ PixmapWidget w(pix);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+ QTest::qWait(1000);
+
+ QPainter p(&pix);
+ p.fillRect(0, 0, size, size, Qt::blue);
+ w.update();
+ QTest::qWait(1000);
+
+ p.fillRect(0, 0, size, size, Qt::green);
+ w.update();
+ QTest::qWait(1000);
+
+ QPixmap actual = QPixmap::grabWindow(w.effectiveWinId(), 0, 0, size, size);
+
+ QVERIFY(lenientCompare(actual, pix));
+}
+
QTEST_MAIN(tst_QPixmap)
#include "tst_qpixmap.moc"