[directfb] Prepare to select the alpha/opaque pixel formats

Right now we assume to use 32bpp but depending on the hardware
this might not be optimal at all. Begin to prepare the code for
not having a 32bpp surfaces.

Change-Id: Iedfa49c568559e074dfaeae2a216c9eb93721d2c
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
This commit is contained in:
Holger Hans Peter Freyther 2011-09-29 18:10:15 +02:00 committed by Qt by Nokia
parent d43775b93b
commit b1c803a925
2 changed files with 21 additions and 2 deletions

View File

@ -74,11 +74,11 @@ QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, bool alpha)
if (alpha) {
surfaceDesc.caps = DSCAPS_PREMULTIPLIED;
surfaceDesc.pixelformat = DSPF_ARGB;
surfaceDesc.pixelformat = QDirectFbBlitter::alphaPixmapFormat();
surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_CAPS | DSDESC_PIXELFORMAT);
} else {
surfaceDesc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT);
surfaceDesc.pixelformat = DSPF_RGB32;
surfaceDesc.pixelformat = QDirectFbBlitter::pixmapFormat();
}
@ -92,6 +92,21 @@ QDirectFbBlitter::~QDirectFbBlitter()
unlock();
}
DFBSurfacePixelFormat QDirectFbBlitter::alphaPixmapFormat()
{
return DSPF_ARGB;
}
DFBSurfacePixelFormat QDirectFbBlitter::pixmapFormat()
{
return DSPF_RGB32;
}
DFBSurfacePixelFormat QDirectFbBlitter::selectPixmapFormat(bool withAlpha)
{
return withAlpha ? alphaPixmapFormat() : pixmapFormat();
}
void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color)
{
m_surface->SetColor(m_surface.data(), color.red(), color.green(), color.blue(), color.alpha());

View File

@ -58,6 +58,10 @@ public:
virtual void fillRect(const QRectF &rect, const QColor &color);
virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect);
static DFBSurfacePixelFormat alphaPixmapFormat();
static DFBSurfacePixelFormat pixmapFormat();
static DFBSurfacePixelFormat selectPixmapFormat(bool withAlpha);
protected:
virtual QImage *doLock();
virtual void doUnlock();