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 | // |
5 | // W A R N I N G |
6 | // ------------- |
7 | // |
8 | // This file is not part of the Qt API. It exists purely as an |
9 | // implementation detail. This header file may change from version to |
10 | // version without notice, or even be removed. |
11 | // |
12 | // We mean it. |
13 | // |
14 | |
15 | #ifndef SHAREDTEXTUREPROVIDER_H |
16 | #define SHAREDTEXTUREPROVIDER_H |
17 | |
18 | #include <QOpenGLFunctions> |
19 | #include <QQuickImageProvider> |
20 | #include <QtQuick/QSGTexture> |
21 | #include <QScopedPointer> |
22 | #include <QHash> |
23 | |
24 | #include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h> |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | class TextureSharingExtension; |
29 | |
30 | class SharedTextureRegistry : public QObject |
31 | { |
32 | Q_OBJECT |
33 | public: |
34 | SharedTextureRegistry(); |
35 | ~SharedTextureRegistry() override; |
36 | |
37 | const QtWaylandClient::QWaylandServerBuffer *bufferForId(const QString &id) const; |
38 | void requestBuffer(const QString &id); |
39 | void abandonBuffer(const QString &id); |
40 | |
41 | static bool preinitialize(); |
42 | |
43 | public slots: |
44 | void receiveBuffer(QtWaylandClient::QWaylandServerBuffer *buffer, const QString &id); |
45 | |
46 | signals: |
47 | void replyReceived(const QString &id); |
48 | |
49 | private slots: |
50 | void handleExtensionActive(); |
51 | |
52 | private: |
53 | TextureSharingExtension *m_extension = nullptr; |
54 | QHash<QString, QtWaylandClient::QWaylandServerBuffer *> m_buffers; |
55 | QStringList m_pendingBuffers; |
56 | }; |
57 | |
58 | class SharedTextureProvider : public QQuickAsyncImageProvider |
59 | { |
60 | public: |
61 | SharedTextureProvider(); |
62 | ~SharedTextureProvider() override; |
63 | |
64 | QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override; |
65 | |
66 | private: |
67 | SharedTextureRegistry *m_registry = nullptr; |
68 | bool m_sharingAvailable = false; |
69 | }; |
70 | |
71 | QT_END_NAMESPACE |
72 | |
73 | #endif // SHAREDTEXTUREPROVIDER_H |
74 |