summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorJulien Brianceau <jbrianceau@nds.com>2012-09-11 14:30:11 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-09-12 05:42:25 (GMT)
commit3dc047a4e11d2b18259d3ee383e81147c9098cb7 (patch)
treec1ad99346019a1c1baf844f0f50e03251729798f /src/plugins/platforms
parent6c564607770479173967b9a74926cbe1c4bc109e (diff)
downloadQt-3dc047a4e11d2b18259d3ee383e81147c9098cb7.zip
Qt-3dc047a4e11d2b18259d3ee383e81147c9098cb7.tar.gz
Qt-3dc047a4e11d2b18259d3ee383e81147c9098cb7.tar.bz2
qpa: add non-opaque fill support
Add non-opaque fill support for qpa through new QBlittable flag "AlphaFillRectCapability" and add related implementation in DirectFB qpa platform. cherry-picked from qt5/qtbase aab15782e21bf0aaea7f2211278e9aa9fc78c6d7 Change-Id: Ia1c74c2926d2e244290dcb62cbd3b6848ba95707 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/directfb/qdirectfbblitter.cpp62
-rw-r--r--src/plugins/platforms/directfb/qdirectfbblitter.h4
2 files changed, 54 insertions, 12 deletions
diff --git a/src/plugins/platforms/directfb/qdirectfbblitter.cpp b/src/plugins/platforms/directfb/qdirectfbblitter.cpp
index f69d47e..efbfc77 100644
--- a/src/plugins/platforms/directfb/qdirectfbblitter.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbblitter.cpp
@@ -56,7 +56,8 @@ static QBlittable::Capabilities dfb_blitter_capabilities()
return QBlittable::Capabilities(QBlittable::SolidRectCapability
|QBlittable::SourcePixmapCapability
|QBlittable::SourceOverPixmapCapability
- |QBlittable::SourceOverScaledPixmapCapability);
+ |QBlittable::SourceOverScaledPixmapCapability
+ |QBlittable::AlphaFillRectCapability);
}
QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, IDirectFBSurface *surface)
@@ -64,17 +65,25 @@ QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, IDirectFBSurface *surface)
, m_surface(surface)
{
m_surface->AddRef(m_surface.data());
+
+ DFBSurfaceCapabilities surfaceCaps;
+ m_surface->GetCapabilities(m_surface.data(), &surfaceCaps);
+ m_premult = (surfaceCaps & DSCAPS_PREMULTIPLIED);
}
QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, bool alpha)
- : QBlittable(rect, dfb_blitter_capabilities())
+ : QBlittable(rect, dfb_blitter_capabilities()), m_premult(false)
{
DFBSurfaceDescription surfaceDesc;
memset(&surfaceDesc,0,sizeof(DFBSurfaceDescription));
surfaceDesc.width = rect.width();
surfaceDesc.height = rect.height();
+ // force alpha format to get AlphaFillRectCapability support
+ alpha = true;
+
if (alpha) {
+ m_premult = true;
surfaceDesc.caps = DSCAPS_PREMULTIPLIED;
surfaceDesc.pixelformat = QDirectFbBlitter::alphaPixmapFormat();
surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT);
@@ -83,7 +92,6 @@ QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, bool alpha)
surfaceDesc.pixelformat = QDirectFbBlitter::pixmapFormat();
}
-
IDirectFB *dfb = QDirectFbConvenience::dfbInterface();
dfb->CreateSurface(dfb , &surfaceDesc, m_surface.outPtr());
m_surface->Clear(m_surface.data(), 0, 0, 0, 0);
@@ -111,14 +119,7 @@ DFBSurfacePixelFormat QDirectFbBlitter::selectPixmapFormat(bool withAlpha)
void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color)
{
- m_surface->SetColor(m_surface.data(), color.red(), color.green(), color.blue(), color.alpha());
-// When the blitter api supports non opaque blits, also remember to change
-// qpixmap_blitter.cpp::fill
-// DFBSurfaceDrawingFlags drawingFlags = color.alpha() ? DSDRAW_BLEND : DSDRAW_NOFX;
-// m_surface->SetDrawingFlags(m_surface, drawingFlags);
- m_surface->SetDrawingFlags(m_surface.data(), DSDRAW_NOFX);
- m_surface->FillRectangle(m_surface.data(), rect.x(), rect.y(),
- rect.width(), rect.height());
+ alphaFillRect(rect, color, QPainter::CompositionMode_Source);
}
void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &srcRect)
@@ -156,6 +157,43 @@ void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, con
DirectFBError("QDirectFBBlitter::drawPixmap()", result);
}
+void QDirectFbBlitter::alphaFillRect(const QRectF &rect, const QColor &color, QPainter::CompositionMode cmode)
+{
+ int x, y, w, h;
+ DFBResult result;
+
+ // check paramters
+ rect.toRect().getRect(&x, &y ,&w, &h);
+ if ((w <= 0) || (h <= 0)) return;
+
+ if ((cmode == QPainter::CompositionMode_Source) || (color.alpha() == 255)) {
+ // CompositionMode_Source case or CompositionMode_SourceOver with opaque color
+
+ m_surface->SetDrawingFlags(m_surface.data(),
+ DFBSurfaceDrawingFlags(m_premult ? (DSDRAW_NOFX | DSDRAW_SRC_PREMULTIPLY) : DSDRAW_NOFX));
+ m_surface->SetPorterDuff(m_surface.data(), DSPD_SRC);
+
+ } else {
+ // CompositionMode_SourceOver case
+
+ // check if operation is useless
+ if (color.alpha() == 0)
+ return;
+
+ m_surface->SetDrawingFlags(m_surface.data(),
+ DFBSurfaceDrawingFlags(m_premult ? (DSDRAW_BLEND | DSDRAW_SRC_PREMULTIPLY) : DSDRAW_BLEND));
+ m_surface->SetPorterDuff(m_surface.data(), DSPD_SRC_OVER);
+ }
+
+ // set color
+ m_surface->SetColor(m_surface.data(), color.red(), color.green(), color.blue(), color.alpha());
+
+ // perform fill
+ result = m_surface->FillRectangle(m_surface.data(), x, y, w, h);
+ if (result != DFB_OK)
+ DirectFBError("QDirectFBBlitter::alphaFillRect()", result);
+}
+
QImage *QDirectFbBlitter::doLock()
{
Q_ASSERT(m_surface);
@@ -248,7 +286,7 @@ bool QDirectFbBlitterPlatformPixmap::fromFile(const QString &filename, const cha
// Deal with resources
if (filename.startsWith(QLatin1Char(':')))
- return QBlittablePlatformPixmap::fromFile(filename, format, flags);
+ return QBlittablePixmapData::fromFile(filename, format, flags);
// Try to use directfb to load it.
DFBDataBufferDescription description;
diff --git a/src/plugins/platforms/directfb/qdirectfbblitter.h b/src/plugins/platforms/directfb/qdirectfbblitter.h
index f998747..77c23d5 100644
--- a/src/plugins/platforms/directfb/qdirectfbblitter.h
+++ b/src/plugins/platforms/directfb/qdirectfbblitter.h
@@ -59,6 +59,7 @@ public:
virtual void fillRect(const QRectF &rect, const QColor &color);
virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect);
+ void alphaFillRect(const QRectF &rect, const QColor &color, QPainter::CompositionMode cmode);
IDirectFBSurface *dfbSurface() const;
@@ -74,6 +75,9 @@ protected:
QImage m_image;
friend class QDirectFbConvenience;
+
+private:
+ bool m_premult;
};
class QDirectFbBlitterPlatformPixmap : public QBlittablePixmapData