summaryrefslogtreecommitdiffstats
path: root/src/hardwareintegration/compositor
diff options
context:
space:
mode:
Diffstat (limited to 'src/hardwareintegration/compositor')
-rw-r--r--src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp54
-rw-r--r--src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h8
-rw-r--r--src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp67
-rw-r--r--src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h8
-rw-r--r--src/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pri13
-rw-r--r--src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp146
-rw-r--r--src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h99
7 files changed, 334 insertions, 61 deletions
diff --git a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp
index fe7f12fd0..35fdc8277 100644
--- a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp
+++ b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.cpp
@@ -40,12 +40,14 @@
#include "drmeglserverbufferintegration.h"
#include <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLTexture>
QT_BEGIN_NAMESPACE
-DrmEglServerBuffer::DrmEglServerBuffer(DrmEglServerBufferIntegration *integration, const QSize &size, QtWayland::ServerBuffer::Format format)
- : QtWayland::ServerBuffer(size,format)
+DrmEglServerBuffer::DrmEglServerBuffer(DrmEglServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format)
+ : QtWayland::ServerBuffer(qimage.size(),format)
, m_integration(integration)
+ , m_texture(nullptr)
{
m_format = format;
@@ -82,38 +84,42 @@ DrmEglServerBuffer::DrmEglServerBuffer(DrmEglServerBufferIntegration *integratio
qWarning("DrmEglServerBuffer: Failed to export egl image");
}
+ m_texture = new QOpenGLTexture(QOpenGLTexture::Target2D);
+ m_texture->create();
+ m_texture->bind();
+
+ m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, qimage.width(), qimage.height(), GL_RGBA, GL_UNSIGNED_BYTE, qimage.constBits());
+
+ m_texture->release();
+ m_texture->setSize(m_size.width(), m_size.height());
}
struct ::wl_resource *DrmEglServerBuffer::resourceForClient(struct ::wl_client *client)
{
- QMultiMap<struct ::wl_client *, Resource *>::iterator it = resourceMap().find(client);
- if (it == resourceMap().end()) {
- QMultiMap<struct ::wl_client *, QtWaylandServer::qt_drm_egl_server_buffer::Resource *>::iterator drm_egl_it = m_integration->resourceMap().find(client);
- if (drm_egl_it == m_integration->resourceMap().end()) {
+ auto *bufferResource = resourceMap().value(client);
+ if (!bufferResource) {
+ auto integrationResource = m_integration->resourceMap().value(client);
+ if (!integrationResource) {
qWarning("DrmEglServerBuffer::resourceForClient: Trying to get resource for ServerBuffer. But client is not bound to the drm_egl interface");
return 0;
}
- struct ::wl_resource *drm_egl_resource = (*drm_egl_it)->handle;
- Resource *resource = add(client, 1, 1);
- m_integration->send_server_buffer_created(drm_egl_resource, resource->handle, m_name, m_size.width(), m_size.height(), m_stride, m_drm_format);
+ struct ::wl_resource *drm_egl_integration_resource = integrationResource->handle;
+ Resource *resource = add(client, 1);
+ m_integration->send_server_buffer_created(drm_egl_integration_resource, resource->handle, m_name, m_size.width(), m_size.height(), m_stride, m_drm_format);
return resource->handle;
}
- return (*it)->handle;
+ return bufferResource->handle;
}
-void DrmEglServerBuffer::bindTextureToBuffer()
+
+QOpenGLTexture *DrmEglServerBuffer::toOpenGlTexture()
{
- if (!QOpenGLContext::currentContext()) {
- qWarning("DrmEglServerBuffer: No current context when creating buffer. Texture loading will fail");
- return;
+ if (!m_texture) {
+ qWarning("DrmEglServerBuffer::toOpenGlTexture: no texture defined");
}
-
- m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ return m_texture;
}
DrmEglServerBufferIntegration::DrmEglServerBufferIntegration()
@@ -130,7 +136,7 @@ void DrmEglServerBufferIntegration::initializeHardware(QWaylandCompositor *compo
m_egl_display = static_cast<EGLDisplay>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("egldisplay"));
if (!m_egl_display) {
- qWarning("Cant initialize drm egl server buffer integration. Missing egl display from platformplugin");
+ qWarning("Can't initialize drm egl server buffer integration. Missing egl display from platform plugin");
return;
}
@@ -183,9 +189,9 @@ bool DrmEglServerBufferIntegration::supportsFormat(QtWayland::ServerBuffer::Form
}
}
-QtWayland::ServerBuffer *DrmEglServerBufferIntegration::createServerBuffer(const QSize &size, QtWayland::ServerBuffer::Format format)
+QtWayland::ServerBuffer *DrmEglServerBufferIntegration::createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format)
{
- return new DrmEglServerBuffer(this, size, format);
+ return new DrmEglServerBuffer(this, qimage, format);
}
QT_END_NAMESPACE
diff --git a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h
index 239a1f7d1..e1cc8768f 100644
--- a/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h
+++ b/src/hardwareintegration/compositor/drm-egl-server/drmeglserverbufferintegration.h
@@ -72,14 +72,15 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy,
QT_BEGIN_NAMESPACE
class DrmEglServerBufferIntegration;
+class QImage;
class DrmEglServerBuffer : public QtWayland::ServerBuffer, public QtWaylandServer::qt_server_buffer
{
public:
- DrmEglServerBuffer(DrmEglServerBufferIntegration *integration, const QSize &size, QtWayland::ServerBuffer::Format format);
+ DrmEglServerBuffer(DrmEglServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format);
struct ::wl_resource *resourceForClient(struct ::wl_client *) override;
- void bindTextureToBuffer() override;
+ QOpenGLTexture *toOpenGlTexture() override;
private:
DrmEglServerBufferIntegration *m_integration;
@@ -88,6 +89,7 @@ private:
int32_t m_name;
int32_t m_stride;
+ QOpenGLTexture *m_texture;
QtWaylandServer::qt_drm_egl_server_buffer::format m_drm_format;
};
@@ -102,7 +104,7 @@ public:
void initializeHardware(QWaylandCompositor *) override;
bool supportsFormat(QtWayland::ServerBuffer::Format format) const override;
- QtWayland::ServerBuffer *createServerBuffer(const QSize &size, QtWayland::ServerBuffer::Format format) override;
+ QtWayland::ServerBuffer *createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override;
EGLDisplay display() const { return m_egl_display; }
diff --git a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp
index 2312a468b..de9e1cf6e 100644
--- a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp
+++ b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.cpp
@@ -40,13 +40,15 @@
#include "libhybriseglserverbufferintegration.h"
#include <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLTexture>
#include <hybris/eglplatformcommon/hybris_nativebufferext.h>
#include <wayland-server.h>
QT_BEGIN_NAMESPACE
-LibHybrisEglServerBuffer::LibHybrisEglServerBuffer(LibHybrisEglServerBufferIntegration *integration, const QSize &size, QtWayland::ServerBuffer::Format format)
- : QtWayland::ServerBuffer(size,format)
+LibHybrisEglServerBuffer::LibHybrisEglServerBuffer(LibHybrisEglServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format)
+ : QtWayland::ServerBuffer(qimage.size(),format)
, m_integration(integration)
+ , m_texture(nullptr)
{
m_format = format;
@@ -63,7 +65,7 @@ LibHybrisEglServerBuffer::LibHybrisEglServerBuffer(LibHybrisEglServerBufferInteg
break;
}
- if (!m_integration->eglHybrisCreateNativeBuffer(size.width(), size.height(), HYBRIS_USAGE_HW_TEXTURE, egl_format, &m_stride, &m_buffer)) {
+ if (!m_integration->eglHybrisCreateNativeBuffer(m_size.width(), m_size.height(), HYBRIS_USAGE_HW_TEXTURE, egl_format, &m_stride, &m_buffer)) {
qWarning("LibHybrisEglServerBuffer: Failed to create egl buffer");
return;
}
@@ -76,48 +78,53 @@ LibHybrisEglServerBuffer::LibHybrisEglServerBuffer(LibHybrisEglServerBufferInteg
m_integration->eglHybrisSerializeNativeBuffer(m_buffer, m_ints.data(), m_fds.data());
m_image = m_integration->eglCreateImageKHR(EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, m_buffer, 0);
+
+ if (!QOpenGLContext::currentContext()) {
+ qWarning("LibHybrisEglServerBuffer: No current context when creating buffer. Texture loading will fail");
+ return;
+ }
+
+ m_texture = new QOpenGLTexture(QOpenGLTexture::Target2D);
+ m_texture->create();
+
+ m_texture->bind();
+
+ m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, qimage.width(), qimage.height(), GL_RGBA, GL_UNSIGNED_BYTE, qimage.constBits());
+
+ m_texture->release();
+ m_texture->setSize(m_size.width(), m_size.height());
}
struct ::wl_resource *LibHybrisEglServerBuffer::resourceForClient(struct ::wl_client *client)
{
- QMultiMap<struct ::wl_client *, Resource *>::iterator it = resourceMap().find(client);
- if (it == resourceMap().end()) {
- QMultiMap<struct ::wl_client *, QtWaylandServer::qt_libhybris_egl_server_buffer::Resource *>::iterator egl_it = m_integration->resourceMap().find(client);
- if (egl_it == m_integration->resourceMap().end()) {
+ auto *bufferResource = resourceMap().value(client);
+ if (!bufferResource) {
+ auto integrationResource = m_integration->resourceMap().value(client);
+ if (!integrationResource) {
qWarning("LibHybrisEglServerBuffer::resourceForClient: Trying to get resource for ServerBuffer. But client is not bound to the libhybris_egl interface");
return 0;
}
- struct ::wl_resource *egl_resource = (*egl_it)->handle;
- Resource *resource = add(client, 1, 1);
- wl_resource *bufRes = wl_client_new_object(client, &qt_libhybris_buffer_interface, 0, 0);
+ struct ::wl_resource *egl_integration_resource = integrationResource->handle;
+ Resource *resource = add(client, 1);
+ wl_resource *bufRes = wl_resource_create(client, &qt_libhybris_buffer_interface,-1, 0);
- m_integration->send_server_buffer_created(egl_resource, resource->handle, bufRes, m_fds.size(), QByteArray((char *)m_ints.data(), m_ints.size() * sizeof(int32_t)),
+ m_integration->send_server_buffer_created(egl_integration_resource, resource->handle, bufRes, m_fds.size(), QByteArray((char *)m_ints.data(), m_ints.size() * sizeof(int32_t)),
m_name, m_size.width(), m_size.height(), m_stride, m_format);
- m_qtbuffers.insert(resource, bufRes);
-
for (int i = 0; i < m_fds.size(); ++i) {
send_add_fd(resource->handle, m_fds.at(i));
}
- return bufRes;
+ return resource->handle;
}
- return m_qtbuffers.value(*it);
+ return bufferResource->handle;
}
-void LibHybrisEglServerBuffer::bindTextureToBuffer()
+QOpenGLTexture *LibHybrisEglServerBuffer::toOpenGlTexture()
{
- if (!QOpenGLContext::currentContext()) {
- qWarning("LibHybrisEglServerBuffer: No current context when creating buffer. Texture loading will fail");
- return;
- }
-
- m_integration->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_image);
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ return m_texture;
}
LibHybrisEglServerBufferIntegration::LibHybrisEglServerBufferIntegration()
@@ -134,7 +141,7 @@ void LibHybrisEglServerBufferIntegration::initializeHardware(QWaylandCompositor
m_egl_display = static_cast<EGLDisplay>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("egldisplay"));
if (!m_egl_display) {
- qWarning("Cant initialize libhybris egl server buffer integration. Missing egl display from platformplugin");
+ qWarning("Can't initialize libhybris egl server buffer integration. Missing egl display from platform plugin");
return;
}
@@ -187,9 +194,9 @@ bool LibHybrisEglServerBufferIntegration::supportsFormat(QtWayland::ServerBuffer
}
}
-QtWayland::ServerBuffer *LibHybrisEglServerBufferIntegration::createServerBuffer(const QSize &size, QtWayland::ServerBuffer::Format format)
+QtWayland::ServerBuffer *LibHybrisEglServerBufferIntegration::createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format)
{
- return new LibHybrisEglServerBuffer(this, size, format);
+ return new LibHybrisEglServerBuffer(this, qimage, format);
}
QT_END_NAMESPACE
diff --git a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h
index e874e416b..0e1593447 100644
--- a/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h
+++ b/src/hardwareintegration/compositor/libhybris-egl-server/libhybriseglserverbufferintegration.h
@@ -78,10 +78,10 @@ class LibHybrisEglServerBufferIntegration;
class LibHybrisEglServerBuffer : public QtWayland::ServerBuffer, public QtWaylandServer::qt_libhybris_buffer
{
public:
- LibHybrisEglServerBuffer(LibHybrisEglServerBufferIntegration *integration, const QSize &size, QtWayland::ServerBuffer::Format format);
+ LibHybrisEglServerBuffer(LibHybrisEglServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format);
struct ::wl_resource *resourceForClient(struct ::wl_client *) override;
- void bindTextureToBuffer() override;
+ QOpenGLTexture *toOpenGlTexture() override;
private:
LibHybrisEglServerBufferIntegration *m_integration;
@@ -91,10 +91,10 @@ private:
int32_t m_name;
int32_t m_stride;
+ QOpenGLTexture *m_texture;
QtWaylandServer::qt_libhybris_egl_server_buffer::format m_hybris_format;
QVector<int32_t> m_ints;
QVector<int32_t> m_fds;
- QHash<Resource *, wl_resource *> m_qtbuffers;
};
class LibHybrisEglServerBufferIntegration :
@@ -108,7 +108,7 @@ public:
void initializeHardware(QWaylandCompositor *);
bool supportsFormat(QtWayland::ServerBuffer::Format format) const override;
- QtWayland::ServerBuffer *createServerBuffer(const QSize &size, QtWayland::ServerBuffer::Format format) override;
+ QtWayland::ServerBuffer *createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override;
EGLDisplay display() const { return m_egl_display; }
diff --git a/src/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pri b/src/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pri
new file mode 100644
index 000000000..4d12024c9
--- /dev/null
+++ b/src/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pri
@@ -0,0 +1,13 @@
+INCLUDEPATH += $$PWD
+
+QMAKE_USE_PRIVATE += wayland-server
+
+SOURCES += \
+ $$PWD/shmserverbufferintegration.cpp
+
+
+HEADERS += \
+ $$PWD/shmserverbufferintegration.h
+
+CONFIG += wayland-scanner
+WAYLANDSERVERSOURCES += $$PWD/../../../extensions/shm-emulation-server-buffer.xml
diff --git a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp
new file mode 100644
index 000000000..7a86785b0
--- /dev/null
+++ b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module 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 <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLTexture>
+#include <QtCore/QSharedMemory>
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+ShmServerBuffer::ShmServerBuffer(ShmServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format)
+ : QtWayland::ServerBuffer(qimage.size(),format)
+ , m_integration(integration)
+ , m_width(qimage.width())
+ , m_height(qimage.height())
+ , m_bpl(qimage.bytesPerLine())
+{
+ m_format = format;
+ switch (m_format) {
+ case RGBA32:
+ m_shm_format = QtWaylandServer::qt_shm_emulation_server_buffer::format_RGBA32;
+ break;
+ case A8:
+ m_shm_format = QtWaylandServer::qt_shm_emulation_server_buffer::format_A8;
+ break;
+ default:
+ qWarning("ShmServerBuffer: unsupported format");
+ m_shm_format = QtWaylandServer::qt_shm_emulation_server_buffer::format_RGBA32;
+ break;
+ }
+
+ QString key = "qt_shm_emulation_" + QString::number(qimage.cacheKey());
+ m_shm = new QSharedMemory(key);
+ int shm_size = qimage.byteCount();
+ bool ok = m_shm->create(shm_size) && m_shm->lock();
+ if (ok) {
+ memcpy(m_shm->data(), qimage.constBits(), shm_size);
+ m_shm->unlock();
+ } else {
+ qWarning() << "Could not create shared memory" << key << shm_size;
+ }
+}
+
+ShmServerBuffer::~ShmServerBuffer()
+{
+ delete m_shm;
+}
+
+struct ::wl_resource *ShmServerBuffer::resourceForClient(struct ::wl_client *client)
+{
+ auto *bufferResource = resourceMap().value(client);
+ if (!bufferResource) {
+ auto integrationResource = m_integration->resourceMap().value(client);
+ if (!integrationResource) {
+ qWarning("ShmServerBuffer::resourceForClient: Trying to get resource for ServerBuffer. But client is not bound to the shm_emulation interface");
+ return nullptr;
+ }
+ struct ::wl_resource *shm_integration_resource = integrationResource->handle;
+ Resource *resource = add(client, 1);
+ m_integration->send_server_buffer_created(shm_integration_resource, resource->handle, m_shm->key(), m_width, m_height, m_bpl, m_shm_format);
+ return resource->handle;
+ }
+ return bufferResource->handle;
+}
+
+
+QOpenGLTexture *ShmServerBuffer::toOpenGlTexture()
+{
+ if (!m_texture) {
+ qWarning("ShmServerBuffer::toOpenGlTexture: no texture defined");
+ }
+ return m_texture;
+}
+
+ShmServerBufferIntegration::ShmServerBufferIntegration()
+{
+}
+
+ShmServerBufferIntegration::~ShmServerBufferIntegration()
+{
+}
+
+void ShmServerBufferIntegration::initializeHardware(QWaylandCompositor *compositor)
+{
+ Q_ASSERT(QGuiApplication::platformNativeInterface());
+
+ QtWaylandServer::qt_shm_emulation_server_buffer::init(compositor->display(), 1);
+}
+
+bool ShmServerBufferIntegration::supportsFormat(QtWayland::ServerBuffer::Format format) const
+{
+ switch (format) {
+ case QtWayland::ServerBuffer::RGBA32:
+ return true;
+ case QtWayland::ServerBuffer::A8:
+ return true;
+ default:
+ return false;
+ }
+}
+
+QtWayland::ServerBuffer *ShmServerBufferIntegration::createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format)
+{
+ return new ShmServerBuffer(this, qimage, format);
+}
+
+QT_END_NAMESPACE
diff --git a/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h
new file mode 100644
index 000000000..c303e5f18
--- /dev/null
+++ b/src/hardwareintegration/compositor/shm-emulation-server/shmserverbufferintegration.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module 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 <QtWaylandCompositor/private/qwlserverbufferintegration_p.h>
+
+#include "qwayland-server-shm-emulation-server-buffer.h"
+
+#include <QtGui/QImage>
+#include <QtGui/QWindow>
+#include <QtGui/qpa/qplatformnativeinterface.h>
+#include <QtGui/QGuiApplication>
+
+#include <QtWaylandCompositor/qwaylandcompositor.h>
+#include <QtWaylandCompositor/private/qwayland-server-server-buffer-extension.h>
+
+QT_BEGIN_NAMESPACE
+
+class ShmServerBufferIntegration;
+class QSharedMemory;
+
+class ShmServerBuffer : public QtWayland::ServerBuffer, public QtWaylandServer::qt_server_buffer
+{
+public:
+ ShmServerBuffer(ShmServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format);
+ ~ShmServerBuffer();
+
+ struct ::wl_resource *resourceForClient(struct ::wl_client *) override;
+ QOpenGLTexture *toOpenGlTexture() override;
+
+private:
+ ShmServerBufferIntegration *m_integration;
+
+ QSharedMemory *m_shm;
+ int m_width;
+ int m_height;
+ int m_bpl;
+ QOpenGLTexture *m_texture = nullptr;
+ QtWaylandServer::qt_shm_emulation_server_buffer::format m_shm_format;
+};
+
+class ShmServerBufferIntegration :
+ public QtWayland::ServerBufferIntegration,
+ public QtWaylandServer::qt_shm_emulation_server_buffer
+{
+public:
+ ShmServerBufferIntegration();
+ ~ShmServerBufferIntegration();
+
+ void initializeHardware(QWaylandCompositor *) override;
+
+ bool supportsFormat(QtWayland::ServerBuffer::Format format) const override;
+ QtWayland::ServerBuffer *createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override;
+
+
+private:
+};
+
+QT_END_NAMESPACE
+
+#endif