diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-03-31 07:41:39 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-03-31 09:32:07 (GMT) |
commit | a93f6b21f636df4840f86099c76d287afb978001 (patch) | |
tree | dc85d58ebc1ac7ee9d653157f42242cbc379a636 /src/plugins/platforms/minimal | |
parent | a31270b5fc88460d6923ac1f2b5b6e90da59c9c8 (diff) | |
download | Qt-a93f6b21f636df4840f86099c76d287afb978001.zip Qt-a93f6b21f636df4840f86099c76d287afb978001.tar.gz Qt-a93f6b21f636df4840f86099c76d287afb978001.tar.bz2 |
Refactoring GraphicsSystem to QPlatformIntegration
QPlatformIntegration is the "main" integration class which needs to be
subclassed.
This is done so that we don't pollute GraphicsSystem with functionality
that really does not belong there.
In lighthouse applications needs now to be started with
-platform some_platform
Diffstat (limited to 'src/plugins/platforms/minimal')
6 files changed, 344 insertions, 0 deletions
diff --git a/src/plugins/platforms/minimal/main.cpp b/src/plugins/platforms/minimal/main.cpp new file mode 100644 index 0000000..44c274b --- /dev/null +++ b/src/plugins/platforms/minimal/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/QPlatformIntegrationPlugin> +#include "qplatformintegration_minimal.h" + +QT_BEGIN_NAMESPACE + +class QMinimalIntegrationPlugin : public QPlatformIntegrationPlugin +{ +public: + QStringList keys() const; + QPlatformIntegration *create(const QString&); +}; + +QStringList QMinimalIntegrationPlugin::keys() const +{ + QStringList list; + list << "Minimal"; + return list; +} + +QPlatformIntegration *QMinimalIntegrationPlugin::create(const QString& system) +{ + if (system.toLower() == "minimal") + return new QMinimalIntegration; + + return 0; +} + +Q_EXPORT_PLUGIN2(minimal, QMinimalIntegrationPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro new file mode 100644 index 0000000..567b551 --- /dev/null +++ b/src/plugins/platforms/minimal/minimal.pro @@ -0,0 +1,13 @@ +TARGET = qminimalgraphicssystem +include(../../qpluginbase.pri) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms + +SOURCES = main.cpp \ + qplatformintegration_minimal.cpp \ + qwindowsurface_minimal.cpp +HEADERS = qplatformintegration_minimal.h \ + qwindowsurface_minimal.h + +target.path += $$[QT_INSTALL_PLUGINS]/platforms +INSTALLS += target diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp new file mode 100644 index 0000000..693e0c3 --- /dev/null +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.cpp @@ -0,0 +1,25 @@ +#include "qplatformintegration_minimal.h" +#include "qwindowsurface_minimal.h" + +#include <QtGui/private/qpixmap_raster_p.h> + +QMinimalIntegration::QMinimalIntegration() +{ + QMinimalScreen *mPrimaryScreen = new QMinimalScreen(); + + mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); + mPrimaryScreen->mDepth = 16; + mPrimaryScreen->mFormat = QImage::Format_RGB16; + mPrimaryScreen->mPhysicalSize = QSize(40, 54); + + mScreens.append(mPrimaryScreen); +} + +QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type) const +{ + return new QRasterPixmapData(type); +} +QWindowSurface *QMinimalIntegration::createWindowSurface(QWidget *widget) const +{ + return new QMinimalWindowSurface(widget); +} diff --git a/src/plugins/platforms/minimal/qplatformintegration_minimal.h b/src/plugins/platforms/minimal/qplatformintegration_minimal.h new file mode 100644 index 0000000..d4eb78b --- /dev/null +++ b/src/plugins/platforms/minimal/qplatformintegration_minimal.h @@ -0,0 +1,85 @@ + +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMINTEGRATION_MINIMAL_H +#define QPLATFORMINTEGRATION_MINIMAL_H + +#include <QtGui/QPlatformIntegration> +#include <QtGui/QPlatformScreen> + +QT_BEGIN_NAMESPACE + +class QMinimalScreen : public QPlatformScreen +{ +public: + QMinimalScreen() + : mDepth(16), mFormat(QImage::Format_RGB16) {} + + QRect geometry() const { return mGeometry; } + int depth() const { return mDepth; } + QImage::Format format() const { return mFormat; } + QSize physicalSize() const { return mPhysicalSize; } + +public: + QRect mGeometry; + int mDepth; + QImage::Format mFormat; + QSize mPhysicalSize; +}; + +class QMinimalIntegration : public QPlatformIntegration +{ +public: + QMinimalIntegration(); + + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + + QList<QPlatformScreen *> screens() const { return mScreens; } + +private: + QList<QPlatformScreen *> mScreens; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp b/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp new file mode 100644 index 0000000..0b2bdd2 --- /dev/null +++ b/src/plugins/platforms/minimal/qwindowsurface_minimal.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwindowsurface_minimal.h" +#include <QtCore/qdebug.h> +#include <QtGui/private/qapplication_p.h> + +QT_BEGIN_NAMESPACE + +QMinimalWindowSurface::QMinimalWindowSurface(QWidget *window) + : QWindowSurface(window) +{ + //qDebug() << "QMinimalWindowSurface::QMinimalWindowSurface:" << (long)this; +} + +QMinimalWindowSurface::~QMinimalWindowSurface() +{ +} + +QPaintDevice *QMinimalWindowSurface::paintDevice() +{ + //qDebug() << "QMinimalWindowSurface::paintDevice"; + return &mImage; +} + +void QMinimalWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(widget); + Q_UNUSED(region); + Q_UNUSED(offset); + + static int c = 0; + QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0')); + qDebug() << "QMinimalWindowSurface::flush() saving contents to" << filename.toLocal8Bit().constData(); + mImage.save(filename); +} + +void QMinimalWindowSurface::setGeometry(const QRect &rect) +{ + //qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect; + QWindowSurface::setGeometry(rect); + QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format(); + if (mImage.size() != rect.size()) + mImage = QImage(rect.size(), format); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/minimal/qwindowsurface_minimal.h b/src/plugins/platforms/minimal/qwindowsurface_minimal.h new file mode 100644 index 0000000..959a731 --- /dev/null +++ b/src/plugins/platforms/minimal/qwindowsurface_minimal.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenVG module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_MINIMAL_H +#define QWINDOWSURFACE_MINIMAL_H + +#include <QtGui/private/qwindowsurface_p.h> + +QT_BEGIN_NAMESPACE + +class QMinimalWindowSurface : public QWindowSurface +{ +public: + QMinimalWindowSurface(QWidget *window); + ~QMinimalWindowSurface(); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + +private: + QImage mImage; +}; + +QT_END_NAMESPACE + +#endif |