summaryrefslogtreecommitdiffstats
path: root/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp60
1 files changed, 43 insertions, 17 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
index b083395..7cacdd9 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
@@ -71,15 +71,21 @@ void QDirectFBPixmapData::resize(int width, int height)
}
format = screen->pixelFormat();
- dfbSurface = QDirectFBScreen::instance()->createDFBSurface(QSize(width, height),
- format,
- QDirectFBScreen::TrackSurface);
+ dfbSurface = screen->createDFBSurface(QSize(width, height),
+ format,
+ QDirectFBScreen::TrackSurface);
+ d = screen->depth();
alpha = false;
if (!dfbSurface) {
invalidate();
qWarning("QDirectFBPixmapData::resize(): Unable to allocate surface");
return;
}
+
+ w = width;
+ h = height;
+ is_null = (w <= 0 || h <= 0);
+ d = metric(QPaintDevice::PdmDepth);
setSerialNumber(++global_ser_no);
}
@@ -163,16 +169,17 @@ bool QDirectFBPixmapData::hasAlphaChannel(const QImage &img)
}
-void QDirectFBPixmapData::fromImage(const QImage &i,
+void QDirectFBPixmapData::fromImage(const QImage &image,
Qt::ImageConversionFlags flags)
{
-#ifdef QT_NO_DIRECTFB_OPAQUE_DETECTION
- Q_UNUSED(flags);
-#endif
- const QImage img = (i.depth() == 1 ? i.convertToFormat(screen->alphaPixmapFormat()) : i);
- if (img.hasAlphaChannel()
+ if (image.depth() == 1) {
+ fromImage(image.convertToFormat(screen->alphaPixmapFormat()), flags);
+ return;
+ }
+
+ if (image.hasAlphaChannel()
#ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION
- && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img))
+ && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(image))
#endif
) {
alpha = true;
@@ -181,14 +188,21 @@ void QDirectFBPixmapData::fromImage(const QImage &i,
alpha = false;
format = screen->pixelFormat();
}
- dfbSurface = screen->copyToDFBSurface(img, format,
- QDirectFBScreen::TrackSurface);
+
+ dfbSurface = screen->createDFBSurface(image, format, QDirectFBScreen::TrackSurface|QDirectFBScreen::NoPreallocated);
if (!dfbSurface) {
qWarning("QDirectFBPixmapData::fromImage()");
invalidate();
return;
}
+ w = image.width();
+ h = image.height();
+ is_null = (w <= 0 || h <= 0);
+ d = metric(QPaintDevice::PdmDepth);
setSerialNumber(++global_ser_no);
+#ifdef QT_NO_DIRECTFB_OPAQUE_DETECTION
+ Q_UNUSED(flags);
+#endif
}
void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect)
@@ -199,7 +213,8 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect)
}
unlockDirectFB();
- IDirectFBSurface *src = static_cast<const QDirectFBPixmapData*>(data)->directFBSurface();
+ const QDirectFBPixmapData *otherData = static_cast<const QDirectFBPixmapData*>(data);
+ IDirectFBSurface *src = otherData->directFBSurface();
alpha = data->hasAlphaChannel();
format = (alpha
? QDirectFBScreen::instance()->alphaPixmapFormat()
@@ -222,6 +237,10 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect)
}
const DFBRectangle blitRect = { rect.x(), rect.y(),
rect.width(), rect.height() };
+ w = rect.width();
+ h = rect.height();
+ d = otherData->d;
+ is_null = (w <= 0 || h <= 0);
DFBResult result = dfbSurface->Blit(dfbSurface, src, &blitRect, 0, 0);
#if (Q_DIRECTFB_VERSION >= 0x010000)
dfbSurface->ReleaseSource(dfbSurface);
@@ -294,9 +313,6 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
}
that->unlockDirectFB();
- int w, h;
- dfbSurface->GetSize(dfbSurface, &w, &h);
-
const QSize size = transform.mapRect(QRect(0, 0, w, h)).size();
if (size.isEmpty())
return QPixmap();
@@ -317,6 +333,10 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
const DFBRectangle destRect = { 0, 0, size.width(), size.height() };
data->dfbSurface->StretchBlit(data->dfbSurface, dfbSurface, 0, &destRect);
+ data->w = size.width();
+ data->h = size.height();
+ data->is_null = (data->w <= 0 || data->h <= 0);
+
#if (Q_DIRECTFB_VERSION >= 0x010000)
data->dfbSurface->ReleaseSource(data->dfbSurface);
#endif
@@ -333,7 +353,7 @@ QImage QDirectFBPixmapData::toImage() const
// DirectFB not to move the surface to videomemory. When that
// happens we can use this (hopefully faster) codepath
#ifndef QT_NO_DIRECTFB_PREALLOCATED
- QImage ret(size(), QDirectFBScreen::getImageFormat(dfbSurface));
+ QImage ret(w, h, QDirectFBScreen::getImageFormat(dfbSurface));
if (IDirectFBSurface *imgSurface = screen->createDFBSurface(ret, QDirectFBScreen::DontTrackSurface)) {
if (hasAlphaChannel()) {
imgSurface->SetBlittingFlags(imgSurface, DSBLIT_BLEND_ALPHACHANNEL);
@@ -383,8 +403,14 @@ QImage * QDirectFBPixmapData::buffer(DFBSurfaceLockFlags lockFlags)
void QDirectFBPixmapData::invalidate()
{
+ if (dfbSurface) {
+ screen->releaseDFBSurface(dfbSurface);
+ dfbSurface = 0;
+ }
setSerialNumber(0);
alpha = false;
+ d = w = h = 0;
+ is_null = true;
format = QImage::Format_Invalid;
}