summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2017-01-12 14:04:04 +0100
committerJohan Helsing <johan.helsing@qt.io>2019-04-04 12:10:05 +0000
commit8663de3fa789d8b8e10c5580b37f6eb3beac9ed6 (patch)
tree326bb613e96f8944b1bb93d9ff90149725b7c26c
parentc87451570f93fd7bf8653c27d6120f6436b9aaae (diff)
downloadqtwayland-8663de3fa789d8b8e10c5580b37f6eb3beac9ed6.tar.gz
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>
-rw-r--r--examples/wayland/wayland.pro19
-rw-r--r--src/compositor/compositor_api/compositor_api.pri15
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp2
-rw-r--r--src/compositor/compositor_api/qwaylandquickcompositor.cpp4
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp76
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem_p.h2
-rw-r--r--src/compositor/extensions/extensions.pri16
-rw-r--r--src/imports/compositor/qwaylandquickcompositorplugin.cpp2
-rw-r--r--src/imports/imports.pro10
-rw-r--r--tests/auto/client/client/tst_client.cpp8
-rw-r--r--tests/auto/client/surface/tst_surface.cpp6
11 files changed, 110 insertions, 50 deletions
diff --git a/examples/wayland/wayland.pro b/examples/wayland/wayland.pro
index f8a360c1..eeb962eb 100644
--- a/examples/wayland/wayland.pro
+++ b/examples/wayland/wayland.pro
@@ -1,10 +1,11 @@
requires(qtHaveModule(waylandcompositor))
-requires(qtConfig(opengl))
TEMPLATE=subdirs
-SUBDIRS += \
- qwindow-compositor \
- minimal-cpp
+qtHaveModule(opengl) {
+ SUBDIRS += \
+ qwindow-compositor \
+ minimal-cpp
+}
qtHaveModule(quick) {
SUBDIRS += minimal-qml
@@ -17,9 +18,13 @@ qtHaveModule(quick) {
SUBDIRS += server-side-decoration
qtHaveModule(waylandclient) {
SUBDIRS += \
- custom-extension \
- server-buffer \
- texture-sharing
+ custom-extension
+
+ qtHaveModule(opengl) {
+ SUBDIRS += \
+ server-buffer \
+ texture-sharing
+ }
}
SUBDIRS += hwlayer-compositor
}
diff --git a/src/compositor/compositor_api/compositor_api.pri b/src/compositor/compositor_api/compositor_api.pri
index 3df06145..233815d8 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 05323543..f0749705 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 426008a6..98ad7acb 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 69c0a31a..9e681dc0 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 3d710d71..2ec02ca6 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
{
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri
index 87de7212..562c3d7a 100644
--- a/src/compositor/extensions/extensions.pri
+++ b/src/compositor/extensions/extensions.pri
@@ -8,7 +8,6 @@ WAYLANDSERVERSOURCES += \
../extensions/touch-extension.xml \
../extensions/qt-key-unstable-v1.xml \
../extensions/qt-windowmanager.xml \
- ../extensions/qt-texture-sharing-unstable-v1.xml \
../3rdparty/protocol/text-input-unstable-v2.xml \
../3rdparty/protocol/viewporter.xml \
../3rdparty/protocol/scaler.xml \
@@ -66,7 +65,7 @@ SOURCES += \
extensions/qwaylandiviapplication.cpp \
extensions/qwaylandivisurface.cpp \
-qtHaveModule(quick):contains(QT_CONFIG, opengl) {
+qtHaveModule(quick) {
HEADERS += \
extensions/qwaylandquickshellsurfaceitem.h \
extensions/qwaylandquickshellsurfaceitem_p.h \
@@ -75,7 +74,6 @@ qtHaveModule(quick):contains(QT_CONFIG, opengl) {
extensions/qwaylandxdgshellv5integration_p.h \
extensions/qwaylandxdgshellv6integration_p.h \
extensions/qwaylandxdgshellintegration_p.h \
- extensions/qwltexturesharingextension_p.h
SOURCES += \
extensions/qwaylandquickshellsurfaceitem.cpp \
@@ -84,7 +82,17 @@ qtHaveModule(quick):contains(QT_CONFIG, opengl) {
extensions/qwaylandxdgshellv5integration.cpp \
extensions/qwaylandxdgshellv6integration.cpp \
extensions/qwaylandxdgshellintegration.cpp \
- extensions/qwltexturesharingextension.cpp
+
+ qtHaveModule(opengl) {
+ WAYLANDSERVERSOURCES += \
+ ../extensions/qt-texture-sharing-unstable-v1.xml
+
+ HEADERS += \
+ extensions/qwltexturesharingextension_p.h
+
+ SOURCES += \
+ extensions/qwltexturesharingextension.cpp
+ }
}
include ($$PWD/pregenerated/xdg-shell-v5.pri)
diff --git a/src/imports/compositor/qwaylandquickcompositorplugin.cpp b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
index df7536ed..c77be966 100644
--- a/src/imports/compositor/qwaylandquickcompositorplugin.cpp
+++ b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
@@ -133,7 +133,9 @@ public:
qmlRegisterType<QWaylandQuickCompositorQuickExtensionContainer>(uri, 1, 0, "WaylandCompositor");
qmlRegisterType<QWaylandQuickItem>(uri, 1, 0, "WaylandQuickItem");
qmlRegisterType<QWaylandQuickItem, 13>(uri, 1, 13, "WaylandQuickItem");
+#if QT_CONFIG(opengl)
qmlRegisterType<QWaylandQuickHardwareLayer>(uri, 1, 2, "WaylandHardwareLayer");
+#endif
qmlRegisterType<QWaylandMouseTracker>(uri, 1, 0, "WaylandMouseTracker");
qmlRegisterType<QWaylandQuickOutput>(uri, 1, 0, "WaylandOutput");
qmlRegisterType<QWaylandQuickSurface>(uri, 1, 0, "WaylandSurface");
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
index c8394f0c..1fced3df 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -2,7 +2,11 @@ TEMPLATE = subdirs
qtHaveModule(quick): {
SUBDIRS += \
- compositor \
- texture-sharing \
- texture-sharing-extension
+ compositor
+
+ qtHaveModule(opengl): {
+ SUBDIRS += \
+ texture-sharing \
+ texture-sharing-extension
+ }
}
diff --git a/tests/auto/client/client/tst_client.cpp b/tests/auto/client/client/tst_client.cpp
index 08120c8c..e9ae5e4b 100644
--- a/tests/auto/client/client/tst_client.cpp
+++ b/tests/auto/client/client/tst_client.cpp
@@ -36,7 +36,9 @@
#include <QPixmap>
#include <QDrag>
#include <QWindow>
+#if QT_CONFIG(opengl)
#include <QOpenGLWindow>
+#endif
#include <QtTest/QtTest>
#include <QtWaylandClient/private/qwaylandintegration_p.h>
@@ -107,6 +109,7 @@ public:
QPoint mousePressPos;
};
+#if QT_CONFIG(opengl)
class TestGlWindow : public QOpenGLWindow
{
Q_OBJECT
@@ -136,6 +139,7 @@ void TestGlWindow::paintGL()
glClear(GL_COLOR_BUFFER_BIT);
++paintGLCalled;
}
+#endif // QT_CONFIG(opengl)
class tst_WaylandClient : public QObject
{
@@ -176,7 +180,9 @@ private slots:
void dontCrashOnMultipleCommits();
void hiddenTransientParent();
void hiddenPopupParent();
+#if QT_CONFIG(opengl)
void glWindow();
+#endif // QT_CONFIG(opengl)
void longWindowTitle();
private:
@@ -458,6 +464,7 @@ void tst_WaylandClient::hiddenPopupParent()
QTRY_VERIFY(compositor->surface());
}
+#if QT_CONFIG(opengl)
void tst_WaylandClient::glWindow()
{
QSKIP("Skipping GL tests, as not supported by all CI systems: See https://bugreports.qt.io/browse/QTBUG-65802");
@@ -483,6 +490,7 @@ void tst_WaylandClient::glWindow()
testWindow->setVisible(false);
QTRY_VERIFY(!compositor->surface());
}
+#endif // QT_CONFIG(opengl)
void tst_WaylandClient::longWindowTitle()
{
diff --git a/tests/auto/client/surface/tst_surface.cpp b/tests/auto/client/surface/tst_surface.cpp
index dddff086..9659235a 100644
--- a/tests/auto/client/surface/tst_surface.cpp
+++ b/tests/auto/client/surface/tst_surface.cpp
@@ -28,7 +28,9 @@
#include "mockcompositor.h"
#include <QtGui/QRasterWindow>
+#if QT_CONFIG(opengl)
#include <QtGui/QOpenGLWindow>
+#endif
using namespace MockCompositor;
@@ -39,7 +41,9 @@ private slots:
void cleanup() { QTRY_VERIFY2(isClean(), qPrintable(dirtyMessage())); }
void createDestroySurface();
void waitForFrameCallbackRaster();
+#if QT_CONFIG(opengl)
void waitForFrameCallbackGl();
+#endif
void negotiateShmFormat();
};
@@ -89,6 +93,7 @@ void tst_surface::waitForFrameCallbackRaster()
}
}
+#if QT_CONFIG(opengl)
void tst_surface::waitForFrameCallbackGl()
{
QSKIP("TODO: This currently fails, needs a fix");
@@ -129,6 +134,7 @@ void tst_surface::waitForFrameCallbackGl()
bufferSpy.removeFirst();
}
}
+#endif // QT_CONFIG(opengl)
void tst_surface::negotiateShmFormat()
{