From add57539ec7cd24346e26b22a5298da50d81e91b Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 27 Aug 2009 20:37:40 -0700 Subject: 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 --- src/gui/embedded/directfb.pri | 1 + .../gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 99 +++++++++++++++------- .../gfxdrivers/directfb/qdirectfbpaintdevice.h | 16 ++-- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 68 ++++++++------- .../gfxdrivers/directfb/qdirectfbpixmap.cpp | 31 ++++--- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h | 6 +- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 39 ++++++++- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 12 +++ .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 5 +- 9 files changed, 185 insertions(+), 92 deletions(-) diff --git a/src/gui/embedded/directfb.pri b/src/gui/embedded/directfb.pri index e868252..7dae9d5 100644 --- a/src/gui/embedded/directfb.pri +++ b/src/gui/embedded/directfb.pri @@ -1,6 +1,7 @@ # These defines might be necessary if your DirectFB driver doesn't # support all of the DirectFB API. # +#DEFINES += QT_NO_DIRECTFB_SUBSURFACE #DEFINES += QT_DIRECTFB_WINDOW_AS_CURSOR #DEFINES += QT_NO_DIRECTFB_IMAGEPROVIDER #DEFINES += QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 106de0d..2e56b9a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -48,14 +48,29 @@ QT_BEGIN_NAMESPACE QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr) - : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr), - bpl(-1), lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0), - imageFormat(QImage::Format_Invalid) -{} + : QCustomRasterPaintDevice(0), dfbSurface(0), screen(scr), + bpl(-1), lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0), imageFormat(QImage::Format_Invalid) +{ +#ifdef QT_DIRECTFB_SUBSURFACE + subSurface = 0; + syncPending = false; +#endif +} QDirectFBPaintDevice::~QDirectFBPaintDevice() { - delete lockedImage; + unlockSurface(); + if (QDirectFBScreen::instance()) { + unlockSurface(); +#ifdef QT_DIRECTFB_SUBSURFACE + if (subSurface) { + screen->releaseDFBSurface(subSurface); + } +#endif + if (dfbSurface) { + screen->releaseDFBSurface(dfbSurface); + } + } delete engine; } @@ -64,30 +79,57 @@ IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const return dfbSurface; } -void QDirectFBPaintDevice::lockDirectFB(DFBSurfaceLockFlags flags) +bool QDirectFBPaintDevice::lockSurface(DFBSurfaceLockFlags lockFlags) { - if (!(lockFlgs & flags)) { - if (lockFlgs) - unlockDirectFB(); - mem = QDirectFBScreen::lockSurface(dfbSurface, flags, &bpl); + if (lockFlgs && (lockFlags & ~lockFlgs)) + unlockSurface(); + if (!mem) { + Q_ASSERT(dfbSurface); +#ifdef QT_DIRECTFB_SUBSURFACE + if (!subSurface) { + DFBResult result; + subSurface = screen->getSubSurface(dfbSurface, QRect(), QDirectFBScreen::TrackSurface, &result); + if (result != DFB_OK || !subSurface) { + DirectFBError("Couldn't create sub surface", result); + return false; + } + } + IDirectFBSurface *surface = subSurface; +#else + IDirectFBSurface *surface = dfbSurface; +#endif + Q_ASSERT(surface); + mem = QDirectFBScreen::lockSurface(surface, lockFlags, &bpl); + lockFlgs = lockFlags; Q_ASSERT(mem); + Q_ASSERT(bpl > 0); const QSize s = size(); - lockedImage = new QImage(mem, s.width(), s.height(), bpl, - QDirectFBScreen::getImageFormat(dfbSurface)); - lockFlgs = flags; + lockedImage = QImage(mem, s.width(), s.height(), bpl, + QDirectFBScreen::getImageFormat(dfbSurface)); + return true; + } +#ifdef QT_DIRECTFB_SUBSURFACE + if (syncPending) { + syncPending = false; + screen->waitIdle(); } +#endif + return false; } -void QDirectFBPaintDevice::unlockDirectFB() +void QDirectFBPaintDevice::unlockSurface() { - if (!lockedImage || !QDirectFBScreen::instance()) - return; - - dfbSurface->Unlock(dfbSurface); - delete lockedImage; - lockedImage = 0; - mem = 0; - lockFlgs = DFBSurfaceLockFlags(0); + if (QDirectFBScreen::instance() && lockFlgs) { +#ifdef QT_DIRECTFB_SUBSURFACE + IDirectFBSurface *surface = subSurface; +#else + IDirectFBSurface *surface = dfbSurface; +#endif + if (surface) { + surface->Unlock(surface); + lockFlgs = static_cast(0); + } + } } void *QDirectFBPaintDevice::memory() const @@ -102,17 +144,10 @@ QImage::Format QDirectFBPaintDevice::format() const int QDirectFBPaintDevice::bytesPerLine() const { - if (bpl == -1) { - // Can only get the stride when we lock the surface - Q_ASSERT(!lockedImage); - QDirectFBPaintDevice* that = const_cast(this); - that->lockDirectFB(DSLF_READ|DSLF_WRITE); - Q_ASSERT(bpl != -1); - } + Q_ASSERT(!mem || bpl != -1); return bpl; } - QSize QDirectFBPaintDevice::size() const { int w, h; @@ -142,8 +177,8 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const case QPaintDevice::PdmDepth: return QDirectFBScreen::depth(imageFormat); case QPaintDevice::PdmNumColors: { - if (lockedImage) - return lockedImage->numColors(); + if (!lockedImage.isNull()) + return lockedImage.numColors(); DFBResult result; IDirectFBPalette *palette = 0; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index f5de44b..cdd2bea 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -62,8 +62,8 @@ public: virtual IDirectFBSurface *directFBSurface() const; - void lockDirectFB(DFBSurfaceLockFlags lock); - void unlockDirectFB(); + bool lockSurface(DFBSurfaceLockFlags lockFlags); + void unlockSurface(); // Reimplemented from QCustomRasterPaintDevice: void *memory() const; @@ -73,7 +73,6 @@ public: int metric(QPaintDevice::PaintDeviceMetric metric) const; DFBSurfaceLockFlags lockFlags() const { return lockFlgs; } QPaintEngine *paintEngine() const; - protected: QDirectFBPaintDevice(QDirectFBScreen *scr); inline int dotsPerMeterX() const @@ -84,17 +83,20 @@ protected: { return (screen->deviceHeight() * 1000) / screen->physicalHeight(); } -protected: + IDirectFBSurface *dfbSurface; - QImage *lockedImage; +#ifdef QT_DIRECTFB_SUBSURFACE + IDirectFBSurface *subSurface; + friend class QDirectFBPaintEnginePrivate; + bool syncPending; +#endif + QImage lockedImage; QDirectFBScreen *screen; int bpl; DFBSurfaceLockFlags lockFlgs; uchar *mem; QDirectFBPaintEngine *engine; QImage::Format imageFormat; -private: - Q_DISABLE_COPY(QDirectFBPaintDevice); }; QT_END_NAMESPACE diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 984b5c6..5bad4de 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -93,6 +93,7 @@ public: inline void lock(); inline void unlock(); + static inline void unlock(QDirectFBPaintDevice *device); inline bool isSimpleBrush(const QBrush &brush) const; @@ -221,6 +222,7 @@ template static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface); #define CLIPPED_PAINT(operation) { \ + d->unlock(); \ DFBRegion clipRegion; \ switch (d->clipType) { \ case QDirectFBPaintEnginePrivate::NoClip: \ @@ -268,6 +270,7 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) QPixmapData *data = static_cast(device)->pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbPixmapData = static_cast(data); + QDirectFBPaintEnginePrivate::unlock(dfbPixmapData); d->dfbDevice = static_cast(dfbPixmapData); } @@ -408,7 +411,6 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) QRasterPaintEngine::drawRects(rects, rectCount); return; } - d->unlock(); if (brush != Qt::NoBrush) { d->setDFBColor(brush.color()); CLIPPED_PAINT(QT_PREPEND_NAMESPACE(fillRects)(rects, rectCount, state()->matrix, d->surface)); @@ -437,7 +439,6 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) QRasterPaintEngine::drawRects(rects, rectCount); return; } - d->unlock(); if (brush != Qt::NoBrush) { d->setDFBColor(brush.color()); CLIPPED_PAINT(fillRects(rects, rectCount, state()->matrix, d->surface)); @@ -463,7 +464,6 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) const QPen &pen = state()->pen; if (pen != Qt::NoPen) { - d->unlock(); d->setDFBColor(pen.color()); CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines)(lines, lineCount, state()->matrix, d->surface)); } @@ -484,7 +484,6 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) const QPen &pen = state()->pen; if (pen != Qt::NoPen) { - d->unlock(); d->setDFBColor(pen.color()); CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines)(lines, lineCount, state()->matrix, d->surface)); } @@ -532,7 +531,6 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, return; } #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE - d->unlock(); bool release; IDirectFBSurface *imgSurface = d->getSurface(image, &release); d->prepareForBlit(QDirectFBScreen::hasAlphaChannel(imgSurface)); @@ -560,25 +558,25 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); d->lock(); QRasterPaintEngine::drawPixmap(r, pixmap, sr); - } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) - || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) - || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip - || (state()->renderHints & QPainter::SmoothPixmapTransform - && state()->matrix.mapRect(r).size() != sr.size())) { - RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); - const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); - d->lock(); - QRasterPaintEngine::drawImage(r, *img, sr); } else { - d->unlock(); - d->prepareForBlit(pixmap.hasAlphaChannel()); QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); - dfbData->unlockDirectFB(); - IDirectFBSurface *s = dfbData->directFBSurface(); - - CLIPPED_PAINT(d->blit(r, s, sr)); + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) + || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) + || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip + || (state()->renderHints & QPainter::SmoothPixmapTransform + && state()->matrix.mapRect(r).size() != sr.size())) { + RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); + const QImage *img = dfbData->buffer(); + d->lock(); + QRasterPaintEngine::drawImage(r, *img, sr); + } else { + QDirectFBPaintEnginePrivate::unlock(dfbData); + d->prepareForBlit(pixmap.hasAlphaChannel()); + IDirectFBSurface *s = dfbData->directFBSurface(); + CLIPPED_PAINT(d->blit(r, s, sr)); + } } } @@ -601,14 +599,16 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip || (state()->renderHints & QPainter::SmoothPixmapTransform && state()->matrix.isScaling())) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); - const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); + QPixmapData *pixmapData = pixmap.pixmapData(); + Q_ASSERT(pixmapData->classId() == QPixmapData::DirectFBClass); + QDirectFBPixmapData *dfbData = static_cast(pixmapData); + const QImage *img = dfbData->buffer(); d->lock(); QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType); data->fromImage(*img, Qt::AutoColor); const QPixmap pix(data); QRasterPaintEngine::drawTiledPixmap(r, pix, offset); } else { - d->unlock(); CLIPPED_PAINT(d->drawTiledPixmap(r, pixmap, offset)); } } @@ -707,7 +707,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) const QColor color = brush.color(); if (!color.isValid()) return; - d->unlock(); d->setDFBColor(color); const QRect r = state()->matrix.mapRect(rect).toRect(); CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height())); @@ -724,7 +723,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) if (texture.pixmapData()->classId() != QPixmapData::DirectFBClass) break; - d->unlock(); CLIPPED_PAINT(d->drawTiledPixmap(rect, texture, rect.topLeft() - state()->brushOrigin)); return; } default: @@ -748,7 +746,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) d->lock(); QRasterPaintEngine::fillRect(rect, color); } else { - d->unlock(); d->setDFBColor(color); const QRect r = state()->matrix.mapRect(rect).toRect(); CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height())); @@ -810,8 +807,7 @@ void QDirectFBPaintEnginePrivate::lock() // lock so we need to call the base implementation of prepare so // it updates its rasterBuffer to point to the new buffer address. Q_ASSERT(dfbDevice); - if (dfbDevice->lockFlags() != (DSLF_WRITE|DSLF_READ)) { - dfbDevice->lockDirectFB(DSLF_READ|DSLF_WRITE); + if (dfbDevice->lockSurface(DSLF_READ|DSLF_WRITE)) { prepare(dfbDevice); } } @@ -819,7 +815,21 @@ void QDirectFBPaintEnginePrivate::lock() void QDirectFBPaintEnginePrivate::unlock() { Q_ASSERT(dfbDevice); - dfbDevice->unlockDirectFB(); +#ifdef QT_DIRECTFB_SUBSURFACE + dfbDevice->syncPending = true; +#else + QDirectFBPaintEnginePrivate::unlock(dfbDevice); +#endif +} + +void QDirectFBPaintEnginePrivate::unlock(QDirectFBPaintDevice *device) +{ +#ifdef QT_NO_DIRECTFB_SUBSURFACE + Q_ASSERT(device); + device->unlockSurface(); +#else + Q_UNUSED(device); +#endif } void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform) @@ -1030,7 +1040,7 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); - dfbData->unlockDirectFB(); + QDirectFBPaintEnginePrivate::unlock(dfbData); const QSize pixmapSize = dfbData->size(); IDirectFBSurface *sourceSurface = dfbData->directFBSurface(); if (transform.isScaling()) { diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 4da2f7c..6550683 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -64,9 +64,6 @@ QDirectFBPixmapData::QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixe QDirectFBPixmapData::~QDirectFBPixmapData() { - unlockDirectFB(); - if (dfbSurface && QDirectFBScreen::instance()) - screen->releaseDFBSurface(dfbSurface); } void QDirectFBPixmapData::resize(int width, int height) @@ -375,9 +372,13 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) QPixmapData::copy(data, rect); return; } - unlockDirectFB(); const QDirectFBPixmapData *otherData = static_cast(data); +#ifdef QT_NO_DIRECTFB_SUBSURFACE + if (otherData->lockFlags()) { + const_cast(otherData)->unlockSurface(); + } +#endif IDirectFBSurface *src = otherData->directFBSurface(); alpha = data->hasAlphaChannel(); imageFormat = (alpha @@ -405,6 +406,7 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) h = rect.height(); d = otherData->d; is_null = (w <= 0 || h <= 0); + unlockSurface(); DFBResult result = dfbSurface->Blit(dfbSurface, src, &blitRect, 0, 0); #if (Q_DIRECTFB_VERSION >= 0x010000) dfbSurface->ReleaseSource(dfbSurface); @@ -465,18 +467,21 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, Qt::TransformationMode mode) const { QDirectFBPixmapData *that = const_cast(this); +#ifdef QT_NO_DIRECTFB_SUBSURFACE + if (lockFlags()) + that->unlockSurface(); +#endif + if (!dfbSurface || transform.type() != QTransform::TxScale || mode != Qt::FastTransformation) { const QImage *image = that->buffer(); Q_ASSERT(image); const QImage transformed = image->transformed(transform, mode); - that->unlockDirectFB(); QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType); data->fromImage(transformed, Qt::AutoColor); return QPixmap(data); } - that->unlockDirectFB(); const QSize size = transform.mapRect(QRect(0, 0, w, h)).size(); if (size.isEmpty()) @@ -556,14 +561,12 @@ QPaintEngine *QDirectFBPixmapData::paintEngine() const QImage *QDirectFBPixmapData::buffer() { - lockDirectFB(DSLF_READ|DSLF_WRITE); - return lockedImage; -} - -QImage * QDirectFBPixmapData::buffer(DFBSurfaceLockFlags lockFlags) -{ - lockDirectFB(lockFlags); - return lockedImage; + if (!lockFlgs) { + lockSurface(DSLF_READ|DSLF_WRITE); + } + Q_ASSERT(lockFlgs); + Q_ASSERT(!lockedImage.isNull()); + return &lockedImage; } void QDirectFBPixmapData::invalidate() diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index 7b4ae47..5d3a2f6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -81,11 +81,9 @@ public: virtual QImage toImage() const; virtual QPaintEngine *paintEngine() const; virtual QImage *buffer(); - virtual int metric(QPaintDevice::PaintDeviceMetric m) const {return QDirectFBPaintDevice::metric(m);} - - QImage *buffer(DFBSurfaceLockFlags lockFlags); - // Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice + virtual int metric(QPaintDevice::PaintDeviceMetric m) const { return QDirectFBPaintDevice::metric(m); } + inline QImage::Format pixelFormat() const { return imageFormat; } static bool hasAlphaChannel(const QImage &img); inline bool hasAlphaChannel() const { return alpha; } 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 diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index e74adb1..0ce7a53 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -54,6 +54,9 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) +#if !defined QT_NO_DIRECTFB_SUBSURFACE && !defined QT_DIRECTFB_SUBSURFACE +#define QT_DIRECTFB_SUBSURFACE +#endif #if !defined QT_NO_DIRECTFB_LAYER && !defined QT_DIRECTFB_LAYER #define QT_DIRECTFB_LAYER #endif @@ -166,8 +169,11 @@ public: return static_cast(inst); } + void waitIdle(); IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const; +#ifdef QT_DIRECTFB_SUBSURFACE IDirectFBSurface *subSurfaceForWidget(const QWidget *widget, const QRect &area = QRect()) const; +#endif IDirectFB *dfb(); #ifdef QT_NO_DIRECTFB_WM @@ -199,6 +205,12 @@ public: IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options, DFBResult *result); +#ifdef QT_DIRECTFB_SUBSURFACE + IDirectFBSurface *getSubSurface(IDirectFBSurface *surface, + const QRect &rect, + SurfaceCreationOptions options, + DFBResult *result); +#endif void flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags, const QRegion ®ion, const QPoint &offset); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 816bd83..e288199 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -201,7 +201,6 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) const QRect oldRect = geometry(); DFBResult result = DFB_OK; // If we're in a resize, the surface shouldn't be locked - Q_ASSERT((lockedImage == 0) || (rect.size() == geometry().size())); #ifdef QT_DIRECTFB_WM if (!dfbWindow) createWindow(); @@ -416,7 +415,9 @@ void QDirectFBWindowSurface::beginPaint(const QRegion &) void QDirectFBWindowSurface::endPaint(const QRegion &) { - unlockDirectFB(); +#ifdef QT_NO_DIRECTFB_SUBSURFACE + unlockSurface(); +#endif } IDirectFBSurface *QDirectFBWindowSurface::directFBSurface() const -- cgit v0.12