summaryrefslogtreecommitdiffstats
path: root/src/plugins/gfxdrivers/directfb
diff options
context:
space:
mode:
authorAnders Bakken <anders@trolltech.com>2009-03-23 19:29:08 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-03-25 15:57:17 (GMT)
commit2474f079d2937c047e9265ed626c120eb32a520f (patch)
tree0e6e0dc33c80d49fd557c7cea1c9134a46829a91 /src/plugins/gfxdrivers/directfb
parent70d80ddc2a86ebb78d04325048c8161c7b28c4b1 (diff)
downloadQt-2474f079d2937c047e9265ed626c120eb32a520f.zip
Qt-2474f079d2937c047e9265ed626c120eb32a520f.tar.gz
Qt-2474f079d2937c047e9265ed626c120eb32a520f.tar.bz2
Optimize bytesPerLine.
No sense in locking every time we want the bpl. The bpl won't change Reviewed-by: Tom Cooksey
Diffstat (limited to 'src/plugins/gfxdrivers/directfb')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp15
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h3
2 files changed, 12 insertions, 6 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
index 6a41a24..8a30ad4 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
@@ -64,7 +64,6 @@ void QDirectFBPaintDevice::lockDirectFB() {
void *mem;
int w, h;
- int bpl;
DFBSurfacePixelFormat format;
DFBResult result = dfbSurface->Lock(dfbSurface, DSLF_WRITE, &mem, &bpl);
@@ -111,11 +110,15 @@ QImage::Format QDirectFBPaintDevice::format() const
int QDirectFBPaintDevice::bytesPerLine() const
{
- // Can only get the stride when we lock the surface
- QDirectFBPaintDevice* that = const_cast<QDirectFBPaintDevice*>(this);
- that->lockDirectFB();
- Q_ASSERT(that->lockedImage);
- return that->lockedImage->bytesPerLine();
+ if (bpl == -1) {
+ // Can only get the stride when we lock the surface
+ Q_ASSERT(!lockedImage);
+ QDirectFBPaintDevice* that = const_cast<QDirectFBPaintDevice*>(this);
+ that->lockDirectFB();
+ Q_ASSERT(bpl != -1);
+ that->unlockDirectFB();
+ }
+ return bpl;
}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
index eaf7537..e19f183 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
@@ -77,6 +77,9 @@ protected:
IDirectFBSurface *dfbSurface;
QImage *lockedImage;
QDirectFBScreen *screen;
+ int bpl;
+private:
+ Q_DISABLE_COPY(QDirectFBPaintDevice)
};
QT_END_HEADER