From 2474f079d2937c047e9265ed626c120eb32a520f Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 23 Mar 2009 12:29:08 -0700 Subject: Optimize bytesPerLine. No sense in locking every time we want the bpl. The bpl won't change Reviewed-by: Tom Cooksey --- src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 15 +++++++++------ src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h | 3 +++ 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(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(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 -- cgit v0.12