summaryrefslogtreecommitdiffstats
path: root/src/hardwareintegration/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/hardwareintegration/client')
-rw-r--r--src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp36
-rw-r--r--src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h13
-rw-r--r--src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp37
-rw-r--r--src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h14
-rw-r--r--src/hardwareintegration/client/shm-emulation-server/shm-emulation-server.pri12
-rw-r--r--src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.cpp143
-rw-r--r--src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.h93
7 files changed, 325 insertions, 23 deletions
diff --git a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp
index 5ded6ff0d..fe2adbf56 100644
--- a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp
+++ b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.cpp
@@ -41,6 +41,7 @@
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QDebug>
#include <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLTexture>
#include <EGL/egl.h>
@@ -98,23 +99,35 @@ DrmServerBuffer::~DrmServerBuffer()
m_integration->eglDestroyImageKHR(m_image);
}
-void DrmServerBuffer::bindTextureToBuffer()
+QOpenGLTexture *DrmServerBuffer::toOpenGlTexture()
{
if (!QOpenGLContext::currentContext())
qWarning("DrmServerBuffer: creating texture with no current context");
- m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
+ if (!m_texture) {
+ m_texture = new QOpenGLTexture(QOpenGLTexture::Target2D);
+ m_texture->create();
+ }
+ m_texture->bind();
+ m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ m_texture->release();
+ m_texture->setSize(m_size.width(), m_size.height());
+ return m_texture;
}
-void DrmEglServerBufferIntegration::initialize(QWaylandDisplay *display)
+void DrmEglServerBufferIntegration::initializeEgl()
{
- m_egl_display = eglGetDisplay((EGLNativeDisplayType) display->wl_display());
- if (EGL_NO_DISPLAY) {
+ if (m_egl_initialized)
+ return;
+ m_egl_initialized = true;
+
+ m_egl_display = eglGetDisplay((EGLNativeDisplayType) m_display->wl_display());
+ if (m_egl_display == EGL_NO_DISPLAY) {
qWarning("Failed to initialize drm egl server buffer integration. Could not get egl display from wl_display.");
return;
}
@@ -136,8 +149,13 @@ void DrmEglServerBufferIntegration::initialize(QWaylandDisplay *display)
qWarning("Failed to initialize drm egl server buffer integration. Could not resolve glEGLImageTargetTexture2DOES");
return;
}
+ m_egl_initialized = true;
+}
- QtWayland::wl_registry::init(wl_display_get_registry(display->wl_display()));
+void DrmEglServerBufferIntegration::initialize(QWaylandDisplay *display)
+{
+ m_display = display;
+ display->addRegistryListener(&wlDisplayHandleGlobal, this);
}
QWaylandServerBuffer *DrmEglServerBufferIntegration::serverBuffer(struct qt_server_buffer *buffer)
@@ -145,12 +163,12 @@ QWaylandServerBuffer *DrmEglServerBufferIntegration::serverBuffer(struct qt_serv
return static_cast<QWaylandServerBuffer *>(qt_server_buffer_get_user_data(buffer));
}
-void DrmEglServerBufferIntegration::registry_global(uint32_t name, const QString &interface, uint32_t version)
+void DrmEglServerBufferIntegration::wlDisplayHandleGlobal(void *data, ::wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
{
Q_UNUSED(version);
if (interface == QStringLiteral("qt_drm_egl_server_buffer")) {
- struct ::wl_registry *registry = QtWayland::wl_registry::object();
- QtWayland::qt_drm_egl_server_buffer::init(registry, name, 1);
+ auto *integration = static_cast<DrmEglServerBufferIntegration *>(data);
+ integration->QtWayland::qt_drm_egl_server_buffer::init(registry, id, 1);
}
}
diff --git a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h
index f848f190e..f1b722997 100644
--- a/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h
+++ b/src/hardwareintegration/client/drm-egl-server/drmeglserverbufferintegration.h
@@ -71,15 +71,15 @@ class DrmServerBuffer : public QWaylandServerBuffer
public:
DrmServerBuffer(DrmEglServerBufferIntegration *integration, int32_t name, int32_t width, int32_t height, int32_t stride, int32_t format);
~DrmServerBuffer();
- void bindTextureToBuffer() override;
+ QOpenGLTexture* toOpenGlTexture() override;
private:
DrmEglServerBufferIntegration *m_integration;
EGLImageKHR m_image;
+ QOpenGLTexture *m_texture = nullptr;
};
class DrmEglServerBufferIntegration
: public QWaylandServerBufferIntegration
- , public QtWayland::wl_registry
, public QtWayland::qt_drm_egl_server_buffer
{
public:
@@ -91,17 +91,24 @@ public:
inline EGLBoolean eglDestroyImageKHR (EGLImageKHR image);
inline void glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
protected:
- void registry_global(uint32_t name, const QString &interface, uint32_t version) override;
void drm_egl_server_buffer_server_buffer_created(struct ::qt_server_buffer *id, int32_t name, int32_t width, int32_t height, int32_t stride, int32_t format) override;
private:
+ static void wlDisplayHandleGlobal(void *data, struct ::wl_registry *registry, uint32_t id,
+ const QString &interface, uint32_t version);
+ void initializeEgl();
+
PFNEGLCREATEIMAGEKHRPROC m_egl_create_image;
PFNEGLDESTROYIMAGEKHRPROC m_egl_destroy_image;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_gl_egl_image_target_texture;
+ QWaylandDisplay *m_display = nullptr;
EGLDisplay m_egl_display;
+ bool m_egl_initialized = false;
};
EGLImageKHR DrmEglServerBufferIntegration::eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
{
+ if (!m_egl_initialized)
+ initializeEgl();
if (!m_egl_create_image) {
qWarning("DrmEglServerBufferIntegration: Trying to used unresolved function eglCreateImageKHR");
return EGL_NO_IMAGE_KHR;
diff --git a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp
index 21af476fd..51b904e75 100644
--- a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp
+++ b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.cpp
@@ -41,6 +41,7 @@
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QDebug>
#include <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLTexture>
#include <hybris/eglplatformcommon/hybris_nativebufferext.h>
#include <EGL/egl.h>
@@ -59,6 +60,7 @@ LibHybrisServerBuffer::LibHybrisServerBuffer(LibHybrisEglServerBufferIntegration
, int32_t format)
: QWaylandServerBuffer()
, m_integration(integration)
+ , m_texture(nullptr)
, m_stride(stride)
, m_hybrisFormat(format)
{
@@ -76,18 +78,28 @@ LibHybrisServerBuffer::~LibHybrisServerBuffer()
m_integration->eglDestroyImageKHR(m_image);
}
-void LibHybrisServerBuffer::bindTextureToBuffer()
+QOpenGLTexture * LibHybrisServerBuffer::toOpenGlTexture()
{
if (!QOpenGLContext::currentContext()) {
qWarning("LibHybrisServerBuffer: creating texture with no current context");
}
+ if (!m_texture) {
+ m_texture = new QOpenGLTexture(QOpenGLTexture::Target2D);
+ m_texture->create();
+ }
+
+ m_texture->bind();
m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ m_texture->release();
+ m_texture->setSize(m_size.width(), m_size.height());
+
+ return m_texture;
}
void LibHybrisServerBuffer::libhybris_buffer_add_fd(int32_t fd)
@@ -114,10 +126,14 @@ void LibHybrisServerBuffer::libhybris_buffer_add_fd(int32_t fd)
}
}
-void LibHybrisEglServerBufferIntegration::initialize(QWaylandDisplay *display)
+void LibHybrisEglServerBufferIntegration::initializeEgl()
{
- m_egl_display = eglGetDisplay((EGLNativeDisplayType) display->wl_display());
- if (EGL_NO_DISPLAY) {
+ if (m_egl_initialized)
+ return;
+ m_egl_initialized = true;
+
+ m_egl_display = eglGetDisplay((EGLNativeDisplayType) m_display->wl_display());
+ if (m_egl_display == EGL_NO_DISPLAY) {
qWarning("Failed to initialize libhybris egl server buffer integration. Could not get egl display from wl_display.");
return;
}
@@ -145,8 +161,13 @@ void LibHybrisEglServerBufferIntegration::initialize(QWaylandDisplay *display)
qWarning("Failed to initialize libhybris egl server buffer integration. Could not resolve eglHybrisCreateRemoteBuffer");
return;
}
+ m_egl_initialized = true;
+}
- QtWayland::wl_registry::init(wl_display_get_registry(display->wl_display()));
+void LibHybrisEglServerBufferIntegration::initialize(QWaylandDisplay *display)
+{
+ m_display = display;
+ display->addRegistryListener(&wlDisplayHandleGlobal, this);
}
QWaylandServerBuffer *LibHybrisEglServerBufferIntegration::serverBuffer(struct qt_server_buffer *buffer)
@@ -154,12 +175,12 @@ QWaylandServerBuffer *LibHybrisEglServerBufferIntegration::serverBuffer(struct q
return static_cast<QWaylandServerBuffer *>(qt_server_buffer_get_user_data(buffer));
}
-void LibHybrisEglServerBufferIntegration::registry_global(uint32_t name, const QString &interface, uint32_t version)
+void LibHybrisEglServerBufferIntegration::wlDisplayHandleGlobal(void *data, ::wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
{
Q_UNUSED(version);
if (interface == QStringLiteral("qt_libhybris_egl_server_buffer")) {
- struct ::wl_registry *registry = QtWayland::wl_registry::object();
- QtWayland::qt_libhybris_egl_server_buffer::init(registry, name, 1);
+ auto *integration = static_cast<LibHybrisEglServerBufferIntegration *>(data);
+ integration->QtWayland::qt_libhybris_egl_server_buffer::init(registry, id, 1);
}
}
diff --git a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h
index e9f0689a2..b3c9c464d 100644
--- a/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h
+++ b/src/hardwareintegration/client/libhybris-egl-server/libhybriseglserverbufferintegration.h
@@ -75,7 +75,7 @@ class LibHybrisServerBuffer : public QWaylandServerBuffer, public QtWayland::qt_
public:
LibHybrisServerBuffer(LibHybrisEglServerBufferIntegration *integration, int32_t numFds, wl_array *ints, int32_t name, int32_t width, int32_t height, int32_t stride, int32_t format);
~LibHybrisServerBuffer();
- void bindTextureToBuffer() override;
+ QOpenGLTexture* toOpenGlTexture() override;
protected:
void libhybris_buffer_add_fd(int32_t fd) override;
@@ -83,6 +83,7 @@ protected:
private:
LibHybrisEglServerBufferIntegration *m_integration;
EGLImageKHR m_image;
+ QOpenGLTexture *m_texture;
int m_numFds;
QVector<int32_t> m_ints;
QVector<int32_t> m_fds;
@@ -92,7 +93,6 @@ private:
class LibHybrisEglServerBufferIntegration
: public QWaylandServerBufferIntegration
- , public QtWayland::wl_registry
, public QtWayland::qt_libhybris_egl_server_buffer
{
public:
@@ -106,19 +106,27 @@ public:
inline EGLBoolean eglHybrisCreateRemoteBuffer(EGLint width, EGLint height, EGLint usage, EGLint format, EGLint stride, int num_ints, int *ints, int num_fds, int *fds, EGLClientBuffer *buffer);
protected:
- void registry_global(uint32_t name, const QString &interface, uint32_t version) override;
void libhybris_egl_server_buffer_server_buffer_created(struct ::qt_libhybris_buffer *id, struct ::qt_server_buffer *qid,
int32_t numFds, wl_array *ints, int32_t name, int32_t width, int32_t height, int32_t stride, int32_t format) override;
private:
+ static void wlDisplayHandleGlobal(void *data, struct ::wl_registry *registry, uint32_t id,
+ const QString &interface, uint32_t version);
+ void initializeEgl();
+
PFNEGLCREATEIMAGEKHRPROC m_egl_create_image;
PFNEGLDESTROYIMAGEKHRPROC m_egl_destroy_image;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_gl_egl_image_target_texture;
PFNEGLHYBRISCREATEREMOTEBUFFERPROC m_egl_create_buffer;
+ QWaylandDisplay *m_display = nullptr;
EGLDisplay m_egl_display;
+ bool m_egl_initialized = false;
};
EGLImageKHR LibHybrisEglServerBufferIntegration::eglCreateImageKHR(EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
{
+ if (!m_egl_initialized)
+ initializeEgl();
+
if (!m_egl_create_image) {
qWarning("LibHybrisEglServerBufferIntegration: Trying to used unresolved function eglCreateImageKHR");
return EGL_NO_IMAGE_KHR;
diff --git a/src/hardwareintegration/client/shm-emulation-server/shm-emulation-server.pri b/src/hardwareintegration/client/shm-emulation-server/shm-emulation-server.pri
new file mode 100644
index 000000000..1a78290d7
--- /dev/null
+++ b/src/hardwareintegration/client/shm-emulation-server/shm-emulation-server.pri
@@ -0,0 +1,12 @@
+INCLUDEPATH += $$PWD
+
+QMAKE_USE += wayland-client
+
+SOURCES += \
+ $$PWD/shmserverbufferintegration.cpp
+
+HEADERS += \
+ $$PWD/shmserverbufferintegration.h
+
+CONFIG += wayland-scanner
+WAYLANDCLIENTSOURCES += $$PWD/../../../extensions/shm-emulation-server-buffer.xml
diff --git a/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.cpp b/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.cpp
new file mode 100644
index 000000000..bc597ebf8
--- /dev/null
+++ b/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.cpp
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "shmserverbufferintegration.h"
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QDebug>
+#include <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLTexture>
+#include <QtGui/QImage>
+#include <QtCore/QSharedMemory>
+
+QT_BEGIN_NAMESPACE
+
+static QOpenGLTexture *createTextureFromShm(const QString &key, int w, int h, int bpl, int format)
+{
+ QSharedMemory shm(key);
+ bool ok;
+ ok = shm.attach(QSharedMemory::ReadOnly);
+ if (!ok) {
+ qWarning() << "Could not attach to" << key;
+ return nullptr;
+ }
+ ok = shm.lock();
+ if (!ok) {
+ qWarning() << "Could not lock" << key << "for reading";
+ return nullptr;
+ }
+
+ QImage::Format imageFormat;
+ switch (format) {
+ case QtWayland::qt_shm_emulation_server_buffer::format_RGBA32:
+ imageFormat = QImage::Format_RGBA8888;
+ break;
+ case QtWayland::qt_shm_emulation_server_buffer::format_A8:
+ imageFormat = QImage::Format_Alpha8;
+ break;
+ default:
+ qWarning() << "ShmServerBuffer: unknown format" << format;
+ imageFormat = QImage::Format_RGBA8888;
+ break;
+ }
+
+ QImage image(static_cast<const uchar*>(shm.constData()), w, h, bpl, imageFormat);
+
+ if (!QOpenGLContext::currentContext())
+ qWarning("ShmServerBuffer: creating texture with no current context");
+
+ auto *tex = new QOpenGLTexture(image, QOpenGLTexture::DontGenerateMipMaps);
+ shm.unlock();
+ return tex;
+}
+
+
+namespace QtWaylandClient {
+ShmServerBuffer::ShmServerBuffer(ShmServerBufferIntegration *integration, const QString &key, int32_t width, int32_t height, int32_t bytes_per_line, int32_t format)
+ : QWaylandServerBuffer()
+ , m_integration(integration)
+ , m_texture(nullptr)
+ , m_key(key)
+ , m_bpl(bytes_per_line)
+ , m_format(format)
+{
+ m_size = QSize(width, height);
+}
+
+ShmServerBuffer::~ShmServerBuffer()
+{
+}
+
+QOpenGLTexture *ShmServerBuffer::toOpenGlTexture()
+{
+ if (!m_texture)
+ m_texture = createTextureFromShm(m_key, m_size.width(), m_size.height(), m_bpl, m_format);
+
+ return m_texture;
+}
+
+void ShmServerBufferIntegration::initialize(QWaylandDisplay *display)
+{
+ m_display = display;
+ display->addRegistryListener(&wlDisplayHandleGlobal, this);
+}
+
+QWaylandServerBuffer *ShmServerBufferIntegration::serverBuffer(struct qt_server_buffer *buffer)
+{
+ return static_cast<QWaylandServerBuffer *>(qt_server_buffer_get_user_data(buffer));
+}
+
+void ShmServerBufferIntegration::wlDisplayHandleGlobal(void *data, ::wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
+{
+ Q_UNUSED(version);
+ if (interface == "qt_shm_emulation_server_buffer") {
+ auto *integration = static_cast<ShmServerBufferIntegration *>(data);
+ integration->QtWayland::qt_shm_emulation_server_buffer::init(registry, id, 1);
+ }
+}
+
+
+void QtWaylandClient::ShmServerBufferIntegration::shm_emulation_server_buffer_server_buffer_created(qt_server_buffer *id, const QString &key, int32_t width, int32_t height, int32_t bytes_per_line, int32_t format)
+{
+ auto *server_buffer = new ShmServerBuffer(this, key, width, height, bytes_per_line, format);
+ qt_server_buffer_set_user_data(id, server_buffer);
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.h b/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.h
new file mode 100644
index 000000000..ce4032ba4
--- /dev/null
+++ b/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SHMSERVERBUFFERINTEGRATION_H
+#define SHMSERVERBUFFERINTEGRATION_H
+
+#include <QtWaylandClient/private/qwayland-wayland.h>
+#include "qwayland-shm-emulation-server-buffer.h"
+#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h>
+
+#include "shmserverbufferintegration.h"
+#include <QtWaylandClient/private/qwaylanddisplay_p.h>
+#include <QtCore/QTextStream>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class ShmServerBufferIntegration;
+
+class ShmServerBuffer : public QWaylandServerBuffer
+{
+public:
+ ShmServerBuffer(ShmServerBufferIntegration *integration, const QString &key, int32_t width, int32_t height, int32_t bytes_per_line, int32_t format);
+ ~ShmServerBuffer();
+ QOpenGLTexture* toOpenGlTexture() override;
+private:
+ ShmServerBufferIntegration *m_integration;
+ QOpenGLTexture *m_texture;
+ QString m_key;
+ int m_bpl;
+ int m_format;
+};
+
+class ShmServerBufferIntegration
+ : public QWaylandServerBufferIntegration
+ , public QtWayland::qt_shm_emulation_server_buffer
+{
+public:
+ void initialize(QWaylandDisplay *display) override;
+
+ virtual QWaylandServerBuffer *serverBuffer(struct qt_server_buffer *buffer) override;
+
+protected:
+ void shm_emulation_server_buffer_server_buffer_created(qt_server_buffer *id, const QString &key, int32_t width, int32_t height, int32_t bytes_per_line, int32_t format) override;
+
+private:
+ static void wlDisplayHandleGlobal(void *data, struct ::wl_registry *registry, uint32_t id,
+ const QString &interface, uint32_t version);
+ QWaylandDisplay *m_display = nullptr;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif