summaryrefslogtreecommitdiffstats
path: root/src/api/studio3dqml
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/studio3dqml')
-rw-r--r--src/api/studio3dqml/q3dsrenderer.cpp8
-rw-r--r--src/api/studio3dqml/q3dsrenderer_p.h5
-rw-r--r--src/api/studio3dqml/q3dsstudio3d.cpp15
-rw-r--r--src/api/studio3dqml/q3dsstudio3d_p.h2
4 files changed, 22 insertions, 8 deletions
diff --git a/src/api/studio3dqml/q3dsrenderer.cpp b/src/api/studio3dqml/q3dsrenderer.cpp
index 33c7b98..e3fce5c 100644
--- a/src/api/studio3dqml/q3dsrenderer.cpp
+++ b/src/api/studio3dqml/q3dsrenderer.cpp
@@ -48,7 +48,8 @@ using namespace Q3DSViewer;
QT_BEGIN_NAMESPACE
-Q3DSRenderer::Q3DSRenderer(bool visibleFlag, qt3ds::Qt3DSAssetVisitor *assetVisitor)
+Q3DSRenderer::Q3DSRenderer(bool visibleFlag, qt3ds::Qt3DSAssetVisitor *assetVisitor,
+ QElapsedTimer *startupTimer)
: m_visibleFlag(visibleFlag)
, m_initElements(false)
, m_runtime(0)
@@ -58,8 +59,9 @@ Q3DSRenderer::Q3DSRenderer(bool visibleFlag, qt3ds::Qt3DSAssetVisitor *assetVisi
, m_visitor(assetVisitor)
, m_settings(new Q3DSViewerSettings(this))
, m_presentation(new Q3DSPresentation(this))
+ , m_startupTimer(startupTimer)
{
- m_startupTimer.start();
+
}
Q3DSRenderer::~Q3DSRenderer()
@@ -170,7 +172,7 @@ void Q3DSRenderer::draw()
bool Q3DSRenderer::initializeRuntime(QOpenGLFramebufferObject *inFbo)
{
- m_runtime = &Q3DSViewerApp::Create(nullptr, new Qt3DSAudioPlayerImpl(), &m_startupTimer);
+ m_runtime = &Q3DSViewerApp::Create(nullptr, new Qt3DSAudioPlayerImpl(), m_startupTimer);
Q_ASSERT(m_runtime);
// Connect presentation ready signal before initializing the app
diff --git a/src/api/studio3dqml/q3dsrenderer_p.h b/src/api/studio3dqml/q3dsrenderer_p.h
index 6d044ff..8927f34 100644
--- a/src/api/studio3dqml/q3dsrenderer_p.h
+++ b/src/api/studio3dqml/q3dsrenderer_p.h
@@ -59,7 +59,8 @@ class Q3DSRenderer : public QObject,
Q_OBJECT
public:
- Q3DSRenderer(bool visibleFlag, qt3ds::Qt3DSAssetVisitor *assetVisitor);
+ Q3DSRenderer(bool visibleFlag, qt3ds::Qt3DSAssetVisitor *assetVisitor,
+ QElapsedTimer *startupTimer);
~Q3DSRenderer();
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size) override;
@@ -102,7 +103,7 @@ protected:
Q3DSViewerSettings *m_settings;
Q3DSPresentation *m_presentation;
QString m_error;
- QElapsedTimer m_startupTimer;
+ QElapsedTimer *m_startupTimer;
};
QT_END_NAMESPACE
diff --git a/src/api/studio3dqml/q3dsstudio3d.cpp b/src/api/studio3dqml/q3dsstudio3d.cpp
index deb4f04..38d32d4 100644
--- a/src/api/studio3dqml/q3dsstudio3d.cpp
+++ b/src/api/studio3dqml/q3dsstudio3d.cpp
@@ -152,6 +152,8 @@ Q3DSStudio3D::Q3DSStudio3D()
connect(this, &Q3DSStudio3D::visibleChanged, this, &Q3DSStudio3D::handleVisibleChanged);
updateEventMasks();
+ m_startupTimer.reset(new QElapsedTimer());
+ m_startupTimer->restart();
}
Q3DSStudio3D::~Q3DSStudio3D()
@@ -278,6 +280,10 @@ void Q3DSStudio3D::componentComplete()
QQmlContext *ctx = QQmlEngine::contextForObject(this);
m_presentation->d_ptr->streamProxy()->setEngine(ctx->engine());
+ QObject::connect(m_presentation, &Q3DSPresentationItem::sourceChanged, [this]() {
+ m_startupTimer->restart();
+ });
+
QQuickFramebufferObject::componentComplete();
}
@@ -296,6 +302,8 @@ void Q3DSStudio3D::handleWindowChanged(QQuickWindow *window)
connect(window, &QQuickWindow::afterAnimating, this, &Q3DSStudio3D::tick);
// Call update after the frame is handled to queue another frame
connect(window, &QQuickWindow::afterSynchronizing, this, &Q3DSStudio3D::update);
+
+ reset();
}
/*!
@@ -315,9 +323,9 @@ void Q3DSStudio3D::reset()
{
// Fake a source change to trigger a reloading of the presentation
m_pendingCommands.m_sourceChanged = true;
- m_pendingCommands.m_source = m_presentation->source();
+ m_pendingCommands.m_source = m_presentation ? m_presentation->source() : QString();
m_pendingCommands.m_variantListChanged = true;
- m_pendingCommands.m_variantList = m_presentation->variantList();
+ m_pendingCommands.m_variantList = m_presentation ? m_presentation->variantList() : QStringList();
}
/*!
@@ -371,7 +379,8 @@ QQuickFramebufferObject::Renderer *Q3DSStudio3D::createRenderer() const
// It is "illegal" to create a connection between the renderer
// 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());
+ Q3DSRenderer *renderer = new Q3DSRenderer(isVisible(), m_presentation->d_ptr->streamProxy(),
+ m_startupTimer.get());
connect(renderer, &Q3DSRenderer::enterSlide,
m_presentation->d_ptr, &Q3DSPresentationPrivate::handleSlideEntered);
diff --git a/src/api/studio3dqml/q3dsstudio3d_p.h b/src/api/studio3dqml/q3dsstudio3d_p.h
index eed8459..0fa91d6 100644
--- a/src/api/studio3dqml/q3dsstudio3d_p.h
+++ b/src/api/studio3dqml/q3dsstudio3d_p.h
@@ -45,6 +45,7 @@
#include <QtStudio3D/private/q3dscommandqueue_p.h>
#include <QtGui/qopenglframebufferobject.h>
#include <QtQuick/qquickframebufferobject.h>
+#include <QtCore/qelapsedtimer.h>
QT_BEGIN_NAMESPACE
@@ -128,6 +129,7 @@ protected:
CommandQueue m_pendingCommands;
qreal m_pixelRatio;
QString m_error;
+ QScopedPointer<QElapsedTimer> m_startupTimer;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Q3DSStudio3D::EventIgnoreFlags)