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 "QtWaylandCompositor/private/qwltexturesharingextension_p.h" |
8 | |
9 | /*! |
10 | \internal |
11 | \qmlmodule QtWayland.Compositor.TextureSharingExtension 1 |
12 | \title Qt Wayland Shared Texture Provider |
13 | \ingroup qmlmodules |
14 | \brief Adds a mechanism to share GPU memory |
15 | |
16 | \section2 Summary |
17 | |
18 | This module lets the compositor export graphical resources that can be used by clients, |
19 | 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 | This module is imported like this: |
27 | |
28 | \code |
29 | import QtWayland.Compositor.TextureSharingExtension 1.0 |
30 | \endcode |
31 | |
32 | To use this module in a compositor, instantiate the extension object as a child of the compositor object, like this: |
33 | |
34 | |
35 | \code |
36 | WaylandCompositor { |
37 | //... |
38 | TextureSharingExtension { |
39 | } |
40 | } |
41 | \endcode |
42 | |
43 | The sharing functionality is provided through a QQuickImageProvider. Use |
44 | the "image:" scheme for the URL source of the image, followed by the |
45 | identifier \e wlshared, followed by the image file path. For example: |
46 | |
47 | \code |
48 | Image { source: "image://wlshared/wallpapers/mybackground.jpg" } |
49 | \endcode |
50 | |
51 | */ |
52 | |
53 | QT_BEGIN_NAMESPACE |
54 | |
55 | class QWaylandTextureSharingExtensionPlugin : public QQmlExtensionPlugin |
56 | { |
57 | Q_OBJECT |
58 | Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) |
59 | public: |
60 | QWaylandTextureSharingExtensionPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) {} |
61 | |
62 | void registerTypes(const char *uri) override |
63 | { |
64 | Q_ASSERT(uri == QStringLiteral("QtWayland.Compositor.TextureSharingExtension" )); |
65 | qmlRegisterType<QWaylandTextureSharingExtensionQuickExtension>(uri: "QtWayland.Compositor.TextureSharingExtension" , versionMajor: 1, versionMinor: 0, qmlName: "TextureSharingExtension" ); |
66 | } |
67 | |
68 | void initializeEngine(QQmlEngine *engine, const char *uri) override |
69 | { |
70 | Q_UNUSED(uri); |
71 | engine->addImageProvider("wlshared" , new QWaylandSharedTextureProvider); |
72 | } |
73 | }; |
74 | |
75 | QT_END_NAMESPACE |
76 | |
77 | #include "plugin.moc" |
78 | |