summaryrefslogtreecommitdiffstats
path: root/src/plugins/android/src
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2020-06-30 15:08:39 +0200
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2020-06-30 18:07:32 +0200
commit127a0db704b588183a718892d416048e9cb42a33 (patch)
tree1fcaaf2da6351d3357e7654f66bb579aecb7dd4f /src/plugins/android/src
parentd97efea0caaa9741f21e7e30b394d292ea80c9b0 (diff)
Android: Use current gl context as share
If a video surface contains gl context, it is now used as a share. Otherwise nothing is rendered. The gl context is set when updatePaintNode is called for the video output quick item. Also context's offscreen window now should be on the same thread as the surface. Task-number: QTBUG-78678 Change-Id: I8f2bdd56a5ce209edc206b74ffa5c48e34e7218f Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/plugins/android/src')
-rw-r--r--src/plugins/android/src/common/qandroidvideooutput.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/android/src/common/qandroidvideooutput.cpp b/src/plugins/android/src/common/qandroidvideooutput.cpp
index fd6eb0e8b..27cea76ad 100644
--- a/src/plugins/android/src/common/qandroidvideooutput.cpp
+++ b/src/plugins/android/src/common/qandroidvideooutput.cpp
@@ -349,14 +349,19 @@ bool QAndroidTextureVideoOutput::renderFrameToFbo()
if (!m_nativeSize.isValid() || !m_surfaceTexture)
return false;
+ 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 || (!QOpenGLContext::currentContext() && !m_glContext)) {
// Create Hidden QWindow surface to create context in this thread.
m_offscreenSurface = new QWindow();
m_offscreenSurface->setSurfaceType(QWindow::OpenGLSurface);
// Needs geometry to be a valid surface, but size is not important.
m_offscreenSurface->setGeometry(0, 0, 1, 1);
m_offscreenSurface->create();
+ m_offscreenSurface->moveToThread(m_surface->thread());
// Create OpenGL context and set share context from surface.
m_glContext = new QOpenGLContext();
@@ -365,7 +370,6 @@ bool QAndroidTextureVideoOutput::renderFrameToFbo()
auto surface = qobject_cast<QAbstractVideoSurface *>(m_surface->property("videoSurface").value<QObject *>());
if (!surface)
surface = m_surface;
- auto shareContext = qobject_cast<QOpenGLContext *>(surface->property("GLContext").value<QObject *>());
if (shareContext)
m_glContext->setShareContext(shareContext);