diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-01-04 01:32:37 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2010-01-04 01:35:17 (GMT) |
commit | b0e7ef2aa62a123b51920b8f0a08af07a9cd9d09 (patch) | |
tree | 7526fb682d51d9debde7f628c666837045d6fe40 /src/openvg | |
parent | fbccab463a8bd77d66adb9f96a67037f73f0019d (diff) | |
download | Qt-b0e7ef2aa62a123b51920b8f0a08af07a9cd9d09.zip Qt-b0e7ef2aa62a123b51920b8f0a08af07a9cd9d09.tar.gz Qt-b0e7ef2aa62a123b51920b8f0a08af07a9cd9d09.tar.bz2 |
Avoid deep QImage copies in the OpenVG paint engine
Task-number: QTBUG-7015
Reviewed-by: Daniel Pope
Diffstat (limited to 'src/openvg')
-rw-r--r-- | src/openvg/qpaintengine_vg.cpp | 19 | ||||
-rw-r--r-- | src/openvg/qpixmapdata_vg.cpp | 2 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index c6ff627..117c910 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -986,6 +986,9 @@ static QImage colorizeBitmap(const QImage &image, const QColor &color) return dest; } +// defined in qpixmapdata_vg.cpp. +const uchar *qt_vg_imageBits(const QImage& image); + static VGImage toVGImage (const QImage & image, Qt::ImageConversionFlags flags = Qt::AutoColor) { @@ -1019,7 +1022,7 @@ static VGImage toVGImage break; } - const uchar *pixels = img.bits(); + const uchar *pixels = qt_vg_imageBits(img); VGImage vgImg = QVGImagePool::instance()->createPermanentImage (format, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER); @@ -1063,7 +1066,7 @@ static VGImage toVGImageSubRect break; } - const uchar *pixels = img.bits() + bpp * sr.x() + + const uchar *pixels = qt_vg_imageBits(img) + bpp * sr.x() + img.bytesPerLine() * sr.y(); VGImage vgImg = QVGImagePool::instance()->createPermanentImage @@ -1085,7 +1088,7 @@ static VGImage toVGImageWithOpacity(const QImage & image, qreal opacity) painter.drawImage(0, 0, image); painter.end(); - const uchar *pixels = img.bits(); + const uchar *pixels = qt_vg_imageBits(img); VGImage vgImg = QVGImagePool::instance()->createPermanentImage (VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER); @@ -1107,7 +1110,7 @@ static VGImage toVGImageWithOpacitySubRect painter.drawImage(QPoint(0, 0), image, sr); painter.end(); - const uchar *pixels = img.bits(); + const uchar *pixels = qt_vg_imageBits(img); VGImage vgImg = QVGImagePool::instance()->createPermanentImage (VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER); @@ -3172,15 +3175,15 @@ void QVGFontGlyphCache::cacheGlyphs if (!scaledImage.isNull()) { // Not a space character if (scaledImage.format() == QImage::Format_Indexed8) { vgImage = vgCreateImage(VG_A_8, scaledImage.width(), scaledImage.height(), VG_IMAGE_QUALITY_FASTER); - vgImageSubData(vgImage, scaledImage.bits(), scaledImage.bytesPerLine(), VG_A_8, 0, 0, scaledImage.width(), scaledImage.height()); + vgImageSubData(vgImage, qt_vg_imageBits(scaledImage), scaledImage.bytesPerLine(), VG_A_8, 0, 0, scaledImage.width(), scaledImage.height()); } else if (scaledImage.format() == QImage::Format_Mono) { QImage img = scaledImage.convertToFormat(QImage::Format_Indexed8); vgImage = vgCreateImage(VG_A_8, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER); - vgImageSubData(vgImage, img.bits(), img.bytesPerLine(), VG_A_8, 0, 0, img.width(), img.height()); + vgImageSubData(vgImage, qt_vg_imageBits(img), img.bytesPerLine(), VG_A_8, 0, 0, img.width(), img.height()); } else { QImage img = scaledImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); vgImage = vgCreateImage(VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER); - vgImageSubData(vgImage, img.bits(), img.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0, img.width(), img.height()); + vgImageSubData(vgImage, qt_vg_imageBits(img), img.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0, img.width(), img.height()); } } origin[0] = -metrics.x.toReal() + 0.5f; @@ -3647,7 +3650,7 @@ void QVGCompositionHelper::drawCursorPixmap if (vgImage == VG_INVALID_HANDLE) return; vgImageSubData - (vgImage, img.bits() + img.bytesPerLine() * (img.height() - 1), + (vgImage, qt_vg_imageBits(img) + img.bytesPerLine() * (img.height() - 1), -(img.bytesPerLine()), VG_sARGB_8888_PRE, 0, 0, img.width(), img.height()); diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index 358ec4d..7de2212 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -232,7 +232,7 @@ QPaintEngine* QVGPixmapData::paintEngine() const // This function works around QImage::bits() making a deep copy if the // QImage is not const. We force it to be const and then get the bits. // XXX: Should add a QImage::constBits() in the future to replace this. -static inline const uchar *qt_vg_imageBits(const QImage& image) +const uchar *qt_vg_imageBits(const QImage& image) { return image.bits(); } |