summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--src/gui/image/qvolatileimage.cpp5
-rw-r--r--src/gui/image/qvolatileimage_p.h1
-rw-r--r--src/openvg/qpixmapdata_vg.cpp2
-rw-r--r--src/s60installs/bwins/QtGuiu.def1
-rw-r--r--src/s60installs/eabi/QtGuiu.def1
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp46
6 files changed, 55 insertions, 1 deletions
diff --git a/src/gui/image/qvolatileimage.cpp b/src/gui/image/qvolatileimage.cpp
index 098e9a1..f5076e1 100644
--- a/src/gui/image/qvolatileimage.cpp
+++ b/src/gui/image/qvolatileimage.cpp
@@ -103,6 +103,11 @@ QVolatileImage &QVolatileImage::operator=(const QVolatileImage &rhs)
return *this;
}
+bool QVolatileImage::paintingActive() const
+{
+ return d->pengine && d->pengine->isActive();
+}
+
bool QVolatileImage::isNull() const
{
return d->image.isNull();
diff --git a/src/gui/image/qvolatileimage_p.h b/src/gui/image/qvolatileimage_p.h
index fc5d6b1..d835f45 100644
--- a/src/gui/image/qvolatileimage_p.h
+++ b/src/gui/image/qvolatileimage_p.h
@@ -71,6 +71,7 @@ public:
~QVolatileImage();
QVolatileImage &operator=(const QVolatileImage &rhs);
+ bool paintingActive() const;
bool isNull() const;
QImage::Format format() const;
int width() const;
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index 80f5b2f..eae10c8 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -377,7 +377,7 @@ VGImage QVGPixmapData::toVGImage()
QVGImagePool::instance()->useImage(this);
}
- if (!source.isNull() && recreate) {
+ if (!source.isNull() && (recreate || source.paintingActive())) {
source.beginDataAccess();
vgImageSubData
(vgImage,
diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def
index 26a0761..45a8d7b 100644
--- a/src/s60installs/bwins/QtGuiu.def
+++ b/src/s60installs/bwins/QtGuiu.def
@@ -12981,4 +12981,5 @@ EXPORTS
?depth@QVolatileImage@@QBEHXZ @ 12980 NONAME ; int QVolatileImage::depth(void) const
?releaseCachedResources@QGraphicsSystem@@UAEXXZ @ 12981 NONAME ; void QGraphicsSystem::releaseCachedResources(void)
?qt_s60_setPartialScreenInputMode@@YAX_N@Z @ 12982 NONAME ; void qt_s60_setPartialScreenInputMode(bool)
+ ?paintingActive@QVolatileImage@@QBE_NXZ @ 12983 NONAME ; bool QVolatileImage::paintingActive(void) const
diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def
index b6a24ab..82ded24 100644
--- a/src/s60installs/eabi/QtGuiu.def
+++ b/src/s60installs/eabi/QtGuiu.def
@@ -12182,4 +12182,5 @@ EXPORTS
_ZNK14QVolatileImage9constBitsEv @ 12181 NONAME
_ZN15QGraphicsSystem22releaseCachedResourcesEv @ 12182 NONAME
_Z32qt_s60_setPartialScreenInputModeb @ 12183 NONAME
+ _ZNK14QVolatileImage14paintingActiveEv @ 12184 NONAME
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"