From 02f1420dadfc9b68a31181d60d6dfd6e622ce3e8 Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Tue, 19 Mar 2019 11:12:03 +0100 Subject: QGraphicsVideoItem: Always use generic painter when no gl paint engine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If eglfs is used, then there is valid current gl context and it has OpenGL shader programs (QGLShaderProgram::hasOpenGLShaderPrograms). This gl context makes QPainterVideoSurface to use QVideoSurfaceGlslPainter instead of QVideoSurfaceGenericPainter. QOpenGLCompositorBackingStore uses QImage as a QPaintDevice. In this case QPainter::beginNativePainting does nothing because of QRasterPaintEngine. Since QVideoSurfaceGlslPainter is supposed to work with a gl paint engine and not with a raster one, this prevents rendering any video content. To work this around, view->setViewport(new QOpenGLWidget) could be used, where QOpenGL2PaintEngineEx will be taken into account. If platform was not eglfs, QGLContext::currentContext() could be unavailable which made QPainterVideoSurface to use QVideoSurfaceGenericPainter and the video was rendered correctly. QVideoSurfaceGenericPainter should be used when the paint engine is not gl based. Task-number: QTBUG-57836 Change-Id: Id4839facddb2494ec5abf729ea80068eb5e2af1d Reviewed-by: Andy Shaw Reviewed-by: Christian Strømme --- src/multimediawidgets/qgraphicsvideoitem.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/multimediawidgets/qgraphicsvideoitem.cpp b/src/multimediawidgets/qgraphicsvideoitem.cpp index 002fc2cc2..38f5c0e5b 100644 --- a/src/multimediawidgets/qgraphicsvideoitem.cpp +++ b/src/multimediawidgets/qgraphicsvideoitem.cpp @@ -376,11 +376,15 @@ void QGraphicsVideoItem::paint( if (widget) connect(widget, SIGNAL(destroyed()), d->surface, SLOT(viewportDestroyed())); - d->surface->setGLContext(const_cast(QGLContext::currentContext())); - if (d->surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { - d->surface->setShaderType(QPainterVideoSurface::GlslShader); - } else { - d->surface->setShaderType(QPainterVideoSurface::FragmentProgramShader); + if (painter->paintEngine()->type() == QPaintEngine::OpenGL + || painter->paintEngine()->type() == QPaintEngine::OpenGL2) + { + d->surface->setGLContext(const_cast(QGLContext::currentContext())); + if (d->surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) { + d->surface->setShaderType(QPainterVideoSurface::GlslShader); + } else { + d->surface->setShaderType(QPainterVideoSurface::FragmentProgramShader); + } } #endif if (d->rendererControl && d->rendererControl->surface() != d->surface) -- cgit v1.2.3