| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2017 Jolla Ltd, author: <[email protected]> |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 or (at your option) any later version |
| 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
| 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
| 22 | ** included in the packaging of this file. Please review the following |
| 23 | ** information to ensure the GNU General Public License requirements will |
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 25 | ** |
| 26 | ** $QT_END_LICENSE$ |
| 27 | ** |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | #ifndef QWAYLANDBUFFERREF_H |
| 31 | #define QWAYLANDBUFFERREF_H |
| 32 | |
| 33 | #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> |
| 34 | #include <QImage> |
| 35 | |
| 36 | #if QT_CONFIG(opengl) |
| 37 | #include <QtGui/qopengl.h> |
| 38 | #endif |
| 39 | |
| 40 | #include <QtWaylandCompositor/QWaylandSurface> |
| 41 | #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> |
| 42 | |
| 43 | struct wl_resource; |
| 44 | |
| 45 | QT_BEGIN_NAMESPACE |
| 46 | |
| 47 | class QOpenGLTexture; |
| 48 | |
| 49 | namespace QtWayland |
| 50 | { |
| 51 | class ClientBuffer; |
| 52 | } |
| 53 | |
| 54 | class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandBufferRef |
| 55 | { |
| 56 | public: |
| 57 | QWaylandBufferRef(); |
| 58 | QWaylandBufferRef(const QWaylandBufferRef &ref); |
| 59 | ~QWaylandBufferRef(); |
| 60 | |
| 61 | QWaylandBufferRef &operator=(const QWaylandBufferRef &ref); |
| 62 | bool isNull() const; |
| 63 | bool hasBuffer() const; |
| 64 | bool hasContent() const; |
| 65 | bool isDestroyed() const; |
| 66 | bool operator==(const QWaylandBufferRef &ref); |
| 67 | bool operator!=(const QWaylandBufferRef &ref); |
| 68 | |
| 69 | struct wl_resource *wl_buffer() const; |
| 70 | |
| 71 | QSize size() const; |
| 72 | QWaylandSurface::Origin origin() const; |
| 73 | |
| 74 | enum BufferType { |
| 75 | BufferType_Null, |
| 76 | BufferType_SharedMemory, |
| 77 | BufferType_Egl |
| 78 | }; |
| 79 | |
| 80 | enum BufferFormatEgl { |
| 81 | BufferFormatEgl_Null, |
| 82 | BufferFormatEgl_RGB, |
| 83 | BufferFormatEgl_RGBA, |
| 84 | BufferFormatEgl_EXTERNAL_OES, |
| 85 | BufferFormatEgl_Y_U_V, |
| 86 | BufferFormatEgl_Y_UV, |
| 87 | BufferFormatEgl_Y_XUXV |
| 88 | }; |
| 89 | |
| 90 | BufferType bufferType() const; |
| 91 | BufferFormatEgl bufferFormatEgl() const; |
| 92 | |
| 93 | bool isSharedMemory() const; |
| 94 | QImage image() const; |
| 95 | |
| 96 | #if QT_CONFIG(opengl) |
| 97 | QOpenGLTexture *toOpenGLTexture(int plane = 0) const; |
| 98 | #endif |
| 99 | |
| 100 | quintptr lockNativeBuffer(); |
| 101 | void unlockNativeBuffer(quintptr handle); |
| 102 | |
| 103 | private: |
| 104 | explicit QWaylandBufferRef(QtWayland::ClientBuffer *buffer); |
| 105 | QtWayland::ClientBuffer *buffer() const; |
| 106 | class QWaylandBufferRefPrivate *const d; |
| 107 | friend class QWaylandBufferRefPrivate; |
| 108 | friend class QWaylandSurfacePrivate; |
| 109 | }; |
| 110 | |
| 111 | QT_END_NAMESPACE |
| 112 | |
| 113 | #endif |
| 114 | |