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