diff options
author | Anders Bakken <anders.bakken@nokia.com> | 2009-08-28 03:37:40 (GMT) |
---|---|---|
committer | Anders Bakken <anders.bakken@nokia.com> | 2009-09-01 22:25:51 (GMT) |
commit | add57539ec7cd24346e26b22a5298da50d81e91b (patch) | |
tree | fda78f056d25bd876b7348bf732463939b9fe648 /src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | |
parent | 913a21aae513714217be233c6cecfb39212a4be8 (diff) | |
download | Qt-add57539ec7cd24346e26b22a5298da50d81e91b.zip Qt-add57539ec7cd24346e26b22a5298da50d81e91b.tar.gz Qt-add57539ec7cd24346e26b22a5298da50d81e91b.tar.bz2 |
Rewrite of DirectFB locking mechanism
DirectFB allows you to have a locked subSurface that remains valid while
you paint on the unlocked "parent" surface.
The only limitation is that when accessing the locked memory you might
have to call DirectFB->WaitIdle() in case pending GPU operations aren't
finished.
After this we keep the locked surface around at all times (from the
first time it's requested) until the surface dies. Previous calls to
lock() will just call WaitIdle if necessary and previous calls to unlock
now just mark the surface as dirty and in need of a WaitIdle if someone
needs to access its pixel data.
Reviewed-by: Donald Carr <donald.carr@nokia.com>
Diffstat (limited to 'src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp')
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index c714989..599b2a9 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -319,14 +319,38 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, if (options & TrackSurface) { d_ptr->allocatedSurfaces.insert(newSurface); - - //qDebug("Created a new DirectFB surface at %p. New count = %d", - // newSurface, d_ptr->allocatedSurfaces.count()); } return newSurface; } +#ifdef QT_DIRECTFB_SUBSURFACE +IDirectFBSurface *QDirectFBScreen::getSubSurface(IDirectFBSurface *surface, + const QRect &rect, + SurfaceCreationOptions options, + DFBResult *resultPtr) +{ + Q_ASSERT(!(options & NoPreallocated)); + Q_ASSERT(surface); + DFBResult res; + DFBResult &result = (resultPtr ? *resultPtr : res); + IDirectFBSurface *subSurface = 0; + if (rect.isNull()) { + result = surface->GetSubSurface(surface, 0, &subSurface); + } else { + const DFBRectangle subRect = { rect.x(), rect.y(), rect.width(), rect.height() }; + result = surface->GetSubSurface(surface, &subRect, &subSurface); + } + if (result != DFB_OK) { + DirectFBError("Can't get sub surface", result); + } else if (options & TrackSurface) { + d_ptr->allocatedSurfaces.insert(subSurface); + } + return subSurface; +} +#endif + + void QDirectFBScreen::releaseDFBSurface(IDirectFBSurface *surface) { Q_ASSERT(QDirectFBScreen::instance()); @@ -1527,6 +1551,11 @@ void QDirectFBScreen::setDirectFBImageProvider(IDirectFBImageProvider *provider) } #endif +void QDirectFBScreen::waitIdle() +{ + d_ptr->dfb->WaitIdle(d_ptr->dfb); +} + IDirectFBSurface * QDirectFBScreen::surfaceForWidget(const QWidget *widget, QRect *rect) const { Q_ASSERT(widget); @@ -1540,6 +1569,7 @@ IDirectFBSurface * QDirectFBScreen::surfaceForWidget(const QWidget *widget, QRec return 0; } +#ifdef QT_DIRECTFB_SUBSURFACE IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, const QRect &area) const { Q_ASSERT(widget); @@ -1550,7 +1580,7 @@ IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, co if (!area.isNull()) rect &= area.translated(widget->mapTo(widget->window(), QPoint(0, 0))); if (!rect.isNull()) { - const DFBRectangle subRect = {rect.x(), rect.y(), rect.width(), rect.height() }; + const DFBRectangle subRect = { rect.x(), rect.y(), rect.width(), rect.height() }; const DFBResult result = surface->GetSubSurface(surface, &subRect, &subSurface); if (result != DFB_OK) { DirectFBError("QDirectFBScreen::subSurface(): Can't get sub surface", result); @@ -1559,6 +1589,7 @@ IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, co } return subSurface; } +#endif QT_END_NAMESPACE |