| 1 | // Copyright (C) 2021 The Qt Company Ltd. | 
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only | 
| 3 |  | 
| 4 | #ifndef QWAYLANDSERVERBUFFERINTEGRATION_H | 
| 5 | #define QWAYLANDSERVERBUFFERINTEGRATION_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 <QtCore/private/qglobal_p.h> | 
| 19 | #include <QtCore/QSize> | 
| 20 | #include <QtGui/qopengl.h> | 
| 21 |  | 
| 22 | #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> | 
| 23 |  | 
| 24 | struct wl_client; | 
| 25 | struct wl_resource; | 
| 26 |  | 
| 27 | QT_BEGIN_NAMESPACE | 
| 28 |  | 
| 29 | class QWaylandCompositor; | 
| 30 | class QOpenGLContext; | 
| 31 | class QOpenGLTexture; | 
| 32 | class QImage; | 
| 33 |  | 
| 34 | namespace QtWayland { | 
| 35 | class Display; | 
| 36 |  | 
| 37 | class Q_WAYLANDCOMPOSITOR_EXPORT ServerBuffer | 
| 38 | { | 
| 39 | public: | 
| 40 |     enum Format { | 
| 41 |         RGBA32, | 
| 42 |         A8, | 
| 43 |         Custom | 
| 44 |     }; | 
| 45 |  | 
| 46 |     ServerBuffer(const QSize &size, ServerBuffer::Format format); | 
| 47 |     virtual ~ServerBuffer(); | 
| 48 |  | 
| 49 |     virtual struct ::wl_resource *resourceForClient(struct ::wl_client *) = 0; | 
| 50 |     virtual bool bufferInUse() { return true; } | 
| 51 |  | 
| 52 |     virtual QOpenGLTexture *toOpenGlTexture() = 0; | 
| 53 |     virtual void releaseOpenGlTexture() {} | 
| 54 |  | 
| 55 |     virtual bool isYInverted() const; | 
| 56 |  | 
| 57 |     QSize size() const; | 
| 58 |     Format format() const; | 
| 59 | protected: | 
| 60 |     QSize m_size; | 
| 61 |     Format m_format; | 
| 62 | }; | 
| 63 |  | 
| 64 | class Q_WAYLANDCOMPOSITOR_EXPORT ServerBufferIntegration | 
| 65 | { | 
| 66 | public: | 
| 67 |     ServerBufferIntegration(); | 
| 68 |     virtual ~ServerBufferIntegration(); | 
| 69 |  | 
| 70 |     virtual bool initializeHardware(QWaylandCompositor *); | 
| 71 |  | 
| 72 |     virtual bool supportsFormat(ServerBuffer::Format format) const = 0; | 
| 73 |     virtual ServerBuffer *createServerBufferFromImage(const QImage &qimage, ServerBuffer::Format format) = 0; | 
| 74 |     virtual ServerBuffer *createServerBufferFromData(QByteArrayView view, const QSize &size, | 
| 75 |                                                      uint glInternalFormat) | 
| 76 |     { | 
| 77 |         Q_UNUSED(view); | 
| 78 |         Q_UNUSED(size); | 
| 79 |         Q_UNUSED(glInternalFormat); | 
| 80 |         return nullptr; | 
| 81 |     } | 
| 82 | }; | 
| 83 |  | 
| 84 | } | 
| 85 |  | 
| 86 | QT_END_NAMESPACE | 
| 87 |  | 
| 88 | #endif //QWAYLANDSERVERBUFFERINTEGRATION_H | 
| 89 |  |