1 | // Copyright (C) 2017 Jolla Ltd, author: <giulio.camuffo@jollamobile.com> |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QWAYLANDBUFFERREF_H |
5 | #define QWAYLANDBUFFERREF_H |
6 | |
7 | #include <QtWaylandCompositor/qtwaylandcompositorglobal.h> |
8 | #include <QtGui/QImage> |
9 | |
10 | #if QT_CONFIG(opengl) |
11 | #include <QtGui/qopengl.h> |
12 | #endif |
13 | |
14 | #include <QtWaylandCompositor/QWaylandSurface> |
15 | |
16 | struct wl_resource; |
17 | |
18 | QT_BEGIN_NAMESPACE |
19 | |
20 | class QOpenGLTexture; |
21 | |
22 | namespace QtWayland |
23 | { |
24 | class ClientBuffer; |
25 | } |
26 | |
27 | class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandBufferRef |
28 | { |
29 | public: |
30 | QWaylandBufferRef(); |
31 | QWaylandBufferRef(const QWaylandBufferRef &ref); |
32 | ~QWaylandBufferRef(); |
33 | |
34 | QWaylandBufferRef &operator=(const QWaylandBufferRef &ref); |
35 | bool isNull() const; |
36 | bool hasBuffer() const; |
37 | bool hasContent() const; |
38 | bool hasProtectedContent() const; |
39 | bool isDestroyed() const; |
40 | #if QT_WAYLANDCOMPOSITOR_REMOVED_SINCE(6, 3) |
41 | bool operator==(const QWaylandBufferRef &ref); |
42 | bool operator!=(const QWaylandBufferRef &ref); |
43 | #endif |
44 | |
45 | struct wl_resource *wl_buffer() const; |
46 | |
47 | QSize size() const; |
48 | QWaylandSurface::Origin origin() const; |
49 | |
50 | enum BufferType { |
51 | BufferType_Null, |
52 | BufferType_SharedMemory, |
53 | BufferType_Egl |
54 | }; |
55 | |
56 | enum BufferFormatEgl { |
57 | BufferFormatEgl_Null, |
58 | BufferFormatEgl_RGB, |
59 | BufferFormatEgl_RGBA, |
60 | BufferFormatEgl_EXTERNAL_OES, |
61 | BufferFormatEgl_Y_U_V, |
62 | BufferFormatEgl_Y_UV, |
63 | BufferFormatEgl_Y_XUXV |
64 | }; |
65 | |
66 | BufferType bufferType() const; |
67 | BufferFormatEgl bufferFormatEgl() const; |
68 | |
69 | bool isSharedMemory() const; |
70 | QImage image() const; |
71 | |
72 | #if QT_CONFIG(opengl) |
73 | QOpenGLTexture *toOpenGLTexture(int plane = 0) const; |
74 | #endif |
75 | |
76 | quintptr lockNativeBuffer(); |
77 | void unlockNativeBuffer(quintptr handle); |
78 | |
79 | private: |
80 | explicit QWaylandBufferRef(QtWayland::ClientBuffer *buffer); |
81 | QtWayland::ClientBuffer *buffer() const; |
82 | class QWaylandBufferRefPrivate *const d; |
83 | friend class QWaylandBufferRefPrivate; |
84 | friend class QWaylandSurfacePrivate; |
85 | |
86 | friend Q_WAYLANDCOMPOSITOR_EXPORT |
87 | bool operator==(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs) noexcept; |
88 | friend inline |
89 | bool operator!=(const QWaylandBufferRef &lhs, const QWaylandBufferRef &rhs) noexcept |
90 | { return !(lhs == rhs); } |
91 | }; |
92 | |
93 | QT_END_NAMESPACE |
94 | |
95 | #endif |
96 | |