directfb: Convert the directfb plugin, disable the OpenGL support

OpenGL was never tested and the platform integration has changed,
remove it from the build and re-enable it once one can test it.

Change-Id: I70d5b5b11de06e6e999d3aae44660f11d2dbc719
Reviewed-on: http://codereview.qt.nokia.com/3666
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Holger Hans Peter Freyther 2011-08-25 00:55:51 +08:00 committed by Lars Knoll
parent 0d7ef7993d
commit 688d9f6ec0
11 changed files with 57 additions and 84 deletions

View File

@ -21,16 +21,16 @@ SOURCES = main.cpp \
qdirectfbconvenience.cpp \ qdirectfbconvenience.cpp \
qdirectfbinput.cpp \ qdirectfbinput.cpp \
qdirectfbcursor.cpp \ qdirectfbcursor.cpp \
qdirectfbwindow.cpp \ qdirectfbwindow.cpp
qdirectfbglcontext.cpp
HEADERS = qdirectfbintegration.h \ HEADERS = qdirectfbintegration.h \
qdirectfbwindowsurface.h \ qdirectfbwindowsurface.h \
qdirectfbblitter.h \ qdirectfbblitter.h \
qdirectfbconvenience.h \ qdirectfbconvenience.h \
qdirectfbinput.h \ qdirectfbinput.h \
qdirectfbcursor.h \ qdirectfbcursor.h \
qdirectfbwindow.h \ qdirectfbwindow.h
qdirectfbglcontext.h
# ### port the GL context
include(../fontdatabases/genericunix/genericunix.pri) include(../fontdatabases/genericunix/genericunix.pri)
target.path += $$[QT_INSTALL_PLUGINS]/platforms target.path += $$[QT_INSTALL_PLUGINS]/platforms

View File

