summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2020-06-08 10:42:03 +0200
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2020-06-10 14:33:49 +0200
commit3d909ba8ac0f43af6d70830a5c95df3e741f1221 (patch)
tree7802b0c29b6dc19c65640e8d46f8dad70c148786 /src
parent22ae5eec6314b59c8a969b743a9c05fb184cc9b2 (diff)
Quick: Allow to build with -no-opengl
Change-Id: I927998b9ffa80a324636855c5dcc92cb57e9d520 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/multimediawidgets/multimediawidgets.pro8
-rw-r--r--src/qtmultimediaquicktools/qdeclarativevideooutput.cpp3
-rw-r--r--src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp10
-rw-r--r--src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h13
-rw-r--r--src/qtmultimediaquicktools/qsgvideonode_texture.cpp14
5 files changed, 38 insertions, 10 deletions
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 <private/qmediapluginloader_p.h>
#include <private/qsgvideonode_p.h>
+#if QT_CONFIG(opengl)
#include <QtGui/QOpenGLContext>
+#endif
+
#include <QtQuick/QQuickWindow>
#include <QtCore/QRunnable>
@@ -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<QObject*>(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<QSGVideoNodeFactoryInterface*> 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<QVideoFrame::PixelFormat> QSGVideoNodeFactory_Texture::supportedPixelForma
QAbstractVideoBuffer::HandleType handleType) const
{
QList<QVideoFrame::PixelFormat> pixelFormats;
+
+ QList<QAbstractVideoBuffer::HandleType> 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);