summaryrefslogtreecommitdiffstats
path: root/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
diff options
context:
space:
mode:
authorAnders Bakken <anders.bakken@nokia.com>2009-05-05 18:25:28 (GMT)
committerAnders Bakken <anders.bakken@nokia.com>2009-05-05 20:22:00 (GMT)
commit183602a565147299a309fc4df3165b702f0d78f4 (patch)
tree4dbf9b0ce8891475fb396fba4990318e5dadf094 /src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
parent083f41c81d735afa30cb6aa355862c3d2e67f55d (diff)
downloadQt-183602a565147299a309fc4df3165b702f0d78f4.zip
Qt-183602a565147299a309fc4df3165b702f0d78f4.tar.gz
Qt-183602a565147299a309fc4df3165b702f0d78f4.tar.bz2
Don't call prepare more than necessary
Store the memory address of our last QRasterBuffer::prepare() call to make sure we reprepare if someone has unlocked and locked the device behind our back. Also optimize QDirectFBDevice::memory() since it might get called a fair bit. Reviewed-by: Donald <qt-info@nokia.com>
Diffstat (limited to 'src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
index 9796280..72e0ce5 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
@@ -58,18 +58,18 @@ IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const
void QDirectFBPaintDevice::lockDirectFB(uint flags)
{
- if (lockedImage) {
- if (lockFlags & flags)
- return;
- unlockDirectFB();
- }
- if (uchar *mem = QDirectFBScreen::lockSurface(dfbSurface, flags, &bpl)) {
- const QSize s = size();
- lockedImage = new QImage(mem, s.width(), s.height(), bpl,
- QDirectFBScreen::getImageFormat(dfbSurface));
- lockFlags = flags;
- } else {
- lockFlags = 0;
+ 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;
+ }
}
}
@@ -82,15 +82,19 @@ void QDirectFBPaintDevice::unlockDirectFB()
dfbSurface->Unlock(dfbSurface);
delete lockedImage;
lockedImage = 0;
+ mem = 0;
+ lock = 0;
}
void *QDirectFBPaintDevice::memory() const
{
- QDirectFBPaintDevice* that = const_cast<QDirectFBPaintDevice*>(this);
- that->lockDirectFB(DSLF_READ|DSLF_WRITE);
- 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;
}