@ -50,9 +50,8 @@ QDirectFBCursor::QDirectFBCursor(QPlatformScreen* screen) :
image = new QPlatformCursorImage(0, 0, 0, 0, 0, 0); image = new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
} }
void QDirectFBCursor::changeCursor(QCursor * cursor, QWidget * widget) void QDirectFBCursor::changeCursor(QCursor * cursor, QWindow * window)
{ {
Q_UNUSED(widget);
int xSpot; int xSpot;
int ySpot; int ySpot;
QPixmap map; QPixmap map;

View File

@ -51,7 +51,7 @@ class QDirectFBCursor : public QPlatformCursor
{ {
public: public:
QDirectFBCursor(QPlatformScreen *screem); QDirectFBCursor(QPlatformScreen *screem);
void changeCursor(QCursor * cursor, QWidget * widget); void changeCursor(QCursor * cursor, QWindow * window);
private: private:
IDirectFBDisplayLayer * m_layer; IDirectFBDisplayLayer * m_layer;

View File

@ -47,7 +47,6 @@
#include <QWindowSystemInterface> #include <QWindowSystemInterface>
#include <QMouseEvent> #include <QMouseEvent>
#include <QEvent> #include <QEvent>
#include <QApplication>
#include <directfb.h> #include <directfb.h>
@ -82,9 +81,9 @@ void QDirectFbInput::stopInputEventLoop()
m_waitStop.acquire(); m_waitStop.acquire();
} }
void QDirectFbInput::addWindow(DFBWindowID id, QWidget *tlw) void QDirectFbInput::addWindow(DFBWindowID id, QWindow *qt_window)
{ {
m_tlwMap.insert(id,tlw); m_tlwMap.insert(id,qt_window);
IDirectFBWindow *window; IDirectFBWindow *window;
m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,id,&window); m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,id,&window);
@ -152,7 +151,7 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event)
} else if (event.window.type == DWET_BUTTONUP) { } else if (event.window.type == DWET_BUTTONUP) {
window->UngrabPointer(window); window->UngrabPointer(window);
} }
QWidget *tlw = m_tlwMap.value(event.window.window_id); QWindow *tlw = m_tlwMap.value(event.window.window_id);
QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons); QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons);
} }
@ -161,7 +160,7 @@ void QDirectFbInput::handleWheelEvent(const DFBEvent &event)
QPoint p(event.window.cx, event.window.cy); QPoint p(event.window.cx, event.window.cy);
QPoint globalPos = globalPoint(event); QPoint globalPos = globalPoint(event);
long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000); long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000);
QWidget *tlw = m_tlwMap.value(event.window.window_id); QWindow *tlw = m_tlwMap.value(event.window.window_id);
QWindowSystemInterface::handleWheelEvent(tlw, timestamp, p, globalPos, QWindowSystemInterface::handleWheelEvent(tlw, timestamp, p, globalPos,
event.window.step*120, event.window.step*120,
Qt::Vertical); Qt::Vertical);
@ -178,13 +177,13 @@ void QDirectFbInput::handleKeyEvents(const DFBEvent &event)
QChar character; QChar character;
if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE) if (DFB_KEY_TYPE(event.window.key_symbol) == DIKT_UNICODE)
character = QChar(event.window.key_symbol); character = QChar(event.window.key_symbol);
QWidget *tlw = m_tlwMap.value(event.window.window_id); QWindow *tlw = m_tlwMap.value(event.window.window_id);
QWindowSystemInterface::handleKeyEvent(tlw, timestamp, type, key, modifiers, character); QWindowSystemInterface::handleKeyEvent(tlw, timestamp, type, key, modifiers, character);
} }
void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event) void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event)
{ {
QWidget *tlw = m_tlwMap.value(event.window.window_id); QWindow *tlw = m_tlwMap.value(event.window.window_id);
switch (event.window.type) { switch (event.window.type) {
case DWET_ENTER: case DWET_ENTER:
QWindowSystemInterface::handleEnterEvent(tlw); QWindowSystemInterface::handleEnterEvent(tlw);

View File

@ -57,7 +57,7 @@ class QDirectFbInput : public QObject
Q_OBJECT Q_OBJECT
public: public:
QDirectFbInput(QObject *parent); QDirectFbInput(QObject *parent);
void addWindow(DFBWindowID id, QWidget *tlw); void addWindow(DFBWindowID id, QWindow *window);
void removeWindow(WId wId); void removeWindow(WId wId);
public slots: public slots:
@ -80,7 +80,7 @@ private:
bool m_shouldStop; bool m_shouldStop;
QSemaphore m_waitStop; QSemaphore m_waitStop;
QHash<DFBWindowID,QWidget *>m_tlwMap; QHash<DFBWindowID,QWindow *>m_tlwMap;
}; };
#endif // QDIRECTFBINPUT_H #endif // QDIRECTFBINPUT_H

View File

@ -49,10 +49,9 @@
#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h> #include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h> #include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
#include <private/qwindowsurface_raster_p.h>
#include <private/qpixmap_raster_p.h>
#include <QtGui/private/qpixmap_blitter_p.h> #include <QtGui/private/qpixmap_blitter_p.h>
#include <QtGui/private/qpixmap_raster_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qplatformpixmap_qpa.h> #include <QtGui/qplatformpixmap_qpa.h>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QThread> #include <QtCore/QThread>
@ -85,7 +84,10 @@ QDirectFbScreen::~QDirectFbScreen()
QDirectFbIntegration::QDirectFbIntegration() QDirectFbIntegration::QDirectFbIntegration()
: mFontDb(new QGenericUnixFontDatabase()) : mFontDb(new QGenericUnixFontDatabase())
, mEventDispatcher(createUnixEventDispatcher())
{ {
QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher);
const QStringList args = QCoreApplication::arguments(); const QStringList args = QCoreApplication::arguments();
int argc = args.size(); int argc = args.size();
char **argv = new char*[argc]; char **argv = new char*[argc];
@ -101,8 +103,9 @@ QDirectFbIntegration::QDirectFbIntegration()
delete[] argv; delete[] argv;
QDirectFbScreen *primaryScreen = new QDirectFbScreen(0); QDirectFbScreen *primaryScreen = new QDirectFbScreen(0);
mScreens.append(primaryScreen); screenAdded(primaryScreen);
mInputRunner = new QThread; mInputRunner = new QThread;
mInput = new QDirectFbInput(0); mInput = new QDirectFbInput(0);
@ -126,21 +129,20 @@ QPlatformPixmap *QDirectFbIntegration::createPlatformPixmap(QPlatformPixmap::Pix
return new QDirectFbBlitterPlatformPixmap; return new QDirectFbBlitterPlatformPixmap;
} }
QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWidget *widget, WId winId) const QPlatformWindow *QDirectFbIntegration::createPlatformWindow(QWindow *window) const
{ {
Q_UNUSED(winId);
QDirectFbInput *input = const_cast<QDirectFbInput *>(mInput);//gah QDirectFbInput *input = const_cast<QDirectFbInput *>(mInput);//gah
return new QDirectFbWindow(widget,input); return new QDirectFbWindow(window,input);
} }
QAbstractEventDispatcher *QDirectFbIntegration::createEventDispatcher() const QAbstractEventDispatcher *QDirectFbIntegration::guiThreadEventDispatcher() const
{ {
return createUnixEventDispatcher(); return mEventDispatcher;
} }
QWindowSurface *QDirectFbIntegration::createWindowSurface(QWidget *widget, WId winId) const QPlatformBackingStore *QDirectFbIntegration::createPlatformBackingStore(QWindow *window) const
{ {
return new QDirectFbWindowSurface(widget,winId); return new QDirectFbWindowSurface(window);
} }
QPlatformFontDatabase *QDirectFbIntegration::fontDatabase() const QPlatformFontDatabase *QDirectFbIntegration::fontDatabase() const

View File

@ -56,7 +56,6 @@ class QDirectFBCursor;
class QDirectFbScreen : public QPlatformScreen class QDirectFbScreen : public QPlatformScreen
{ {
Q_OBJECT
public: public:
QDirectFbScreen(int display); QDirectFbScreen(int display);
~QDirectFbScreen(); ~QDirectFbScreen();
@ -86,19 +85,17 @@ public:
~QDirectFbIntegration(); ~QDirectFbIntegration();
QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const; QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; QPlatformWindow *createPlatformWindow(QWindow *window) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
QAbstractEventDispatcher *createEventDispatcher() const; QAbstractEventDispatcher *guiThreadEventDispatcher() const;
QList<QPlatformScreen *> screens() const { return mScreens; }
QPlatformFontDatabase *fontDatabase() const; QPlatformFontDatabase *fontDatabase() const;
private: private:
QList<QPlatformScreen *> mScreens;
QDirectFbInput *mInput; QDirectFbInput *mInput;
QThread *mInputRunner; QThread *mInputRunner;
QPlatformFontDatabase *mFontDb; QPlatformFontDatabase *mFontDb;
QAbstractEventDispatcher *mEventDispatcher;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -41,15 +41,12 @@
#include "qdirectfbwindow.h" #include "qdirectfbwindow.h"
#include "qdirectfbinput.h" #include "qdirectfbinput.h"
#include "qdirectfbglcontext.h"
#include <QWidget>
#include "qdirectfbwindowsurface.h" #include "qdirectfbwindowsurface.h"
#include <directfb.h> #include <directfb.h>
QDirectFbWindow::QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler) QDirectFbWindow::QDirectFbWindow(QWindow *tlw, QDirectFbInput *inputhandler)
: QPlatformWindow(tlw), m_inputHandler(inputhandler), m_context(0) : QPlatformWindow(tlw), m_inputHandler(inputhandler), m_context(0)
{ {
IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer();
@ -63,10 +60,10 @@ QDirectFbWindow::QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler)
|DWDESC_OPTIONS |DWDESC_OPTIONS
#endif #endif
|DWDESC_CAPS); |DWDESC_CAPS);
description.width = tlw->rect().width(); description.width = tlw->width();
description.height = tlw->rect().height(); description.height = tlw->height();
description.posx = tlw->rect().x(); description.posx = tlw->x();
description.posy = tlw->rect().y(); description.posy = tlw->y();
if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED) if (layerConfig.surface_caps & DSCAPS_PREMULTIPLIED)
description.surface_caps = DSCAPS_PREMULTIPLIED; description.surface_caps = DSCAPS_PREMULTIPLIED;
@ -85,7 +82,7 @@ QDirectFbWindow::QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler)
m_dfbWindow->SetOpacity(m_dfbWindow,0xff); m_dfbWindow->SetOpacity(m_dfbWindow,0xff);
setVisible(widget()->isVisible()); setVisible(window()->visible());
DFBWindowID id; DFBWindowID id;
m_dfbWindow->GetID(m_dfbWindow, &id); m_dfbWindow->GetID(m_dfbWindow, &id);
@ -100,17 +97,20 @@ QDirectFbWindow::~QDirectFbWindow()
void QDirectFbWindow::setGeometry(const QRect &rect) void QDirectFbWindow::setGeometry(const QRect &rect)
{ {
bool isMoveOnly = (rect.topLeft() != geometry().topLeft()) && (rect.size() == geometry().size()); // bool isMoveOnly = (rect.topLeft() != geometry().topLeft()) && (rect.size() == geometry().size());
QPlatformWindow::setGeometry(rect); QPlatformWindow::setGeometry(rect);
if (widget()->isVisible() && !(widget()->testAttribute(Qt::WA_DontShowOnScreen))) { if (window()->visible()) {
m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(), m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(),
rect.width(), rect.height()); rect.width(), rect.height());
// ### TODO port, verify if this is needed
#if 0
//Hack. When moving since the WindowSurface of a window becomes invalid when moved //Hack. When moving since the WindowSurface of a window becomes invalid when moved
if (isMoveOnly) { //if resize then windowsurface is updated. if (isMoveOnly) { //if resize then windowsurface is updated.
widget()->windowSurface()->resize(rect.size()); widget()->windowSurface()->resize(rect.size());
widget()->update(); window()->update();
} }
#endif
} }
} }
@ -170,22 +170,3 @@ WId QDirectFbWindow::winId() const
return WId(id); return WId(id);
} }
QPlatformGLContext *QDirectFbWindow::glContext() const
{
if (!m_context) {
IDirectFBSurface *surface;
DFBResult result = m_dfbWindow->GetSurface(m_dfbWindow,&surface);
if (result != DFB_OK) {
qWarning("could not retrieve surface in QDirectFbWindow::glContext()");
return 0;
}
IDirectFBGL *gl;
result = surface->GetGL(surface,&gl);
if (result != DFB_OK) {
qWarning("could not retrieve IDirectFBGL in QDirectFbWindow::glContext()");
return 0;
}
const_cast<QDirectFbWindow *>(this)->m_context = new QDirectFbGLContext(gl);
}
return m_context;
}

