Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qplatformgraphicsbuffer.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"qplatformgraphicsbuffer.h"
5
#
include
<
QtGui
/
QOpenGLContext
>
6
#
include
<
QtGui
/
QOpenGLFunctions
>
7
#
include
<
QtGui
/
qopengl
.
h
>
8
#
include
<
QtCore
/
QDebug
>
9
10
QT_BEGIN_NAMESPACE
11
/*!
12
\class QPlatformGraphicsBuffer
13
\inmodule QtGui
14
\since 5.5
15
\brief The QPlatformGraphicsBuffer is a windowsystem abstraction for native graphics buffers
16
17
Different platforms have different ways of representing graphics buffers. On
18
some platforms, it is possible to create one graphics buffer that you can bind
19
to a texture and also get main memory access to the image bits. On the
20
other hand, on some platforms all graphics buffer abstraction is completely
21
hidden.
22
23
QPlatformGraphicsBuffer is an abstraction of a single Graphics Buffer.
24
25
There is no public constructor nor any public factory function.
26
27
\internal
28
*/
29
30
/*!
31
\enum QPlatformGraphicsBuffer::AccessType
32
33
This enum describes the access that is desired or granted for the graphics
34
buffer.
35
36
\value None
37
\value SWReadAccess
38
\value SWWriteAccess
39
\value TextureAccess
40
\value HWCompositor
41
*/
42
43
/*!
44
\enum QPlatformGraphicsBuffer::Origin
45
46
This enum describes the origin of the content of the buffer.
47
48
\value OriginTopLeft
49
\value OriginBottomLeft
50
*/
51
52
/*!
53
Protected constructor to initialize the private members.
54
55
\a size is the size of the buffer.
56
\a format is the format of the buffer.
57
58
\sa size() format()
59
*/
60
QPlatformGraphicsBuffer::QPlatformGraphicsBuffer(
const
QSize &size,
const
QPixelFormat &format)
61
: m_size(size)
62
, m_format(format)
63
{
64
}
65
66
67
/*!
68
Virtual destructor.
69
*/
70
QPlatformGraphicsBuffer::~QPlatformGraphicsBuffer()
71
{
72
}
73
74
/*!
75
Binds the content of this graphics buffer into the currently bound texture.
76
77
This function should fail for buffers not capable of locking to TextureAccess.
78
79
\a rect is the subrect which is desired to be bounded to the texture. This
80
argument has a no less than semantic, meaning more (if not all) of the buffer
81
can be bounded to the texture. An empty QRect is interpreted as entire buffer
82
should be bound.
83
84
This function only supports binding buffers to the GL_TEXTURE_2D texture
85
target.
86
87
Returns true on success, otherwise false.
88
*/
89
bool
QPlatformGraphicsBuffer::bindToTexture(
const
QRect &rect)
const
90
{
91
Q_UNUSED(rect);
92
return
false
;
93
}
94
95
/*!
96
\fn QPlatformGraphicsBuffer::AccessTypes QPlatformGraphicsBuffer::isLocked() const
97
Function to check if the buffer is locked.
98
99
\sa lock()
100
*/
101
102
/*!
103
Before the data can be retrieved or before a buffer can be bound to a
104
texture it needs to be locked. This is a separate function call since this
105
operation might be time consuming, and it would not be satisfactory to do
106
it per function call.
107
108
\a access is the access type wanted.
109
110
\a rect is the subrect which is desired to be locked. This
111
argument has a no less than semantic, meaning more (if not all) of the buffer
112
can be locked. An empty QRect is interpreted as entire buffer should be locked.
113
114
Return true on successfully locking all AccessTypes specified \a access
115
otherwise returns false and no locks have been granted.
116
*/
117
bool
QPlatformGraphicsBuffer::lock(AccessTypes access,
const
QRect &rect)
118
{
119
bool
locked = doLock(access, rect);
120
if
(locked)
121
m_lock_access |= access;
122
123
return
locked;
124
}
125
126
/*!
127
Unlocks the current buffer lock.
128
129
This function calls doUnlock, and then emits the unlocked signal with the
130
AccessTypes from before doUnlock was called.
131
*/
132
void
QPlatformGraphicsBuffer::unlock()
133
{
134
if
(m_lock_access == None)
135
return
;
136
AccessTypes previous = m_lock_access;
137
doUnlock();
138
m_lock_access = None;
139
emit unlocked(previous);
140
}
141
142
143
/*!
144
\fn QPlatformGraphicsBuffer::doLock(AccessTypes access, const QRect &rect = QRect())
145
146
This function should be reimplemented by subclasses. If one of the \a
147
access types specified cannot be locked, then all should fail and this
148
function should return false.
149
150
\a rect is the subrect which is desired to be locked. This
151
argument has a no less than semantic, meaning more (if not all) of the
152
buffer can be locked. An empty QRect should be interpreted as the entire buffer
153
should be locked.
154
155
It is safe to call isLocked() to verify the current lock state.
156
*/
157
158
/*!
159
\fn QPlatformGraphicsBuffer::doUnlock()
160
161
This function should remove all locks set on the buffer.
162
163
It is safe to call isLocked() to verify the current lock state.
164
*/
165
166
/*!
167
\fn QPlatformGraphicsBuffer::unlocked(AccessTypes previousAccessTypes)
168
169
Signal that is emitted after unlocked has been called.
170
171
\a previousAccessTypes is the access types locked before unlock was called.
172
*/
173
174
/*!
175
Accessor for the bytes of the buffer. This function needs to be called on a
176
buffer with SWReadAccess access lock. Behavior is undefined for modifying
177
the memory returned when not having a SWWriteAccess.
178
*/
179
const
uchar *QPlatformGraphicsBuffer::data()
const
180
{
return
nullptr
; }
181
182
/*!
183
Accessor for the bytes of the buffer. This function needs to be called on a
184
buffer with SWReadAccess access lock. Behavior is undefined for modifying
185
the memory returned when not having a SWWriteAccess.
186
*/
187
uchar *QPlatformGraphicsBuffer::data()
188
{
189
return
nullptr
;
190
}
191
192
/*!
193
Accessor for the length of the data buffer. This function is a convenience
194
function multiplying height of buffer with bytesPerLine().
195
196
\sa data() bytesPerLine() size()
197
*/
198
int
QPlatformGraphicsBuffer::byteCount()
const
199
{
200
return
size().height() * bytesPerLine();
201
}
202
203
/*!
204
Accessor for bytes per line in the graphics buffer.
205
*/
206
int
QPlatformGraphicsBuffer::bytesPerLine()
const
207
{
208
return
0;
209
}
210
211
212
/*!
213
In origin of the content of the graphics buffer.
214
215
Default implementation is OriginTopLeft, as this is the coordinate
216
system default for Qt. However, for most regular OpenGL textures
217
this will be OriginBottomLeft.
218
*/
219
QPlatformGraphicsBuffer::Origin QPlatformGraphicsBuffer::origin()
const
220
{
221
return
OriginTopLeft;
222
}
223
224
/*!
225
\fn QPlatformGraphicsBuffer::size() const
226
227
Accessor for content size.
228
*/
229
230
/*!
231
\fn QPlatformGraphicsBuffer::format() const
232
233
Accessor for the pixel format of the buffer.
234
*/
235
236
QT_END_NAMESPACE
237
238
#
include
"moc_qplatformgraphicsbuffer.cpp"
QPlatformGraphicsBufferHelper
\inmodule QtGui
qtbase
src
gui
kernel
qplatformgraphicsbuffer.cpp
Generated on
for Qt by
1.14.0