From e1ce31e9ecf7e773895632fcf3087369a50c04f1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 10 Mar 2011 11:22:05 +0200 Subject: Avoid image conversion in fromSymbianCFbsBitmap for certain formats. From now on the image data coming from CFbsBitmap will not be forced to RGB32 or ARGB32_Premultiplied in openvg. This allows copy-less creation and drawing of pixmaps not just from bitmaps with display mode EColor16MAP and EColor16MU, but also a few other modes, like EColor64K. Painting into such pixmaps or drawing them via the raster engine is potentially slower in such cases, which is now reflected in the fromSymbianCFbsBitmap documentation. Note that this patch has no effect on extended bitmaps (e.g. skin graphics), those must always be rasterized first regardless of the display mode. Task-number: QTBUG-18027 Reviewed-by: Jani Hautakangas --- src/gui/image/qpixmap_s60.cpp | 2 ++ src/openvg/qpaintengine_vg.cpp | 5 ++++- src/openvg/qvg_symbian.cpp | 23 ++++++++++++++++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index ca5f133..fbdebf3 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -374,6 +374,8 @@ CFbsBitmap *QPixmap::toSymbianCFbsBitmap() const To be sure that QPixmap does not modify your original instance, you should make a copy of your \c CFbsBitmap before calling this function. If the CFbsBitmap is not valid this function will return a null QPixmap. + For performance reasons it is recommended to use a \a bitmap with a display + mode of EColor16MAP or EColor16MU whenever possible. \warning This function is only available on Symbian OS. diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index f0f198f..f1b3277 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -4018,6 +4018,8 @@ VGImageFormat qt_vg_image_to_vg_format(QImage::Format format) switch (format) { case QImage::Format_MonoLSB: return VG_BW_1; + case QImage::Format_Indexed8: + return VG_sL_8; case QImage::Format_ARGB32_Premultiplied: return VG_sARGB_8888_PRE; case QImage::Format_RGB32: @@ -4028,7 +4030,8 @@ VGImageFormat qt_vg_image_to_vg_format(QImage::Format format) return VG_sRGB_565; case QImage::Format_ARGB4444_Premultiplied: return VG_sARGB_4444; - default: break; + default: + break; } return VG_sARGB_8888; // XXX } diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp index 5eb64bd..405151d 100644 --- a/src/openvg/qvg_symbian.cpp +++ b/src/openvg/qvg_symbian.cpp @@ -150,6 +150,21 @@ void QVGPixmapData::releaseNativeImageHandle() } } +static inline bool conversionLessFormat(QImage::Format format) +{ + switch (format) { + case QImage::Format_RGB16: // EColor64K + case QImage::Format_RGB32: // EColor16MU + case QImage::Format_ARGB32: // EColor16MA + case QImage::Format_ARGB32_Premultiplied: // EColor16MAP + case QImage::Format_MonoLSB: // EGray2 + case QImage::Format_Indexed8: // EGray256, EColor256 + return true; + default: + return false; + } +} + void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) { if (type == QPixmapData::SgImage && pixmap) { @@ -178,9 +193,11 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) source = QVolatileImage(bitmap); // duplicates only, if possible if (source.isNull()) return; - // Here we may need to copy if the formats do not match. - // (e.g. for display modes other than EColor16MAP and EColor16MU) - source.ensureFormat(idealFormat(&source.imageRef(), Qt::AutoColor)); + if (!conversionLessFormat(source.format())) { + // Here we may need to copy if the formats do not match. + // (e.g. for display modes other than EColor16MAP and EColor16MU) + source.ensureFormat(idealFormat(&source.imageRef(), Qt::AutoColor)); + } recreate = true; } else if (type == QPixmapData::VolatileImage && pixmap) { QVolatileImage *img = static_cast(pixmap); -- cgit v0.12