View File

@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
class QDirectFbWindow : public QPlatformWindow class QDirectFbWindow : public QPlatformWindow
{ {
public: public:
QDirectFbWindow(QWidget *tlw, QDirectFbInput *inputhandler); QDirectFbWindow(QWindow *tlw, QDirectFbInput *inputhandler);
~QDirectFbWindow(); ~QDirectFbWindow();
void setGeometry(const QRect &rect); void setGeometry(const QRect &rect);
@ -65,13 +65,9 @@ public:
void lower(); void lower();
WId winId() const; WId winId() const;
QPlatformGLContext *glContext() const;
private: private:
IDirectFBWindow *m_dfbWindow; IDirectFBWindow *m_dfbWindow;
QDirectFbInput *m_inputHandler; QDirectFbInput *m_inputHandler;
QPlatformGLContext *m_context;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -49,20 +49,20 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
QDirectFbWindowSurface::QDirectFbWindowSurface(QWidget *window, WId wId) QDirectFbWindowSurface::QDirectFbWindowSurface(QWindow *window)
: QWindowSurface(window), m_pixmap(0), m_pmdata(0), m_dfbSurface(0) : QPlatformBackingStore(window), m_pixmap(0), m_pmdata(0), m_dfbSurface(0)
{ {
IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer(); IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer();
DFBWindowID id(wId); DFBWindowID id(window->winId());
IDirectFBWindow *dfbWindow; IDirectFBWindow *dfbWindow;
layer->GetWindow(layer,id,&dfbWindow); layer->GetWindow(layer,id,&dfbWindow);
dfbWindow->GetSurface(dfbWindow,&m_dfbSurface); dfbWindow->GetSurface(dfbWindow,&m_dfbSurface);
//WRONGSIZE //WRONGSIZE
QDirectFbBlitter *blitter = new QDirectFbBlitter(window->rect().size(), m_dfbSurface); QDirectFbBlitter *blitter = new QDirectFbBlitter(window->size(), m_dfbSurface);
m_pmdata = new QDirectFbBlitterPlatformPixmap; m_pmdata = new QDirectFbBlitterPlatformPixmap;
m_pmdata->setBlittable(blitter); m_pmdata->setBlittable(blitter);
m_pixmap = new QPixmap(m_pmdata); m_pixmap = new QPixmap(m_pmdata);
@ -78,9 +78,8 @@ QPaintDevice *QDirectFbWindowSurface::paintDevice()
return m_pixmap; return m_pixmap;
} }
void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset) void QDirectFbWindowSurface::flush(QWindow *, const QRegion &region, const QPoint &offset)
{ {
Q_UNUSED(widget);
m_pmdata->blittable()->unlock(); m_pmdata->blittable()->unlock();
QVector<QRect> rects = region.rects(); QVector<QRect> rects = region.rects();
@ -91,9 +90,9 @@ void QDirectFbWindowSurface::flush(QWidget *widget, const QRegion &region, const
} }
} }
void QDirectFbWindowSurface::resize(const QSize &size) void QDirectFbWindowSurface::resize(const QSize &size, const QRegion& reg)
{ {
QWindowSurface::resize(size); QPlatformBackingStore::resize(size, reg);
//Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable //Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable
m_dfbSurface->AddRef(m_dfbSurface); m_dfbSurface->AddRef(m_dfbSurface);

View File

@ -42,22 +42,22 @@
#ifndef QWINDOWSURFACE_DIRECTFB_H #ifndef QWINDOWSURFACE_DIRECTFB_H
#define QWINDOWSURFACE_DIRECTFB_H #define QWINDOWSURFACE_DIRECTFB_H
#include <QtGui/private/qwindowsurface_p.h> #include <qplatformbackingstore_qpa.h>
#include <private/qpixmap_blitter_p.h> #include <private/qpixmap_blitter_p.h>
#include <directfb.h> #include <directfb.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDirectFbWindowSurface : public QWindowSurface class QDirectFbWindowSurface : public QPlatformBackingStore
{ {
public: public:
QDirectFbWindowSurface(QWidget *window, WId wid); QDirectFbWindowSurface(QWindow *window);
~QDirectFbWindowSurface(); ~QDirectFbWindowSurface();
QPaintDevice *paintDevice(); QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset); void flush(QWindow *window, const QRegion &region, const QPoint &offset);
void resize (const QSize &size); void resize (const QSize &size, const QRegion &staticContents);
bool scroll(const QRegion &area, int dx, int dy); bool scroll(const QRegion &area, int dx, int dy);
void beginPaint(const QRegion &region); void beginPaint(const QRegion &region);