From 154c3a9b44082a176a9700b5086a7bc758155a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Fri, 20 Jan 2017 14:27:08 +0200 Subject: Move scene2d to own module and implement conditional plugin loading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add quick3dscene2d module - Add importsscene2d qml module - Modify RenderAspect to load plugins conditionally - change autotests to match the module change Change-Id: If6596472acbd9a377561b2bfd2094a0585c781ac Reviewed-by: Antti Määttä --- src/quick3d/quick3dscene2d/items/qscene2d_p.h | 219 ++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 src/quick3d/quick3dscene2d/items/qscene2d_p.h (limited to 'src/quick3d/quick3dscene2d/items/qscene2d_p.h') diff --git a/src/quick3d/quick3dscene2d/items/qscene2d_p.h b/src/quick3d/quick3dscene2d/items/qscene2d_p.h new file mode 100644 index 000000000..1aecbedd7 --- /dev/null +++ b/src/quick3d/quick3dscene2d/items/qscene2d_p.h @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_P_H +#define QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Quick { + +class QScene2D; +class Scene2DManager; + +// render thread -> render thread +static const QEvent::Type INITIALIZE = QEvent::Type(QEvent::User + 1); + +// main thread -> main thread, render thread +static const QEvent::Type RENDER = QEvent::Type(QEvent::User + 2); + +// main thread -> main thread +static const QEvent::Type RENDERSYNC = QEvent::Type(QEvent::User + 3); + +// render thread -> main thread +static const QEvent::Type PREPARE = QEvent::Type(QEvent::User + 4); +static const QEvent::Type INITIALIZED = QEvent::Type(QEvent::User + 5); +static const QEvent::Type RENDERED = QEvent::Type(QEvent::User + 6); + +// main thread -> render thread +static const QEvent::Type QUIT = QEvent::Type(QEvent::User + 7); + +class Q_AUTOTEST_EXPORT Scene2DSharedObject +{ +public: + Scene2DSharedObject(Scene2DManager *manager); + ~Scene2DSharedObject(); + + QQuickRenderControl *m_renderControl; + QQuickWindow *m_quickWindow; + Scene2DManager *m_renderManager; + QOffscreenSurface *m_surface; + + QThread *m_renderThread; + QObject *m_renderObject; + + QWaitCondition m_cond; + QMutex m_mutex; + + bool isInitialized() const; + void setInitialized(); + + void requestQuit(); + bool isQuit() const; + + void requestRender(bool sync); + + bool isSyncRequested() const; + void clearSyncRequest(); + + void wait(); + void wake(); + + bool isPrepared() const; + void setPrepared(); + + void disallowRender(); + bool canRender() const; + + void cleanup(); + +private: + + bool m_disallowed; + bool m_quit; + bool m_requestSync; + bool m_requestRender; + bool m_prepared; + bool m_initialized; +}; + +typedef QSharedPointer Scene2DSharedObjectPtr; + +class Q_AUTOTEST_EXPORT QScene2DPrivate : public Qt3DCore::QNodePrivate +{ +public: + Q_DECLARE_PUBLIC(QScene2D) + + QScene2DPrivate(); + ~QScene2DPrivate(); + + Scene2DManager *m_renderManager; + QMetaObject::Connection m_textureDestroyedConnection; + Qt3DRender::QRenderTargetOutput *m_output; +}; + +struct QScene2DData +{ + QScene2D::RenderPolicy renderPolicy; + Scene2DSharedObjectPtr sharedObject; + Qt3DCore::QNodeId output; +}; + +class Scene2DManager : public QObject +{ + Q_OBJECT +public: + Scene2DManager(QScene2DPrivate *priv); + ~Scene2DManager(); + + QQmlEngine *m_qmlEngine; + QQmlComponent *m_qmlComponent; + QQuickItem *m_rootItem; + QQuickItem *m_item; + + QScene2DPrivate *m_priv; + QSharedPointer m_sharedObject; + + QUrl m_source; + Qt3DCore::QNodeId m_id; + QMetaObject::Connection m_connection; + QScene2D::RenderPolicy m_renderPolicy; + + bool m_requested; + bool m_initialized; + bool m_renderSyncRequested; + bool m_backendInitialized; + bool m_noSourceMode; + bool m_ownEngine; + + void requestRender(); + void requestRenderSync(); + void doRenderSync(); + void startIfInitialized(); + void stopAndClean(); + void run(); + void updateSizes(); + + void setSource(const QUrl &url); + void setItem(QQuickItem *item); + + bool event(QEvent *e) Q_DECL_OVERRIDE; + bool forwardEvent(QEvent *event); + + Q_SIGNAL void onLoadedChanged(); + + void cleanup(); + void setEngine(QQmlEngine *engine); + void engineDestroyed(); +}; + +} // namespace Quick +} // namespace Qt3DRender + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(Qt3DRender::Quick::Scene2DSharedObjectPtr) + +#endif // QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_P_H -- cgit v1.2.3 From dbd24a90610a3a229781edf7c1eb0962b8fb0b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Wed, 1 Feb 2017 14:27:59 +0200 Subject: Split scene2d implementation to multiple files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7926898be5409334ec46b59eec76678c613b0d87 Reviewed-by: Tomi Korpipää Reviewed-by: Kevin Ottens --- src/quick3d/quick3dscene2d/items/qscene2d_p.h | 113 +------------------------- 1 file changed, 1 insertion(+), 112 deletions(-) (limited to 'src/quick3d/quick3dscene2d/items/qscene2d_p.h') diff --git a/src/quick3d/quick3dscene2d/items/qscene2d_p.h b/src/quick3d/quick3dscene2d/items/qscene2d_p.h index 1aecbedd7..4c9a6a842 100644 --- a/src/quick3d/quick3dscene2d/items/qscene2d_p.h +++ b/src/quick3d/quick3dscene2d/items/qscene2d_p.h @@ -48,21 +48,10 @@ // We mean it. // -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include -#include -#include #include +#include QT_BEGIN_NAMESPACE @@ -90,56 +79,6 @@ static const QEvent::Type RENDERED = QEvent::Type(QEvent::User + 6); // main thread -> render thread static const QEvent::Type QUIT = QEvent::Type(QEvent::User + 7); -class Q_AUTOTEST_EXPORT Scene2DSharedObject -{ -public: - Scene2DSharedObject(Scene2DManager *manager); - ~Scene2DSharedObject(); - - QQuickRenderControl *m_renderControl; - QQuickWindow *m_quickWindow; - Scene2DManager *m_renderManager; - QOffscreenSurface *m_surface; - - QThread *m_renderThread; - QObject *m_renderObject; - - QWaitCondition m_cond; - QMutex m_mutex; - - bool isInitialized() const; - void setInitialized(); - - void requestQuit(); - bool isQuit() const; - - void requestRender(bool sync); - - bool isSyncRequested() const; - void clearSyncRequest(); - - void wait(); - void wake(); - - bool isPrepared() const; - void setPrepared(); - - void disallowRender(); - bool canRender() const; - - void cleanup(); - -private: - - bool m_disallowed; - bool m_quit; - bool m_requestSync; - bool m_requestRender; - bool m_prepared; - bool m_initialized; -}; - -typedef QSharedPointer Scene2DSharedObjectPtr; class Q_AUTOTEST_EXPORT QScene2DPrivate : public Qt3DCore::QNodePrivate { @@ -161,59 +100,9 @@ struct QScene2DData Qt3DCore::QNodeId output; }; -class Scene2DManager : public QObject -{ - Q_OBJECT -public: - Scene2DManager(QScene2DPrivate *priv); - ~Scene2DManager(); - - QQmlEngine *m_qmlEngine; - QQmlComponent *m_qmlComponent; - QQuickItem *m_rootItem; - QQuickItem *m_item; - - QScene2DPrivate *m_priv; - QSharedPointer m_sharedObject; - - QUrl m_source; - Qt3DCore::QNodeId m_id; - QMetaObject::Connection m_connection; - QScene2D::RenderPolicy m_renderPolicy; - - bool m_requested; - bool m_initialized; - bool m_renderSyncRequested; - bool m_backendInitialized; - bool m_noSourceMode; - bool m_ownEngine; - - void requestRender(); - void requestRenderSync(); - void doRenderSync(); - void startIfInitialized(); - void stopAndClean(); - void run(); - void updateSizes(); - - void setSource(const QUrl &url); - void setItem(QQuickItem *item); - - bool event(QEvent *e) Q_DECL_OVERRIDE; - bool forwardEvent(QEvent *event); - - Q_SIGNAL void onLoadedChanged(); - - void cleanup(); - void setEngine(QQmlEngine *engine); - void engineDestroyed(); -}; - } // namespace Quick } // namespace Qt3DRender QT_END_NAMESPACE -Q_DECLARE_METATYPE(Qt3DRender::Quick::Scene2DSharedObjectPtr) - #endif // QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_P_H -- cgit v1.2.3 From 725d9ec67f003ed077cc01b15f13d86551c4586f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Wed, 1 Feb 2017 15:23:54 +0200 Subject: Enumerize event ids MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Scene2DEvent to holds the enums. Change-Id: Icd8febe7808acdbe639f9f5aaa5caba0548aa363 Reviewed-by: Tomi Korpipää Reviewed-by: Kevin Ottens --- src/quick3d/quick3dscene2d/items/qscene2d_p.h | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'src/quick3d/quick3dscene2d/items/qscene2d_p.h') diff --git a/src/quick3d/quick3dscene2d/items/qscene2d_p.h b/src/quick3d/quick3dscene2d/items/qscene2d_p.h index 4c9a6a842..82865035f 100644 --- a/src/quick3d/quick3dscene2d/items/qscene2d_p.h +++ b/src/quick3d/quick3dscene2d/items/qscene2d_p.h @@ -62,24 +62,6 @@ namespace Quick { class QScene2D; class Scene2DManager; -// render thread -> render thread -static const QEvent::Type INITIALIZE = QEvent::Type(QEvent::User + 1); - -// main thread -> main thread, render thread -static const QEvent::Type RENDER = QEvent::Type(QEvent::User + 2); - -// main thread -> main thread -static const QEvent::Type RENDERSYNC = QEvent::Type(QEvent::User + 3); - -// render thread -> main thread -static const QEvent::Type PREPARE = QEvent::Type(QEvent::User + 4); -static const QEvent::Type INITIALIZED = QEvent::Type(QEvent::User + 5); -static const QEvent::Type RENDERED = QEvent::Type(QEvent::User + 6); - -// main thread -> render thread -static const QEvent::Type QUIT = QEvent::Type(QEvent::User + 7); - - class Q_AUTOTEST_EXPORT QScene2DPrivate : public Qt3DCore::QNodePrivate { public: -- cgit v1.2.3 From fddaeae702df644c1792a29f1875201e8bd64e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Fri, 17 Feb 2017 15:53:30 +0200 Subject: cleanup scene2d - change mouse event handling Task-number: QTBUG-58876 Change-Id: I103125ff15a4b28a67832eb7b86b1abbd2f3fde8 Reviewed-by: Sean Harmer --- src/quick3d/quick3dscene2d/items/qscene2d_p.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/quick3d/quick3dscene2d/items/qscene2d_p.h') diff --git a/src/quick3d/quick3dscene2d/items/qscene2d_p.h b/src/quick3d/quick3dscene2d/items/qscene2d_p.h index 82865035f..e40d3d6a9 100644 --- a/src/quick3d/quick3dscene2d/items/qscene2d_p.h +++ b/src/quick3d/quick3dscene2d/items/qscene2d_p.h @@ -73,6 +73,7 @@ public: Scene2DManager *m_renderManager; QMetaObject::Connection m_textureDestroyedConnection; Qt3DRender::QRenderTargetOutput *m_output; + QVector m_entities; }; struct QScene2DData @@ -80,6 +81,7 @@ struct QScene2DData QScene2D::RenderPolicy renderPolicy; Scene2DSharedObjectPtr sharedObject; Qt3DCore::QNodeId output; + QVector entityIds; }; } // namespace Quick -- cgit v1.2.3 From 337bc59bb3a162d1a64b05d1dc82b5ec4b99049d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Mon, 13 Mar 2017 09:32:53 +0200 Subject: Scene2D cleanup - register pick events when scene is initialized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current model where mouseGrab is connected to picker signal doesn't work. The pressed event is not sent to scene2d item, because it is already lost when scene2d gets the grabMouse message where it registers to the picker events. This breaks the mouse event sequence (press-move-release) for the quick item. Instead hook to setScene of the node to message scene2d when the scene gets initialized and always register to the picker events. Task-number: QTBUG-58876 Change-Id: Ic9ca4b0899a030336ef20ff2cffbe10b567c36f5 Reviewed-by: Antti Määttä --- src/quick3d/quick3dscene2d/items/qscene2d_p.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/quick3d/quick3dscene2d/items/qscene2d_p.h') diff --git a/src/quick3d/quick3dscene2d/items/qscene2d_p.h b/src/quick3d/quick3dscene2d/items/qscene2d_p.h index e40d3d6a9..217058f5c 100644 --- a/src/quick3d/quick3dscene2d/items/qscene2d_p.h +++ b/src/quick3d/quick3dscene2d/items/qscene2d_p.h @@ -55,6 +55,10 @@ QT_BEGIN_NAMESPACE +namespace Qt3DCore { +class QScene; +} + namespace Qt3DRender { namespace Quick { @@ -70,6 +74,8 @@ public: QScene2DPrivate(); ~QScene2DPrivate(); + void setScene(Qt3DCore::QScene *scene) Q_DECL_OVERRIDE; + Scene2DManager *m_renderManager; QMetaObject::Connection m_textureDestroyedConnection; Qt3DRender::QRenderTargetOutput *m_output; @@ -82,6 +88,7 @@ struct QScene2DData Scene2DSharedObjectPtr sharedObject; Qt3DCore::QNodeId output; QVector entityIds; + bool mouseEnabled; }; } // namespace Quick -- cgit v1.2.3