diff options
author | Anders Bakken <anders@trolltech.com> | 2009-03-23 19:29:08 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-03-25 15:57:17 (GMT) |
commit | 2474f079d2937c047e9265ed626c120eb32a520f (patch) | |
tree | 0e6e0dc33c80d49fd557c7cea1c9134a46829a91 /src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp | |
parent | 70d80ddc2a86ebb78d04325048c8161c7b28c4b1 (diff) | |
download | Qt-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/qdirectfbpaintdevice.cpp')
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 15 |
1 files changed, 9 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; } |