summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAnders Bakken <anders.bakken@nokia.com>2009-09-08 17:20:36 (GMT)
committerAnders Bakken <anders.bakken@nokia.com>2009-09-08 22:27:54 (GMT)
commitf52dc5bf1e885c9a4d226c2484249e7d9faf0a99 (patch)
tree3c60cc5df64190936848824eb5e5f9b9fb506d98 /src
parentd0b29a5238def992bf7946d5c3eb36129b0cc44b (diff)
downloadQt-f52dc5bf1e885c9a4d226c2484249e7d9faf0a99.zip
Qt-f52dc5bf1e885c9a4d226c2484249e7d9faf0a99.tar.gz
Qt-f52dc5bf1e885c9a4d226c2484249e7d9faf0a99.tar.bz2
Fix QDirectFBPixmapData::fromImage
This fix should optimize pixmap loading on most platforms and also fixes a bug on a certain hardware where the alpha channel of an image was not retained upon loading it. This patch also takes care of handling dithering better in QDirectFBPixmapData::fromImage(). Reviewed-by: Donald Carr <donald.carr@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
index 6550683..f88055e 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
@@ -330,17 +330,17 @@ bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescripti
#endif
-void QDirectFBPixmapData::fromImage(const QImage &image,
+void QDirectFBPixmapData::fromImage(const QImage &img,
Qt::ImageConversionFlags flags)
{
- if (image.depth() == 1) {
- fromImage(image.convertToFormat(screen->alphaPixmapFormat()), flags);
+ if (img.depth() == 1) {
+ fromImage(img.convertToFormat(screen->alphaPixmapFormat()), flags);
return;
}
- if (image.hasAlphaChannel()
+ if (img.hasAlphaChannel()
#ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION
- && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(image))
+ && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img))
#endif
) {
alpha = true;
@@ -349,13 +349,37 @@ void QDirectFBPixmapData::fromImage(const QImage &image,
alpha = false;
imageFormat = screen->pixelFormat();
}
+ QImage image;
+ if (flags != Qt::AutoColor) {
+ image = img.convertToFormat(imageFormat, flags);
+ flags = Qt::AutoColor;
+ } else {
+ image = img;
+ }
+
+ IDirectFBSurface *imageSurface = screen->createDFBSurface(image, image.format(), QDirectFBScreen::DontTrackSurface);
+ if (!imageSurface) {
+ qWarning("QDirectFBPixmapData::fromImage()");
+ invalidate();
+ return;
+ }
- dfbSurface = screen->createDFBSurface(image, imageFormat, QDirectFBScreen::TrackSurface|QDirectFBScreen::NoPreallocated);
+ dfbSurface = screen->createDFBSurface(image.size(), imageFormat, QDirectFBScreen::TrackSurface);
if (!dfbSurface) {
qWarning("QDirectFBPixmapData::fromImage()");
invalidate();
return;
}
+
+ if (image.hasAlphaChannel()) {
+ dfbSurface->Clear(dfbSurface, 0, 0, 0, 0);
+ dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_BLEND_ALPHACHANNEL);
+ } else {
+ dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
+ }
+ dfbSurface->Blit(dfbSurface, imageSurface, 0, 0, 0);
+ imageSurface->Release(imageSurface);
+
w = image.width();
h = image.height();
is_null = (w <= 0 || h <= 0);