1// Copyright (C) 2017 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#ifndef SHMSERVERBUFFERINTEGRATION_H
5#define SHMSERVERBUFFERINTEGRATION_H
6
7#include <QtWaylandClient/private/qwayland-wayland.h>
8#include "qwayland-shm-emulation-server-buffer.h"
9#include <QtWaylandClient/private/qwaylandserverbufferintegration_p.h>
10
11#include "shmserverbufferintegration.h"
12#include <QtWaylandClient/private/qwaylanddisplay_p.h>
13#include <QtCore/QTextStream>
14
15QT_BEGIN_NAMESPACE
16
17namespace QtWaylandClient {
18
19class ShmServerBufferIntegration;
20
21class ShmServerBuffer : public QWaylandServerBuffer
22{
23public:
24 ShmServerBuffer(const QString &key, const QSize &size, int bytesPerLine, QWaylandServerBuffer::Format format);
25 ~ShmServerBuffer() override;
26 QOpenGLTexture* toOpenGlTexture() override;
27private:
28 QOpenGLTexture *m_texture = nullptr;
29 QString m_key;
30 int m_bpl;
31};
32
33class ShmServerBufferIntegration
34 : public QWaylandServerBufferIntegration
35 , public QtWayland::qt_shm_emulation_server_buffer
36{
37public:
38 void initialize(QWaylandDisplay *display) override;
39
40 QWaylandServerBuffer *serverBuffer(struct qt_server_buffer *buffer) override;
41
42protected:
43 void shm_emulation_server_buffer_server_buffer_created(qt_server_buffer *id, const QString &key, int32_t width, int32_t height, int32_t bytes_per_line, int32_t format) override;
44
45private:
46 static void wlDisplayHandleGlobal(void *data, struct ::wl_registry *registry, uint32_t id,
47 const QString &interface, uint32_t version);
48 QWaylandDisplay *m_display = nullptr;
49};
50
51}
52
53QT_END_NAMESPACE
54
55#endif
56

source code of qtwayland/src/hardwareintegration/client/shm-emulation-server/shmserverbufferintegration.h