summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Bakken <anders.bakken@nokia.com>2009-04-07 05:16:13 (GMT)
committerAnders Bakken <anders.bakken@nokia.com>2009-04-07 05:16:13 (GMT)
commit6ee9fd3cdb932dd8d7a2ad6a5ac61300aefc1058 (patch)
tree5a52bc59754ab69d38effaaae52e803ba74f70ce
parent3eb0951fa7664e39c74df8edfca51c2a1199209b (diff)
downloadQt-6ee9fd3cdb932dd8d7a2ad6a5ac61300aefc1058.zip
Qt-6ee9fd3cdb932dd8d7a2ad6a5ac61300aefc1058.tar.gz
Qt-6ee9fd3cdb932dd8d7a2ad6a5ac61300aefc1058.tar.bz2
Make sure to set blitting flags
Need to set blitting flags before blitting from a surface with alpha channel. Otherwise alpha areas become white. For some reason setting the porterduff to DSPD_SRC does not fix this. Reviewed-by: TrustMe
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp23
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp24
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h21
3 files changed, 43 insertions, 25 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
index 9df3051..923025a 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
@@ -187,30 +187,13 @@ bool QDirectFBPixmapData::hasAlphaChannel() const
{
if (!serialNumber())
return false;
+ DFBSurfacePixelFormat format;
+ dfbSurface->GetPixelFormat(dfbSurface, &format);
+ return QDirectFBScreen::hasAlpha(format);
// We don't need to ask DFB for this really. Can just keep track
// of what image format this has. It should always have either
// QDirectFBScreen::alphaPixmapFormat() or QScreen::pixelFormat()
-
- DFBSurfacePixelFormat format;
- dfbSurface->GetPixelFormat(dfbSurface, &format);
- switch (format) {
- case DSPF_ARGB1555:
- case DSPF_ARGB:
- case DSPF_LUT8:
- case DSPF_AiRGB:
- case DSPF_A1:
- case DSPF_ARGB2554:
- case DSPF_ARGB4444:
- case DSPF_AYUV:
- case DSPF_A4:
- case DSPF_ARGB1666:
- case DSPF_ARGB6666:
- case DSPF_LUT2:
- return true;
- default:
- return false;
- }
}
QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index dd147cf..bbb0678 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -185,7 +185,15 @@ IDirectFBSurface *QDirectFBScreen::copyDFBSurface(IDirectFBSurface *src,
QSize size;
src->GetSize(src, &size.rwidth(), &size.rheight());
IDirectFBSurface *surface = createDFBSurface(size, format, options);
- surface->SetBlittingFlags(surface, DSBLIT_NOFX);
+ DFBSurfacePixelFormat dspf;
+ src->GetPixelFormat(src, &dspf);
+ DFBSurfaceBlittingFlags flags = QDirectFBScreen::hasAlpha(dspf)
+ ? DSBLIT_BLEND_ALPHACHANNEL
+ : DSBLIT_NOFX;
+ if (flags & DSBLIT_BLEND_ALPHACHANNEL)
+ surface->Clear(surface, 0, 0, 0, 0);
+
+ surface->SetBlittingFlags(surface, flags);
surface->Blit(surface, src, 0, 0, 0);
surface->ReleaseSource(surface); // ??? Is this always right?
return surface;
@@ -281,10 +289,16 @@ IDirectFBSurface *QDirectFBScreen::copyToDFBSurface(const QImage &img,
QDirectFBScreen::releaseDFBSurface(dfbSurface);
return 0;
}
+
Q_ASSERT(imgSurface);
- DFBResult result;
- dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- result = dfbSurface->Blit(dfbSurface, imgSurface, 0, 0, 0);
+ DFBSurfaceBlittingFlags flags = img.hasAlphaChannel()
+ ? DSBLIT_BLEND_ALPHACHANNEL
+ : DSBLIT_NOFX;
+ if (flags & DSBLIT_BLEND_ALPHACHANNEL)
+ dfbSurface->Clear(dfbSurface, 0, 0, 0, 0);
+
+ dfbSurface->SetBlittingFlags(dfbSurface, flags);
+ DFBResult result = dfbSurface->Blit(dfbSurface, imgSurface, 0, 0, 0);
if (result != DFB_OK)
DirectFBError("QDirectFBPixmapData::fromImage()", result);
dfbSurface->ReleaseSource(dfbSurface);
@@ -370,7 +384,7 @@ DFBSurfacePixelFormat QDirectFBScreen::getSurfacePixelFormat(QImage::Format form
};
}
-static inline bool isPremultiplied(IDirectFBSurface *surface)
+static inline bool isPremultiplied(IDirectFBSurface *surface)
{
Q_ASSERT(surface);
DFBSurfaceCapabilities caps;
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
index a1e93c6..f394ac1 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
@@ -119,6 +119,7 @@ public:
static QImage::Format getImageFormat(IDirectFBSurface *surface);
static bool initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description, QImage::Format format);
static inline bool isPremultiplied(QImage::Format format);
+ static inline bool hasAlpha(DFBSurfacePixelFormat format);
QImage::Format alphaPixmapFormat() const;
#ifndef QT_NO_DIRECTFB_PALETTE
@@ -151,6 +152,26 @@ inline bool QDirectFBScreen::isPremultiplied(QImage::Format format)
return false;
}
+inline bool QDirectFBScreen::hasAlpha(DFBSurfacePixelFormat format)
+{
+ switch (format) {
+ case DSPF_ARGB1555:
+ case DSPF_ARGB:
+ case DSPF_LUT8:
+ case DSPF_AiRGB:
+ case DSPF_A1:
+ case DSPF_ARGB2554:
+ case DSPF_ARGB4444:
+ case DSPF_AYUV:
+ case DSPF_A4:
+ case DSPF_ARGB1666:
+ case DSPF_ARGB6666:
+ case DSPF_LUT2:
+ return true;
+ default:
+ return false;
+ }
+}
QT_END_HEADER