diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2017-01-12 14:04:04 +0100 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2019-04-04 12:10:05 +0000 |
commit | 8663de3fa789d8b8e10c5580b37f6eb3beac9ed6 (patch) | |
tree | 326bb613e96f8944b1bb93d9ff90149725b7c26c /src/compositor/compositor_api | |
parent | c87451570f93fd7bf8653c27d6120f6436b9aaae (diff) |
Compositor: Don't require OpenGL to build the QML APIs
[ChangeLog][Compositor API] The compositor API now works without OpenGL support.
This makes the compositor API work with shared memory clients only. If OpenGL
clients connect they will currently punch holes in the compositor window, but
fixing that is out of scope for this patch.
Fixes: QTBUG-74896
Change-Id: I6c1ba82f28ba9edecf380e471124e15d16f9518e
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/compositor/compositor_api')
5 files changed, 63 insertions, 36 deletions
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri index 3df061459..233815d87 100644 --- a/src/compositor/compositor_api/compositor_api.pri +++ b/src/compositor/compositor_api/compositor_api.pri @@ -63,23 +63,28 @@ qtConfig(draganddrop) { compositor_api/qwaylanddrag.cpp } -qtHaveModule(quick):qtConfig(opengl) { +qtHaveModule(quick) { DEFINES += QT_WAYLAND_COMPOSITOR_QUICK SOURCES += \ compositor_api/qwaylandquickcompositor.cpp \ compositor_api/qwaylandquicksurface.cpp \ compositor_api/qwaylandquickoutput.cpp \ - compositor_api/qwaylandquickitem.cpp \ - compositor_api/qwaylandquickhardwarelayer.cpp + compositor_api/qwaylandquickitem.cpp HEADERS += \ compositor_api/qwaylandquickcompositor.h \ compositor_api/qwaylandquicksurface.h \ compositor_api/qwaylandquickoutput.h \ compositor_api/qwaylandquickitem.h \ - compositor_api/qwaylandquickitem_p.h \ - compositor_api/qwaylandquickhardwarelayer_p.h + compositor_api/qwaylandquickitem_p.h + + qtHaveModule(opengl) { + SOURCES += \ + compositor_api/qwaylandquickhardwarelayer.cpp + HEADERS += \ + compositor_api/qwaylandquickhardwarelayer_p.h + } QT += qml qml-private quick quick-private } diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index 053235432..f07497051 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -243,8 +243,10 @@ QWaylandCompositorPrivate::~QWaylandCompositorPrivate() delete data_device_manager; #endif +#if QT_CONFIG(opengl) // Some client buffer integrations need to clean up before the destroying the wl_display client_buffer_integration.reset(); +#endif wl_display_destroy(display); } diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp index 426008a60..98ad7acb6 100644 --- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp @@ -128,6 +128,7 @@ void QWaylandQuickCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const return; } +#if QT_CONFIG(opengl) QWaylandQuickOutput *output = static_cast<QWaylandQuickOutput *>(defaultOutput()); if (!output) { emit grabber->failed(QWaylandSurfaceGrabber::RendererNotReady); @@ -169,6 +170,9 @@ void QWaylandQuickCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const state->grabber = grabber; state->buffer = buffer; static_cast<QQuickWindow *>(output->window())->scheduleRenderJob(state, QQuickWindow::NoStage); +#else + emit grabber->failed(QWaylandSurfaceGrabber::UnknownBufferType); +#endif } QT_END_NAMESPACE diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp index 69c0a31a3..9e681dc0f 100644 --- a/src/compositor/compositor_api/qwaylandquickitem.cpp +++ b/src/compositor/compositor_api/qwaylandquickitem.cpp @@ -73,6 +73,7 @@ QT_BEGIN_NAMESPACE +#if QT_CONFIG(opengl) static const struct { const char * const vertexShaderSourceFile; const char * const fragmentShaderSourceFile; @@ -259,6 +260,7 @@ void QWaylandBufferMaterial::ensureTextures(int count) m_textures << nullptr; } } +#endif // QT_CONFIG(opengl) QMutex *QWaylandQuickItemPrivate::mutex = nullptr; @@ -284,10 +286,12 @@ public: if (m_ref.hasBuffer()) { if (buffer.isSharedMemory()) { m_sgTex = surfaceItem->window()->createTextureFromImage(buffer.image()); - if (m_sgTex) { +#if QT_CONFIG(opengl) + if (m_sgTex) m_sgTex->bind(); - } +#endif } else { +#if QT_CONFIG(opengl) QQuickWindow::CreateTextureOptions opt; QWaylandQuickSurface *surface = qobject_cast<QWaylandQuickSurface *>(surfaceItem->surface()); if (surface && surface->useTextureAlpha()) { @@ -297,6 +301,9 @@ public: auto texture = buffer.toOpenGLTexture(); auto size = surface->bufferSize(); m_sgTex = surfaceItem->window()->createTextureFromId(texture->textureId(), size, opt); +#else + qCWarning(qLcWaylandCompositor) << "Without OpenGL support only shared memory textures are supported"; +#endif } } emit textureChanged(); @@ -1328,7 +1335,11 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat const QRectF rect = invertY ? QRectF(0, height(), width(), -height()) : QRectF(0, 0, width(), height()); - if (ref.isSharedMemory() || bufferTypes[ref.bufferFormatEgl()].canProvideTexture) { + if (ref.isSharedMemory() +#if QT_CONFIG(opengl) + || bufferTypes[ref.bufferFormatEgl()].canProvideTexture +#endif + ) { // This case could covered by the more general path below, but this is more efficient (especially when using ShaderEffect items). QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode *>(oldNode); @@ -1354,45 +1365,48 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat node->setSourceRect(QRectF(source.topLeft() * scale, source.size() * scale)); return node; - } else { - Q_ASSERT(!d->provider); + } - QSGGeometryNode *node = static_cast<QSGGeometryNode *>(oldNode); +#if QT_CONFIG(opengl) + Q_ASSERT(!d->provider); - if (!node) { - node = new QSGGeometryNode; - d->newTexture = true; - } + QSGGeometryNode *node = static_cast<QSGGeometryNode *>(oldNode); - QSGGeometry *geometry = node->geometry(); - QWaylandBufferMaterial *material = static_cast<QWaylandBufferMaterial *>(node->material()); + if (!node) { + node = new QSGGeometryNode; + d->newTexture = true; + } - if (!geometry) - geometry = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4); + QSGGeometry *geometry = node->geometry(); + QWaylandBufferMaterial *material = static_cast<QWaylandBufferMaterial *>(node->material()); - if (!material) - material = new QWaylandBufferMaterial(ref.bufferFormatEgl()); + if (!geometry) + geometry = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4); - if (d->newTexture) { - d->newTexture = false; - for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++) - if (auto texture = ref.toOpenGLTexture(plane)) - material->setTextureForPlane(plane, texture); - material->bind(); - } + if (!material) + material = new QWaylandBufferMaterial(ref.bufferFormatEgl()); - QSGGeometry::updateTexturedRectGeometry(geometry, rect, QRectF(0, 0, 1, 1)); + if (d->newTexture) { + d->newTexture = false; + for (int plane = 0; plane < bufferTypes[ref.bufferFormatEgl()].planeCount; plane++) + if (auto texture = ref.toOpenGLTexture(plane)) + material->setTextureForPlane(plane, texture); + material->bind(); + } - node->setGeometry(geometry); - node->setFlag(QSGNode::OwnsGeometry, true); + QSGGeometry::updateTexturedRectGeometry(geometry, rect, QRectF(0, 0, 1, 1)); - node->setMaterial(material); - node->setFlag(QSGNode::OwnsMaterial, true); + node->setGeometry(geometry); + node->setFlag(QSGNode::OwnsGeometry, true); - return node; - } + node->setMaterial(material); + node->setFlag(QSGNode::OwnsMaterial, true); - Q_UNREACHABLE(); + return node; +#else + qCWarning(qLcWaylandCompositor) << "Without OpenGL support only shared memory textures are supported"; + return nullptr; +#endif // QT_CONFIG(opengl) } void QWaylandQuickItem::setTouchEventsEnabled(bool enabled) diff --git a/src/compositor/compositor_api/qwaylandquickitem_p.h b/src/compositor/compositor_api/qwaylandquickitem_p.h index 3d710d71b..2ec02ca6d 100644 --- a/src/compositor/compositor_api/qwaylandquickitem_p.h +++ b/src/compositor/compositor_api/qwaylandquickitem_p.h @@ -64,6 +64,7 @@ class QWaylandSurfaceTextureProvider; class QMutex; class QOpenGLTexture; +#if QT_CONFIG(opengl) class QWaylandBufferMaterialShader : public QSGMaterialShader { public: @@ -102,6 +103,7 @@ private: const QWaylandBufferRef::BufferFormatEgl m_format; QVarLengthArray<QOpenGLTexture*, 3> m_textures; }; +#endif // QT_CONFIG(opengl) class QWaylandQuickItemPrivate : public QQuickItemPrivate { |