1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtQml/qqmlextensionplugin.h>
5#include <QtQml/qqmlengine.h>
6
7#include "sharedtextureprovider_p.h"
8
9/*!
10 \internal
11 \qmlmodule QtWayland.Client.TextureSharing 1
12 \title Qt Wayland Shared Texture Provider
13 \ingroup qmlmodules
14 \brief Adds an image provider which utilizes shared GPU memory
15
16 \section2 Summary
17
18 This module allows Qt Wayland clients to use graphical resources exported
19 by the compositor, without allocating any graphics memory in the client.
20
21 \note The texture sharing functionality is considered experimental and
22 currently unsupported in Qt 6.
23
24 \section2 Usage
25
26 To use this module, import it like this:
27 \code
28 import QtWayland.Client.TextureSharing 1.0
29 \endcode
30
31 The sharing functionality is provided through a QQuickImageProvider. Use
32 the "image:" scheme for the URL source of the image, followed by the
33 identifier \e wlshared, followed by the image file path. For example:
34
35 \code
36 Image { source: "image://wlshared/wallpapers/mybackground.jpg" }
37 \endcode
38
39 The shared texture module does not provide any directly usable QML types.
40*/
41
42QT_BEGIN_NAMESPACE
43
44class QWaylandTextureSharingPlugin : public QQmlExtensionPlugin
45{
46 Q_OBJECT
47 Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
48public:
49 QWaylandTextureSharingPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) {}
50
51 void registerTypes(const char *uri) override
52 {
53 Q_ASSERT(uri == QStringLiteral("QtWayland.Client.TextureSharing"));
54 qmlRegisterModule(uri, versionMajor: 1, versionMinor: 0);
55 }
56
57 void initializeEngine(QQmlEngine *engine, const char *uri) override
58 {
59 Q_UNUSED(uri);
60 engine->addImageProvider(id: "wlshared", new SharedTextureProvider);
61 }
62};
63
64QT_END_NAMESPACE
65
66#include "plugin.moc"
67

source code of qtwayland/src/imports/texture-sharing/plugin.cpp