summaryrefslogtreecommitdiffstats
path: root/src/openvg/qpixmapdata_vg.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-10-29 12:52:31 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-10-29 12:52:31 (GMT)
commit969750777896dc50f9f5b8043b5da3a4a161e616 (patch)
tree11e8599f5727df234be8c9ab783db47ac12f2a43 /src/openvg/qpixmapdata_vg.cpp
parentc02ef9eb331f03dbd59d2fd938c53b54f5c65cea (diff)
parent3cf35876400cb008fb25c8a3191c996af6059264 (diff)
downloadQt-969750777896dc50f9f5b8043b5da3a4a161e616.zip
Qt-969750777896dc50f9f5b8043b5da3a4a161e616.tar.gz
Qt-969750777896dc50f9f5b8043b5da3a4a161e616.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public: Play whole file in spectrum analyzer demo Do not unnecessarily reset state of spectrum demo Set SpectrumAnalyserThread parent to 0 before calling moveToThread() Avoid being killed by graphics out-of-memory monitor. Revert function renaming in QtOpenVG. Support tactile feedback in QWidgets from QS60Style Support tactile feeedback from QS60Style for QWidgets Making the buttons less finger unfriendly Readded .def file entries after a little stunt Do not crash on Symbian Temporarily remove .def file entries for a little stunt Fixed crash with QClipboard in Symbian^3 Fallback to vgWritePixels in drawPixmap.
Diffstat (limited to 'src/openvg/qpixmapdata_vg.cpp')
-rw-r--r--src/openvg/qpixmapdata_vg.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index e8ec333..509882b 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -65,6 +65,7 @@ QVGPixmapData::QVGPixmapData(PixelType type)
recreate = true;
inImagePool = false;
inLRU = false;
+ failedToAlloc = false;
#if !defined(QT_NO_EGL)
context = 0;
qt_vg_register_pixmap(this);
@@ -155,6 +156,9 @@ void QVGPixmapData::resize(int wid, int ht)
void QVGPixmapData::fromImage
(const QImage &image, Qt::ImageConversionFlags flags)
{
+ if(image.isNull())
+ return;
+
QImage img = image;
createPixmapForImage(img, flags, false);
}
@@ -203,10 +207,19 @@ void QVGPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags
else
resize(image.width(), image.height());
- if (inPlace && image.data_ptr()->convertInPlace(sourceFormat(), flags))
+ QImage::Format format = sourceFormat();
+ int d = image.depth();
+ if (d == 1 || d == 16 || d == 24 || (d == 32 && !image.hasAlphaChannel()))
+ format = QImage::Format_RGB32;
+ else if (!(flags & Qt::NoOpaqueDetection) && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels())
+ format = sourceFormat();
+ else
+ format = QImage::Format_RGB32;
+
+ if (inPlace && image.data_ptr()->convertInPlace(format, flags))
source = image;
else
- source = image.convertToFormat(sourceFormat());
+ source = image.convertToFormat(format);
recreate = true;
}
@@ -278,7 +291,7 @@ QPaintEngine* QVGPixmapData::paintEngine() const
VGImage QVGPixmapData::toVGImage()
{
- if (!isValid())
+ if (!isValid() || failedToAlloc)
return VG_INVALID_HANDLE;
#if !defined(QT_NO_EGL)
@@ -294,11 +307,13 @@ VGImage QVGPixmapData::toVGImage()
if (vgImage == VG_INVALID_HANDLE) {
vgImage = QVGImagePool::instance()->createImageForPixmap
- (VG_sARGB_8888_PRE, w, h, VG_IMAGE_QUALITY_FASTER, this);
+ (qt_vg_image_to_vg_format(source.format()), w, h, VG_IMAGE_QUALITY_FASTER, this);
// Bail out if we run out of GPU memory - try again next time.
- if (vgImage == VG_INVALID_HANDLE)
+ if (vgImage == VG_INVALID_HANDLE) {
+ failedToAlloc = true;
return VG_INVALID_HANDLE;
+ }
inImagePool = true;
} else if (inImagePool) {
@@ -309,7 +324,7 @@ VGImage QVGPixmapData::toVGImage()
vgImageSubData
(vgImage,
source.constBits(), source.bytesPerLine(),
- VG_sARGB_8888_PRE, 0, 0, w, h);
+ qt_vg_image_to_vg_format(source.format()), 0, 0, w, h);
}
recreate = false;