Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwltexturesharingextension_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWLTEXTURESHARINGEXTENSION_P_H
5#define QWLTEXTURESHARINGEXTENSION_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "wayland-util.h"
19
20#include <QtCore/QMap>
21#include <QtCore/QHash>
22
23#include <QtWaylandCompositor/QWaylandCompositorExtensionTemplate>
24#include <QtWaylandCompositor/QWaylandQuickExtension>
25#include <QtWaylandCompositor/QWaylandCompositor>
26
27#include <QQuickImageProvider>
28
29#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
30#include <QtWaylandCompositor/private/qwlserverbufferintegration_p.h>
31
32#include <QtWaylandCompositor/private/qwayland-server-qt-texture-sharing-unstable-v1.h>
33
35
36namespace QtWayland
37{
38 class ServerBufferIntegration;
39}
40
43
44class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandSharedTextureProvider : public QQuickAsyncImageProvider
45{
46public:
49
50 QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override;
51 void setExtensionReady(QWaylandTextureSharingExtension *extension);
52
53private:
54 QList<SharedTextureImageResponse*> m_pendingResponses;
55};
56
57class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandTextureSharingExtension
58 : public QWaylandCompositorExtensionTemplate<QWaylandTextureSharingExtension>
59 , public QtWaylandServer::zqt_texture_sharing_v1
60{
62 Q_PROPERTY(QString imageSearchPath WRITE setImageSearchPath)
63public:
67
68 void initialize() override;
69
70 void setImageSearchPath(const QString &path);
71
72 static QWaylandTextureSharingExtension *self() { return s_self; }
73
74public Q_SLOTS:
75 void requestBuffer(const QString &key);
76
79
80protected Q_SLOTS:
81 void cleanupBuffers();
82
83protected:
84 void zqt_texture_sharing_v1_request_image(Resource *resource, const QString &key) override;
85 void zqt_texture_sharing_v1_abandon_image(Resource *resource, const QString &key) override;
86 void zqt_texture_sharing_v1_destroy_resource(Resource *resource) override;
87
88 virtual bool customPixelData(const QString &key, QByteArray *data, QSize *size, uint *glInternalFormat)
89 {
93 Q_UNUSED(glInternalFormat);
94 return false;
95 }
96
97private:
98 QtWayland::ServerBuffer *getBuffer(const QString &key);
99 bool initServerBufferIntegration();
100 QtWayland::ServerBuffer *getCompressedBuffer(const QString &key);
101 QString getExistingFilePath(const QString &key) const;
102 void dumpBufferInfo();
103
104 struct BufferInfo
105 {
106 BufferInfo(QtWayland::ServerBuffer *b = nullptr) : buffer(b) {}
108 bool usedLocally = false;
109 };
110
111 QStringList m_image_dirs;
112 QStringList m_image_suffixes;
113 QHash<QString, BufferInfo> m_server_buffers;
114 QtWayland::ServerBufferIntegration *m_server_buffer_integration = nullptr;
115
116 static QWaylandTextureSharingExtension *s_self;
117};
118
120
122
123#endif // QWLTEXTURESHARINGEXTENSION_P_H
\inmodule QtCore
Definition qbytearray.h:57
The QQuickAsyncImageProvider class provides an interface for asynchronous control of QML image reques...
The QQuickImageResponse class provides an interface for asynchronous image loading in QQuickAsyncImag...
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\qmltype WaylandCompositor \instantiates QWaylandCompositor \inqmlmodule QtWayland....
virtual bool customPixelData(const QString &key, QByteArray *data, QSize *size, uint *glInternalFormat)
void bufferResult(const QString &key, QtWayland::ServerBuffer *buffer)
static QWaylandTextureSharingExtension * self()
void extension()
[6]
Definition dialogs.cpp:230
Combined button and popup list for selecting options.
static bool initialize()
Definition qctf.cpp:94
static QOpenGLCompositor * compositor
GLboolean GLboolean GLboolean b
GLuint64 key
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint buffer
GLsizei const GLchar *const * path
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
#define Q_UNUSED(x)
unsigned int uint
Definition qtypes.h:34
#define Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(className)