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
qplatformsharedgraphicscache.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
"qplatformsharedgraphicscache.h"
6
7
QT_BEGIN_NAMESPACE
8
9
/*!
10
\class QPlatformSharedGraphicsCache
11
\since 5.0
12
\internal
13
\preliminary
14
\ingroup qpa
15
\brief The QPlatformSharedGraphicsCache is an abstraction of a cross-process graphics cache.
16
17
If supported, it is possible to retrieve a QPlatformSharedGraphicsCache object from the
18
platform integration. This is typically used to store graphical items which should be shared
19
between several processes.
20
21
Items are requested from the cache by calling requestItems(). If the cache contains the
22
requested items in the requested cache, the itemsAvailable() signal is emitted with the ID of
23
the graphical buffer and each item's coordinates inside the buffer. Before requesting items
24
from a cache, the user must call ensureCacheInitialized() to set the correct parameters for
25
the cache.
26
27
If the cache does not yet contain the requested items, it will emit a similar itemsMissing()
28
signal. The client can then call updateItems() with rasterizations of the items and they will be
29
entered into the shared cache. As the items are rendered into the cache, itemsAvailable() signals
30
will be emitted for each of the items which have previously been requested and which have not
31
yet been reported as ready.
32
33
Using beginRequestBatch() and endRequestBatch(), it's possible to batch glyph requests, which
34
could improve performance in cases where you have a sequence of requests pending, and you
35
do not need the results during this sequence.
36
*/
37
38
/*!
39
\enum QPlatformSharedGraphicsCache::BufferType
40
41
Defines how the type of buffer required to contain a cache.
42
43
\value OpenGLTexture The buffer will be allocated in graphics memory, and an OpenGL texture
44
for a buffer belonging to the cache can be requested using
45
textureIdForBuffer().
46
*/
47
48
/*!
49
\enum QPlatformSharedGraphicsCache::PixelFormat
50
51
Defines the pixel format of a cache.
52
53
\value Alpha8 The cache will use 8 bits to represent the alpha value of each pixel. If an
54
OpenGL texture is created for a buffer belong to the cache, it will have the
55
pixel format GL_ALPHA.
56
*/
57
58
/*!
59
\fn void QPlatformSharedGraphicsCache::ensureCacheInitialized(const QByteArray &cacheId, BufferType bufferType, PixelFormat pixelFormat)
60
61
Initializes a cache named \a cacheId if it has not yet been initialized. The \a bufferType and
62
\a pixelFormat gives the format of the buffers that will be used to contain the items in the
63
cache. If a cache with the same \a cacheId has previously been initialized, the call will be
64
ignored. The cache will keep its previously set buffer type and pixel format.
65
*/
66
67
/*!
68
\fn void QPlatformSharedGraphicsCache::requestItems(const QByteArray &cacheId, const QList<quint32> &itemIds)
69
70
Requests all the items in \a itemIds from the cache with the name \a cacheId.
71
72
If any or all of the items are available in the cache, one or more itemsAvailable() signals will be
73
emitted corresponding to the items. If the cache does not contain all of the items in question,
74
then an itemsMissing() signal will be emitted corresponding to the missing items. The user
75
is at this point expected to call insertItems() to insert the missing items into the cache. If
76
the inserted items have previously been requested by the user, at which point an itemsAvailable()
77
signal will be emitted corresponding to the items.
78
79
Before requesting items from a cache, the user must call ensureCacheInitialized() with the
80
correct parameters for the cache.
81
*/
82
83
/*!
84
\fn void QPlatformSharedGraphicsCache::insertItems(const QByteArray &cacheId, const QList<quint32> &itemIds, const QList<QImage> &items)
85
86
Inserts the items in \a itemIds into the cache named \a cacheId. The appearance of
87
each item is stored in \a items. The format of the QImage objects is expected to match the
88
pixel format of the cache as it was initialized in ensureCacheInitialized().
89
90
When the items have been successfully entered into the cache, one or more itemsAvailable() signals
91
will be emitted for the items.
92
93
If the cache already contains the items, the behavior is implementation-specific. The
94
implementation may choose to ignore the items or it may overwrite the existing instances in
95
the cache. Either way, itemsAvailable() signals corresponding to the inserted items will be
96
emitted.
97
*/
98
99
/*!
100
\fn void QPlatformSharedGraphicsCache::releaseItems(const QByteArray &cacheId, const QList<quint32> &itemIds)
101
102
Releases the reference to the items in \a itemIds from the cache named \a cacheId. This should
103
only be called when all references to the items have been released by the user, and they are no
104
longer needed.
105
*/
106
107
/*!
108
\fn void QPlatformSharedGraphicsCache::itemsMissing(const QByteArray &cacheId, const QList<quint32> &itemIds)
109
110
This signal is emitted when requestItems() has been called for one or more items in the
111
cache named \a cacheId which are not yet available in the cache. The user is then expected to
112
call insertItems() to update the cache with the respective items, at which point they will
113
become available to all clients of the shared cache.
114
115
The \a itemIds list contains the IDs of the items that need to be inserted into the cache.
116
117
\sa itemsAvailable(), insertItems(), requestItems()
118
*/
119
120
/*!
121
\fn void QPlatformSharedGraphicsCache::itemsAvailable(const QByteArray &cacheId, void *bufferId, const QList<quint32> &itemIds, const QList<QPoint> &positionsInBuffer)
122
123
This signal can be emitted at any time when either requestItems() or insertItems() has been
124
called by the application for one or more items in the cache named \a cacheId, as long as
125
releaseItems() has not subsequently been called for the same items. It instructs the application
126
on where to find the items that have been entered into the cache. When the application receives
127
a buffer, it is expected to reference it using referenceBuffer() on it if it keeps a reference
128
to the buffer.
129
130
The \a bufferId is an ID for the buffer that contains the items. The \a bufferId can be
131
converted to a format usable by the application depending on which format it was given at
132
initialization. If it is a OpenGLTexture, its texture ID can be requested using the
133
textureIdForBuffer() function. The dimensions of the buffer are given by \a bufferSize.
134
135
The items provided by the cache are identified in the \a itemIds list. The
136
\a positionsInBuffer list contains the locations inside the buffer of each item. Each entry in
137
\a positionsInBuffer corresponds to an item in \a itemIds.
138
139
The buffer and the items' locations within the buffer can be considered valid until an
140
itemsInvalidated() signal has been emitted for the items, or until releaseItems() is called
141
for the items.
142
143
\sa itemsMissing(), requestItems(), bufferType()
144
*/
145
146
/*!
147
\fn void QPlatformSharedGraphicsCache::itemsUpdated(const QByteArray &cacheId, void *bufferId, const QList<quint32> &itemIds, const QList<QPoint> &positionsInBuffer)
148
149
This signal is similar in usage to the itemsAvailable() signal, but will be emitted when
150
the location of a previously requested or inserted item has been updated. The application
151
must update its data for the respective items and release any references to old buffers held
152
by the items.
153
154
If the application no longer holds any references to previously referenced items in a given
155
cache, it should call releaseItems() for these items, at which point it will no longer receive
156
any itemsUpdated() signal for these items.
157
158
\sa requestItems(), insertItems(), itemsAvailable()
159
*/
160
161
/*!
162
\fn void QPlatformSharedGraphicsCache::itemsInvalidated(const QByteArray &cacheId, const QList<quint32> &itemIds)
163
164
This signal is emitted when the items given by \a itemIds in the cache named \a cacheId have
165
been removed from the cache and the previously reported information about them is considered
166
invalid. It will only be emitted for items for which a buffer has previously been identified
167
through the itemsAvailable() signal (either as response to a requestItems() call or an
168
insertItems() call.)
169
170
The application is expected to throw away information about the items in the \a itemIds array
171
and drop any references it might have to the memory held by the buffer. If the items are still
172
required by the application, it can re-commit them to the cache using the insertItems() function.
173
174
If the application no longer holds any references to previously referenced items in a given
175
cache, it should call releaseItems() for these items, at which point it will no longer receive
176
any itemsInvalidated() signal for these items.
177
*/
178
179
/*!
180
\fn void QPlatformSharedGraphicsCache::beginRequestBatch()
181
182
This is a hint to the cache that a burst of requests is pending. In some implementations, this
183
will improve performance, as the cache can focus on handling the requests and wait with the
184
results until it is done. It should typically be called prior to a sequence of calls to
185
requestItems() and releaseItems().
186
187
Any call to beginRequestBatch() must be followed at some point by a call to endRequestBatch().
188
Failing to do this may lead to the results of requests never being emitted.
189
190
\note beginRequestBatch() and endRequestBatch() have no stacking logic. Calling
191
beginRequestBatch() twice in a row has no effect, and the single existing batch will be ended
192
by the earliest call to endRequestBatch().
193
194
\sa endRequestBatch(), requestBatchStarted()
195
*/
196
197
/*!
198
\fn void QPlatformSharedGraphicsCache::endRequestBatch()
199
200
Signals to the cache that the request sequence which has previously been commenced using
201
beginRequestBatch() has now finished.
202
203
\sa beginRequestBatch(), requestBatchStarted()
204
*/
205
206
/*!
207
\fn bool QPlatformSharedGraphicsCache::requestBatchStarted() const
208
209
Returns \c true if a request batch has previously been started using beginRequestBatch()
210
and not yet stopped using endRequestBatch().
211
212
\sa beginRequestBatch(), endRequestBatch()
213
*/
214
215
/*!
216
\fn uint QPlatformSharedGraphicsCache::textureIdForBuffer(void *bufferId)
217
218
Returns an OpenGL texture ID corresponding to the buffer \a bufferId, which has previously
219
been passed through signals itemsAvailable() or itemsUpdated(). The relevant OpenGL context
220
should be current when calling this function.
221
222
\sa eglImageForBuffer(), sizeOfBuffer()
223
*/
224
225
/*!
226
\fn void *QPlatformSharedGraphicsCache::eglImageForBuffer(void *bufferId)
227
228
Returns an EGLImageKHR image corresponding to the buffer \a bufferId.
229
230
\sa textureIdForBuffer(), sizeOfBuffer()
231
*/
232
233
/*!
234
\fn void QPlatformSharedGraphicsCache::referenceBuffer(void *bufferId)
235
236
Registers a reference to the buffer \a bufferId.
237
238
\sa dereferenceBuffer()
239
*/
240
241
/*!
242
\fn bool QPlatformSharedGraphicsCache::dereferenceBuffer(void *bufferId)
243
244
Removed a previously registered reference to the buffer \a bufferId. Returns \c true if there
245
are still more references to the buffer in question, or false if this was the last reference
246
(in which case the buffer may have been deleted in the cache.)
247
248
\sa dereferenceBuffer()
249
*/
250
251
/*!
252
\fn QSize QPlatformSharedGraphicsCache::sizeOfBuffer(void *bufferId)
253
254
Returns the size of the buffer \a bufferId.
255
256
\sa textureIdForBuffer(), eglImageForBuffer()
257
*/
258
259
QT_END_NAMESPACE
260
261
#
include
"moc_qplatformsharedgraphicscache.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
qtbase
src
gui
kernel
qplatformsharedgraphicscache.cpp
Generated on
for Qt by
1.16.1