diff options
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 23 | ||||
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 24 | ||||
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 21 |
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 |