diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-08-08 14:50:56 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2014-08-08 15:56:44 +0300 |
commit | 78a6d2d7340fbfdc5b5dbfd9974435714bb786fb (patch) | |
tree | a2bb1c366ace5d89e7857e250a7a8cd4fdc493bf | |
parent | 89bb3812ac99a34783ad9c10254a20c25e2d214e (diff) |
Initial version of new software backend for the QtQuick scene graph
Based on the scene graph plugin from Qt Gerrit playground
Change-Id: Ic6e65f912fef70ba5f153113ce68107b56608151
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r-- | software-backend.pro | 3 | ||||
-rw-r--r-- | softwarecontext/context.cpp | 108 | ||||
-rw-r--r-- | softwarecontext/context.h | 78 | ||||
-rw-r--r-- | softwarecontext/pluginmain.cpp | 71 | ||||
-rw-r--r-- | softwarecontext/pluginmain.h | 68 | ||||
-rw-r--r-- | softwarecontext/softwarecontext.json | 3 | ||||
-rw-r--r-- | softwarecontext/softwarecontext.pro | 23 |
7 files changed, 354 insertions, 0 deletions
diff --git a/software-backend.pro b/software-backend.pro new file mode 100644 index 0000000000..90289dd979 --- /dev/null +++ b/software-backend.pro @@ -0,0 +1,3 @@ +TEMPLATE=subdirs +SUBDIRS=softwarecontext + diff --git a/softwarecontext/context.cpp b/softwarecontext/context.cpp new file mode 100644 index 0000000000..e65b854af8 --- /dev/null +++ b/softwarecontext/context.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Scenegraph Playground module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "context.h" + +#include <QtCore/QCoreApplication> +#include <QtCore/QElapsedTimer> + +#include <QtGui/QWindow> + +#include <QtQuick/QSGFlatColorMaterial> +#include <QtQuick/QSGVertexColorMaterial> +#include <QtQuick/QSGOpaqueTextureMaterial> +#include <QtQuick/QSGTextureMaterial> +#include <private/qsgdefaultimagenode_p.h> +#include <private/qsgdefaultrectanglenode_p.h> +#include <private/qsgdistancefieldglyphnode_p_p.h> +#include <private/qsgdefaultglyphnode_p.h> + +#ifndef QSG_NO_RENDERER_TIMING +static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty(); +#endif + +namespace SoftwareContext +{ + +RenderContext::RenderContext(QSGContext *ctx) + : QSGRenderContext(ctx) +{ +} +Context::Context(QObject *parent) + : QSGContext(parent) +{ +} + +void RenderContext::initialize(QOpenGLContext *context) +{ + QSGRenderContext::initialize(context); +} + +void RenderContext::invalidate() +{ + QSGRenderContext::invalidate(); +} + +QSGTexture *RenderContext::createTexture(const QImage &image) const +{ + return QSGRenderContext::createTexture(image); +} + +QSGTexture *RenderContext::createTextureNoAtlas(const QImage &image) const +{ + return QSGRenderContext::createTextureNoAtlas(image); +} + +QSGRenderer *RenderContext::createRenderer() +{ + return QSGRenderContext::createRenderer(); +} + + +void RenderContext::renderNextFrame(QSGRenderer *renderer, GLuint fbo) +{ + QSGRenderContext::renderNextFrame(renderer, fbo); +} + + + + +} // namespace diff --git a/softwarecontext/context.h b/softwarecontext/context.h new file mode 100644 index 0000000000..6ab405c890 --- /dev/null +++ b/softwarecontext/context.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Scenegraph Playground module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CONTEXT_H +#define CONTEXT_H + +#include <private/qsgcontext_p.h> +#include <QtCore/QElapsedTimer> +#include <QtGui/QOpenGLShaderProgram> + +namespace SoftwareContext +{ + +class RenderContext : public QSGRenderContext +{ +public: + RenderContext(QSGContext *ctx); + void initialize(QOpenGLContext *context); + void invalidate(); + void renderNextFrame(QSGRenderer *renderer, GLuint fbo); + QSGTexture *createTexture(const QImage &image) const; + QSGTexture *createTextureNoAtlas(const QImage &image) const; + QSGRenderer *createRenderer(); +}; + +class Context : public QSGContext +{ + Q_OBJECT +public: + explicit Context(QObject *parent = 0); + + QSGRenderContext *createRenderContext() { return new RenderContext(this); } + +private: +}; + +} // namespace + +#endif // CONTEXT_H diff --git a/softwarecontext/pluginmain.cpp b/softwarecontext/pluginmain.cpp new file mode 100644 index 0000000000..192e6225bc --- /dev/null +++ b/softwarecontext/pluginmain.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Scenegraph Playground module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "pluginmain.h" +#include "context.h" + +ContextPlugin::ContextPlugin(QObject *parent) + : QSGContextPlugin(parent) +{ +} + +QStringList ContextPlugin::keys() const +{ + return QStringList() << QLatin1String("softwarecontext"); +} + +QSGContext *ContextPlugin::create(const QString &) const +{ + if (!instance) + instance = new SoftwareContext::Context(); + return instance; +} + +QQuickTextureFactory *ContextPlugin::createTextureFactoryFromImage(const QImage &image) +{ + return 0; +} + +SoftwareContext::Context *ContextPlugin::instance = 0; + + + diff --git a/softwarecontext/pluginmain.h b/softwarecontext/pluginmain.h new file mode 100644 index 0000000000..f8ebf3cb9b --- /dev/null +++ b/softwarecontext/pluginmain.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Scenegraph Playground module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PLUGINMAIN_H +#define PLUGINMAIN_H + +#include <private/qsgcontext_p.h> +#include <private/qsgcontextplugin_p.h> + +#include <qplugin.h> + +#include "context.h" + +class ContextPlugin : public QSGContextPlugin +{ + Q_OBJECT + + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSGContextFactoryInterface" FILE "softwarecontext.json") + +public: + ContextPlugin(QObject *parent = 0); + + QStringList keys() const; + QSGContext *create(const QString &key) const; + QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image); + + static SoftwareContext::Context *instance; +}; + +#endif // PLUGINMAIN_H diff --git a/softwarecontext/softwarecontext.json b/softwarecontext/softwarecontext.json new file mode 100644 index 0000000000..ca87c6c38a --- /dev/null +++ b/softwarecontext/softwarecontext.json @@ -0,0 +1,3 @@ +{ + "Keys": ["softwarecontext"] +} diff --git a/softwarecontext/softwarecontext.pro b/softwarecontext/softwarecontext.pro new file mode 100644 index 0000000000..1d1aea4df1 --- /dev/null +++ b/softwarecontext/softwarecontext.pro @@ -0,0 +1,23 @@ +TEMPLATE=lib +TARGET=softwarecontext + +CONFIG += plugin + +QT += gui-private core-private quick-private qml-private + +SOURCES += \ + context.cpp \ + pluginmain.cpp + +HEADERS += \ + context.h \ + pluginmain.h + +OTHER_FILES += softwarecontext.json + +target.path += $$[QT_INSTALL_PLUGINS]/scenegraph + +files.path += $$[QT_INSTALL_PLUGINS]/scenegraph + +INSTALLS += target files + |