summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2010-04-13 09:38:49 (GMT)
committerPaul Olav Tvete <paul.tvete@nokia.com>2010-04-13 09:38:49 (GMT)
commite8af272c0c95ab531a060d3e8e8e75b7b03619f4 (patch)
treea37fb5c48b9ab0b49a493da303c6884efc705a1f
parentc8f86b525a6eabb91ad4da2dfdd423a32263359a (diff)
downloadQt-e8af272c0c95ab531a060d3e8e8e75b7b03619f4.zip
Qt-e8af272c0c95ab531a060d3e8e8e75b7b03619f4.tar.gz
Qt-e8af272c0c95ab531a060d3e8e8e75b7b03619f4.tar.bz2
Port the QVFb backend to the new API
-rw-r--r--src/plugins/platforms/qvfb/main.cpp16
-rw-r--r--src/plugins/platforms/qvfb/qvfb.pro11
-rw-r--r--src/plugins/platforms/qvfb/qvfbintegration.cpp (renamed from src/plugins/platforms/qvfb/qgraphicssystem_qvfb.cpp)91
-rw-r--r--src/plugins/platforms/qvfb/qvfbintegration.h (renamed from src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h)28
-rw-r--r--src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp38
-rw-r--r--src/plugins/platforms/qvfb/qwindowsurface_qvfb.h26
6 files changed, 113 insertions, 97 deletions
diff --git a/src/plugins/platforms/qvfb/main.cpp b/src/plugins/platforms/qvfb/main.cpp
index b28dde8..409f11c 100644
--- a/src/plugins/platforms/qvfb/main.cpp
+++ b/src/plugins/platforms/qvfb/main.cpp
@@ -39,34 +39,34 @@
**
****************************************************************************/
-#include <private/qgraphicssystemplugin_p.h>
-#include "qgraphicssystem_qvfb.h"
+#include <QPlatformIntegrationPlugin>
+#include "qvfbintegration.h"
#include <qstringlist.h>
QT_BEGIN_NAMESPACE
-class QVFbGraphicsSystemPlugin : public QGraphicsSystemPlugin
+class QVFbIntegrationPlugin : public QPlatformIntegrationPlugin
{
public:
QStringList keys() const;
- QGraphicsSystem *create(const QString&);
+ QPlatformIntegration *create(const QString&);
};
-QStringList QVFbGraphicsSystemPlugin::keys() const
+QStringList QVFbIntegrationPlugin::keys() const
{
QStringList list;
list << "QVFb";
return list;
}
-QGraphicsSystem* QVFbGraphicsSystemPlugin::create(const QString& system)
+QPlatformIntegration* QVFbIntegrationPlugin::create(const QString& system)
{
if (system.toLower() == "qvfb")
- return new QVFbGraphicsSystem;
+ return new QVFbIntegration;
return 0;
}
-Q_EXPORT_PLUGIN2(qvfb, QVFbGraphicsSystemPlugin)
+Q_EXPORT_PLUGIN2(qvfb, QVFbIntegrationPlugin)
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qvfb/qvfb.pro b/src/plugins/platforms/qvfb/qvfb.pro
index b321725..4dec274 100644
--- a/src/plugins/platforms/qvfb/qvfb.pro
+++ b/src/plugins/platforms/qvfb/qvfb.pro
@@ -1,12 +1,11 @@
-TARGET = qvfbgraphicssystem
+TARGET = qvfbintegration
include(../../qpluginbase.pri)
-QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+SOURCES = main.cpp qvfbintegration.cpp qwindowsurface_qvfb.cpp
+HEADERS = qvfbintegration.h qwindowsurface_qvfb.h
-SOURCES = main.cpp qgraphicssystem_qvfb.cpp qwindowsurface_qvfb.cpp
-HEADERS = qgraphicssystem_qvfb.h qwindowsurface_qvfb.h
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
diff --git a/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.cpp b/src/plugins/platforms/qvfb/qvfbintegration.cpp
index 19058a6..2a877e0 100644
--- a/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.cpp
+++ b/src/plugins/platforms/qvfb/qvfbintegration.cpp
@@ -52,7 +52,7 @@
#include <qvfbhdr.h>
#include <qsocketnotifier.h>
-#include "qgraphicssystem_qvfb.h"
+#include "qvfbintegration.h"
#include "qwindowsurface_qvfb.h"
#include <QtGui/private/qpixmap_raster_p.h>
#include <QtCore/qdebug.h>
@@ -65,12 +65,12 @@
QT_BEGIN_NAMESPACE
-class QVFbGraphicsSystemScreenKeyboardHandler : public QObject
+class QVFbScreenKeyboardHandler : public QObject
{
Q_OBJECT
public:
- QVFbGraphicsSystemScreenKeyboardHandler();
- ~QVFbGraphicsSystemScreenKeyboardHandler();
+ QVFbScreenKeyboardHandler();
+ ~QVFbScreenKeyboardHandler();
private slots:
void readKeyboardData();
@@ -83,7 +83,7 @@ private:
QSocketNotifier *keyNotifier;
};
-QVFbGraphicsSystemScreenKeyboardHandler::QVFbGraphicsSystemScreenKeyboardHandler()
+QVFbScreenKeyboardHandler::QVFbScreenKeyboardHandler()
{
int displayId = 0; //TODO displayId
const QString keyboardDev = QT_VFB_KEYBOARD_PIPE(displayId);
@@ -97,8 +97,8 @@ QVFbGraphicsSystemScreenKeyboardHandler::QVFbGraphicsSystemScreenKeyboardHandler
kbdFD = QT_OPEN(keyboardDev.toLatin1().constData(), O_RDWR | O_NDELAY);
if (kbdFD == -1) {
- perror("QVFbGraphicsSystemScreenKeyboardHandler");
- qWarning("QVFbGraphicsSystemScreenKeyboardHandler: Unable to open device %s",
+ perror("QVFbScreenKeyboardHandler");
+ qWarning("QVFbScreenKeyboardHandler: Unable to open device %s",
qPrintable(keyboardDev));
return;
}
@@ -112,7 +112,7 @@ QVFbGraphicsSystemScreenKeyboardHandler::QVFbGraphicsSystemScreenKeyboardHandler
}
-QVFbGraphicsSystemScreenKeyboardHandler::~QVFbGraphicsSystemScreenKeyboardHandler()
+QVFbScreenKeyboardHandler::~QVFbScreenKeyboardHandler()
{
if (kbdFD >= 0)
QT_CLOSE(kbdFD);
@@ -120,7 +120,7 @@ QVFbGraphicsSystemScreenKeyboardHandler::~QVFbGraphicsSystemScreenKeyboardHandle
}
-void QVFbGraphicsSystemScreenKeyboardHandler::readKeyboardData()
+void QVFbScreenKeyboardHandler::readKeyboardData()
{
int n;
do {
@@ -161,12 +161,12 @@ void QVFbGraphicsSystemScreenKeyboardHandler::readKeyboardData()
-class QVFbGraphicsSystemScreenMouseHandler : public QObject
+class QVFbScreenMouseHandler : public QObject
{
Q_OBJECT
public:
- QVFbGraphicsSystemScreenMouseHandler();
- ~QVFbGraphicsSystemScreenMouseHandler();
+ QVFbScreenMouseHandler();
+ ~QVFbScreenMouseHandler();
private slots:
void readMouseData();
@@ -181,7 +181,7 @@ private:
int oldButtonState;
};
-QVFbGraphicsSystemScreenMouseHandler::QVFbGraphicsSystemScreenMouseHandler()
+QVFbScreenMouseHandler::QVFbScreenMouseHandler()
{
int displayId = 0; //TODO: displayId
QString mouseDev = QT_VFB_MOUSE_PIPE(displayId);
@@ -206,13 +206,13 @@ QVFbGraphicsSystemScreenMouseHandler::QVFbGraphicsSystemScreenMouseHandler()
}
-QVFbGraphicsSystemScreenMouseHandler::~QVFbGraphicsSystemScreenMouseHandler()
+QVFbScreenMouseHandler::~QVFbScreenMouseHandler()
{
if (mouseFD >= 0)
QT_CLOSE(mouseFD);
}
-void QVFbGraphicsSystemScreenMouseHandler::readMouseData()
+void QVFbScreenMouseHandler::readMouseData()
{
int n;
do {
@@ -229,7 +229,7 @@ void QVFbGraphicsSystemScreenMouseHandler::readMouseData()
mb += sizeof(QPoint);
int bstate = *reinterpret_cast<int *>(mb);
mb += sizeof(int);
- int wheel = *reinterpret_cast<int *>(mb);
+ //int wheel = *reinterpret_cast<int *>(mb);
int button = bstate ^ oldButtonState;
QEvent::Type type = QEvent::MouseMove;
@@ -254,16 +254,16 @@ void QVFbGraphicsSystemScreenMouseHandler::readMouseData()
}
-class QVFbGraphicsSystemScreenPrivate
+class QVFbScreenPrivate
{
public:
- QVFbGraphicsSystemScreenPrivate(QVFbGraphicsSystemScreen *)
+ QVFbScreenPrivate(QVFbScreen *)
: shmrgn(0), hdr(0), data(0), mouseHandler(0), keyboardHandler(0)
{
connect(0); //for now we only handle one screen
}
- ~QVFbGraphicsSystemScreenPrivate() { disconnect(); }
+ ~QVFbScreenPrivate() { disconnect(); }
void setDirty(const QRect &r);
bool connect(int displayId);
@@ -279,22 +279,22 @@ private:
unsigned char *shmrgn;
QVFbHeader *hdr;
uchar *data;
- QVFbGraphicsSystemScreenMouseHandler *mouseHandler;
- QVFbGraphicsSystemScreenKeyboardHandler *keyboardHandler;
+ QVFbScreenMouseHandler *mouseHandler;
+ QVFbScreenKeyboardHandler *keyboardHandler;
QImage img;
};
-void QVFbGraphicsSystemScreenPrivate::setDirty(const QRect &r)
+void QVFbScreenPrivate::setDirty(const QRect &r)
{
hdr->dirty = true;
hdr->update = hdr->update.united(r);
}
-bool QVFbGraphicsSystemScreenPrivate::connect(int displayId)
+bool QVFbScreenPrivate::connect(int displayId)
{
key_t key = ftok(QT_VFB_MOUSE_PIPE(displayId).toLatin1(), 'b');
@@ -339,12 +339,12 @@ bool QVFbGraphicsSystemScreenPrivate::connect(int displayId)
qDebug("connected %dx%d %d bpp", w, h, d);
- mouseHandler = new QVFbGraphicsSystemScreenMouseHandler;
- keyboardHandler = new QVFbGraphicsSystemScreenKeyboardHandler;
+ mouseHandler = new QVFbScreenMouseHandler;
+ keyboardHandler = new QVFbScreenKeyboardHandler;
return true;
}
-void QVFbGraphicsSystemScreenPrivate::disconnect()
+void QVFbScreenPrivate::disconnect()
{
if ((long)shmrgn != -1 && shmrgn) {
shmdt((char*)shmrgn);
@@ -357,76 +357,81 @@ void QVFbGraphicsSystemScreenPrivate::disconnect()
}
-QVFbGraphicsSystemScreen::QVFbGraphicsSystemScreen()
+QVFbScreen::QVFbScreen()
{
- d_ptr = new QVFbGraphicsSystemScreenPrivate(this);
+ d_ptr = new QVFbScreenPrivate(this);
}
-QVFbGraphicsSystemScreen::~QVFbGraphicsSystemScreen()
+QVFbScreen::~QVFbScreen()
{
delete d_ptr;
}
-void QVFbGraphicsSystemScreen::setDirty(const QRect &rect)
+void QVFbScreen::setDirty(const QRect &rect)
{
d_ptr->setDirty(rect);
}
-QRect QVFbGraphicsSystemScreen::geometry() const {
+QRect QVFbScreen::geometry() const {
return QRect(QPoint(), d_ptr->screenSize());
}
-int QVFbGraphicsSystemScreen::depth() const
+int QVFbScreen::depth() const
{
return d_ptr->depth();
}
-QImage::Format QVFbGraphicsSystemScreen::format() const
+QImage::Format QVFbScreen::format() const
{
return d_ptr->format();
}
-QSize QVFbGraphicsSystemScreen::physicalSize() const {
+QSize QVFbScreen::physicalSize() const {
return (d_ptr->screenSize()*254)/720;
}
#if 0
-int QVFbGraphicsSystemScreen::linestep() const {
+int QVFbScreen::linestep() const {
return d_ptr->screenImage() ? d_ptr->screenImage()->bytesPerLine() : 0;
}
-uchar *QVFbGraphicsSystemScreen::base() const {
+uchar *QVFbScreen::base() const {
return d_ptr->screenImage() ? d_ptr->screenImage()->bits() : 0;
}
#endif
-QImage *QVFbGraphicsSystemScreen::screenImage()
+QImage *QVFbScreen::screenImage()
{
return d_ptr->screenImage();
}
-QVFbGraphicsSystem::QVFbGraphicsSystem()
+QVFbIntegration::QVFbIntegration()
{
- mPrimaryScreen = new QVFbGraphicsSystemScreen();
+ mPrimaryScreen = new QVFbScreen();
mScreens.append(mPrimaryScreen);
}
-QPixmapData *QVFbGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
+QPixmapData *QVFbIntegration::createPixmapData(QPixmapData::PixelType type) const
{
return new QRasterPixmapData(type);
}
-QWindowSurface *QVFbGraphicsSystem::createWindowSurface(QWidget *widget) const
+QWindowSurface *QVFbIntegration::createWindowSurfaceForWindow(QWidget *widget, WId) const
{
if (widget->windowType() == Qt::Desktop)
return 0; // Don't create an explicit window surface for the destkop.
- return new QVFbWindowSurface
- (const_cast<QVFbGraphicsSystem *>(this), mPrimaryScreen, widget);
+ return new QVFbWindowSurface(mPrimaryScreen, widget);
+}
+
+
+QPlatformWindow *QVFbIntegration::createPlatformWindow(QWidget *widget, WId) const
+{
+ return new QVFbWindow(mPrimaryScreen, widget);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h b/src/plugins/platforms/qvfb/qvfbintegration.h
index b31869c..1207678 100644
--- a/src/plugins/platforms/qvfb/qgraphicssystem_qvfb.h
+++ b/src/plugins/platforms/qvfb/qvfbintegration.h
@@ -42,18 +42,19 @@
#ifndef QGRAPHICSSYSTEM_QVFB_H
#define QGRAPHICSSYSTEM_QVFB_H
-#include <QtGui/private/qgraphicssystem_p.h>
+#include <QPlatformScreen>
+#include <QPlatformIntegration>
QT_BEGIN_NAMESPACE
-class QVFbGraphicsSystemScreenPrivate;
+class QVFbScreenPrivate;
-class QVFbGraphicsSystemScreen : public QGraphicsSystemScreen
+class QVFbScreen : public QPlatformScreen
{
public:
- QVFbGraphicsSystemScreen();
- ~QVFbGraphicsSystemScreen();
+ QVFbScreen();
+ ~QVFbScreen();
QRect geometry() const;
int depth() const;
@@ -66,25 +67,26 @@ public:
public:
- QVFbGraphicsSystemScreenPrivate *d_ptr;
+ QVFbScreenPrivate *d_ptr;
};
-class QVFbGraphicsSystemPrivate;
+class QVFbIntegrationPrivate;
-class QVFbGraphicsSystem : public QGraphicsSystem
+class QVFbIntegration : public QPlatformIntegration
{
public:
- QVFbGraphicsSystem();
+ QVFbIntegration();
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
+ QWindowSurface *createWindowSurfaceForWindow(QWidget *widget, WId winId) const;
- QList<QGraphicsSystemScreen *> screens() const { return mScreens; }
+ QList<QPlatformScreen *> screens() const { return mScreens; }
private:
- QVFbGraphicsSystemScreen *mPrimaryScreen;
- QList<QGraphicsSystemScreen *> mScreens;
+ QVFbScreen *mPrimaryScreen;
+ QList<QPlatformScreen *> mScreens;
};
diff --git a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp
index 0aafe28..b46d9c0 100644
--- a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp
+++ b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.cpp
@@ -41,15 +41,15 @@
#include "qwindowsurface_qvfb.h"
-#include "qgraphicssystem_qvfb.h"
+#include "qvfbintegration.h"
#include <QtCore/qdebug.h>
#include <QtGui/qpainter.h>
#include <private/qapplication_p.h>
QT_BEGIN_NAMESPACE
-QVFbWindowSurface::QVFbWindowSurface(QVFbGraphicsSystem *graphicsSystem,
- QVFbGraphicsSystemScreen *screen, QWidget *window)
+QVFbWindowSurface::QVFbWindowSurface(//QVFbIntegration *graphicsSystem,
+ QVFbScreen *screen, QWidget *window)
: QWindowSurface(window),
mScreen(screen)
{
@@ -69,36 +69,40 @@ void QVFbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoi
Q_UNUSED(widget);
Q_UNUSED(offset);
- QRect rect = geometry();
- QPoint topLeft = rect.topLeft();
+// QRect rect = geometry();
+// QPoint topLeft = rect.topLeft();
mScreen->setDirty(region.boundingRect());
}
-void QVFbWindowSurface::setGeometry(const QRect &)
+void QVFbWindowSurface::resize(const QSize&)
{
// any size you like as long as it's full-screen...
QRect rect(mScreen->availableGeometry());
- QWindowSystemInterface::handleGeometryChange(this->window(), rect);
-
- QWindowSurface::setGeometry(rect);
+ QWindowSurface::resize(rect.size());
}
-bool QVFbWindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- return QWindowSurface::scroll(area, dx, dy);
-}
-void QVFbWindowSurface::beginPaint(const QRegion &region)
+QVFbWindow::QVFbWindow(QVFbScreen *screen, QWidget *window)
+ : QPlatformWindow(window),
+ mScreen(screen)
{
- Q_UNUSED(region);
}
-void QVFbWindowSurface::endPaint(const QRegion &region)
+
+void QVFbWindow::setGeometry(const QRect &)
{
- Q_UNUSED(region);
+
+// any size you like as long as it's full-screen...
+
+ QRect rect(mScreen->availableGeometry());
+ QWindowSystemInterface::handleGeometryChange(this->widget(), rect);
+
+ QPlatformWindow::setGeometry(rect);
}
+
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h
index 1971caa..9228189 100644
--- a/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h
+++ b/src/plugins/platforms/qvfb/qwindowsurface_qvfb.h
@@ -43,32 +43,38 @@
#define QWINDOWSURFACE_QVFB_H
#include <QtGui/private/qwindowsurface_p.h>
+#include <QPlatformWindow>
QT_BEGIN_NAMESPACE
-class QVFbGraphicsSystem;
-class QVFbGraphicsSystemScreen;
+class QVFbIntegration;
+class QVFbScreen;
class QVFbWindowSurface : public QWindowSurface
{
public:
- QVFbWindowSurface(QVFbGraphicsSystem *graphicsSystem,
- QVFbGraphicsSystemScreen *screen, QWidget *window);
+ QVFbWindowSurface(QVFbScreen *screen, QWidget *window);
~QVFbWindowSurface();
QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void setGeometry(const QRect &rect);
- bool scroll(const QRegion &area, int dx, int dy);
+ void resize(const QSize &size);
+
+private:
+ QVFbScreen *mScreen;
+};
- void beginPaint(const QRegion &region);
- void endPaint(const QRegion &region);
+class QVFbWindow : public QPlatformWindow
+{
+public:
+ QVFbWindow(QVFbScreen *screen, QWidget *window);
+ void setGeometry(const QRect &rect);
private:
- QVFbGraphicsSystem *mGraphicsSystem;
- QVFbGraphicsSystemScreen *mScreen;
+ QVFbScreen *mScreen;
};
+
QT_END_NAMESPACE
#endif