summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-03-19 11:12:03 +0100
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-05-13 08:42:27 +0000
commit02f1420dadfc9b68a31181d60d6dfd6e622ce3e8 (patch)
treea85e6740799dc8ff2e19cce78bcacaf1a78e8a1f
parent4bcd9000baf27241c52931365c91a42c5ae2f83c (diff)
QGraphicsVideoItem: Always use generic painter when no gl paint engine
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 <andy.shaw@qt.io> Reviewed-by: Christian Strømme <christian.stromme@qt.io>
-rw-r--r--src/multimediawidgets/qgraphicsvideoitem.cpp14
1 files 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 *>(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 *>(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)