summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAnders Bakken <anders.bakken@nokia.com>2009-08-17 20:34:36 (GMT)
committerAnders Bakken <anders.bakken@nokia.com>2009-08-17 22:11:00 (GMT)
commitf844d3905e80194be7d56cbb631ae31ef36f29f8 (patch)
tree135ffef3b89917285718698bba7abcac85916326 /src/plugins
parent469c79c72dcac4e2306682c8c2a650c5e6a74d3d (diff)
downloadQt-f844d3905e80194be7d56cbb631ae31ef36f29f8.zip
Qt-f844d3905e80194be7d56cbb631ae31ef36f29f8.tar.gz
Qt-f844d3905e80194be7d56cbb631ae31ef36f29f8.tar.bz2
Clean up DirectFB with WM enabled
When we have proper window manager support from DirectFB we shouldn't create our own primary surface. This patch vastly cleans up a number of issues in QDirectFBScreen regarding this. Reviewed-by: Donald <qt-info@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp146
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h2
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp46
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h5
4 files changed, 123 insertions, 76 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index c54c1c6..774162c 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -64,13 +64,16 @@ public:
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
IDirectFB *dfb;
- IDirectFBSurface *primarySurface;
DFBSurfaceFlipFlags flipFlags;
+ QDirectFBScreen::DirectFBFlags directFBFlags;
+ QImage::Format alphaPixmapFormat;
+ IDirectFBScreen *dfbScreen;
+#ifdef QT_NO_DIRECTFB_WM
+ IDirectFBSurface *primarySurface;
+#endif
#ifndef QT_NO_DIRECTFB_LAYER
IDirectFBDisplayLayer *dfbLayer;
#endif
- IDirectFBScreen *dfbScreen;
-
QSet<IDirectFBSurface*> allocatedSurfaces;
#ifndef QT_NO_DIRECTFB_MOUSE
@@ -79,26 +82,26 @@ public:
#ifndef QT_NO_DIRECTFB_KEYBOARD
QDirectFBKeyboardHandler *keyboard;
#endif
- QDirectFBScreen::DirectFBFlags directFBFlags;
- QImage::Format alphaPixmapFormat;
QColor backgroundColor;
QDirectFBScreen *q;
};
QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr)
- : QWSGraphicsSystem(qptr), dfb(0), primarySurface(0), flipFlags(DSFLIP_NONE)
+ : QWSGraphicsSystem(qptr), dfb(0), flipFlags(DSFLIP_NONE),
+ directFBFlags(QDirectFBScreen::NoFlags), alphaPixmapFormat(QImage::Format_Invalid),
+ dfbScreen(0)
+#ifdef QT_NO_DIRECTFB_WM
+ , primarySurface(0)
+#endif
#ifndef QT_NO_DIRECTFB_LAYER
, dfbLayer(0)
#endif
- , dfbScreen(0)
#ifndef QT_NO_DIRECTFB_MOUSE
, mouse(0)
#endif
#ifndef QT_NO_DIRECTFB_KEYBOARD
, keyboard(0)
#endif
- , directFBFlags(QDirectFBScreen::NoFlags)
- , alphaPixmapFormat(QImage::Format_Invalid)
, q(qptr)
{
#ifndef QT_NO_QWS_SIGNALHANDLER
@@ -119,8 +122,10 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate()
(*it)->Release(*it);
}
+#ifdef QT_NO_DIRECTFB_WM
if (primarySurface)
primarySurface->Release(primarySurface);
+#endif
#ifndef QT_NO_DIRECTFB_LAYER
if (dfbLayer)
@@ -366,10 +371,12 @@ IDirectFB *QDirectFBScreen::dfb()
return d_ptr->dfb;
}
+#ifdef QT_NO_DIRECTFB_WM
IDirectFBSurface *QDirectFBScreen::primarySurface()
{
return d_ptr->primarySurface;
}
+#endif
#ifndef QT_NO_DIRECTFB_LAYER
IDirectFBDisplayLayer *QDirectFBScreen::dfbDisplayLayer()
@@ -863,6 +870,36 @@ static inline bool setIntOption(const QStringList &arguments, const QString &var
return false;
}
+static inline int depth(QImage::Format format)
+{
+ switch (format) {
+ case QImage::Format_Mono:
+ case QImage::Format_MonoLSB:
+ return 1;
+ case QImage::Format_Indexed8:
+ return 8;
+ case QImage::Format_RGB32:
+ case QImage::Format_ARGB32:
+ case QImage::Format_ARGB32_Premultiplied:
+ return 32;
+ case QImage::Format_ARGB8565_Premultiplied:
+ case QImage::Format_RGB666:
+ case QImage::Format_ARGB6666_Premultiplied:
+ case QImage::Format_ARGB8555_Premultiplied:
+ case QImage::Format_RGB888:
+ return 24;
+ case QImage::Format_RGB555:
+ case QImage::Format_RGB444:
+ case QImage::Format_RGB16:
+ case QImage::Format_ARGB4444_Premultiplied:
+ return 16;
+ case QImage::Format_Invalid:
+ case QImage::NImageFormats:
+ break;
+ }
+ return -1;
+}
+
bool QDirectFBScreen::connect(const QString &displaySpec)
{
DFBResult result = DFB_OK;
@@ -923,7 +960,9 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
DFBSurfaceDescription description;
memset(&description, 0, sizeof(DFBSurfaceDescription));
+ IDirectFBSurface *surface;
+#ifdef QT_NO_DIRECTFB_WM
description.flags = DSDESC_CAPS;
if (::setIntOption(displayArgs, QLatin1String("width"), &description.width))
description.flags |= DSDESC_WIDTH;
@@ -959,8 +998,15 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
return false;
}
+ surface = d_ptr->primarySurface;
+#else
+ description.flags = DSDESC_WIDTH|DSDESC_HEIGHT;
+ description.width = description.height = 1;
+ surface = createDFBSurface(description, DontTrackSurface);
+#endif
// Work out what format we're going to use for surfaces with an alpha channel
- d_ptr->alphaPixmapFormat = QDirectFBScreen::getImageFormat(d_ptr->primarySurface);
+ d_ptr->alphaPixmapFormat = QDirectFBScreen::getImageFormat(surface);
+
setPixelFormat(d_ptr->alphaPixmapFormat);
switch (d_ptr->alphaPixmapFormat) {
case QImage::Format_RGB666:
@@ -994,29 +1040,11 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
// works already
break;
}
- d_ptr->primarySurface->GetSize(d_ptr->primarySurface, &w, &h);
+ QScreen::d = ::depth(pixelFormat());
data = 0;
lstep = 0;
size = 0;
- dw = w;
- dh = h;
-
- DFBSurfacePixelFormat format;
- result = d_ptr->primarySurface->GetPixelFormat(d_ptr->primarySurface, &format);
- if (result == DFB_OK)
- QScreen::d = depth(format);
- else
- DirectFBError("QDirectFBScreen: error getting surface format", result);
-
- physWidth = physHeight = -1;
- ::setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth);
- ::setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight);
- const int dpi = 72;
- if (physWidth < 0)
- physWidth = qRound(dw * 25.4 / dpi);
- if (physHeight < 0)
- physHeight = qRound(dh * 25.4 / dpi);
#ifndef QT_NO_DIRECTFB_LAYER
result = d_ptr->dfb->GetDisplayLayer(d_ptr->dfb, DLID_PRIMARY,
@@ -1035,12 +1063,35 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
"Unable to get screen!", result);
return false;
}
+ result = d_ptr->dfbScreen->GetSize(d_ptr->dfbScreen, &w, &h);
+ if (result != DFB_OK) {
+ DirectFBError("QDirectFBScreen::connect: "
+ "Unable to get screen size!", result);
+ return false;
+ }
+
+ dw = w;
+ dh = h;
+
+ Q_ASSERT(dw != 0 && dh != 0);
+
+ physWidth = physHeight = -1;
+ ::setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth);
+ ::setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight);
+ const int dpi = 72;
+ if (physWidth < 0)
+ physWidth = qRound(dw * 25.4 / dpi);
+ if (physHeight < 0)
+ physHeight = qRound(dh * 25.4 / dpi);
setGraphicsSystem(d_ptr);
#if (Q_DIRECTFB_VERSION >= 0x000923)
if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive))
- printDirectFBInfo(d_ptr->dfb, d_ptr->primarySurface);
+ printDirectFBInfo(d_ptr->dfb, surface);
+#endif
+#ifndef QT_NO_DIRECTFB_WM
+ surface->Release(surface);
#endif
QRegExp backgroundColorRegExp("bgcolor=?(.+)");
@@ -1056,8 +1107,10 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
void QDirectFBScreen::disconnect()
{
+#ifdef QT_NO_DIRECTFB_WM
d_ptr->primarySurface->Release(d_ptr->primarySurface);
d_ptr->primarySurface = 0;
+#endif
foreach (IDirectFBSurface *surf, d_ptr->allocatedSurfaces)
surf->Release(surf);
@@ -1153,25 +1206,9 @@ QWSWindowSurface *QDirectFBScreen::createSurface(const QString &key) const
// QT_NO_DIRECTFB_WM isn't set), exposeRegion will simply return. If
// QT_NO_DIRECTFB_WM is set, exposeRegion will compose only non-directFB
// window surfaces. Normal, directFB surfaces are handled by DirectFB.
-static inline bool needExposeRegion()
-{
-#ifdef QT_NO_DIRECTFB_WM
- return true;
-#endif
-#ifdef QT_NO_DIRECTFB_LAYER
-#ifndef QT_NO_QWS_CURSOR
- return true;
-#endif
-#endif
- return false;
-}
-
void QDirectFBScreen::exposeRegion(QRegion r, int changing)
{
- if (!needExposeRegion()) {
- return;
- }
-
+#ifdef QT_NO_DIRECTFB_WM
const QList<QWSWindow*> windows = QWSServer::instance()->clientWindows();
if (changing < 0 || changing >= windows.size())
return;
@@ -1206,8 +1243,8 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing)
source.x(), source.y(), source.width(), source.height()
};
d_ptr->primarySurface->Blit(d_ptr->primarySurface, surface, &rect,
- windowGeometry.x() + source.x(),
- windowGeometry.y() + source.y());
+ windowGeometry.x() + source.x(),
+ windowGeometry.y() + source.y());
} else {
const QVector<QRect> rects = insideWindow.rects();
QVarLengthArray<DFBRectangle, 16> dfbRectangles(n);
@@ -1224,7 +1261,7 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing)
dfbPoints[i].y = (windowGeometry.y() + source.y());
}
d_ptr->primarySurface->BatchBlit(d_ptr->primarySurface, surface, dfbRectangles.constData(),
- dfbPoints.constData(), n);
+ dfbPoints.constData(), n);
}
}
}
@@ -1244,10 +1281,18 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing)
}
}
flipSurface(d_ptr->primarySurface, d_ptr->flipFlags, r, QPoint());
+#else
+ Q_UNUSED(r);
+ Q_UNUSED(changing);
+#endif
}
void QDirectFBScreen::solidFill(const QColor &color, const QRegion &region)
{
+#ifdef QT_DIRECTFB_WM
+ Q_UNUSED(color);
+ Q_UNUSED(region);
+#else
if (region.isEmpty())
return;
@@ -1270,6 +1315,7 @@ void QDirectFBScreen::solidFill(const QColor &color, const QRegion &region)
}
d_ptr->primarySurface->FillRectangles(d_ptr->primarySurface, rectArray.constData(), n);
}
+#endif
}
void QDirectFBScreen::erase(const QRegion &region)
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
index a95708b..3f9248e 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
@@ -133,7 +133,9 @@ public:
}
IDirectFB *dfb();
+#ifdef QT_NO_DIRECTFB_WM
IDirectFBSurface *primarySurface();
+#endif
#ifndef QT_NO_DIRECTFB_LAYER
IDirectFBDisplayLayer *dfbDisplayLayer();
#endif
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
index 55d6466..584f334 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
@@ -60,8 +60,6 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect
{
#ifdef QT_NO_DIRECTFB_WM
mode = Offscreen;
-#else
- mode = Window;
#endif
setSurfaceFlags(Opaque | Buffered);
#ifdef QT_DIRECTFB_TIMING
@@ -78,17 +76,18 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect
, flipFlags(flip)
, boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
{
+#ifdef QT_NO_DIRECTFB_WM
if (widget && widget->testAttribute(Qt::WA_PaintOnScreen)) {
setSurfaceFlags(Opaque | RegionReserved);
mode = Primary;
} else {
-#ifdef QT_NO_DIRECTFB_WM
mode = Offscreen;
-#else
- mode = Window;
-#endif
setSurfaceFlags(Opaque | Buffered);
}
+#else
+ setSurfaceFlags(Opaque | Buffered);
+#endif
+
#ifdef QT_DIRECTFB_TIMING
frames = 0;
timer.start();
@@ -170,8 +169,10 @@ static DFBResult setGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const
void QDirectFBWindowSurface::setGeometry(const QRect &rect)
{
+#ifdef QT_NO_DIRECTFB_WM
IDirectFBSurface *primarySurface = screen->primarySurface();
Q_ASSERT(primarySurface);
+#endif
if (rect.isNull()) {
#ifndef QT_NO_DIRECTFB_WM
if (dfbWindow) {
@@ -180,9 +181,10 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect)
}
#endif
if (dfbSurface) {
- if (dfbSurface != primarySurface) {
+#ifdef QT_NO_DIRECTFB_WM
+ if (dfbSurface != primarySurface)
+#endif
dfbSurface->Release(dfbSurface);
- }
dfbSurface = 0;
}
} else if (rect != geometry()) {
@@ -190,8 +192,12 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect)
DFBResult result = DFB_OK;
// If we're in a resize, the surface shouldn't be locked
Q_ASSERT((lockedImage == 0) || (rect.size() == geometry().size()));
- switch (mode) {
- case Primary:
+#ifdef QT_DIRECTFB_WM
+ if (!dfbWindow)
+ createWindow();
+ ::setGeometry(dfbWindow, oldRect, rect);
+#else
+ if (mode == Primary) {
if (dfbSurface && dfbSurface != primarySurface)
dfbSurface->Release(dfbSurface);
if (rect == screen->region().boundingRect()) {
@@ -201,15 +207,7 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect)
rect.width(), rect.height() };
result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface);
}
- break;
- case Window:
-#ifndef QT_NO_DIRECTFB_WM
- if (!dfbWindow)
- createWindow();
- ::setGeometry(dfbWindow, oldRect, rect);
-#endif
- break;
- case Offscreen: {
+ } else {
if (!dfbSurface || oldRect.size() != rect.size()) {
if (dfbSurface)
dfbSurface->Release(dfbSurface);
@@ -218,9 +216,8 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect)
const QRegion region = QRegion(oldRect.isEmpty() ? screen->region() : QRegion(oldRect)).subtracted(rect);
screen->erase(region);
screen->flipSurface(primarySurface, flipFlags, region, QPoint());
- break; }
}
-
+#endif
if (size() != geometry().size()) {
delete engine;
engine = 0;
@@ -348,6 +345,7 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion &region,
}
const QRect windowGeometry = QDirectFBWindowSurface::geometry();
+#ifdef QT_NO_DIRECTFB_WM
IDirectFBSurface *primarySurface = screen->primarySurface();
if (mode == Offscreen) {
primarySurface->SetBlittingFlags(primarySurface, DSBLIT_NOFX);
@@ -400,9 +398,9 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion &region,
}
if (mode == Offscreen) {
screen->flipSurface(primarySurface, flipFlags, region, offset + windowGeometry.topLeft());
- } else {
- screen->flipSurface(dfbSurface, flipFlags, region, offset);
- }
+ } else
+#endif
+ screen->flipSurface(dfbSurface, flipFlags, region, offset);
#ifdef QT_DIRECTFB_TIMING
enum { Secs = 3 };
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
index 396cc32..64b1920 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
@@ -92,11 +92,12 @@ private:
IDirectFBWindow *dfbWindow;
#endif
+#ifdef QT_NO_DIRECTFB_WM
enum Mode {
Primary,
- Offscreen,
- Window
+ Offscreen
} mode;
+#endif
QList<QImage*> bufferImages;
DFBSurfaceFlipFlags flipFlags;