summaryrefslogtreecommitdiffstats
path: root/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm')
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm
index 7e2f8722e..0759702e8 100644
--- a/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfvideoframerenderer.mm
@@ -126,8 +126,14 @@ QOpenGLFramebufferObject *AVFVideoFrameRenderer::initRenderer(AVPlayerLayer *lay
//Get size from AVPlayerLayer
m_targetSize = QSize(layer.bounds.size.width, layer.bounds.size.height);
+ QOpenGLContext *shareContext = !m_glContext && m_surface
+ ? qobject_cast<QOpenGLContext*>(m_surface->property("GLContext").value<QObject*>())
+ : nullptr;
+
//Make sure we have an OpenGL context to make current
- if (!QOpenGLContext::currentContext() && !m_glContext) {
+ if ((shareContext && shareContext != QOpenGLContext::currentContext())
+ || (!QOpenGLContext::currentContext() && !m_glContext)) {
+
//Create Hidden QWindow surface to create context in this thread
m_offscreenSurface = new QWindow();
m_offscreenSurface->setSurfaceType(QWindow::OpenGLSurface);
@@ -135,12 +141,6 @@ QOpenGLFramebufferObject *AVFVideoFrameRenderer::initRenderer(AVPlayerLayer *lay
m_offscreenSurface->setGeometry(0, 0, 1, 1);
m_offscreenSurface->create();
- //Create OpenGL context and set share context from surface
- QOpenGLContext *shareContext = 0;
- if (m_surface) {
- //QOpenGLContext *renderThreadContext = 0;
- shareContext = qobject_cast<QOpenGLContext*>(m_surface->property("GLContext").value<QObject*>());
- }
m_glContext = new QOpenGLContext();
m_glContext->setFormat(m_offscreenSurface->requestedFormat());