Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwlclientbuffer_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWLCLIENTBUFFER_P_H
5#define QWLCLIENTBUFFER_P_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/QRect>
19#include <QtGui/qopengl.h>
20#include <QImage>
21#include <QAtomicInt>
22
23#include <QtWaylandCompositor/QWaylandSurface>
24#include <QtWaylandCompositor/QWaylandBufferRef>
25#include <QtCore/private/qglobal_p.h>
26
27#include <wayland-server-core.h>
28
30
31class QWaylandClientBufferIntegration;
34class QOpenGLTexture;
35
36namespace QtWayland {
37
39{
40 struct wl_listener listener;
41 class ClientBuffer *surfaceBuffer = nullptr;
42};
43
44class Q_WAYLANDCOMPOSITOR_EXPORT ClientBuffer
45{
46public:
47 ClientBuffer(struct ::wl_resource *bufferResource);
48
49 virtual ~ClientBuffer();
50
51 virtual QWaylandBufferRef::BufferFormatEgl bufferFormatEgl() const;
52 virtual QSize size() const = 0;
53 virtual QWaylandSurface::Origin origin() const = 0;
54
55 virtual quintptr lockNativeBuffer() { return 0; }
56 virtual void unlockNativeBuffer(quintptr native_buffer) const { Q_UNUSED(native_buffer); }
57
58 virtual QImage image() const { return QImage(); }
59
60 inline bool isCommitted() const { return m_committed; }
61 virtual void setCommitted(QRegion &damage);
62 bool isDestroyed() { return m_destroyed; }
63
64 virtual bool isProtected() { return false; }
65
66 inline struct ::wl_resource *waylandBufferHandle() const { return m_buffer; }
67
68 bool isSharedMemory() const { return wl_shm_buffer_get(m_buffer); }
69
70#if QT_CONFIG(opengl)
71 virtual QOpenGLTexture *toOpenGlTexture(int plane = 0) = 0;
72#endif
73
74 static bool hasContent(ClientBuffer *buffer) { return buffer && buffer->waylandBufferHandle(); }
75 static bool hasProtectedContent(ClientBuffer *buffer) { return buffer && buffer->isProtected(); }
76
77protected:
78 void ref();
79 void deref();
80 void sendRelease();
81 virtual void setDestroyed();
82
83 struct ::wl_resource *m_buffer = nullptr;
85 bool m_textureDirty = false;
86
87private:
88 bool m_committed = false;
89 bool m_destroyed = false;
90
91 QAtomicInt m_refCount;
92
93 friend class ::QWaylandBufferRef;
94 friend class BufferManager;
95};
96
97class Q_WAYLANDCOMPOSITOR_EXPORT SharedMemoryBuffer : public ClientBuffer
98{
99public:
100 SharedMemoryBuffer(struct ::wl_resource *bufferResource);
101
102 QSize size() const override;
103 QWaylandSurface::Origin origin() const override;
104 QImage image() const override;
105
106#if QT_CONFIG(opengl)
107 QOpenGLTexture *toOpenGlTexture(int plane = 0) override;
108
109private:
110 QOpenGLTexture *m_shmTexture = nullptr;
111#endif
112};
113
114}
115
117
118#endif // QWLCLIENTBUFFER_P_H
\inmodule QtCore
Definition qatomic.h:112
\inmodule QtGui
Definition qimage.h:37
\inmodule QtGui
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
\inmodule QtCore
Definition qsize.h:25
\inmodule QtWaylandCompositor
\qmltype WaylandCompositor \instantiates QWaylandCompositor \inqmlmodule QtWayland....
Origin
This enum type is used to specify the origin of a QWaylandSurface's buffer.
static bool hasProtectedContent(ClientBuffer *buffer)
virtual quintptr lockNativeBuffer()
static bool hasContent(ClientBuffer *buffer)
virtual QImage image() const
struct::wl_resource * waylandBufferHandle() const
virtual QWaylandSurface::Origin origin() const =0
virtual void unlockNativeBuffer(quintptr native_buffer) const
virtual QSize size() const =0
Combined button and popup list for selecting options.
Definition image.cpp:4
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint buffer
GLint ref
#define Q_UNUSED(x)
size_t quintptr
Definition qtypes.h:167