diff options
15 files changed, 736 insertions, 0 deletions
diff --git a/src/extensions/shm-emulation-server-buffer.xml b/src/extensions/shm-emulation-server-buffer.xml new file mode 100644 index 000000000..7fb7069f2 --- /dev/null +++ b/src/extensions/shm-emulation-server-buffer.xml @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<protocol name="shm_emulation_server_buffer"> + <copyright> + Copyright (C) 2017 The Qt Company Ltd. + Contact: http://www.qt.io/licensing/ + + This file is part of the plugins of the Qt Toolkit. + + $QT_BEGIN_LICENSE:BSD$ + You may use this file under the terms of the BSD license as follows: + + "Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of The Qt Company Ltd nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + + $QT_END_LICENSE$ + </copyright> + <interface name="qt_shm_emulation_server_buffer" version="1"> + <description summary="shm-based server buffer for testing on desktop"> + This is software-based implementation of the qt_server_buffer extension. + It is intended for testing and debugging purposes only. + </description> + <enum name="format"> + <entry name="RGBA32" value="0"/> + <entry name="A8" value="1"/> + </enum> + <event name="server_buffer_created"> + <description summary="shm buffer information"> + Informs the client about a newly created server buffer. + The "key" argument contains a QSharedMemory key. + </description> + <arg name="id" type="new_id" interface="qt_server_buffer"/> + <arg name="key" type="string"/> + <arg name="width" type="int"/> + <arg name="height" type="int"/> + <arg name="bytes_per_line" type="int"/> + <arg name="format" type="int"/> + </event> + </interface> +</protocol> + 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 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 diff --git a/src/plugins/hardwareintegration/client/client.pro b/src/plugins/hardwareintegration/client/client.pro index a5967c710..f1c71f084 100644 --- a/src/plugins/hardwareintegration/client/client.pro +++ b/src/plugins/hardwareintegration/client/client.pro @@ -13,3 +13,6 @@ qtConfig(drm-egl-server): \ SUBDIRS += drm-egl-server qtConfig(libhybris-egl-server): \ SUBDIRS += libhybris-egl-server + +### TODO: make shm-emulation configurable +SUBDIRS += shm-emulation-server diff --git a/src/plugins/hardwareintegration/client/shm-emulation-server/main.cpp b/src/plugins/hardwareintegration/client/shm-emulation-server/main.cpp new file mode 100644 index 000000000..8c3ba8420 --- /dev/null +++ b/src/plugins/hardwareintegration/client/shm-emulation-server/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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 <QtWaylandClient/private/qwaylandserverbufferintegrationplugin_p.h> +#include "shmserverbufferintegration.h" + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +class ShmServerBufferPlugin : public QWaylandServerBufferIntegrationPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QWaylandServerBufferIntegrationFactoryInterface_iid FILE "shm-emulation-server.json") +public: + QWaylandServerBufferIntegration *create(const QString&, const QStringList&) override; +}; + +QWaylandServerBufferIntegration *ShmServerBufferPlugin::create(const QString& system, const QStringList& paramList) +{ + Q_UNUSED(paramList); + Q_UNUSED(system); + return new ShmServerBufferIntegration(); +} + +} + +QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/hardwareintegration/client/shm-emulation-server/shm-emulation-server.json b/src/plugins/hardwareintegration/client/shm-emulation-server/shm-emulation-server.json new file mode 100644 index 000000000..1bf8ded87 --- /dev/null +++ b/src/plugins/hardwareintegration/client/shm-emulation-server/shm-emulation-server.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "shm-emulation-server" ] +} diff --git a/src/plugins/hardwareintegration/client/shm-emulation-server/shm-emulation-server.pro b/src/plugins/hardwareintegration/client/shm-emulation-server/shm-emulation-server.pro new file mode 100644 index 000000000..8b1c6e5f2 --- /dev/null +++ b/src/plugins/hardwareintegration/client/shm-emulation-server/shm-emulation-server.pro @@ -0,0 +1,15 @@ +# We have a bunch of C code with casts, so we can't have this option +QMAKE_CXXFLAGS_WARN_ON -= -Wcast-qual + +QT += waylandclient-private + +include(../../../../hardwareintegration/client/shm-emulation-server/shm-emulation-server.pri) + +OTHER_FILES += \ + shm-emulation-server.json + +SOURCES += main.cpp + +PLUGIN_TYPE = wayland-graphics-integration-client +PLUGIN_CLASS_NAME = ShmServerBufferPlugin +load(qt_plugin) diff --git a/src/plugins/hardwareintegration/compositor/compositor.pro b/src/plugins/hardwareintegration/compositor/compositor.pro index 299116257..0b2a4292c 100644 --- a/src/plugins/hardwareintegration/compositor/compositor.pro +++ b/src/plugins/hardwareintegration/compositor/compositor.pro @@ -13,3 +13,6 @@ qtConfig(drm-egl-server): \ SUBDIRS += drm-egl-server qtConfig(libhybris-egl-server): \ SUBDIRS += libhybris-egl-server + +### TODO: make shm-emulation configurable +SUBDIRS += shm-emulation-server diff --git a/src/plugins/hardwareintegration/compositor/shm-emulation-server/main.cpp b/src/plugins/hardwareintegration/compositor/shm-emulation-server/main.cpp new file mode 100644 index 000000000..9496361e9 --- /dev/null +++ b/src/plugins/hardwareintegration/compositor/shm-emulation-server/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** 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 <QtWaylandCompositor/private/qwlserverbufferintegrationplugin_p.h> +#include "shmserverbufferintegration.h" + +QT_BEGIN_NAMESPACE + +class ShmServerBufferIntegrationPlugin : public QtWayland::ServerBufferIntegrationPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QtWaylandServerBufferIntegrationFactoryInterface_iid FILE "shm-emulation-server.json") +public: + QtWayland::ServerBufferIntegration *create(const QString&, const QStringList&) override; +}; + +QtWayland::ServerBufferIntegration *ShmServerBufferIntegrationPlugin::create(const QString& system, const QStringList& paramList) +{ + Q_UNUSED(paramList); + Q_UNUSED(system); + return new ShmServerBufferIntegration(); +} + +QT_END_NAMESPACE + +#include "main.moc" diff --git a/src/plugins/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.json b/src/plugins/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.json new file mode 100644 index 000000000..1bf8ded87 --- /dev/null +++ b/src/plugins/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "shm-emulation-server" ] +} diff --git a/src/plugins/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pro b/src/plugins/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pro new file mode 100644 index 000000000..56a1bac21 --- /dev/null +++ b/src/plugins/hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pro @@ -0,0 +1,12 @@ +QT = waylandcompositor waylandcompositor-private core-private gui-private + +OTHER_FILES += shm-emulation-server.json + +SOURCES += \ + main.cpp + +include($PWD/../../../../../hardwareintegration/compositor/shm-emulation-server/shm-emulation-server.pri) + +PLUGIN_TYPE = wayland-graphics-integration-server +PLUGIN_CLASS_NAME = ShmServerBufferIntegrationPlugin +load(qt_plugin) |