diff options
author | Anders Bakken <anders.bakken@nokia.com> | 2009-09-02 22:08:03 (GMT) |
---|---|---|
committer | Anders Bakken <anders.bakken@nokia.com> | 2009-09-04 00:54:30 (GMT) |
commit | dbcd5955769f2a7b23b1b6f91211ed8160a66859 (patch) | |
tree | a468556ff8ea33247827880ef00a4a77b7fae634 /src/plugins | |
parent | 72cca6fe7739c7b5ccd5fc17fb3e1913cc82dce1 (diff) | |
download | Qt-dbcd5955769f2a7b23b1b6f91211ed8160a66859.zip Qt-dbcd5955769f2a7b23b1b6f91211ed8160a66859.tar.gz Qt-dbcd5955769f2a7b23b1b6f91211ed8160a66859.tar.bz2 |
Fix a bug in DFBWindowSurface::setGeometry
Make sure to release the surface of a window before resizing. Seemingly
certain versions of DirectFB change the surface when the window is
resized.
Also clean up setGeometry()
Reviewed-by: Donald Carr <donald.carr@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 9e0691d..58f7098 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -184,11 +184,23 @@ static DFBResult setWindowGeometry(IDirectFBWindow *dfbWindow, const QRect &old, void QDirectFBWindowSurface::setGeometry(const QRect &rect) { + const QRect oldRect = geometry(); + if (oldRect == rect) + return; + IDirectFBSurface *oldSurface = dfbSurface; -#ifdef QT_NO_DIRECTFB_WM - IDirectFBSurface *primarySurface = screen->primarySurface(); - Q_ASSERT(primarySurface); + const bool sizeChanged = oldRect.size() != rect.size(); + if (sizeChanged) { + delete engine; + engine = 0; + unlockSurface(); +#ifdef QT_DIRECTFB_SUBSURFACE + releaseSubSurface(); #endif + releaseSurface(); + Q_ASSERT(!dfbSurface); + } + if (rect.isNull()) { #ifndef QT_NO_DIRECTFB_WM if (dfbWindow) { @@ -196,27 +208,25 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) dfbWindow = 0; } #endif - if (dfbSurface) { -#ifdef QT_NO_DIRECTFB_WM - if (dfbSurface != primarySurface) + Q_ASSERT(!dfbSurface); +#ifdef QT_DIRECTFB_SUBSURFACE + Q_ASSERT(!subSurface); #endif - dfbSurface->Release(dfbSurface); - dfbSurface = 0; - } - } else if (rect != geometry()) { - const QRect oldRect = geometry(); - DFBResult result = DFB_OK; - // If we're in a resize, the surface shouldn't be locked + } else { #ifdef QT_DIRECTFB_WM if (!dfbWindow) { createWindow(rect); } else { setWindowGeometry(dfbWindow, oldRect, rect); + Q_ASSERT(!sizeChanged || !dfbSurface); + if (sizeChanged) + dfbWindow->GetSurface(dfbWindow, &dfbSurface); } #else + IDirectFBSurface *primarySurface = screen->primarySurface(); + DFBResult result = DFB_OK; if (mode == Primary) { - if (dfbSurface && dfbSurface != primarySurface) - dfbSurface->Release(dfbSurface); + Q_ASSERT(primarySurface); if (rect == screen->region().boundingRect()) { dfbSurface = primarySurface; } else { @@ -224,27 +234,21 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) rect.width(), rect.height() }; result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface); } - } else { - if (!dfbSurface || oldRect.size() != rect.size()) { - if (dfbSurface) - dfbSurface->Release(dfbSurface); + } else { // mode == Offscreen + if (!dfbSurface) { dfbSurface = screen->createDFBSurface(rect.size(), screen->pixelFormat(), QDirectFBScreen::DontTrackSurface); } const QRegion region = QRegion(oldRect.isEmpty() ? screen->region() : QRegion(oldRect)).subtracted(rect); screen->erase(region); screen->flipSurface(primarySurface, flipFlags, region, QPoint()); } -#endif - if (size() != geometry().size()) { - delete engine; - engine = 0; - } - if (result != DFB_OK) DirectFBErrorFatal("QDirectFBWindowSurface::setGeometry()", result); +#endif } if (oldSurface != dfbSurface) updateFormat(); + QWSWindowSurface::setGeometry(rect); } @@ -417,8 +421,9 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, void QDirectFBWindowSurface::beginPaint(const QRegion &) { - if (!engine) + if (!engine) { engine = new QDirectFBPaintEngine(this); + } } void QDirectFBWindowSurface::endPaint(const QRegion &) |