diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2019-08-07 16:52:00 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2019-08-13 11:52:25 +0300 |
commit | 7ea21a4315b1c6df104d80a700680dd1f9d204dc (patch) | |
tree | 8b5dca8ca23a2acdab6f8ad1f911faad1fdb1ddc /src/api/studio3dqml/q3dsstudio3d.cpp | |
parent | d2a1092b93e9669288dc1d5825bfec849bec9f95 (diff) |
Make runtime initialization optionally not block QML
Runtime initialization made non-blocking by offloading it to a worker
thread. This causes various object thread affinities in runtime
to be incorrect. This is relevant at least for the singaling,
where having affinity to non-existing initialization thread would
cause signals to not be delivered.
To work around this issue, signal proxy thread affinitions and
signal connections are set after initialization has completed.
Similarly, behavior script QML engine initialization is deferred
so that it can be done in correct thread.
Task-number: QT3DS-3805
Change-Id: Ie8b64f4ecd93e4c422e369e625080652d67bde27
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/api/studio3dqml/q3dsstudio3d.cpp')
-rw-r--r-- | src/api/studio3dqml/q3dsstudio3d.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/api/studio3dqml/q3dsstudio3d.cpp b/src/api/studio3dqml/q3dsstudio3d.cpp index 8183d7b..736846e 100644 --- a/src/api/studio3dqml/q3dsstudio3d.cpp +++ b/src/api/studio3dqml/q3dsstudio3d.cpp @@ -211,6 +211,31 @@ void Q3DSStudio3D::setError(const QString &error) } /*! + \qmlproperty bool Studio3D::asyncInit + + If set to \c{true}, indicates that renderer initialization should be done asynchronously + in a helper thread. This improves UI responsiveness while initialization is happening, + but can lead to slower initialization. Asynchronous initialization may not work properly + on all platforms. + + Defaults to \c{false}. + + Changing this property after renderer is created doesn't do anything. +*/ +bool Q3DSStudio3D::asyncInit() const +{ + return m_asyncInit; +} + +void Q3DSStudio3D::setAsyncInit(bool enabled) +{ + if (enabled != m_asyncInit) { + m_asyncInit = enabled; + Q_EMIT asyncInitChanged(m_asyncInit); + } +} + +/*! \qmlproperty EventIgnoreFlags Studio3D::ignoredEvents This property can be used to ignore mouse/wheel/keyboard events. @@ -295,7 +320,10 @@ void Q3DSStudio3D::handleWindowChanged(QQuickWindow *window) if (!window) return; - window->setClearBeforeRendering(false); + // We need to enable clearing until the presentation starts rendering and takes care of that. + // Note that having this flag as false assumes presentation is always full screen. + window->setClearBeforeRendering(m_asyncInit); + m_pixelRatio = window->devicePixelRatio(); // Call tick every frame of the GUI thread to notify QML about new frame via frameUpdate signal @@ -380,8 +408,7 @@ QQuickFramebufferObject::Renderer *Q3DSStudio3D::createRenderer() const // and the plugin, and vice-versa. The only valid time the two // may communicate is during Q3DSRenderer::synchronize(). Q3DSRenderer *renderer = new Q3DSRenderer(isVisible(), m_presentation->d_ptr->streamProxy(), - m_startupTimer.get()); - + m_startupTimer.get(), m_asyncInit); connect(renderer, &Q3DSRenderer::enterSlide, m_presentation->d_ptr, &Q3DSPresentationPrivate::handleSlideEntered); connect(renderer, &Q3DSRenderer::dataOutputValueUpdated, |