summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-02-13 08:10:29 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-02-16 08:39:34 +0100
commitacb68bd3bbbc0001bcf460dd175ff92cc3ce594a (patch)
tree76d2be850df2f3214910f9ffe1bffaeadd80fbde /tests
parent4a4b8d5ebc81b1d6711d0cdb720eba6e6954baba (diff)
downloadqtwayland-acb68bd3bbbc0001bcf460dd175ff92cc3ce594a.tar.gz
Move server-buffer example to manual tests
This is undocumented and demonstrates an experimental feature which was never maintained or exercised. It's a nice feature, so we keep the example around for when we get the time to bring it back. Pick-to: 6.5 Task-number: QTBUG-110993 Change-Id: I045cb2ef02a50017a26226c493607100ea0f1b95 Reviewed-by: Inho Lee <inho.lee@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/CMakeLists.txt4
-rw-r--r--tests/manual/server-buffer/CMakeLists.txt5
-rw-r--r--tests/manual/server-buffer/README32
-rw-r--r--tests/manual/server-buffer/compositor/CMakeLists.txt57
-rw-r--r--tests/manual/server-buffer/compositor/compositor.pro26
-rw-r--r--tests/manual/server-buffer/compositor/compositor.qrc7
-rw-r--r--tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.jpgbin0 -> 21801 bytes
-rw-r--r--tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.txt5
-rw-r--r--tests/manual/server-buffer/compositor/images/background.pngbin0 -> 9528 bytes
-rw-r--r--tests/manual/server-buffer/compositor/main.cpp29
-rw-r--r--tests/manual/server-buffer/compositor/qml/main.qml43
-rw-r--r--tests/manual/server-buffer/compositor/sharebufferextension.cpp86
-rw-r--r--tests/manual/server-buffer/compositor/sharebufferextension.h53
-rw-r--r--tests/manual/server-buffer/cpp-client/CMakeLists.txt44
-rw-r--r--tests/manual/server-buffer/cpp-client/cpp-client.pro15
-rw-r--r--tests/manual/server-buffer/cpp-client/main.cpp88
-rw-r--r--tests/manual/server-buffer/cpp-client/sharebufferextension.cpp36
-rw-r--r--tests/manual/server-buffer/cpp-client/sharebufferextension.h36
-rw-r--r--tests/manual/server-buffer/server-buffer.pro6
-rw-r--r--tests/manual/server-buffer/share-buffer.xml13
20 files changed, 585 insertions, 0 deletions
diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt
index cb9924c0..f7e9c6c5 100644
--- a/tests/manual/CMakeLists.txt
+++ b/tests/manual/CMakeLists.txt
@@ -13,3 +13,7 @@ if(TARGET Qt::WaylandCompositor)
add_subdirectory(scaling-compositor)
add_subdirectory(hwlayer-compositor)
endif()
+
+if(QT_FEATURE_opengl AND TARGET Qt::Quick AND TARGET Qt::WaylandClient)
+ qt_internal_add_example(server-buffer)
+endif()
diff --git a/tests/manual/server-buffer/CMakeLists.txt b/tests/manual/server-buffer/CMakeLists.txt
new file mode 100644
index 00000000..973063c7
--- /dev/null
+++ b/tests/manual/server-buffer/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.16)
+project(server-buffer)
+
+add_subdirectory(cpp-client)
+add_subdirectory(compositor)
diff --git a/tests/manual/server-buffer/README b/tests/manual/server-buffer/README
new file mode 100644
index 00000000..da20b0f5
--- /dev/null
+++ b/tests/manual/server-buffer/README
@@ -0,0 +1,32 @@
+This example shows how to use the low-level server buffer extension. This
+version of Qt also provides a texture sharing extension that provides more
+functionality and convenience for sharing graphical assets with Qt Quick
+clients: see the texture-sharing example.
+
+Compile up both compositor and client.
+
+If you have the dmabuf-server buffer integration (and you are running Mesa)
+then start the compositor with:
+
+$ QT_WAYLAND_SERVER_BUFFER_INTEGRATION=dmabuf-server ./compositor
+
+
+Note: if you are running a compositor on an X11 desktop, you also need to
+set QT_XCB_GL_INTEGRATION=xcb_egl as usual.
+
+The compositor broadcasts the name of the server buffer integration to
+all clients through the hardware integration extension. Therefore,
+all you need to do is to start the client with
+
+$ ./cpp-client -platform wayland
+
+The client will show all the buffers shared by the compositor.
+
+For testing on desktop, there is also a shared memory based server buffer
+integration that works with any graphics hardware:
+
+$ QT_WAYLAND_SERVER_BUFFER_INTEGRATION=shm-emulation-server QT_XCB_GL_INTEGRATION=xcb_egl ./compositor
+
+Note: the shm-emulation-server integration does not actually share graphics
+buffers, so it will not give any graphics memory savings. It is intended solely
+for testing during development and should never be used in production.
diff --git a/tests/manual/server-buffer/compositor/CMakeLists.txt b/tests/manual/server-buffer/compositor/CMakeLists.txt
new file mode 100644
index 00000000..5f4fb0c5
--- /dev/null
+++ b/tests/manual/server-buffer/compositor/CMakeLists.txt
@@ -0,0 +1,57 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(compositor)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/wayland/server-buffer/compositor")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml WaylandCompositor)
+
+qt_add_executable(compositor
+ main.cpp
+ sharebufferextension.cpp sharebufferextension.h
+)
+
+qt6_generate_wayland_protocol_server_sources(compositor
+ FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/../share-buffer.xml
+)
+
+set_target_properties(compositor PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(compositor PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::Qml
+ Qt::WaylandCompositorPrivate
+)
+
+# Resources:
+set(compositor_resource_files
+ "images/Siberischer_tiger_de_edit02.jpg"
+ "images/background.png"
+ "qml/main.qml"
+)
+
+qt6_add_resources(compositor "compositor"
+ PREFIX
+ "/"
+ FILES
+ ${compositor_resource_files}
+)
+
+install(TARGETS compositor
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/tests/manual/server-buffer/compositor/compositor.pro b/tests/manual/server-buffer/compositor/compositor.pro
new file mode 100644
index 00000000..26334c63
--- /dev/null
+++ b/tests/manual/server-buffer/compositor/compositor.pro
@@ -0,0 +1,26 @@
+QT += core gui qml
+
+QT += waylandcompositor-private
+
+CONFIG += wayland-scanner
+CONFIG += c++11
+SOURCES += \
+ main.cpp \
+ sharebufferextension.cpp
+
+OTHER_FILES = \
+ qml/main.qml \
+ images/background.jpg
+
+WAYLANDSERVERSOURCES += \
+ ../share-buffer.xml
+
+RESOURCES += compositor.qrc
+
+TARGET = compositor
+
+HEADERS += \
+ sharebufferextension.h
+
+target.path = $$[QT_INSTALL_EXAMPLES]/wayland/server-buffer/compositor
+INSTALLS += target
diff --git a/tests/manual/server-buffer/compositor/compositor.qrc b/tests/manual/server-buffer/compositor/compositor.qrc
new file mode 100644
index 00000000..b50594b5
--- /dev/null
+++ b/tests/manual/server-buffer/compositor/compositor.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/background.png</file>
+ <file>images/Siberischer_tiger_de_edit02.jpg</file>
+ <file>qml/main.qml</file>
+ </qresource>
+</RCC>
diff --git a/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.jpg b/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.jpg
new file mode 100644
index 00000000..eb1b73f8
--- /dev/null
+++ b/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.jpg
Binary files differ
diff --git a/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.txt b/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.txt
new file mode 100644
index 00000000..3a26c00d
--- /dev/null
+++ b/tests/manual/server-buffer/compositor/images/Siberischer_tiger_de_edit02.txt
@@ -0,0 +1,5 @@
+Image from https://en.wikipedia.org/wiki/File:Siberischer_tiger_de_edit02.jpg
+
+Author: S. Taheri, edited by Fir0002
+
+License: Creative Commons Attribution-Share Alike 2.5 Generic
diff --git a/tests/manual/server-buffer/compositor/images/background.png b/tests/manual/server-buffer/compositor/images/background.png
new file mode 100644
index 00000000..292160cd
--- /dev/null
+++ b/tests/manual/server-buffer/compositor/images/background.png
Binary files differ
diff --git a/tests/manual/server-buffer/compositor/main.cpp b/tests/manual/server-buffer/compositor/main.cpp
new file mode 100644
index 00000000..3c33620c
--- /dev/null
+++ b/tests/manual/server-buffer/compositor/main.cpp
@@ -0,0 +1,29 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtCore/QUrl>
+#include <QtCore/QDebug>
+#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlApplicationEngine>
+
+#include <QtQml/qqml.h>
+#include <QtQml/QQmlEngine>
+
+#include "sharebufferextension.h"
+
+static void registerTypes()
+{
+ qmlRegisterType<ShareBufferExtensionQuickExtension>("io.qt.examples.sharebufferextension", 1, 0, "ShareBufferExtension");
+}
+
+int main(int argc, char *argv[])
+{
+ // Make sure there is a valid OpenGL context in the main thread
+ qputenv("QSG_RENDER_LOOP", "basic");
+
+ QGuiApplication app(argc, argv);
+ registerTypes();
+ QQmlApplicationEngine appEngine(QUrl("qrc:///qml/main.qml"));
+
+ return app.exec();
+}
diff --git a/tests/manual/server-buffer/compositor/qml/main.qml b/tests/manual/server-buffer/compositor/qml/main.qml
new file mode 100644
index 00000000..484a9563
--- /dev/null
+++ b/tests/manual/server-buffer/compositor/qml/main.qml
@@ -0,0 +1,43 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtWayland.Compositor
+import QtWayland.Compositor.WlShell
+import QtQuick.Window
+
+import io.qt.examples.sharebufferextension
+
+WaylandCompositor {
+ WaylandOutput {
+ sizeFollowsWindow: true
+ window: Window {
+ width: 1024
+ height: 768
+ visible: true
+ Image {
+ id: surfaceArea
+ anchors.fill: parent
+ fillMode: Image.Tile
+ source: "qrc:/images/background.png"
+ smooth: false
+ }
+ }
+ }
+
+ Component {
+ id: chromeComponent
+ ShellSurfaceItem {
+ onSurfaceDestroyed: destroy()
+ }
+ }
+
+ WlShell {
+ onWlShellSurfaceCreated: (shellSurface) => {
+ chromeComponent.createObject(surfaceArea, { "shellSurface": shellSurface } );
+ }
+ }
+
+ ShareBufferExtension {
+ }
+}
diff --git a/tests/manual/server-buffer/compositor/sharebufferextension.cpp b/tests/manual/server-buffer/compositor/sharebufferextension.cpp
new file mode 100644
index 00000000..b1b499ff
--- /dev/null
+++ b/tests/manual/server-buffer/compositor/sharebufferextension.cpp
@@ -0,0 +1,86 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "sharebufferextension.h"
+
+#include <QWaylandSurface>
+
+#include <QDebug>
+
+#include <QQuickWindow>
+
+#include <QPainter>
+#include <QPen>
+
+ShareBufferExtension::ShareBufferExtension(QWaylandCompositor *compositor)
+ : QWaylandCompositorExtensionTemplate(compositor)
+{
+}
+
+void ShareBufferExtension::initialize()
+{
+ QWaylandCompositorExtensionTemplate::initialize();
+ QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
+ init(compositor->display(), 1);
+}
+
+QtWayland::ServerBuffer *ShareBufferExtension::addImage(const QImage &img)
+{
+ if (!m_server_buffer_integration) {
+ QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
+
+ m_server_buffer_integration = QWaylandCompositorPrivate::get(compositor)->serverBufferIntegration();
+ if (!m_server_buffer_integration) {
+ qWarning("Could not find a server buffer integration");
+ return nullptr;
+ }
+ }
+
+ QImage image = img.convertToFormat(QImage::Format_RGBA8888);
+
+ auto *buffer = m_server_buffer_integration->createServerBufferFromImage(image, QtWayland::ServerBuffer::RGBA32);
+
+ m_server_buffers.append(buffer);
+ return buffer;
+}
+
+void ShareBufferExtension::createServerBuffers()
+{
+ QImage image(100,100,QImage::Format_ARGB32_Premultiplied);
+ image.fill(QColor(0x55,0x0,0x55,0x01));
+ {
+ QPainter p(&image);
+ QPen pen = p.pen();
+ pen.setWidthF(3);
+ pen.setColor(Qt::red);
+ p.setPen(pen);
+ p.drawLine(0,0,100,100);
+ pen.setColor(Qt::green);
+ p.setPen(pen);
+ p.drawLine(100,0,0,100);
+ pen.setColor(Qt::blue);
+ p.setPen(pen);
+ p.drawLine(25,15,75,15);
+ }
+
+ addImage(image);
+
+ QImage image2(":/images/Siberischer_tiger_de_edit02.jpg");
+ addImage(image2);
+
+ m_server_buffers_created = true;
+}
+
+
+void ShareBufferExtension::share_buffer_bind_resource(Resource *resource)
+{
+ if (!m_server_buffers_created)
+ createServerBuffers();
+
+ for (auto *buffer : std::as_const(m_server_buffers)) {
+ qDebug() << "sending" << buffer << "to client";
+ struct ::wl_client *client = wl_resource_get_client(resource->handle);
+ struct ::wl_resource *buffer_resource = buffer->resourceForClient(client);
+ send_cross_buffer(resource->handle, buffer_resource);
+ }
+}
diff --git a/tests/manual/server-buffer/compositor/sharebufferextension.h b/tests/manual/server-buffer/compositor/sharebufferextension.h
new file mode 100644
index 00000000..98dcc7d8
--- /dev/null
+++ b/tests/manual/server-buffer/compositor/sharebufferextension.h
@@ -0,0 +1,53 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SHAREBUFFEREXTENSION_H
+#define SHAREBUFFEREXTENSION_H
+
+#include "wayland-util.h"
+
+#include <QtCore/QMap>
+
+#include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate>
+#include <QtWaylandCompositor/QWaylandQuickExtension>
+#include <QtWaylandCompositor/QWaylandCompositor>
+
+#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
+#include <QtWaylandCompositor/private/qwlserverbufferintegration_p.h>
+
+#include "qwayland-server-share-buffer.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWayland
+{
+ class ServerBufferIntegration;
+};
+
+
+class ShareBufferExtension : public QWaylandCompositorExtensionTemplate<ShareBufferExtension>
+ , public QtWaylandServer::qt_share_buffer
+{
+ Q_OBJECT
+public:
+ ShareBufferExtension(QWaylandCompositor *compositor = nullptr);
+ void initialize() override;
+
+protected slots:
+ QtWayland::ServerBuffer *addImage(const QImage &image);
+
+protected:
+ void share_buffer_bind_resource(Resource *resource) override;
+
+private:
+ void createServerBuffers();
+ QList<QtWayland::ServerBuffer *> m_server_buffers;
+ QtWayland::ServerBufferIntegration *m_server_buffer_integration = nullptr;
+ bool m_server_buffers_created = false;
+};
+
+Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(ShareBufferExtension)
+
+QT_END_NAMESPACE
+
+#endif // SHAREBUFFEREXTENSION_H
diff --git a/tests/manual/server-buffer/cpp-client/CMakeLists.txt b/tests/manual/server-buffer/cpp-client/CMakeLists.txt
new file mode 100644
index 00000000..01c0df44
--- /dev/null
+++ b/tests/manual/server-buffer/cpp-client/CMakeLists.txt
@@ -0,0 +1,44 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(server-buffer-cpp-client)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/wayland/server-buffer/cpp-client")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL WaylandClient)
+
+qt_add_executable(server-buffer-cpp-client
+ main.cpp
+ sharebufferextension.cpp sharebufferextension.h
+)
+
+qt6_generate_wayland_protocol_client_sources(server-buffer-cpp-client
+ FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/../share-buffer.xml
+)
+
+set_target_properties(server-buffer-cpp-client PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(server-buffer-cpp-client PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::GuiPrivate
+ Qt::OpenGL
+ Qt::WaylandClientPrivate
+)
+
+install(TARGETS server-buffer-cpp-client
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/tests/manual/server-buffer/cpp-client/cpp-client.pro b/tests/manual/server-buffer/cpp-client/cpp-client.pro
new file mode 100644
index 00000000..6ac55132
--- /dev/null
+++ b/tests/manual/server-buffer/cpp-client/cpp-client.pro
@@ -0,0 +1,15 @@
+QT += waylandclient-private gui-private opengl
+CONFIG += wayland-scanner
+
+WAYLANDCLIENTSOURCES += ../share-buffer.xml
+
+SOURCES += main.cpp \
+ sharebufferextension.cpp
+
+HEADERS += \
+ sharebufferextension.h
+
+TARGET = server-buffer-cpp-client
+
+target.path = $$[QT_INSTALL_EXAMPLES]/wayland/server-buffer/cpp-client
+INSTALLS += target
diff --git a/tests/manual/server-buffer/cpp-client/main.cpp b/tests/manual/server-buffer/cpp-client/main.cpp
new file mode 100644
index 00000000..8adac252
--- /dev/null
+++ b/tests/manual/server-buffer/cpp-client/main.cpp
@@ -0,0 +1,88 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QGuiApplication>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QOpenGLWindow>
+#include <QOpenGLTexture>
+#include <QOpenGLTextureBlitter>
+#include <QPainter>
+#include <QMouseEvent>
+#include <QPlatformSurfaceEvent>
+
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandintegration_p.h>
+#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h>
+#include "sharebufferextension.h"
+
+#include <QDebug>
+#include <QtGui/qpa/qplatformnativeinterface.h>
+#include <QTimer>
+#include <QMap>
+
+class TestWindow : public QOpenGLWindow
+{
+ Q_OBJECT
+
+public:
+ TestWindow()
+ {
+ m_extension = new ShareBufferExtension;
+ connect(m_extension, SIGNAL(bufferReceived(QtWaylandClient::QWaylandServerBuffer*)), this, SLOT(receiveBuffer(QtWaylandClient::QWaylandServerBuffer*)));
+ }
+
+public slots:
+ void receiveBuffer(QtWaylandClient::QWaylandServerBuffer *buffer)
+ {
+ m_buffers.append(buffer);
+ update();
+ }
+
+protected:
+
+ void initializeGL() override
+ {
+ m_blitter = new QOpenGLTextureBlitter;
+ m_blitter->create();
+ }
+
+ void paintGL() override {
+ glClearColor(.5, .45, .42, 1.);
+ glClear(GL_COLOR_BUFFER_BIT);
+ int x = 0;
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ for (auto buffer: m_buffers) {
+ m_blitter->bind();
+ QPointF pos(x,0);
+ QSize s(buffer->size());
+ QRectF targetRect(pos, s);
+ QOpenGLTexture *texture = buffer->toOpenGlTexture();
+ auto surfaceOrigin = QOpenGLTextureBlitter::OriginTopLeft;
+ QMatrix4x4 targetTransform = QOpenGLTextureBlitter::targetTransform(targetRect, QRect(QPoint(), size()));
+ m_blitter->blit(texture->textureId(), targetTransform, surfaceOrigin);
+ m_blitter->release();
+ x += s.width() + 10;
+ }
+ }
+
+private:
+
+ QOpenGLTextureBlitter *m_blitter = nullptr;
+ ShareBufferExtension *m_extension = nullptr;
+ QList<QtWaylandClient::QWaylandServerBuffer*> m_buffers;
+
+};
+
+int main (int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ TestWindow window;
+ window.show();
+
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/server-buffer/cpp-client/sharebufferextension.cpp b/tests/manual/server-buffer/cpp-client/sharebufferextension.cpp
new file mode 100644
index 00000000..3641ec63
--- /dev/null
+++ b/tests/manual/server-buffer/cpp-client/sharebufferextension.cpp
@@ -0,0 +1,36 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "sharebufferextension.h"
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtWaylandClient/private/qwaylandintegration_p.h>
+#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h>
+#include <QtGui/QGuiApplication>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/QWindow>
+#include <QtGui/QPlatformSurfaceEvent>
+#include <QtGui/qpa/qplatformnativeinterface.h>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+ShareBufferExtension::ShareBufferExtension()
+ : QWaylandClientExtensionTemplate(/* Supported protocol version */ 1 )
+{
+
+ auto *wayland_integration = static_cast<QtWaylandClient::QWaylandIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ m_server_buffer_integration = wayland_integration->serverBufferIntegration();
+ if (!m_server_buffer_integration) {
+ qCritical() << "This application requires a working serverBufferIntegration";
+ QGuiApplication::quit();
+ }
+}
+
+void ShareBufferExtension::share_buffer_cross_buffer(struct ::qt_server_buffer *buffer)
+{
+ QtWaylandClient::QWaylandServerBuffer *serverBuffer = m_server_buffer_integration->serverBuffer(buffer);
+ emit bufferReceived(serverBuffer);
+}
+
+
+QT_END_NAMESPACE
diff --git a/tests/manual/server-buffer/cpp-client/sharebufferextension.h b/tests/manual/server-buffer/cpp-client/sharebufferextension.h
new file mode 100644
index 00000000..78e3ca7f
--- /dev/null
+++ b/tests/manual/server-buffer/cpp-client/sharebufferextension.h
@@ -0,0 +1,36 @@
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SHAREBUFFEREXTENSION_H
+#define SHAREBUFFEREXTENSION_H
+
+#include <qpa/qwindowsysteminterface.h>
+#include <QtWaylandClient/private/qwayland-wayland.h>
+#include <QtWaylandClient/qwaylandclientextension.h>
+#include "qwayland-share-buffer.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+ class QWaylandServerBuffer;
+ class QWaylandServerBufferIntegration;
+};
+
+class ShareBufferExtension : public QWaylandClientExtensionTemplate<ShareBufferExtension>
+ , public QtWayland::qt_share_buffer
+{
+ Q_OBJECT
+public:
+ ShareBufferExtension();
+
+signals:
+ void bufferReceived(QtWaylandClient::QWaylandServerBuffer *buffer);
+
+private:
+ void share_buffer_cross_buffer(struct ::qt_server_buffer *buffer) override;
+ QtWaylandClient::QWaylandServerBufferIntegration *m_server_buffer_integration = nullptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // SHAREBUFFEREXTENSION_H
diff --git a/tests/manual/server-buffer/server-buffer.pro b/tests/manual/server-buffer/server-buffer.pro
new file mode 100644
index 00000000..0c737ea8
--- /dev/null
+++ b/tests/manual/server-buffer/server-buffer.pro
@@ -0,0 +1,6 @@
+TEMPLATE=subdirs
+
+SUBDIRS += cpp-client compositor
+
+EXAMPLE_FILES += \
+ share-buffer.xml
diff --git a/tests/manual/server-buffer/share-buffer.xml b/tests/manual/server-buffer/share-buffer.xml
new file mode 100644
index 00000000..53020c4e
--- /dev/null
+++ b/tests/manual/server-buffer/share-buffer.xml
@@ -0,0 +1,13 @@
+<protocol name="share_buffer">
+
+ <copyright>
+ Copyright (C) 2015 The Qt Company Ltd.
+ SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+ </copyright>
+
+ <interface name="qt_share_buffer" version="1">
+ <event name="cross_buffer">
+ <arg name="buffer" type="object" interface="qt_server_buffer"/>
+ </event>
+ </interface>
+</protocol>