summaryrefslogtreecommitdiffstats
path: root/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
index 924090c..72e0ce5 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
@@ -56,15 +56,20 @@ IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const
}
-void QDirectFBPaintDevice::lockDirectFB()
+void QDirectFBPaintDevice::lockDirectFB(uint flags)
{
- if (lockedImage)
- return; // Already locked
-
- if (uchar *mem = QDirectFBScreen::lockSurface(dfbSurface, DSLF_WRITE, &bpl)) {
- const QSize s = size();
- lockedImage = new QImage(mem, s.width(), s.height(), bpl,
- QDirectFBScreen::getImageFormat(dfbSurface));
+ if (!(lock & flags)) {
+ if (lock)
+ unlockDirectFB();
+ if ((mem = QDirectFBScreen::lockSurface(dfbSurface, flags, &bpl))) {
+ const QSize s = size();
+ lockedImage = new QImage(mem, s.width(), s.height(), bpl,
+ QDirectFBScreen::getImageFormat(dfbSurface));
+ lock = flags;
+ Q_ASSERT(mem);
+ } else {
+ lock = 0;
+ }
}
}
@@ -77,15 +82,19 @@ void QDirectFBPaintDevice::unlockDirectFB()
dfbSurface->Unlock(dfbSurface);
delete lockedImage;
lockedImage = 0;
+ mem = 0;
+ lock = 0;
}
-void* QDirectFBPaintDevice::memory() const
+void *QDirectFBPaintDevice::memory() const
{
- QDirectFBPaintDevice* that = const_cast<QDirectFBPaintDevice*>(this);
- that->lockDirectFB();
- Q_ASSERT(that->lockedImage);
- return that->lockedImage->bits();
+ if (lock != (DSLF_READ|DSLF_WRITE)) {
+ QDirectFBPaintDevice *that = const_cast<QDirectFBPaintDevice*>(this);
+ that->lockDirectFB(DSLF_READ|DSLF_WRITE);
+ Q_ASSERT(that->lockedImage);
+ }
+ return mem;
}
@@ -101,7 +110,7 @@ int QDirectFBPaintDevice::bytesPerLine() const
// Can only get the stride when we lock the surface
Q_ASSERT(!lockedImage);
QDirectFBPaintDevice* that = const_cast<QDirectFBPaintDevice*>(this);
- that->lockDirectFB();
+ that->lockDirectFB(DSLF_READ);
Q_ASSERT(bpl != -1);
}
return bpl;