diff options
Diffstat (limited to 'src/engine/Qt3DSRuntimeView.cpp')
-rw-r--r-- | src/engine/Qt3DSRuntimeView.cpp | 101 |
1 files changed, 71 insertions, 30 deletions
diff --git a/src/engine/Qt3DSRuntimeView.cpp b/src/engine/Qt3DSRuntimeView.cpp index 0a8fd54..62f7e82 100644 --- a/src/engine/Qt3DSRuntimeView.cpp +++ b/src/engine/Qt3DSRuntimeView.cpp @@ -52,6 +52,9 @@ #include "Qt3DSDLLManager.h" #include "foundation/Qt3DSSimpleTypes.h" #include "foundation/TrackingAllocator.h" +#include "foundation/Qt3DSPerfTimer.h" +#include <QtGui/qopengl.h> + // For perf log timestamp #include <time.h> #include "Qt3DSArray.h" @@ -171,14 +174,15 @@ public: bool BeginLoad(const QString &sourcePath, const QStringList &variantList) override; bool HasOfflineLoadingCompleted() override; bool InitializeGraphics(const QSurfaceFormat &format, bool delayedLoading, - bool initInRenderThread, const QByteArray &shaderCache) override; + bool initInRenderThread, const QByteArray &shaderCache, + QString &errors) override; void connectSignals() override; void finishAsyncInit() override; void Cleanup() override; bool CanRender() override; - void Render() override; + bool Render() override; bool WasLastFrameDirty() override; bool HandleMessage(const QEvent *inEvent) override; @@ -227,6 +231,7 @@ public: void deleteMeshes(const QStringList &meshNames) override; void addImageProvider(const QString &providerId, QQmlImageProviderBase *provider) override; uint textureId(const QString &elementPath) override; + uint textureId(const QString &elementPath, QSize &size, GLenum &format) override; void SetAttribute(const char *elementPath, const char *attributeName, const char *value) override; bool GetAttribute(const char *elementPath, const char *attributeName, void *value) override; @@ -301,16 +306,19 @@ bool CRuntimeView::HasOfflineLoadingCompleted() } bool CRuntimeView::InitializeGraphics(const QSurfaceFormat &format, bool delayedLoading, - bool initInRenderThread, const QByteArray &shaderCache) + bool initInRenderThread, const QByteArray &shaderCache, + QString &errors) { m_ApplicationCore->EndLoad(); // Next call will initialize the render portion of the scenes. This *must* have a loaded // application to go further as it will bind scene graph data to application data. - m_RuntimeFactory = m_RuntimeFactoryCore->CreateRenderFactory(format, delayedLoading); + m_RuntimeFactory = m_RuntimeFactoryCore->CreateRenderFactory(format,delayedLoading, + signalProxy()); m_Application = m_ApplicationCore->CreateApplication(*m_InputEngine, m_AudioPlayer, *m_RuntimeFactory, shaderCache, - initInRenderThread); + initInRenderThread, + errors); if (!m_Application->createSuccessful()) return false; @@ -324,26 +332,31 @@ bool CRuntimeView::InitializeGraphics(const QSurfaceFormat &format, bool delayed void CRuntimeView::connectSignals() { - m_Presentation->signalProxy()->moveToThread(QThread::currentThread()); signalProxy()->moveToThread(QThread::currentThread()); - QObject::connect(m_Presentation->signalProxy(), &QPresentationSignalProxy::SigSlideEntered, - signalProxy(), &QRuntimeViewSignalProxy::SigSlideEntered); - QObject::connect(m_Presentation->signalProxy(), &QPresentationSignalProxy::SigSlideExited, - signalProxy(), &QRuntimeViewSignalProxy::SigSlideExited); - QObject::connect(m_Presentation->signalProxy(), &QPresentationSignalProxy::SigCustomSignal, - signalProxy(), &QRuntimeViewSignalProxy::SigCustomSignal); - QObject::connect(m_Presentation->signalProxy(), - &QPresentationSignalProxy::SigPresentationReady, - signalProxy(), &QRuntimeViewSignalProxy::SigPresentationReady); - QObject::connect(m_Presentation->signalProxy(), &QPresentationSignalProxy::SigElementsCreated, - signalProxy(), &QRuntimeViewSignalProxy::SigElementsCreated); - QObject::connect(m_Presentation->signalProxy(), &QPresentationSignalProxy::SigMaterialsCreated, - signalProxy(), &QRuntimeViewSignalProxy::SigMaterialsCreated); - QObject::connect(m_Presentation->signalProxy(), - &QPresentationSignalProxy::SigDataOutputValueUpdated, - signalProxy(), - &QRuntimeViewSignalProxy::SigDataOutputValueUpdated); + const auto preslist = m_Application->GetPresentationList(); + + // Connect signalproxies of every presentation. + for (const auto &it : preslist) { + it->signalProxy()->moveToThread((QThread::currentThread())); + QObject::connect(it->signalProxy(), &QPresentationSignalProxy::SigSlideEntered, + signalProxy(), &QRuntimeViewSignalProxy::SigSlideEntered); + QObject::connect(it->signalProxy(), &QPresentationSignalProxy::SigSlideExited, + signalProxy(), &QRuntimeViewSignalProxy::SigSlideExited); + QObject::connect(it->signalProxy(), &QPresentationSignalProxy::SigCustomSignal, + signalProxy(), &QRuntimeViewSignalProxy::SigCustomSignal); + QObject::connect(it->signalProxy(), + &QPresentationSignalProxy::SigPresentationReady, + signalProxy(), &QRuntimeViewSignalProxy::SigPresentationReady); + QObject::connect(it->signalProxy(), &QPresentationSignalProxy::SigElementsCreated, + signalProxy(), &QRuntimeViewSignalProxy::SigElementsCreated); + QObject::connect(it->signalProxy(), &QPresentationSignalProxy::SigMaterialsCreated, + signalProxy(), &QRuntimeViewSignalProxy::SigMaterialsCreated); + QObject::connect(it->signalProxy(), + &QPresentationSignalProxy::SigDataOutputValueUpdated, + signalProxy(), + &QRuntimeViewSignalProxy::SigDataOutputValueUpdated); + } } void CRuntimeView::finishAsyncInit() @@ -357,6 +370,11 @@ void CRuntimeView::Cleanup() { // Q3DStudio_virtual_delete( m_Timer, CTimer ); // Q3DStudio_virtual_delete( m_PerfFileStream, CFileStream ); + const auto preslist = m_Application->GetPresentationList(); + + for (const auto &it : preslist) + QObject::disconnect(it->signalProxy(), 0, signalProxy(), 0); + m_Application = nullptr; Q3DStudio_virtual_delete(m_InputEngine, CTegraInputEngine); if (m_RenderEngine) { @@ -366,8 +384,6 @@ void CRuntimeView::Cleanup() CDLLManager &theDLLManager = CDLLManager::GetDLLManager(); theDLLManager.Cleanup(); - if (m_Presentation) - QObject::disconnect(m_Presentation->signalProxy(), 0, signalProxy(), 0); m_InputEngine = nullptr; m_RenderEngine = nullptr; @@ -385,8 +401,9 @@ bool CRuntimeView::CanRender() * returns KD_TRUE to call egl_render and swap properly, KD_FALSE if there has been no scene update *or redraw. */ -void CRuntimeView::Render() +bool CRuntimeView::Render() { + bool ret = true; if (m_Application.mPtr == nullptr) { // InitializeGraphics has not been called QT3DS_ASSERT(false); @@ -394,12 +411,21 @@ void CRuntimeView::Render() PerfLogGeneralEvent1(DATALOGGER_FRAME); - m_Application->UpdateAndRender(); + ret = m_Application->UpdateAndRender(); if (m_startupTime < 0 && m_startupTimer && m_startupTimer->isValid()) { + m_startupTime = m_startupTimer->elapsed(); m_startupTimer->invalidate(); - qCDebug(PERF_INFO, "RuntimeView: First frame at - %dms", m_startupTime); + double currentTime = m_Application.mPtr->GetRuntimeFactoryCore().GetPerfTimer().CurrentDuration(); + +#ifdef QT3DS_ENABLE_PERF_LOGGING + // Output startup perf logging data + m_Application->OutputPerfLoggingData(); +#endif + qCDebug(PERF_INFO, "*** First frame rendered ***"); + qCDebug(PERF_INFO, "Runtime startup time: %.0fms", currentTime); + qCDebug(PERF_INFO, "Application startup time: %dms", m_startupTime); } if (m_showOnScreenStats) { @@ -439,6 +465,7 @@ void CRuntimeView::Render() manager.PopState(); } + return ret; } bool CRuntimeView::WasLastFrameDirty() @@ -610,7 +637,7 @@ void CRuntimeView::GoToTime(const char *elementPath, const float time) Q3DStudio::CQmlEngine &theBridgeEngine = static_cast<Q3DStudio::CQmlEngine &>(m_RuntimeFactoryCore->GetScriptEngineQml()); - theBridgeEngine.GotoTime(elementPath, time); + theBridgeEngine.GotoTime(elementPath, time, false); } } @@ -756,6 +783,20 @@ uint CRuntimeView::textureId(const QString &elementPath) return 0; } +uint CRuntimeView::textureId(const QString &elementPath, QSize &size, GLenum &format) +{ + if (m_Application) { + Q3DStudio::CQmlEngine &theBridgeEngine + = static_cast<Q3DStudio::CQmlEngine &>(m_RuntimeFactoryCore->GetScriptEngineQml()); + return theBridgeEngine.textureId(elementPath, + &m_RuntimeFactory->GetQt3DSRenderContext().GetRenderer(), + size, format); + } + size = {}; + format = GL_INVALID_ENUM; + return 0; +} + void CRuntimeView::SetAttribute(const char *elementPath, const char *attributeName, const char *value) { @@ -809,7 +850,7 @@ bool CRuntimeView::PeekCustomAction(char *&outElementPath, char *&outActionName) Q3DStudio::TElement *theElement = nullptr; actionAvailable = theBridgeEngine.PeekSignal(theElement, outActionName); if (actionAvailable && theElement) - outElementPath = (char *)theElement->m_Path.c_str(); + outElementPath = (char *)theElement->path().c_str(); } return actionAvailable; |