diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-09-01 22:43:48 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-09-01 22:43:48 (GMT) |
commit | b52bfac9d05de835682b9c2b2e1d79e0246e708a (patch) | |
tree | 456eb1b84771bb619877a9765bb9e431a073eb0b /src/plugins | |
parent | 93906071c31a5008625e727dad530a6f05441baa (diff) | |
parent | add57539ec7cd24346e26b22a5298da50d81e91b (diff) | |
download | Qt-b52bfac9d05de835682b9c2b2e1d79e0246e708a.zip Qt-b52bfac9d05de835682b9c2b2e1d79e0246e708a.tar.gz Qt-b52bfac9d05de835682b9c2b2e1d79e0246e708a.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Diffstat (limited to 'src/plugins')
10 files changed, 225 insertions, 170 deletions
diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index c5da3df..d397050 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -1,47 +1,15 @@ TARGET = qdirectfbscreen include(../../qpluginbase.pri) +include($$QT_SOURCE_TREE/src/gui/embedded/directfb.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers -# These defines might be necessary if your DirectFB driver doesn't -# support all of the DirectFB API. -# -#DEFINES += QT_DIRECTFB_WINDOW_AS_CURSOR -#DEFINES += QT_NO_DIRECTFB_IMAGEPROVIDER -#DEFINES += QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE -#DEFINES += QT_DIRECTFB_IMAGECACHE -#DEFINES += QT_NO_DIRECTFB_WM -#DEFINES += QT_NO_DIRECTFB_LAYER -#DEFINES += QT_NO_DIRECTFB_PALETTE -#DEFINES += QT_NO_DIRECTFB_PREALLOCATED -#DEFINES += QT_NO_DIRECTFB_MOUSE -#DEFINES += QT_NO_DIRECTFB_KEYBOARD -#DEFINES += QT_DIRECTFB_TIMING -#DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION -#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS -#DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" -#DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" - target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target -HEADERS = qdirectfbscreen.h \ - qdirectfbwindowsurface.h \ - qdirectfbpaintengine.h \ - qdirectfbpaintdevice.h \ - qdirectfbpixmap.h \ - qdirectfbkeyboard.h \ - qdirectfbmouse.h - -SOURCES = qdirectfbscreen.cpp \ - qdirectfbscreenplugin.cpp \ - qdirectfbwindowsurface.cpp \ - qdirectfbpaintengine.cpp \ - qdirectfbpaintdevice.cpp \ - qdirectfbpixmap.cpp \ - qdirectfbkeyboard.cpp \ - qdirectfbmouse.cpp +SOURCES += qdirectfbscreenplugin.cpp QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB LIBS += $$QT_LIBS_DIRECTFB DEFINES += $$QT_DEFINES_DIRECTFB +contains(gfx-plugins, directfb):DEFINES += QT_QWS_DIRECTFB diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp index 2fb1520..896f512 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp @@ -121,8 +121,8 @@ QDirectFBMouseHandlerPrivate::QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler return; } - int flags = ::fcntl(fd, F_GETFL, 0); - ::fcntl(fd, F_SETFL, flags | O_NONBLOCK); + int flags = fcntl(fd, F_GETFL, 0); + fcntl(fd, F_SETFL, flags | O_NONBLOCK); // DirectFB seems to assume that the mouse always starts centered prevPoint = QPoint(screen->deviceWidth() / 2, screen->deviceHeight() / 2); 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<DFBSurfaceLockFlags>(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<QDirectFBPaintDevice*>(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 9a9553e..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; @@ -109,7 +110,7 @@ public: #endif void prepareForBlit(bool alpha); -private: + IDirectFBSurface *surface; bool antialiased; @@ -129,7 +130,6 @@ private: QRect currentClip; QDirectFBPaintEngine *q; - friend class QDirectFBPaintEngine; }; class SurfaceCache @@ -222,6 +222,7 @@ template <class T> 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: \ @@ -269,6 +270,7 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) QPixmapData *data = static_cast<QPixmap*>(device)->pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbPixmapData = static_cast<QDirectFBPixmapData*>(data); + QDirectFBPaintEnginePrivate::unlock(dfbPixmapData); d->dfbDevice = static_cast<QDirectFBPaintDevice*>(dfbPixmapData); } @@ -409,14 +411,13 @@ 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(::fillRects<QRect>(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(fillRects<QRect>)(rects, rectCount, state()->matrix, d->surface)); } if (pen != Qt::NoPen) { d->setDFBColor(pen.color()); - CLIPPED_PAINT(::drawRects<QRect>(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects<QRect>)(rects, rectCount, state()->matrix, d->surface)); } } @@ -438,14 +439,13 @@ 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<QRectF>(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(fillRects<QRectF>(rects, rectCount, state()->matrix, d->surface)); } if (pen != Qt::NoPen) { d->setDFBColor(pen.color()); - CLIPPED_PAINT(::drawRects<QRectF>(rects, rectCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects<QRectF>)(rects, rectCount, state()->matrix, d->surface)); } } @@ -464,9 +464,8 @@ 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(::drawLines<QLine>(lines, lineCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines<QLine>)(lines, lineCount, state()->matrix, d->surface)); } } @@ -485,9 +484,8 @@ 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(::drawLines<QLineF>(lines, lineCount, state()->matrix, d->surface)); + CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines<QLineF>)(lines, lineCount, state()->matrix, d->surface)); } } @@ -533,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)); @@ -561,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<QDirectFBPixmapData*>(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<QDirectFBPixmapData*>(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)); + } } } @@ -602,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<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer(DSLF_READ); + QPixmapData *pixmapData = pixmap.pixmapData(); + Q_ASSERT(pixmapData->classId() == QPixmapData::DirectFBClass); + QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(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)); } } @@ -708,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())); @@ -725,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: @@ -749,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())); @@ -811,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); } } @@ -820,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) @@ -1031,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<QDirectFBPixmapData*>(data); - dfbData->unlockDirectFB(); + QDirectFBPaintEnginePrivate::unlock(dfbData); const QSize pixmapSize = dfbData->size(); IDirectFBSurface *sourceSurface = dfbData->directFBSurface(); if (transform.isScaling()) { @@ -1040,8 +1049,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix offset.ry() *= transform.m22(); const QSizeF mappedSize(pixmapSize.width() * transform.m11(), pixmapSize.height() * transform.m22()); - qreal y = ::fixCoord(destinationRect.y(), mappedSize.height(), offset.y()); - const qreal startX = ::fixCoord(destinationRect.x(), mappedSize.width(), offset.x()); + qreal y = fixCoord(destinationRect.y(), mappedSize.height(), offset.y()); + const qreal startX = fixCoord(destinationRect.x(), mappedSize.width(), offset.x()); while (y <= destinationRect.bottom()) { qreal x = startX; while (x <= destinationRect.right()) { @@ -1052,8 +1061,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix y += mappedSize.height(); } } else { - qreal y = ::fixCoord(destinationRect.y(), pixmapSize.height(), offset.y()); - const qreal startX = ::fixCoord(destinationRect.x(), pixmapSize.width(), offset.x()); + qreal y = fixCoord(destinationRect.y(), pixmapSize.height(), offset.y()); + const qreal startX = fixCoord(destinationRect.x(), pixmapSize.width(), offset.x()); int horizontal = qMax(1, destinationRect.width() / pixmapSize.width()) + 1; if (startX != destinationRect.x()) ++horizontal; @@ -1165,12 +1174,12 @@ template <class T> static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface) { if (n == 1) { - const QLine l = ::map(transform, lines[0]); + const QLine l = map(transform, lines[0]); surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); } else { QVarLengthArray<DFBRegion, 32> lineArray(n); for (int i=0; i<n; ++i) { - const QLine l = ::map(transform, lines[i]); + const QLine l = map(transform, lines[i]); lineArray[i].x1 = l.x1(); lineArray[i].y1 = l.y1(); lineArray[i].x2 = l.x2(); @@ -1184,12 +1193,12 @@ template <class T> static inline void fillRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface) { if (n == 1) { - const QRect r = ::mapRect(transform, rects[0]); + const QRect r = mapRect(transform, rects[0]); surface->FillRectangle(surface, r.x(), r.y(), r.width(), r.height()); } else { QVarLengthArray<DFBRectangle, 32> rectArray(n); for (int i=0; i<n; ++i) { - const QRect r = ::mapRect(transform, rects[i]); + const QRect r = mapRect(transform, rects[i]); rectArray[i].x = r.x(); rectArray[i].y = r.y(); rectArray[i].w = r.width(); @@ -1203,7 +1212,7 @@ template <class T> static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface) { for (int i=0; i<n; ++i) { - const QRect r = ::mapRect(transform, rects[i]); + const QRect r = mapRect(transform, rects[i]); surface->DrawRectangle(surface, r.x(), r.y(), r.width(), r.height()); } } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 0717020..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) @@ -167,7 +164,7 @@ static bool checkForAlphaPixels(const QImage &img) bool QDirectFBPixmapData::hasAlphaChannel(const QImage &img) { #ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION - return ::checkForAlphaPixels(img); + return checkForAlphaPixels(img); #else return img.hasAlphaChannel(); #endif @@ -375,9 +372,13 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) QPixmapData::copy(data, rect); return; } - unlockDirectFB(); const QDirectFBPixmapData *otherData = static_cast<const QDirectFBPixmapData*>(data); +#ifdef QT_NO_DIRECTFB_SUBSURFACE + if (otherData->lockFlags()) { + const_cast<QDirectFBPixmapData*>(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); @@ -443,7 +445,7 @@ void QDirectFBPixmapData::fill(const QColor &color) alpha = (color.alpha() < 255); - if (alpha && ::isOpaqueFormat(imageFormat)) { + if (alpha && isOpaqueFormat(imageFormat)) { QSize size; dfbSurface->GetSize(dfbSurface, &size.rwidth(), &size.rheight()); screen->releaseDFBSurface(dfbSurface); @@ -465,18 +467,21 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, Qt::TransformationMode mode) const { QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(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 59fa191..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()); @@ -999,9 +1023,9 @@ static void printDirectFBInfo(IDirectFB *fb, IDirectFBSurface *primarySurface) dev.name, dev.vendor, dev.driver.name, dev.driver.major, dev.driver.minor, dev.driver.vendor, DFB_PIXELFORMAT_INDEX(pixelFormat), QDirectFBScreen::getImageFormat(primarySurface), dev.acceleration_mask, - ::flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(), - dev.blitting_flags, ::flagDescriptions(dev.blitting_flags, blitDescriptions).constData(), - dev.drawing_flags, ::flagDescriptions(dev.drawing_flags, drawDescriptions).constData(), + flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(), + dev.blitting_flags, flagDescriptions(dev.blitting_flags, blitDescriptions).constData(), + dev.drawing_flags, flagDescriptions(dev.drawing_flags, drawDescriptions).constData(), (dev.video_memory >> 10)); } #endif @@ -1067,7 +1091,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec) #ifdef QT_DIRECTFB_IMAGECACHE int imageCacheSize = 4 * 1024 * 1024; // 4 MB - ::setIntOption(displayArgs, QLatin1String("imagecachesize"), &imageCacheSize); + setIntOption(displayArgs, QLatin1String("imagecachesize"), &imageCacheSize); QDirectFBPaintEngine::initImageCache(imageCacheSize); #endif @@ -1191,8 +1215,8 @@ bool QDirectFBScreen::connect(const QString &displaySpec) "Unable to get screen size!", result); return false; } - ::setIntOption(displayArgs, QLatin1String("width"), &w); - ::setIntOption(displayArgs, QLatin1String("height"), &h); + setIntOption(displayArgs, QLatin1String("width"), &w); + setIntOption(displayArgs, QLatin1String("height"), &h); dw = w; dh = h; @@ -1200,8 +1224,8 @@ bool QDirectFBScreen::connect(const QString &displaySpec) Q_ASSERT(dw != 0 && dh != 0); physWidth = physHeight = -1; - ::setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth); - ::setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight); + setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth); + setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight); const int dpi = 72; if (physWidth < 0) physWidth = qRound(dw * 25.4 / dpi); @@ -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<QDirectFBScreen*>(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 73a6dd7..e288199 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -102,6 +102,11 @@ QDirectFBWindowSurface::~QDirectFBWindowSurface() { } +bool QDirectFBWindowSurface::isValid() const +{ + return true; +} + #ifdef QT_DIRECTFB_WM void QDirectFBWindowSurface::raise() { @@ -111,14 +116,7 @@ void QDirectFBWindowSurface::raise() sibling->raise(); } } -#endif -bool QDirectFBWindowSurface::isValid() const -{ - return true; -} - -#ifndef QT_NO_DIRECTFB_WM void QDirectFBWindowSurface::createWindow() { IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer(); @@ -148,10 +146,8 @@ void QDirectFBWindowSurface::createWindow() dfbWindow->GetSurface(dfbWindow, &dfbSurface); updateFormat(); } -#endif // QT_NO_DIRECTFB_WM -#ifndef QT_NO_DIRECTFB_WM -static DFBResult setGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const QRect &rect) +static DFBResult setWindowGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const QRect &rect) { DFBResult result = DFB_OK; const bool isMove = old.isEmpty() || rect.topLeft() != old.topLeft(); @@ -178,7 +174,7 @@ static DFBResult setGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const #endif return result; } -#endif +#endif // QT_NO_DIRECTFB_WM void QDirectFBWindowSurface::setGeometry(const QRect &rect) { @@ -205,11 +201,10 @@ 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(); - ::setGeometry(dfbWindow, oldRect, rect); + setWindowGeometry(dfbWindow, oldRect, rect); #else if (mode == Primary) { if (dfbSurface && dfbSurface != primarySurface) @@ -271,12 +266,12 @@ bool QDirectFBWindowSurface::scroll(const QRegion ®ion, int dx, int dy) return false; dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); if (region.numRects() == 1) { - ::scrollSurface(dfbSurface, region.boundingRect(), dx, dy); + scrollSurface(dfbSurface, region.boundingRect(), dx, dy); } else { const QVector<QRect> rects = region.rects(); const int n = rects.size(); for (int i=0; i<n; ++i) { - ::scrollSurface(dfbSurface, rects.at(i), dx, dy); + scrollSurface(dfbSurface, rects.at(i), dx, dy); } } return true; @@ -420,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 |