diff options
author | Anders Bakken <anders.bakken@nokia.com> | 2009-03-27 17:58:37 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-03-30 14:49:35 (GMT) |
commit | 34059fba55816496d2570b3306ac2b631b12a5c6 (patch) | |
tree | f66e2313829c50eaf9d85423b3fea3d7d5c3f24e /src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | |
parent | 637b8aa2361fea8c0ea6579a6308ae594e6d8633 (diff) | |
download | Qt-34059fba55816496d2570b3306ac2b631b12a5c6.zip Qt-34059fba55816496d2570b3306ac2b631b12a5c6.tar.gz Qt-34059fba55816496d2570b3306ac2b631b12a5c6.tar.bz2 |
Work around raster engine not ignoring the pad byte in RGB32
DirectFB sets the alpha byte to 0 in RGB32 for all drawing operations.
The raster paint engine needs this padding byte to be 0xFF as it shares
some code paths with RGBA8888_Premultiplied. So, always fall back to
raster engine for draw operations.
This is really due to a bug in the raster paint engine (Tracked by task
184073), which should ignore the extra byte. Once this task is fixed,
this patch can probably be reverted.
Reviewed-by: Tom Cooksey
Diffstat (limited to 'src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp')
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 6d942a4..3099205 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -71,15 +71,10 @@ void QDirectFBPixmapData::resize(int width, int height) return; } - DFBSurfaceDescription description; - description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH - | DSDESC_HEIGHT - | DSDESC_PIXELFORMAT); - QDirectFBScreen::initSurfaceDescriptionPixelFormat(&description, screen->pixelFormat()); - description.width = width; - description.height = height; - - dfbSurface = screen->createDFBSurface(&description, QDirectFBScreen::TrackSurface); + dfbSurface = QDirectFBScreen::instance()->createDFBSurface(QSize(width, height), + screen->pixelFormat(), + QDirectFBScreen::TrackSurface); + forceRaster = (screen->pixelFormat() == QImage::Format_RGB32); if (!dfbSurface) { setSerialNumber(0); qWarning("QDirectFBPixmapData::resize(): Unable to allocate surface"); @@ -92,10 +87,12 @@ void QDirectFBPixmapData::resize(int width, int height) void QDirectFBPixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags) { - dfbSurface = screen->copyToDFBSurface(img, - img.hasAlphaChannel() ? screen->alphaPixmapFormat() - : screen->pixelFormat(), - QDirectFBScreen::TrackSurface); + const QImage::Format format = img.hasAlphaChannel() ? + screen->alphaPixmapFormat() + : screen->pixelFormat(); + dfbSurface = screen->copyToDFBSurface(img, format, + QDirectFBScreen::TrackSurface); + forceRaster = (format == QImage::Format_RGB32); if (!dfbSurface) { qWarning("QDirectFBPixmapData::fromImage()"); setSerialNumber(0); @@ -112,22 +109,18 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) } IDirectFBSurface *src = static_cast<const QDirectFBPixmapData*>(data)->directFbSurface(); + const QImage::Format format = (data->hasAlphaChannel() + ? QDirectFBScreen::instance()->alphaPixmapFormat() + : QDirectFBScreen::instance()->pixelFormat()); - DFBSurfaceDescription description; - description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH | - DSDESC_HEIGHT | - DSDESC_PIXELFORMAT); - description.width = rect.width(); - description.height = rect.height(); - src->GetPixelFormat(src, &description.pixelformat); - src->GetCapabilities(src, &description.caps); - - dfbSurface = screen->createDFBSurface(&description, QDirectFBScreen::TrackSurface); + dfbSurface = screen->createDFBSurface(rect.size(), format, + QDirectFBScreen::TrackSurface); if (!dfbSurface) { qWarning("QDirectFBPixmapData::copy()"); setSerialNumber(0); return; } + forceRaster = (format == QImage::Format_RGB32); dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); const DFBRectangle blitRect = { rect.x(), rect.y(), @@ -160,6 +153,7 @@ void QDirectFBPixmapData::fill(const QColor &color) screen->releaseDFBSurface(dfbSurface); // release old surface dfbSurface = screen->createDFBSurface(&description, QDirectFBScreen::TrackSurface); + forceRaster = false; setSerialNumber(++global_ser_no); if (!dfbSurface) { qWarning("QDirectFBPixmapData::fill()"); @@ -168,8 +162,23 @@ void QDirectFBPixmapData::fill(const QColor &color) } } - dfbSurface->Clear(dfbSurface, color.red(), color.green(), color.blue(), - color.alpha()); + if (forceRaster) { + // in DSPF_RGB32 all dfb drawing causes the Alpha byte to be + // set to 0. This causes issues for the raster engine. + char *mem; + int bpl; + const int h = QPixmapData::height(); + dfbSurface->Lock(dfbSurface, DSLF_WRITE, (void**)&mem, &bpl); + const int c = color.rgba(); + for (int i = 0; i < h; ++i) { + memset(mem, c, bpl); + mem += bpl; + } + dfbSurface->Unlock(dfbSurface); + } else { + dfbSurface->Clear(dfbSurface, color.red(), color.green(), color.blue(), + color.alpha()); + } } bool QDirectFBPixmapData::hasAlphaChannel() const |