diff options
Diffstat (limited to 'src/imports/multimedia/qdeclarativevideooutput_render.cpp')
-rw-r--r-- | src/imports/multimedia/qdeclarativevideooutput_render.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/imports/multimedia/qdeclarativevideooutput_render.cpp b/src/imports/multimedia/qdeclarativevideooutput_render.cpp index b74898f90..f65e0512c 100644 --- a/src/imports/multimedia/qdeclarativevideooutput_render.cpp +++ b/src/imports/multimedia/qdeclarativevideooutput_render.cpp @@ -171,7 +171,7 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode, if (!m_glContext) { m_glContext = QOpenGLContext::currentContext(); - m_surface->setProperty("GLContext", QVariant::fromValue<QObject*>(m_glContext)); + m_surface->scheduleOpenGLContextUpdate(); } if (m_frameChanged) { @@ -223,6 +223,11 @@ QAbstractVideoSurface *QDeclarativeVideoRendererBackend::videoSurface() const return m_surface; } +QOpenGLContext *QDeclarativeVideoRendererBackend::glContext() const +{ + return m_glContext; +} + void QDeclarativeVideoRendererBackend::present(const QVideoFrame &frame) { m_frameMutex.lock(); @@ -287,4 +292,16 @@ bool QSGVideoItemSurface::present(const QVideoFrame &frame) return true; } +void QSGVideoItemSurface::scheduleOpenGLContextUpdate() +{ + //This method is called from render thread + QMetaObject::invokeMethod(this, "updateOpenGLContext"); +} + +void QSGVideoItemSurface::updateOpenGLContext() +{ + //Set a dynamic property to access the OpenGL context in Qt Quick render thread. + this->setProperty("GLContext", QVariant::fromValue<QObject*>(m_backend->glContext())); +} + QT_END_NAMESPACE |