From 3d909ba8ac0f43af6d70830a5c95df3e741f1221 Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Mon, 8 Jun 2020 10:42:03 +0200 Subject: Quick: Allow to build with -no-opengl Change-Id: I927998b9ffa80a324636855c5dcc92cb57e9d520 Reviewed-by: Laszlo Agocs --- src/multimediawidgets/multimediawidgets.pro | 8 +++++--- src/qtmultimediaquicktools/qdeclarativevideooutput.cpp | 3 +-- .../qdeclarativevideooutput_render.cpp | 10 +++++++++- .../qdeclarativevideooutput_render_p.h | 13 +++++++++++-- src/qtmultimediaquicktools/qsgvideonode_texture.cpp | 14 ++++++++++++-- 5 files changed, 38 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/multimediawidgets/multimediawidgets.pro b/src/multimediawidgets/multimediawidgets.pro index 3163bb1f0..82237a0be 100644 --- a/src/multimediawidgets/multimediawidgets.pro +++ b/src/multimediawidgets/multimediawidgets.pro @@ -1,9 +1,11 @@ # distinct from Qt Multimedia TARGET = QtMultimediaWidgets -QT = core gui multimedia openglwidgets widgets-private +QT = core gui multimedia widgets-private QT_PRIVATE += multimedia-private -qtHaveModule(opengl): \ - QT_PRIVATE += opengl +qtHaveModule(opengl) { + QT += openglwidgets + QT_PRIVATE += opengl +} PRIVATE_HEADERS += \ qvideowidget_p.h \ diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp index caa022c5c..5f5b2f2a0 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp @@ -257,14 +257,13 @@ bool QDeclarativeVideoOutput::createBackend(QMediaService *service) } } } -#if QT_CONFIG(opengl) + if (!backendAvailable) { if (!m_backend) m_backend.reset(new QDeclarativeVideoRendererBackend(this)); if (m_backend->init(service)) backendAvailable = true; } -#endif // QDeclarativeVideoWindowBackend only works when there is a service with a QVideoWindowControl. // Without service, the QDeclarativeVideoRendererBackend should always work. diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp index bdfa23dfb..02026a182 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp @@ -47,7 +47,10 @@ #include #include +#if QT_CONFIG(opengl) #include +#endif + #include #include @@ -60,7 +63,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, videoNodeFactoryLoader, QDeclarativeVideoRendererBackend::QDeclarativeVideoRendererBackend(QDeclarativeVideoOutput *parent) : QDeclarativeVideoBackend(parent), - m_glContext(0), m_frameChanged(false) { m_surface = new QSGVideoItemSurface(this); @@ -277,6 +279,7 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode, QMutexLocker lock(&m_frameMutex); +#if QT_CONFIG(opengl) if (!m_glContext) { m_glContext = QOpenGLContext::currentContext(); m_surface->scheduleOpenGLContextUpdate(); @@ -288,6 +291,7 @@ QSGNode *QDeclarativeVideoRendererBackend::updatePaintNode(QSGNode *oldNode, obj->event(&ev); } } +#endif bool isFrameModified = false; if (m_frameChanged) { @@ -402,10 +406,12 @@ QRectF QDeclarativeVideoRendererBackend::adjustedViewport() const return viewport; } +#if QT_CONFIG(opengl) QOpenGLContext *QDeclarativeVideoRendererBackend::glContext() const { return m_glContext; } +#endif void QDeclarativeVideoRendererBackend::present(const QVideoFrame &frame) { @@ -478,6 +484,7 @@ bool QSGVideoItemSurface::present(const QVideoFrame &frame) return true; } +#if QT_CONFIG(opengl) void QSGVideoItemSurface::scheduleOpenGLContextUpdate() { //This method is called from render thread @@ -489,5 +496,6 @@ void QSGVideoItemSurface::updateOpenGLContext() //Set a dynamic property to access the OpenGL context in Qt Quick render thread. this->setProperty("GLContext", QVariant::fromValue(m_backend->glContext())); } +#endif QT_END_NAMESPACE diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h b/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h index c69e74150..445c5a01a 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h @@ -83,7 +83,10 @@ public: QSGNode *updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data) override; QAbstractVideoSurface *videoSurface() const override; QRectF adjustedViewport() const override; + +#if QT_CONFIG(opengl) QOpenGLContext *glContext() const; +#endif friend class QSGVideoItemSurface; void present(const QVideoFrame &frame); @@ -101,7 +104,11 @@ private: QList m_videoNodeFactories; QSGVideoItemSurface *m_surface; QVideoSurfaceFormat m_surfaceFormat; - QOpenGLContext *m_glContext; + +#if QT_CONFIG(opengl) + QOpenGLContext *m_glContext = nullptr; +#endif + QVideoFrame m_frame; QVideoFrame m_frameOnFlush; bool m_frameChanged; @@ -131,10 +138,12 @@ public: bool start(const QVideoSurfaceFormat &format) override; void stop() override; bool present(const QVideoFrame &frame) override; - void scheduleOpenGLContextUpdate(); +#if QT_CONFIG(opengl) + void scheduleOpenGLContextUpdate(); private slots: void updateOpenGLContext(); +#endif private: QDeclarativeVideoRendererBackend *m_backend; diff --git a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp index f96d2caf3..7b819511a 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp +++ b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp @@ -49,9 +49,19 @@ QList QSGVideoNodeFactory_Texture::supportedPixelForma QAbstractVideoBuffer::HandleType handleType) const { QList pixelFormats; + + QList types; + auto rhi = QSGRhiSupport::instance(); - auto metalEnabled = rhi->isRhiEnabled() && rhi->rhiBackend() == QRhi::Metal && handleType == QAbstractVideoBuffer::MTLTextureHandle; - if (handleType == QAbstractVideoBuffer::GLTextureHandle || metalEnabled) { + auto metalEnabled = rhi->isRhiEnabled() && rhi->rhiBackend() == QRhi::Metal; + if (metalEnabled) + types.append(QAbstractVideoBuffer::MTLTextureHandle); + +#if QT_CONFIG(opengl) + types.append(QAbstractVideoBuffer::GLTextureHandle); +#endif + + if (types.contains(handleType)) { pixelFormats.append(QVideoFrame::Format_RGB565); pixelFormats.append(QVideoFrame::Format_RGB32); pixelFormats.append(QVideoFrame::Format_ARGB32); -- cgit v1.2.3