summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAnders Bakken <agbakken@gmail.com>2010-11-08 22:12:25 (GMT)
committerDonald Carr <donald.carr@nokia.com>2010-11-08 22:41:45 (GMT)
commite00af84cc9230df411981d2f3b9296b61d5d1c50 (patch)
tree463271a54eb2569bf855e5895b0e1517d8b8520a /src/plugins
parentfc5d4032c2bc9f93dc1ae9e4c8b31d4968f672cb (diff)
downloadQt-e00af84cc9230df411981d2f3b9296b61d5d1c50.zip
Qt-e00af84cc9230df411981d2f3b9296b61d5d1c50.tar.gz
Qt-e00af84cc9230df411981d2f3b9296b61d5d1c50.tar.bz2
DFB: Make sure QPixmap::hasAlpha is respected
An IDirectFBSurface can have an alpha channel for an opaque QPixmap. This change will make sure we don't blend unless QPixmap::hasAlpha returns true. Merge-request: 913 Reviewed-by: Donald Carr <donald.carr@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
index d5697e0..c16a242 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
@@ -113,7 +113,11 @@ public:
static inline int cacheCost(const QImage &img) { return img.width() * img.height() * img.depth() / 8; }
#endif
- void prepareForBlit(IDirectFBSurface *surface);
+ enum BlitFlag {
+ HasAlpha = 0x1,
+ Premultiplied = 0x2
+ };
+ void prepareForBlit(uint blitFlags);
IDirectFBSurface *surface;
@@ -617,7 +621,12 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image,
#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE
bool release;
IDirectFBSurface *imgSurface = d->getSurface(image, &release);
- d->prepareForBlit(imgSurface);
+ uint blitFlags = 0;
+ if (image.hasAlphaChannel())
+ blitFlags |= QDirectFBPaintEnginePrivate::HasAlpha;
+ if (QDirectFBScreen::isPremultiplied(image.format()))
+ blitFlags |= QDirectFBPaintEnginePrivate::Premultiplied;
+ d->prepareForBlit(blitFlags);
CLIPPED_PAINT(d->blit(r, imgSurface, sr));
if (release) {
#if (Q_DIRECTFB_VERSION >= 0x010000)
@@ -657,7 +666,13 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap,
} else {
QDirectFBPaintEnginePrivate::unlock(dfbData);
IDirectFBSurface *s = dfbData->directFBSurface();
- d->prepareForBlit(s);
+ uint blitFlags = 0;
+ if (pixmap.hasAlphaChannel())
+ blitFlags |= QDirectFBPaintEnginePrivate::HasAlpha;
+ if (QDirectFBScreen::isPremultiplied(dfbData->pixelFormat()))
+ blitFlags |= QDirectFBPaintEnginePrivate::Premultiplied;
+
+ d->prepareForBlit(blitFlags);
CLIPPED_PAINT(d->blit(r, s, sr));
}
}
@@ -1032,12 +1047,12 @@ void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints)
}
}
-void QDirectFBPaintEnginePrivate::prepareForBlit(IDirectFBSurface *s)
+void QDirectFBPaintEnginePrivate::prepareForBlit(uint flags)
{
DFBSurfaceBlittingFlags blittingFlags = DSBLIT_NOFX;
- if (QDirectFBScreen::isPremultiplied(QDirectFBScreen::getImageFormat(s)))
+ if (flags & Premultiplied)
blittingFlags |= DSBLIT_SRC_PREMULTIPLY;
- if (QDirectFBScreen::hasAlphaChannel(s))
+ if (flags & HasAlpha)
blittingFlags |= DSBLIT_BLEND_ALPHACHANNEL;
if (opacity != 255) {
blittingFlags |= DSBLIT_BLEND_COLORALPHA;
@@ -1164,7 +1179,12 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix
Q_ASSERT(data->classId() == QPixmapData::DirectFBClass);
QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data);
IDirectFBSurface *sourceSurface = dfbData->directFBSurface();
- prepareForBlit(sourceSurface);
+ uint blitFlags = 0;
+ if (dfbData->hasAlphaChannel())
+ blitFlags |= HasAlpha;
+ if (QDirectFBScreen::isPremultiplied(dfbData->pixelFormat()))
+ blitFlags |= Premultiplied;
+ prepareForBlit(blitFlags);
QDirectFBPaintEnginePrivate::unlock(dfbData);
const QSize pixmapSize = dfbData->size();
if (transform.isScaling()) {