| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef SHMSERVERBUFFERINTEGRATION_H |
| 5 | #define SHMSERVERBUFFERINTEGRATION_H |
| 6 | |
| 7 | #include <QtWaylandCompositor/private/qwlserverbufferintegration_p.h> |
| 8 | |
| 9 | #include "qwayland-server-shm-emulation-server-buffer.h" |
| 10 | |
| 11 | #include <QtGui/QImage> |
| 12 | #include <QtGui/QWindow> |
| 13 | #include <QtGui/qpa/qplatformnativeinterface.h> |
| 14 | #include <QtGui/QGuiApplication> |
| 15 | |
| 16 | #include <QtWaylandCompositor/qwaylandcompositor.h> |
| 17 | #include <QtWaylandCompositor/private/qwayland-server-server-buffer-extension.h> |
| 18 | |
| 19 | QT_BEGIN_NAMESPACE |
| 20 | |
| 21 | class ShmServerBufferIntegration; |
| 22 | class QSharedMemory; |
| 23 | |
| 24 | class ShmServerBuffer : public QtWayland::ServerBuffer, public QtWaylandServer::qt_server_buffer |
| 25 | { |
| 26 | public: |
| 27 | ShmServerBuffer(ShmServerBufferIntegration *integration, const QImage &qimage, QtWayland::ServerBuffer::Format format); |
| 28 | ~ShmServerBuffer() override; |
| 29 | |
| 30 | struct ::wl_resource *resourceForClient(struct ::wl_client *) override; |
| 31 | bool bufferInUse() override; |
| 32 | QOpenGLTexture *toOpenGlTexture() override; |
| 33 | |
| 34 | private: |
| 35 | ShmServerBufferIntegration *m_integration = nullptr; |
| 36 | |
| 37 | QSharedMemory *m_shm = nullptr; |
| 38 | int m_width; |
| 39 | int m_height; |
| 40 | int m_bpl; |
| 41 | QOpenGLTexture *m_texture = nullptr; |
| 42 | QtWaylandServer::qt_shm_emulation_server_buffer::format m_shm_format; |
| 43 | }; |
| 44 | |
| 45 | class ShmServerBufferIntegration : |
| 46 | public QtWayland::ServerBufferIntegration, |
| 47 | public QtWaylandServer::qt_shm_emulation_server_buffer |
| 48 | { |
| 49 | public: |
| 50 | ShmServerBufferIntegration(); |
| 51 | ~ShmServerBufferIntegration() override; |
| 52 | |
| 53 | bool initializeHardware(QWaylandCompositor *) override; |
| 54 | |
| 55 | bool supportsFormat(QtWayland::ServerBuffer::Format format) const override; |
| 56 | QtWayland::ServerBuffer *createServerBufferFromImage(const QImage &qimage, QtWayland::ServerBuffer::Format format) override; |
| 57 | |
| 58 | |
| 59 | private: |
| 60 | }; |
| 61 | |
| 62 | QT_END_NAMESPACE |
| 63 | |
| 64 | #endif |
| 65 | |