diff options
Diffstat (limited to 'src/imports/texture-sharing')
-rw-r--r-- | src/imports/texture-sharing/CMakeLists.txt | 48 | ||||
-rw-r--r-- | src/imports/texture-sharing/plugin.cpp | 47 | ||||
-rw-r--r-- | src/imports/texture-sharing/qmldir | 3 | ||||
-rw-r--r-- | src/imports/texture-sharing/sharedtextureprovider.cpp | 111 | ||||
-rw-r--r-- | src/imports/texture-sharing/sharedtextureprovider.h | 118 | ||||
-rw-r--r-- | src/imports/texture-sharing/sharedtextureprovider_p.h | 73 | ||||
-rw-r--r-- | src/imports/texture-sharing/texture-sharing.pro | 21 | ||||
-rw-r--r-- | src/imports/texture-sharing/texturesharingextension.cpp | 45 | ||||
-rw-r--r-- | src/imports/texture-sharing/texturesharingextension.h | 77 | ||||
-rw-r--r-- | src/imports/texture-sharing/texturesharingextension_p.h | 53 |
10 files changed, 212 insertions, 384 deletions
diff --git a/src/imports/texture-sharing/CMakeLists.txt b/src/imports/texture-sharing/CMakeLists.txt new file mode 100644 index 000000000..61d6690e6 --- /dev/null +++ b/src/imports/texture-sharing/CMakeLists.txt @@ -0,0 +1,48 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Generated from texture-sharing.pro. + +##################################################################### +## qwaylandtexturesharing Plugin: +##################################################################### + +qt_internal_add_qml_module(WaylandTextureSharing + URI "QtWayland.Client.TextureSharing" + VERSION "1.${PROJECT_VERSION_MINOR}" + NO_PLUGIN_OPTIONAL + NO_GENERATE_PLUGIN_SOURCE + NO_GENERATE_QMLTYPES + PLUGIN_TARGET WaylandTextureSharing + # no qmltypes file available, so nothing to install + CLASS_NAME QWaylandTextureSharingPlugin + SOURCES + plugin.cpp + sharedtextureprovider.cpp sharedtextureprovider_p.h + texturesharingextension.cpp texturesharingextension_p.h + LIBRARIES + Qt::Core + Qt::CorePrivate + Qt::Gui + Qt::GuiPrivate + Qt::OpenGL + Qt::Qml + Qt::QuickPrivate + Qt::WaylandClient + Qt::WaylandClientPrivate + PRIVATE_HEADER_FILTERS + "^qwayland-.*\.h|^wayland-.*-protocol\.h" + NO_GENERATE_CPP_EXPORTS +) + +qt6_generate_wayland_protocol_client_sources(WaylandTextureSharing + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/../../extensions/qt-texture-sharing-unstable-v1.xml +) + +qt_internal_add_autogen_sync_header_dependencies(WaylandTextureSharing WaylandCompositor) + +#### Keys ignored in scope 1:.:.:texture-sharing.pro:<TRUE>: +# CXX_MODULE = "qml" +# IMPORT_VERSION = "1.$$QT_MINOR_VERSION" +# TARGETPATH = "QtWayland/Client/TextureSharing" diff --git a/src/imports/texture-sharing/plugin.cpp b/src/imports/texture-sharing/plugin.cpp index 9cf6bbca1..0f1f61369 100644 --- a/src/imports/texture-sharing/plugin.cpp +++ b/src/imports/texture-sharing/plugin.cpp @@ -1,48 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWaylandClient 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$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtQml/qqmlextensionplugin.h> #include <QtQml/qqmlengine.h> -#include "sharedtextureprovider.h" +#include "sharedtextureprovider_p.h" /*! + \internal \qmlmodule QtWayland.Client.TextureSharing 1 \title Qt Wayland Shared Texture Provider \ingroup qmlmodules @@ -52,6 +17,10 @@ This module allows Qt Wayland clients to use graphical resources exported by the compositor, without allocating any graphics memory in the client. + + \note The texture sharing functionality is considered experimental and + currently unsupported in Qt 6. + \section2 Usage To use this module, import it like this: diff --git a/src/imports/texture-sharing/qmldir b/src/imports/texture-sharing/qmldir deleted file mode 100644 index cf3b74c48..000000000 --- a/src/imports/texture-sharing/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module QtWayland.Client.TextureSharing -plugin qwaylandtexturesharing -classname QWaylandTextureSharingPlugin diff --git a/src/imports/texture-sharing/sharedtextureprovider.cpp b/src/imports/texture-sharing/sharedtextureprovider.cpp index 707e94ae6..ded29b44e 100644 --- a/src/imports/texture-sharing/sharedtextureprovider.cpp +++ b/src/imports/texture-sharing/sharedtextureprovider.cpp @@ -1,44 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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 "sharedtextureprovider.h" +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + + +#include "sharedtextureprovider_p.h" #include <QFile> #include <QDebug> @@ -49,58 +13,19 @@ #include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h> #include <QtGui/QGuiApplication> #include <QtGui/private/qguiapplication_p.h> +#include <QtQuick/private/qsgrhisupport_p.h> #include <QtGui/qpa/qplatformnativeinterface.h> #include <QtGui/QWindow> #include <QOpenGLTexture> #include <QImageReader> +#include <QtCore/qpointer.h> #include <QTimer> -#include "texturesharingextension.h" +#include "texturesharingextension_p.h" QT_BEGIN_NAMESPACE -SharedTexture::SharedTexture(QtWaylandClient::QWaylandServerBuffer *buffer) - : m_buffer(buffer), m_tex(nullptr) -{ -} - -int SharedTexture::textureId() const -{ - updateGLTexture(); - return m_tex ? m_tex->textureId() : 0; -} - -QSize SharedTexture::textureSize() const -{ - updateGLTexture(); - return m_tex ? QSize(m_tex->width(), m_tex->height()) : QSize(); -} - -bool SharedTexture::hasAlphaChannel() const -{ - return true; -} - -bool SharedTexture::hasMipmaps() const -{ - updateGLTexture(); - return m_tex ? (m_tex->mipLevels() > 1) : false; -} - -void SharedTexture::bind() -{ - updateGLTexture(); - if (m_tex) - m_tex->bind(); -} - -inline void SharedTexture::updateGLTexture() const -{ - if (!m_tex && m_buffer) - m_tex = m_buffer->toOpenGlTexture(); -} - class SharedTextureFactory : public QQuickTextureFactory { public: @@ -128,9 +53,16 @@ public: return m_buffer ? (m_buffer->size().width() * m_buffer->size().height() * 4) : 0; } - QSGTexture *createTexture(QQuickWindow *) const override + QSGTexture *createTexture(QQuickWindow *window) const override { - return new SharedTexture(const_cast<QtWaylandClient::QWaylandServerBuffer *>(m_buffer)); + if (m_buffer != nullptr) { + QOpenGLTexture *texture = const_cast<QtWaylandClient::QWaylandServerBuffer *>(m_buffer)->toOpenGlTexture(); + return QNativeInterface::QSGOpenGLTexture::fromNative(texture->textureId(), + window, + m_buffer->size(), + QQuickWindow::TextureHasAlphaChannel); + } + return nullptr; } private: @@ -184,6 +116,11 @@ void SharedTextureRegistry::handleExtensionActive() bool SharedTextureRegistry::preinitialize() { + if (QSGRhiSupport::instance()->rhiBackend() != QRhi::OpenGLES2) { + qWarning() << "The shared-texture extension is only supported on OpenGL. Use QQuickWindow::setSceneGraphBackend() to override the default."; + return false; + } + auto *serverBufferIntegration = QGuiApplicationPrivate::platformIntegration()->nativeInterface()->nativeResourceForIntegration("server_buffer_integration"); if (!serverBufferIntegration) { @@ -270,7 +207,7 @@ public: } -public slots: +public Q_SLOTS: void doResponse(const QString &key) { if (key != m_id) return; // not our buffer @@ -319,4 +256,6 @@ QQuickImageResponse *SharedTextureProvider::requestImageResponse(const QString & QT_END_NAMESPACE +#include "moc_sharedtextureprovider_p.cpp" + #include "sharedtextureprovider.moc" diff --git a/src/imports/texture-sharing/sharedtextureprovider.h b/src/imports/texture-sharing/sharedtextureprovider.h deleted file mode 100644 index f25c7de9c..000000000 --- a/src/imports/texture-sharing/sharedtextureprovider.h +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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 SHAREDTEXTUREPROVIDER_H -#define SHAREDTEXTUREPROVIDER_H - -#include <QOpenGLFunctions> -#include <QQuickImageProvider> -#include <QtQuick/QSGTexture> -#include <QScopedPointer> -#include <QHash> - -#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h> - -QT_BEGIN_NAMESPACE - -class TextureSharingExtension; - -class SharedTextureRegistry : public QObject -{ - Q_OBJECT -public: - SharedTextureRegistry(); - ~SharedTextureRegistry() override; - - const QtWaylandClient::QWaylandServerBuffer *bufferForId(const QString &id) const; - void requestBuffer(const QString &id); - void abandonBuffer(const QString &id); - - static bool preinitialize(); - -public slots: - void receiveBuffer(QtWaylandClient::QWaylandServerBuffer *buffer, const QString &id); - -signals: - void replyReceived(const QString &id); - -private slots: - void handleExtensionActive(); - -private: - TextureSharingExtension *m_extension = nullptr; - QHash<QString, QtWaylandClient::QWaylandServerBuffer *> m_buffers; - QStringList m_pendingBuffers; -}; - -class SharedTextureProvider : public QQuickAsyncImageProvider -{ -public: - SharedTextureProvider(); - ~SharedTextureProvider() override; - - QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override; - -private: - SharedTextureRegistry *m_registry = nullptr; - bool m_sharingAvailable = false; -}; - -class SharedTexture : public QSGTexture -{ - Q_OBJECT -public: - SharedTexture(QtWaylandClient::QWaylandServerBuffer *buffer); - - int textureId() const override; - QSize textureSize() const override; - bool hasAlphaChannel() const override; - bool hasMipmaps() const override; - - void bind() override; - -private: - void updateGLTexture() const; - QtWaylandClient::QWaylandServerBuffer *m_buffer = nullptr; - mutable QOpenGLTexture *m_tex = nullptr; -}; - - -QT_END_NAMESPACE - -#endif // SHAREDTEXTUREPROVIDER_H diff --git a/src/imports/texture-sharing/sharedtextureprovider_p.h b/src/imports/texture-sharing/sharedtextureprovider_p.h new file mode 100644 index 000000000..aac772619 --- /dev/null +++ b/src/imports/texture-sharing/sharedtextureprovider_p.h @@ -0,0 +1,73 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef SHAREDTEXTUREPROVIDER_H +#define SHAREDTEXTUREPROVIDER_H + +#include <QOpenGLFunctions> +#include <QQuickImageProvider> +#include <QtQuick/QSGTexture> +#include <QScopedPointer> +#include <QHash> + +#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h> + +QT_BEGIN_NAMESPACE + +class TextureSharingExtension; + +class SharedTextureRegistry : public QObject +{ + Q_OBJECT +public: + SharedTextureRegistry(); + ~SharedTextureRegistry() override; + + const QtWaylandClient::QWaylandServerBuffer *bufferForId(const QString &id) const; + void requestBuffer(const QString &id); + void abandonBuffer(const QString &id); + + static bool preinitialize(); + +public Q_SLOTS: + void receiveBuffer(QtWaylandClient::QWaylandServerBuffer *buffer, const QString &id); + +Q_SIGNALS: + void replyReceived(const QString &id); + +private Q_SLOTS: + void handleExtensionActive(); + +private: + TextureSharingExtension *m_extension = nullptr; + QHash<QString, QtWaylandClient::QWaylandServerBuffer *> m_buffers; + QStringList m_pendingBuffers; +}; + +class SharedTextureProvider : public QQuickAsyncImageProvider +{ +public: + SharedTextureProvider(); + ~SharedTextureProvider() override; + + QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override; + +private: + SharedTextureRegistry *m_registry = nullptr; + bool m_sharingAvailable = false; +}; + +QT_END_NAMESPACE + +#endif // SHAREDTEXTUREPROVIDER_H diff --git a/src/imports/texture-sharing/texture-sharing.pro b/src/imports/texture-sharing/texture-sharing.pro deleted file mode 100644 index bec769ecb..000000000 --- a/src/imports/texture-sharing/texture-sharing.pro +++ /dev/null @@ -1,21 +0,0 @@ -CXX_MODULE = qml -TARGET = qwaylandtexturesharing -TARGETPATH = QtWayland/Client/TextureSharing -IMPORT_VERSION = 1.$$QT_MINOR_VERSION - -HEADERS += \ - sharedtextureprovider.h \ - texturesharingextension.h - -SOURCES += \ - plugin.cpp \ - sharedtextureprovider.cpp \ - texturesharingextension.cpp - -QT += quick-private qml gui-private core-private waylandclient waylandclient-private -CONFIG += wayland-scanner - -WAYLANDCLIENTSOURCES += ../../extensions/qt-texture-sharing-unstable-v1.xml - - -load(qml_plugin) diff --git a/src/imports/texture-sharing/texturesharingextension.cpp b/src/imports/texture-sharing/texturesharingextension.cpp index 31106d694..4a2360078 100644 --- a/src/imports/texture-sharing/texturesharingextension.cpp +++ b/src/imports/texture-sharing/texturesharingextension.cpp @@ -1,44 +1,7 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -/**************************************************************************** -** -** Copyright (C) 2019 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 "texturesharingextension.h" +#include "texturesharingextension_p.h" #include <QtWaylandClient/private/qwaylanddisplay_p.h> #include <QtWaylandClient/private/qwaylandintegration_p.h> #include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h> @@ -84,3 +47,5 @@ void TextureSharingExtension::abandonImage(const QString &key) } QT_END_NAMESPACE + +#include "moc_texturesharingextension_p.cpp" diff --git a/src/imports/texture-sharing/texturesharingextension.h b/src/imports/texture-sharing/texturesharingextension.h deleted file mode 100644 index 7b864fbc8..000000000 --- a/src/imports/texture-sharing/texturesharingextension.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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 TEXTURESHARINGEXTENSION_H -#define TEXTURESHARINGEXTENSION_H - -#include <qpa/qwindowsysteminterface.h> -#include <QtWaylandClient/private/qwayland-wayland.h> -#include <QtWaylandClient/qwaylandclientextension.h> -#include "qwayland-qt-texture-sharing-unstable-v1.h" - -QT_BEGIN_NAMESPACE - -namespace QtWaylandClient { - class QWaylandServerBuffer; - class QWaylandServerBufferIntegration; -}; - -class TextureSharingExtension : public QWaylandClientExtensionTemplate<TextureSharingExtension> - , public QtWayland::zqt_texture_sharing_v1 -{ - Q_OBJECT -public: - TextureSharingExtension(); - -public slots: - void requestImage(const QString &key); - void abandonImage(const QString &key); - -signals: - void bufferReceived(QtWaylandClient::QWaylandServerBuffer *buffer, const QString &key); - -private: - void zqt_texture_sharing_v1_provide_buffer(struct ::qt_server_buffer *buffer, const QString &key) override; - void zqt_texture_sharing_v1_image_failed(const QString &key, const QString &message) override; - QtWaylandClient::QWaylandServerBufferIntegration *m_server_buffer_integration = nullptr; -}; - -QT_END_NAMESPACE - -#endif // TEXTURESHARINGEXTENSION_H diff --git a/src/imports/texture-sharing/texturesharingextension_p.h b/src/imports/texture-sharing/texturesharingextension_p.h new file mode 100644 index 000000000..4a00de8eb --- /dev/null +++ b/src/imports/texture-sharing/texturesharingextension_p.h @@ -0,0 +1,53 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#ifndef TEXTURESHARINGEXTENSION_H +#define TEXTURESHARINGEXTENSION_H + +#include <qpa/qwindowsysteminterface.h> +#include <QtWaylandClient/private/qwayland-wayland.h> +#include <QtWaylandClient/qwaylandclientextension.h> +#include "qwayland-qt-texture-sharing-unstable-v1.h" +#include "private/qglobal_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + class QWaylandServerBuffer; + class QWaylandServerBufferIntegration; +}; + +class TextureSharingExtension : public QWaylandClientExtensionTemplate<TextureSharingExtension> + , public QtWayland::zqt_texture_sharing_v1 +{ + Q_OBJECT +public: + TextureSharingExtension(); + +public Q_SLOTS: + void requestImage(const QString &key); + void abandonImage(const QString &key); + +Q_SIGNALS: + void bufferReceived(QtWaylandClient::QWaylandServerBuffer *buffer, const QString &key); + +private: + void zqt_texture_sharing_v1_provide_buffer(struct ::qt_server_buffer *buffer, const QString &key) override; + void zqt_texture_sharing_v1_image_failed(const QString &key, const QString &message) override; + QtWaylandClient::QWaylandServerBufferIntegration *m_server_buffer_integration = nullptr; +}; + +QT_END_NAMESPACE + +#endif // TEXTURESHARINGEXTENSION_H |