diff options
author | Paul Olav Tvete <paul.tvete@qt.io> | 2020-07-09 15:32:37 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@qt.io> | 2020-08-26 16:10:41 +0200 |
commit | 585f20dce37c398d8b2e6367008e3329dac79e24 (patch) | |
tree | 13437a0dac59ade4ab3cfb5684956ac47bf05720 /src/hardwareintegration | |
parent | f7885bb4eb2660ff4e287996061c9c1d987e5c60 (diff) | |
download | qtwayland-585f20dce37c398d8b2e6367008e3329dac79e24.tar.gz |
Support multiple buffer integrations
Allow compositors to support more than one type of hardware client
buffer integration.
[ChangeLog][QtWaylandCompositor] QtWaylandCompositor now supports
multiple client buffer integrations. QT_WAYLAND_CLIENT_BUFFER_INTEGRATION
will now accept a semicolon-separated list.
Fixes: QTBUG-68846
Change-Id: Iff1fa0a45b01f6a45dd744c37a89bac7d5e70658
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/hardwareintegration')
10 files changed, 27 insertions, 18 deletions
diff --git a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp index 9010e740..a4fbc6b5 100644 --- a/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabufclientbufferintegration.cpp @@ -395,16 +395,12 @@ void LinuxDmabufClientBufferIntegration::deleteImage(EGLImageKHR image) QtWayland::ClientBuffer *LinuxDmabufClientBufferIntegration::createBufferFor(wl_resource *resource) { - // fallback for shared memory buffers - if (wl_shm_buffer_get(resource)) - return nullptr; - auto it = m_importedBuffers.find(resource); if (it != m_importedBuffers.end()) { m_importedBuffers.value(resource); return new LinuxDmabufClientBuffer(this, it.value()->resource()->handle, m_importedBuffers.value(resource)); } - qCWarning(qLcWaylandCompositorHardwareIntegration) << "could not create client buffer for dmabuf buffer"; + return nullptr; } diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp index 127ea278..a826c5fc 100644 --- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp @@ -468,7 +468,10 @@ void WaylandEglClientBufferIntegration::initializeHardware(struct wl_display *di QtWayland::ClientBuffer *WaylandEglClientBufferIntegration::createBufferFor(wl_resource *buffer) { - if (wl_shm_buffer_get(buffer)) + Q_D(WaylandEglClientBufferIntegration); + int w = -1; + bool q = d->egl_query_wayland_buffer(d->egl_display, buffer, EGL_WIDTH, &w); + if (!q || w <= 0) return nullptr; return new WaylandEglClientBuffer(this, buffer); } diff --git a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp index b07657c2..9bdf8eb5 100644 --- a/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp +++ b/src/hardwareintegration/compositor/wayland-eglstream-controller/waylandeglstreamintegration.cpp @@ -290,10 +290,9 @@ void WaylandEglStreamClientBufferIntegration::attachEglStreamConsumer(struct ::w Q_D(WaylandEglStreamClientBufferIntegration); Q_UNUSED(wl_surface); - // NOTE: must use getBuffer to create the buffer here, so the buffer will end up in the buffer manager's hash - + auto *clientBuffer = new WaylandEglStreamClientBuffer(this, wl_buffer); auto *bufferManager = QWaylandCompositorPrivate::get(m_compositor)->bufferManager(); - auto *clientBuffer = static_cast<WaylandEglStreamClientBuffer*>(bufferManager->getBuffer(wl_buffer)); + bufferManager->registerBuffer(wl_buffer, clientBuffer); d->initEglStream(clientBuffer, wl_buffer); } diff --git a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp index d1c47069..770656c2 100644 --- a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp +++ b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.cpp @@ -75,12 +75,12 @@ void XCompositeEglClientBufferIntegration::initializeHardware(struct ::wl_displa } else { qFatal("Platform integration doesn't have native interface"); } - new XCompositeHandler(m_compositor, mDisplay); + mHandler = new XCompositeHandler(m_compositor, mDisplay); } QtWayland::ClientBuffer *XCompositeEglClientBufferIntegration::createBufferFor(wl_resource *buffer) { - if (wl_shm_buffer_get(buffer)) + if (!mHandler->isXCompositeBuffer(buffer)) return nullptr; return new XCompositeEglClientBuffer(this, buffer); } diff --git a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h index 80ce88b5..ae7354f8 100644 --- a/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h +++ b/src/hardwareintegration/compositor/xcomposite-egl/xcompositeeglintegration.h @@ -40,6 +40,8 @@ QT_BEGIN_NAMESPACE +class XCompositeHandler; + class XCompositeEglClientBufferIntegration : public QtWayland::ClientBufferIntegration { public: @@ -53,6 +55,7 @@ public: private: Display *mDisplay = nullptr; EGLDisplay mEglDisplay = EGL_NO_DISPLAY; + XCompositeHandler *mHandler = nullptr; }; class XCompositeEglClientBuffer : public QtWayland::ClientBuffer diff --git a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp index 8b7a9c9d..b8415e88 100644 --- a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp +++ b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp @@ -102,7 +102,7 @@ void XCompositeGLXClientBufferIntegration::initializeHardware(struct ::wl_displa QtWayland::ClientBuffer *XCompositeGLXClientBufferIntegration::createBufferFor(wl_resource *buffer) { - if (wl_shm_buffer_get(buffer)) + if (!mHandler->isXCompositeBuffer(buffer)) return nullptr; return new XCompositeGLXClientBuffer(this, buffer); } diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp b/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp index 67cef004..b79a713a 100644 --- a/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp +++ b/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.cpp @@ -27,21 +27,24 @@ ** ****************************************************************************/ +#include "xcompositehandler.h" #include "xcompositebuffer.h" QT_BEGIN_NAMESPACE XCompositeBuffer::XCompositeBuffer(Window window, const QSize &size, - struct ::wl_client *client, uint32_t id) + struct ::wl_client *client, uint32_t id, XCompositeHandler *handler) : QtWaylandServer::wl_buffer(client, id, 1) , mWindow(window) , mOrigin(QWaylandSurface::OriginBottomLeft) , mSize(size) + , mHandler(handler) { } -void XCompositeBuffer::buffer_destroy_resource(Resource *) +void XCompositeBuffer::buffer_destroy_resource(Resource *resource) { + mHandler->removeBuffer(resource->handle); delete this; } diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h b/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h index 4bf035f2..0e6e6345 100644 --- a/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h +++ b/src/hardwareintegration/compositor/xcomposite_share/xcompositebuffer.h @@ -48,11 +48,13 @@ QT_BEGIN_NAMESPACE +class XCompositeHandler; + class XCompositeBuffer : public QtWaylandServer::wl_buffer { public: XCompositeBuffer(Window window, const QSize &size, - struct ::wl_client *client, uint32_t id); + struct ::wl_client *client, uint32_t id, XCompositeHandler *handler); Window window(); @@ -71,6 +73,7 @@ private: Window mWindow; QWaylandSurface::Origin mOrigin; QSize mSize; + XCompositeHandler *mHandler = nullptr; }; QT_END_NAMESPACE diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp b/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp index 1e43c033..c4e2d226 100644 --- a/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp +++ b/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.cpp @@ -59,7 +59,8 @@ void XCompositeHandler::xcomposite_bind_resource(Resource *resource) void XCompositeHandler::xcomposite_create_buffer(Resource *resource, uint32_t id, uint32_t window, int32_t width, int32_t height) { - new XCompositeBuffer(Window(window), QSize(width, height), resource->client(), id); + auto *buf = new XCompositeBuffer(Window(window), QSize(width, height), resource->client(), id, this); + mKnownBuffers.insert(buf->resource()->handle); } QT_END_NAMESPACE diff --git a/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h b/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h index 5ff72e26..4f7dc406 100644 --- a/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h +++ b/src/hardwareintegration/compositor/xcomposite_share/xcompositehandler.h @@ -43,16 +43,17 @@ class XCompositeHandler : public QtWaylandServer::qt_xcomposite { public: XCompositeHandler(QWaylandCompositor *compositor, Display *display); + bool isXCompositeBuffer(wl_resource *resource) { return mKnownBuffers.contains(resource); } + void removeBuffer(wl_resource *resource) { mKnownBuffers.remove(resource); } private: QWindow *mFakeRootWindow = nullptr; - QString mDisplayString; + QSet<wl_resource *> mKnownBuffers; void xcomposite_bind_resource(Resource *resource) override; void xcomposite_create_buffer(Resource *resource, uint32_t id, uint32_t x_window, int32_t width, int32_t height) override; - }; QT_END_NAMESPACE |