diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-06-15 15:27:55 (GMT) |
---|---|---|
committer | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2011-06-16 08:15:03 (GMT) |
commit | 6afe7a233e66f0cae803590d536b4d379b7c1625 (patch) | |
tree | 9885124e37367b7fb2ec967db3c4c4fbdfdcab07 /src/gui/painting | |
parent | 5e35452ad8420886f54df89d19205acb88ebb363 (diff) | |
download | Qt-6afe7a233e66f0cae803590d536b4d379b7c1625.zip Qt-6afe7a233e66f0cae803590d536b4d379b7c1625.tar.gz Qt-6afe7a233e66f0cae803590d536b4d379b7c1625.tar.bz2 |
Handle QVolatileImage-backed pixmaps optimally in drawPixmap().
When drawing such pixmaps (used by both the openvg and opengl graphics
systems) onto another pixmap or to a QImage, the performance was
sub-optimal due to missing and accidentally disabled support
specific to QVolatileImage. This is now fixed and drawing pixmaps into
a QImage is also made optimal by using the QS60PaintEngine for
QImage too. This will cause a 5-7x (or even up to 12x on certain
hardware and platform) increase in offscreen pixmap drawing
performance.
Task-number: QTBUG-19880
Reviewed-by: Jani Hautakangas
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qpaintengine_s60.cpp | 30 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_s60_p.h | 2 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/gui/painting/qpaintengine_s60.cpp b/src/gui/painting/qpaintengine_s60.cpp index 091e2e6..fd7bea2 100644 --- a/src/gui/painting/qpaintengine_s60.cpp +++ b/src/gui/painting/qpaintengine_s60.cpp @@ -60,7 +60,7 @@ bool QS60PaintEngine::begin(QPaintDevice *device) { Q_D(QS60PaintEngine); - if (pixmapData->classId() == QPixmapData::RasterClass) { + if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { pixmapData->beginDataAccess(); bool ret = QRasterPaintEngine::begin(device); // Make sure QPaintEngine::paintDevice() returns the proper device. @@ -69,13 +69,12 @@ bool QS60PaintEngine::begin(QPaintDevice *device) d->pdev = device; return ret; } - return QRasterPaintEngine::begin(device); } bool QS60PaintEngine::end() { - if (pixmapData->classId() == QPixmapData::RasterClass) { + if (pixmapData && pixmapData->classId() == QPixmapData::RasterClass) { bool ret = QRasterPaintEngine::end(); pixmapData->endDataAccess(); return ret; @@ -91,12 +90,14 @@ void QS60PaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) QRasterPaintEngine::drawPixmap(p, pm); srcData->endDataAccess(); } else { - void *nativeData = pm.pixmapData()->toNativeType(QPixmapData::VolatileImage); - if (nativeData) { - QVolatileImage *img = static_cast<QVolatileImage *>(nativeData); - img->beginDataAccess(); - QRasterPaintEngine::drawImage(p, img->imageRef()); - img->endDataAccess(true); + QVolatileImage img = pm.pixmapData()->toVolatileImage(); + if (!img.isNull()) { + img.beginDataAccess(); + // imageRef() would detach and since we received the QVolatileImage + // from toVolatileImage() by value, it would cause a copy which + // would ruin our goal. So use constImageRef() instead. + QRasterPaintEngine::drawImage(p, img.constImageRef()); + img.endDataAccess(true); } else { QRasterPaintEngine::drawPixmap(p, pm); } @@ -111,12 +112,11 @@ void QS60PaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRect QRasterPaintEngine::drawPixmap(r, pm, sr); srcData->endDataAccess(); } else { - void *nativeData = pm.pixmapData()->toNativeType(QPixmapData::VolatileImage); - if (nativeData) { - QVolatileImage *img = static_cast<QVolatileImage *>(nativeData); - img->beginDataAccess(); - QRasterPaintEngine::drawImage(r, img->imageRef(), sr); - img->endDataAccess(true); + QVolatileImage img = pm.pixmapData()->toVolatileImage(); + if (!img.isNull()) { + img.beginDataAccess(); + QRasterPaintEngine::drawImage(r, img.constImageRef(), sr); + img.endDataAccess(true); } else { QRasterPaintEngine::drawPixmap(r, pm, sr); } diff --git a/src/gui/painting/qpaintengine_s60_p.h b/src/gui/painting/qpaintengine_s60_p.h index 2a3b443..5535c24 100644 --- a/src/gui/painting/qpaintengine_s60_p.h +++ b/src/gui/painting/qpaintengine_s60_p.h @@ -65,7 +65,7 @@ class QS60PaintEngine : public QRasterPaintEngine Q_DECLARE_PRIVATE(QS60PaintEngine) public: - QS60PaintEngine(QPaintDevice *device, QS60PixmapData* data); + QS60PaintEngine(QPaintDevice *device, QS60PixmapData *data = 0); bool begin(QPaintDevice *device); bool end(); |