Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/coreapi/qsggeometry.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the Qt scene graph research project. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
24 | ** | - | ||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
35 | ** | - | ||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||
37 | ** | - | ||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||
39 | - | |||||||||||||
40 | #include "qsggeometry.h" | - | ||||||||||||
41 | #include "qsggeometry_p.h" | - | ||||||||||||
42 | #if QT_CONFIG(opengl) | - | ||||||||||||
43 | # include <qopenglcontext.h> | - | ||||||||||||
44 | # include <qopenglfunctions.h> | - | ||||||||||||
45 | # include <private/qopenglextensions_p.h> | - | ||||||||||||
46 | #endif | - | ||||||||||||
47 | - | |||||||||||||
48 | #ifdef Q_OS_QNX | - | ||||||||||||
49 | #include <malloc.h> | - | ||||||||||||
50 | #endif | - | ||||||||||||
51 | - | |||||||||||||
52 | QT_BEGIN_NAMESPACE | - | ||||||||||||
53 | - | |||||||||||||
54 | - | |||||||||||||
55 | QSGGeometry::Attribute QSGGeometry::Attribute::create(int attributeIndex, int tupleSize, int primitiveType, bool isPrimitive) | - | ||||||||||||
56 | { | - | ||||||||||||
57 | Attribute a = { attributeIndex, tupleSize, primitiveType, isPrimitive, UnknownAttribute, 0 }; | - | ||||||||||||
58 | return a; executed 1994 times by 145 tests: return a; Executed by:
| 1994 | ||||||||||||
59 | } | - | ||||||||||||
60 | - | |||||||||||||
61 | QSGGeometry::Attribute QSGGeometry::Attribute::createWithAttributeType(int pos, int tupleSize, int primitiveType, AttributeType attributeType) | - | ||||||||||||
62 | { | - | ||||||||||||
63 | Attribute a; | - | ||||||||||||
64 | a.position = pos; | - | ||||||||||||
65 | a.tupleSize = tupleSize; | - | ||||||||||||
66 | a.type = primitiveType; | - | ||||||||||||
67 | a.isVertexCoordinate = attributeType == PositionAttribute; | - | ||||||||||||
68 | a.attributeType = attributeType; | - | ||||||||||||
69 | a.reserved = 0; | - | ||||||||||||
70 | return a; executed 502 times by 74 tests: return a; Executed by:
| 502 | ||||||||||||
71 | } | - | ||||||||||||
72 | - | |||||||||||||
73 | /*! | - | ||||||||||||
74 | Convenience function which returns attributes to be used for 2D solid | - | ||||||||||||
75 | color drawing. | - | ||||||||||||
76 | */ | - | ||||||||||||
77 | - | |||||||||||||
78 | const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_Point2D() | - | ||||||||||||
79 | { | - | ||||||||||||
80 | static Attribute data[] = { | - | ||||||||||||
81 | Attribute::createWithAttributeType(0, 2, FloatType, PositionAttribute) | - | ||||||||||||
82 | }; | - | ||||||||||||
83 | static AttributeSet attrs = { 1, sizeof(float) * 2, data }; | - | ||||||||||||
84 | return attrs; executed 200426 times by 13 tests: return attrs; Executed by:
| 200426 | ||||||||||||
85 | } | - | ||||||||||||
86 | - | |||||||||||||
87 | /*! | - | ||||||||||||
88 | Convenience function which returns attributes to be used for textured 2D drawing. | - | ||||||||||||
89 | */ | - | ||||||||||||
90 | - | |||||||||||||
91 | const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_TexturedPoint2D() | - | ||||||||||||
92 | { | - | ||||||||||||
93 | static Attribute data[] = { | - | ||||||||||||
94 | Attribute::createWithAttributeType(0, 2, FloatType, PositionAttribute), | - | ||||||||||||
95 | Attribute::createWithAttributeType(1, 2, FloatType, TexCoordAttribute) | - | ||||||||||||
96 | }; | - | ||||||||||||
97 | static AttributeSet attrs = { 2, sizeof(float) * 4, data }; | - | ||||||||||||
98 | return attrs; executed 254492 times by 35 tests: return attrs; Executed by:
| 254492 | ||||||||||||
99 | } | - | ||||||||||||
100 | - | |||||||||||||
101 | /*! | - | ||||||||||||
102 | Convenience function which returns attributes to be used for per vertex colored 2D drawing. | - | ||||||||||||
103 | */ | - | ||||||||||||
104 | - | |||||||||||||
105 | const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_ColoredPoint2D() | - | ||||||||||||
106 | { | - | ||||||||||||
107 | static Attribute data[] = { | - | ||||||||||||
108 | Attribute::createWithAttributeType(0, 2, FloatType, PositionAttribute), | - | ||||||||||||
109 | Attribute::createWithAttributeType(1, 4, UnsignedByteType, ColorAttribute) | - | ||||||||||||
110 | }; | - | ||||||||||||
111 | static AttributeSet attrs = { 2, 2 * sizeof(float) + 4 * sizeof(char), data }; | - | ||||||||||||
112 | return attrs; executed 73421 times by 66 tests: return attrs; Executed by:
| 73421 | ||||||||||||
113 | } | - | ||||||||||||
114 | - | |||||||||||||
115 | - | |||||||||||||
116 | /*! | - | ||||||||||||
117 | \class QSGGeometry::Attribute | - | ||||||||||||
118 | \brief The QSGGeometry::Attribute describes a single vertex attribute in a QSGGeometry. | - | ||||||||||||
119 | \inmodule QtQuick | - | ||||||||||||
120 | - | |||||||||||||
121 | The QSGGeometry::Attribute struct describes the attribute register position, | - | ||||||||||||
122 | the size of the attribute tuple and the attribute type. | - | ||||||||||||
123 | - | |||||||||||||
124 | It also contains a hint to the renderer if this attribute is the attribute | - | ||||||||||||
125 | describing the position. The scene graph renderer may use this information | - | ||||||||||||
126 | to perform optimizations. | - | ||||||||||||
127 | - | |||||||||||||
128 | It contains a number of bits which are reserved for future use. | - | ||||||||||||
129 | - | |||||||||||||
130 | \sa QSGGeometry | - | ||||||||||||
131 | */ | - | ||||||||||||
132 | - | |||||||||||||
133 | /*! | - | ||||||||||||
134 | \fn QSGGeometry::Attribute QSGGeometry::Attribute::create(int pos, int tupleSize, int primitiveType, bool isPosition) | - | ||||||||||||
135 | - | |||||||||||||
136 | Creates a new QSGGeometry::Attribute for attribute register \a pos with \a | - | ||||||||||||
137 | tupleSize. The \a primitiveType can be any of the supported types from | - | ||||||||||||
138 | QSGGeometry::Type, such as QSGGeometry::FloatType or | - | ||||||||||||
139 | QSGGeometry::UnsignedByteType. | - | ||||||||||||
140 | - | |||||||||||||
141 | If the attribute describes the position for the vertex, the \a isPosition | - | ||||||||||||
142 | hint should be set to \c true. The scene graph renderer may use this | - | ||||||||||||
143 | information to perform optimizations. | - | ||||||||||||
144 | - | |||||||||||||
145 | \note Scene graph backends for APIs other than OpenGL may require an | - | ||||||||||||
146 | accurate description of attributes' usage, and therefore it is recommended | - | ||||||||||||
147 | to use createWithAttributeType() instead. | - | ||||||||||||
148 | - | |||||||||||||
149 | Use the create function to construct the attribute, rather than an | - | ||||||||||||
150 | initialization list, to ensure that all fields are initialized. | - | ||||||||||||
151 | */ | - | ||||||||||||
152 | - | |||||||||||||
153 | /*! | - | ||||||||||||
154 | \fn QSGGeometry::Attribute QSGGeometry::Attribute::createWithAttributeType(int pos, int tupleSize, int primitiveType, AttributeType attributeType) | - | ||||||||||||
155 | - | |||||||||||||
156 | Creates a new QSGGeometry::Attribute for attribute register \a pos with \a | - | ||||||||||||
157 | tupleSize. The \a primitiveType can be any of the supported types from | - | ||||||||||||
158 | QSGGeometry::Type, such as QSGGeometry::FloatType or | - | ||||||||||||
159 | QSGGeometry::UnsignedByteType. | - | ||||||||||||
160 | - | |||||||||||||
161 | \a attributeType describes the intended use of the attribute. | - | ||||||||||||
162 | - | |||||||||||||
163 | Use the create function to construct the attribute, rather than an | - | ||||||||||||
164 | initialization list, to ensure that all fields are initialized. | - | ||||||||||||
165 | */ | - | ||||||||||||
166 | - | |||||||||||||
167 | - | |||||||||||||
168 | /*! | - | ||||||||||||
169 | \class QSGGeometry::AttributeSet | - | ||||||||||||
170 | \brief The QSGGeometry::AttributeSet describes how the vertices in a QSGGeometry | - | ||||||||||||
171 | are built up. | - | ||||||||||||
172 | \inmodule QtQuick | - | ||||||||||||
173 | - | |||||||||||||
174 | \sa QSGGeometry | - | ||||||||||||
175 | */ | - | ||||||||||||
176 | - | |||||||||||||
177 | - | |||||||||||||
178 | /*! | - | ||||||||||||
179 | \class QSGGeometry::Point2D | - | ||||||||||||
180 | \brief The QSGGeometry::Point2D struct is a convenience struct for accessing | - | ||||||||||||
181 | 2D Points. | - | ||||||||||||
182 | - | |||||||||||||
183 | \inmodule QtQuick | - | ||||||||||||
184 | */ | - | ||||||||||||
185 | - | |||||||||||||
186 | - | |||||||||||||
187 | /*! | - | ||||||||||||
188 | \fn void QSGGeometry::Point2D::set(float x, float y) | - | ||||||||||||
189 | - | |||||||||||||
190 | Sets the x and y values of this point to \a x and \a y. | - | ||||||||||||
191 | */ | - | ||||||||||||
192 | - | |||||||||||||
193 | - | |||||||||||||
194 | /*! | - | ||||||||||||
195 | \class QSGGeometry::ColoredPoint2D | - | ||||||||||||
196 | \brief The QSGGeometry::ColoredPoint2D struct is a convenience struct for accessing | - | ||||||||||||
197 | 2D Points with a color. | - | ||||||||||||
198 | - | |||||||||||||
199 | \inmodule QtQuick | - | ||||||||||||
200 | */ | - | ||||||||||||
201 | - | |||||||||||||
202 | - | |||||||||||||
203 | /*! | - | ||||||||||||
204 | \fn void QSGGeometry::ColoredPoint2D::set(float x, float y, uchar red, uchar green, uchar blue, uchar alpha) | - | ||||||||||||
205 | - | |||||||||||||
206 | Sets the position of the vertex to \a x and \a y and the color to \a red, \a | - | ||||||||||||
207 | green, \a blue, and \a alpha. | - | ||||||||||||
208 | */ | - | ||||||||||||
209 | - | |||||||||||||
210 | - | |||||||||||||
211 | /*! | - | ||||||||||||
212 | \class QSGGeometry::TexturedPoint2D | - | ||||||||||||
213 | \brief The QSGGeometry::TexturedPoint2D struct is a convenience struct for accessing | - | ||||||||||||
214 | 2D Points with texture coordinates. | - | ||||||||||||
215 | - | |||||||||||||
216 | \inmodule QtQuick | - | ||||||||||||
217 | */ | - | ||||||||||||
218 | - | |||||||||||||
219 | - | |||||||||||||
220 | /*! | - | ||||||||||||
221 | \fn void QSGGeometry::TexturedPoint2D::set(float x, float y, float tx, float ty) | - | ||||||||||||
222 | - | |||||||||||||
223 | Sets the position of the vertex to \a x and \a y and the texture coordinate | - | ||||||||||||
224 | to \a tx and \a ty. | - | ||||||||||||
225 | */ | - | ||||||||||||
226 | - | |||||||||||||
227 | - | |||||||||||||
228 | - | |||||||||||||
229 | /*! | - | ||||||||||||
230 | \class QSGGeometry | - | ||||||||||||
231 | - | |||||||||||||
232 | \brief The QSGGeometry class provides low-level | - | ||||||||||||
233 | storage for graphics primitives in the \l{Qt Quick Scene Graph}. | - | ||||||||||||
234 | - | |||||||||||||
235 | \inmodule QtQuick | - | ||||||||||||
236 | - | |||||||||||||
237 | The QSGGeometry class stores the geometry of the primitives | - | ||||||||||||
238 | rendered with the scene graph. It contains vertex data and | - | ||||||||||||
239 | optionally index data. The mode used to draw the geometry is | - | ||||||||||||
240 | specified with setDrawingMode(), which maps directly to the graphics API's | - | ||||||||||||
241 | drawing mode, such as \c GL_TRIANGLE_STRIP, \c GL_TRIANGLES, or | - | ||||||||||||
242 | \c GL_POINTS in case of OpenGL. | - | ||||||||||||
243 | - | |||||||||||||
244 | Vertices can be as simple as points defined by x and y values or | - | ||||||||||||
245 | can be more complex where each vertex contains a normal, texture | - | ||||||||||||
246 | coordinates and a 3D position. The QSGGeometry::AttributeSet is | - | ||||||||||||
247 | used to describe how the vertex data is built up. The attribute | - | ||||||||||||
248 | set can only be specified on construction. The QSGGeometry class | - | ||||||||||||
249 | provides a few convenience attributes and attribute sets by | - | ||||||||||||
250 | default. The defaultAttributes_Point2D() function returns an | - | ||||||||||||
251 | attribute set to be used in normal solid color rectangles, while | - | ||||||||||||
252 | the defaultAttributes_TexturedPoint2D function returns attributes | - | ||||||||||||
253 | to be used for textured 2D geometry. The vertex data is internally | - | ||||||||||||
254 | stored as a \c {void *} and is accessible with the vertexData() | - | ||||||||||||
255 | function. Convenience accessors for the common attribute sets are | - | ||||||||||||
256 | available with vertexDataAsPoint2D() and | - | ||||||||||||
257 | vertexDataAsTexturedPoint2D(). Vertex data is allocated by passing | - | ||||||||||||
258 | a vertex count to the constructor or by calling allocate() later. | - | ||||||||||||
259 | - | |||||||||||||
260 | The QSGGeometry can optionally contain indices of either unsigned | - | ||||||||||||
261 | 32-bit, unsigned 16-bit, or unsigned 8-bit integers. The index type | - | ||||||||||||
262 | must be specified during construction and cannot be changed. | - | ||||||||||||
263 | - | |||||||||||||
264 | Below is a snippet illustrating how a geometry composed of | - | ||||||||||||
265 | position and color vertices can be built. | - | ||||||||||||
266 | - | |||||||||||||
267 | \code | - | ||||||||||||
268 | struct MyPoint2D { | - | ||||||||||||
269 | float x; | - | ||||||||||||
270 | float y; | - | ||||||||||||
271 | float r; | - | ||||||||||||
272 | float g; | - | ||||||||||||
273 | float b; | - | ||||||||||||
274 | float a; | - | ||||||||||||
275 | - | |||||||||||||
276 | void set(float x_, float y_, float r_, float g_, float b_, float a_) { | - | ||||||||||||
277 | x = x_; | - | ||||||||||||
278 | y = y_; | - | ||||||||||||
279 | r = r_; | - | ||||||||||||
280 | g = g_; | - | ||||||||||||
281 | b = b_; | - | ||||||||||||
282 | a = a_; | - | ||||||||||||
283 | } | - | ||||||||||||
284 | }; | - | ||||||||||||
285 | - | |||||||||||||
286 | QSGGeometry::Attribute MyPoint2D_Attributes[] = { | - | ||||||||||||
287 | QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true), | - | ||||||||||||
288 | QSGGeometry::Attribute::create(1, 4, GL_FLOAT, false) | - | ||||||||||||
289 | }; | - | ||||||||||||
290 | - | |||||||||||||
291 | QSGGeometry::AttributeSet MyPoint2D_AttributeSet = { | - | ||||||||||||
292 | 2, | - | ||||||||||||
293 | sizeof(MyPoint2D), | - | ||||||||||||
294 | MyPoint2D_Attributes | - | ||||||||||||
295 | }; | - | ||||||||||||
296 | - | |||||||||||||
297 | ... | - | ||||||||||||
298 | - | |||||||||||||
299 | geometry = new QSGGeometry(MyPoint2D_AttributeSet, 2); | - | ||||||||||||
300 | geometry->setDrawingMode(GL_LINES); | - | ||||||||||||
301 | - | |||||||||||||
302 | MyPoint2D *vertices = static_cast<MyPoint2D *>(geometry->vertexData()); | - | ||||||||||||
303 | vertices[0].set(0, 0, 1, 0, 0, 1); | - | ||||||||||||
304 | vertices[1].set(width(), height(), 0, 0, 1, 1); | - | ||||||||||||
305 | \endcode | - | ||||||||||||
306 | - | |||||||||||||
307 | The QSGGeometry is a software buffer and client-side in terms of | - | ||||||||||||
308 | OpenGL rendering, as the buffers used in 2D graphics typically consist of | - | ||||||||||||
309 | many small buffers that change every frame and do not benefit from | - | ||||||||||||
310 | being uploaded to graphics memory. However, the QSGGeometry | - | ||||||||||||
311 | supports hinting to the renderer that a buffer should be | - | ||||||||||||
312 | uploaded using the setVertexDataPattern() and | - | ||||||||||||
313 | setIndexDataPattern() functions. Whether this hint is respected or | - | ||||||||||||
314 | not is implementation specific. | - | ||||||||||||
315 | - | |||||||||||||
316 | \sa QSGGeometryNode, {Scene Graph - Custom Geometry} | - | ||||||||||||
317 | - | |||||||||||||
318 | \note All classes with QSG prefix should be used solely on the scene graph's | - | ||||||||||||
319 | rendering thread. See \l {Scene Graph and Rendering} for more information. | - | ||||||||||||
320 | - | |||||||||||||
321 | */ | - | ||||||||||||
322 | - | |||||||||||||
323 | /*! | - | ||||||||||||
324 | \fn int QSGGeometry::attributeCount() const | - | ||||||||||||
325 | - | |||||||||||||
326 | Returns the number of attributes in the attrbute set used by this geometry. | - | ||||||||||||
327 | */ | - | ||||||||||||
328 | - | |||||||||||||
329 | /*! | - | ||||||||||||
330 | \fn QSGGeometry::Attribute *QSGGeometry::attributes() const | - | ||||||||||||
331 | - | |||||||||||||
332 | Returns an array with the attributes of this geometry. The size of the array | - | ||||||||||||
333 | is given with attributeCount(). | - | ||||||||||||
334 | */ | - | ||||||||||||
335 | - | |||||||||||||
336 | /*! | - | ||||||||||||
337 | \fn uint *QSGGeometry::indexDataAsUInt() | - | ||||||||||||
338 | - | |||||||||||||
339 | Convenience function to access the index data as a mutable array of | - | ||||||||||||
340 | 32-bit unsigned integers. | - | ||||||||||||
341 | */ | - | ||||||||||||
342 | - | |||||||||||||
343 | /*! | - | ||||||||||||
344 | \fn const uint *QSGGeometry::indexDataAsUInt() const | - | ||||||||||||
345 | - | |||||||||||||
346 | Convenience function to access the index data as an immutable array of | - | ||||||||||||
347 | 32-bit unsigned integers. | - | ||||||||||||
348 | */ | - | ||||||||||||
349 | - | |||||||||||||
350 | /*! | - | ||||||||||||
351 | \fn quint16 *QSGGeometry::indexDataAsUShort() | - | ||||||||||||
352 | - | |||||||||||||
353 | Convenience function to access the index data as a mutable array of | - | ||||||||||||
354 | 16-bit unsigned integers. | - | ||||||||||||
355 | */ | - | ||||||||||||
356 | - | |||||||||||||
357 | /*! | - | ||||||||||||
358 | \fn const quint16 *QSGGeometry::indexDataAsUShort() const | - | ||||||||||||
359 | - | |||||||||||||
360 | Convenience function to access the index data as an immutable array of | - | ||||||||||||
361 | 16-bit unsigned integers. | - | ||||||||||||
362 | */ | - | ||||||||||||
363 | - | |||||||||||||
364 | /*! | - | ||||||||||||
365 | \fn const QSGGeometry::ColoredPoint2D *QSGGeometry::vertexDataAsColoredPoint2D() const | - | ||||||||||||
366 | - | |||||||||||||
367 | Convenience function to access the vertex data as an immutable | - | ||||||||||||
368 | array of QSGGeometry::ColoredPoint2D. | - | ||||||||||||
369 | */ | - | ||||||||||||
370 | - | |||||||||||||
371 | /*! | - | ||||||||||||
372 | \fn QSGGeometry::ColoredPoint2D *QSGGeometry::vertexDataAsColoredPoint2D() | - | ||||||||||||
373 | - | |||||||||||||
374 | Convenience function to access the vertex data as a mutable | - | ||||||||||||
375 | array of QSGGeometry::ColoredPoint2D. | - | ||||||||||||
376 | */ | - | ||||||||||||
377 | - | |||||||||||||
378 | /*! | - | ||||||||||||
379 | \fn const QSGGeometry::TexturedPoint2D *QSGGeometry::vertexDataAsTexturedPoint2D() const | - | ||||||||||||
380 | - | |||||||||||||
381 | Convenience function to access the vertex data as an immutable | - | ||||||||||||
382 | array of QSGGeometry::TexturedPoint2D. | - | ||||||||||||
383 | */ | - | ||||||||||||
384 | - | |||||||||||||
385 | /*! | - | ||||||||||||
386 | \fn QSGGeometry::TexturedPoint2D *QSGGeometry::vertexDataAsTexturedPoint2D() | - | ||||||||||||
387 | - | |||||||||||||
388 | Convenience function to access the vertex data as a mutable | - | ||||||||||||
389 | array of QSGGeometry::TexturedPoint2D. | - | ||||||||||||
390 | */ | - | ||||||||||||
391 | - | |||||||||||||
392 | /*! | - | ||||||||||||
393 | \fn const QSGGeometry::Point2D *QSGGeometry::vertexDataAsPoint2D() const | - | ||||||||||||
394 | - | |||||||||||||
395 | Convenience function to access the vertex data as an immutable | - | ||||||||||||
396 | array of QSGGeometry::Point2D. | - | ||||||||||||
397 | */ | - | ||||||||||||
398 | - | |||||||||||||
399 | /*! | - | ||||||||||||
400 | \fn QSGGeometry::Point2D *QSGGeometry::vertexDataAsPoint2D() | - | ||||||||||||
401 | - | |||||||||||||
402 | Convenience function to access the vertex data as a mutable | - | ||||||||||||
403 | array of QSGGeometry::Point2D. | - | ||||||||||||
404 | */ | - | ||||||||||||
405 | - | |||||||||||||
406 | - | |||||||||||||
407 | /*! | - | ||||||||||||
408 | Constructs a geometry object based on \a attributes. | - | ||||||||||||
409 | - | |||||||||||||
410 | The object allocate space for \a vertexCount vertices based on the | - | ||||||||||||
411 | accumulated size in \a attributes and for \a indexCount. | - | ||||||||||||
412 | - | |||||||||||||
413 | The \a indexType maps to the OpenGL index type and can be | - | ||||||||||||
414 | \c GL_UNSIGNED_SHORT and \c GL_UNSIGNED_BYTE. On OpenGL implementations that | - | ||||||||||||
415 | support it, such as desktop OpenGL, \c GL_UNSIGNED_INT can also be used. | - | ||||||||||||
416 | - | |||||||||||||
417 | Geometry objects are constructed with \c GL_TRIANGLE_STRIP as default | - | ||||||||||||
418 | drawing mode. | - | ||||||||||||
419 | - | |||||||||||||
420 | The attribute structure is assumed to be POD and the geometry object | - | ||||||||||||
421 | assumes this will not go away. There is no memory management involved. | - | ||||||||||||
422 | */ | - | ||||||||||||
423 | - | |||||||||||||
424 | QSGGeometry::QSGGeometry(const QSGGeometry::AttributeSet &attributes, | - | ||||||||||||
425 | int vertexCount, | - | ||||||||||||
426 | int indexCount, | - | ||||||||||||
427 | int indexType) | - | ||||||||||||
428 | : m_drawing_mode(DrawTriangleStrip) | - | ||||||||||||
429 | , m_vertex_count(0) | - | ||||||||||||
430 | , m_index_count(0) | - | ||||||||||||
431 | , m_index_type(indexType) | - | ||||||||||||
432 | , m_attributes(attributes) | - | ||||||||||||
433 | , m_data(nullptr) | - | ||||||||||||
434 | , m_index_data_offset(-1) | - | ||||||||||||
435 | , m_server_data(nullptr) | - | ||||||||||||
436 | , m_owns_data(false) | - | ||||||||||||
437 | , m_index_usage_pattern(AlwaysUploadPattern) | - | ||||||||||||
438 | , m_vertex_usage_pattern(AlwaysUploadPattern) | - | ||||||||||||
439 | , m_line_width(1.0) | - | ||||||||||||
440 | { | - | ||||||||||||
441 | Q_UNUSED(m_reserved_bits); | - | ||||||||||||
442 | Q_ASSERT(m_attributes.count > 0); | - | ||||||||||||
443 | Q_ASSERT(m_attributes.stride > 0); | - | ||||||||||||
444 | #if QT_CONFIG(opengl) | - | ||||||||||||
445 | Q_ASSERT_X(indexType != GL_UNSIGNED_INT | - | ||||||||||||
446 | || static_cast<QOpenGLExtensions *>(QOpenGLContext::currentContext()->functions()) | - | ||||||||||||
447 | ->hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint), | - | ||||||||||||
448 | "QSGGeometry::QSGGeometry", | - | ||||||||||||
449 | "GL_UNSIGNED_INT is not supported, geometry will not render" | - | ||||||||||||
450 | ); | - | ||||||||||||
451 | #endif | - | ||||||||||||
452 | if (indexType != UnsignedByteType
| 0-531813 | ||||||||||||
453 | && indexType != UnsignedShortType
| 33-531780 | ||||||||||||
454 | && indexType != UnsignedIntType) {
| 0-33 | ||||||||||||
455 | qFatal("QSGGeometry: Unsupported index type, %x.\n", indexType); | - | ||||||||||||
456 | } never executed: end of block | 0 | ||||||||||||
457 | - | |||||||||||||
458 | // Because allocate reads m_vertex_count, m_index_count and m_owns_data, these | - | ||||||||||||
459 | // need to be set before calling allocate... | - | ||||||||||||
460 | allocate(vertexCount, indexCount); | - | ||||||||||||
461 | } executed 531813 times by 74 tests: end of block Executed by:
| 531813 | ||||||||||||
462 | - | |||||||||||||
463 | /*! | - | ||||||||||||
464 | \fn int QSGGeometry::sizeOfVertex() const | - | ||||||||||||
465 | - | |||||||||||||
466 | Returns the size in bytes of one vertex. | - | ||||||||||||
467 | - | |||||||||||||
468 | This value comes from the attributes. | - | ||||||||||||
469 | */ | - | ||||||||||||
470 | - | |||||||||||||
471 | /*! | - | ||||||||||||
472 | \fn int QSGGeometry::sizeOfIndex() const | - | ||||||||||||
473 | - | |||||||||||||
474 | Returns the byte size of the index type. | - | ||||||||||||
475 | - | |||||||||||||
476 | This value is either \c 1 when index type is \c GL_UNSIGNED_BYTE or \c 2 | - | ||||||||||||
477 | when index type is \c GL_UNSIGNED_SHORT. For Desktop OpenGL, | - | ||||||||||||
478 | \c GL_UNSIGNED_INT with the value \c 4 is also supported. | - | ||||||||||||
479 | */ | - | ||||||||||||
480 | - | |||||||||||||
481 | /*! | - | ||||||||||||
482 | Destroys the geometry object and the vertex and index data it has allocated. | - | ||||||||||||
483 | */ | - | ||||||||||||
484 | - | |||||||||||||
485 | QSGGeometry::~QSGGeometry() | - | ||||||||||||
486 | { | - | ||||||||||||
487 | if (m_owns_data)
| 218391-313422 | ||||||||||||
488 | free(m_data); executed 313422 times by 68 tests: free(m_data); Executed by:
| 313422 | ||||||||||||
489 | - | |||||||||||||
490 | if (m_server_data)
| 0-531813 | ||||||||||||
491 | delete m_server_data; never executed: delete m_server_data; | 0 | ||||||||||||
492 | } executed 531813 times by 74 tests: end of block Executed by:
| 531813 | ||||||||||||
493 | - | |||||||||||||
494 | /*! | - | ||||||||||||
495 | \fn int QSGGeometry::vertexCount() const | - | ||||||||||||
496 | - | |||||||||||||
497 | Returns the number of vertices in this geometry object. | - | ||||||||||||
498 | */ | - | ||||||||||||
499 | - | |||||||||||||
500 | /*! | - | ||||||||||||
501 | \fn int QSGGeometry::indexCount() const | - | ||||||||||||
502 | - | |||||||||||||
503 | Returns the number of indices in this geometry object. | - | ||||||||||||
504 | */ | - | ||||||||||||
505 | - | |||||||||||||
506 | - | |||||||||||||
507 | - | |||||||||||||
508 | /*! | - | ||||||||||||
509 | \fn void *QSGGeometry::vertexData() | - | ||||||||||||
510 | - | |||||||||||||
511 | Returns a pointer to the raw vertex data of this geometry object. | - | ||||||||||||
512 | - | |||||||||||||
513 | \sa vertexDataAsPoint2D(), vertexDataAsTexturedPoint2D() | - | ||||||||||||
514 | */ | - | ||||||||||||
515 | - | |||||||||||||
516 | /*! | - | ||||||||||||
517 | \fn const void *QSGGeometry::vertexData() const | - | ||||||||||||
518 | - | |||||||||||||
519 | Returns a pointer to the raw vertex data of this geometry object. | - | ||||||||||||
520 | - | |||||||||||||
521 | \sa vertexDataAsPoint2D(), vertexDataAsTexturedPoint2D() | - | ||||||||||||
522 | */ | - | ||||||||||||
523 | - | |||||||||||||
524 | /*! | - | ||||||||||||
525 | Returns a pointer to the raw index data of this geometry object. | - | ||||||||||||
526 | - | |||||||||||||
527 | \sa indexDataAsUShort(), indexDataAsUInt() | - | ||||||||||||
528 | */ | - | ||||||||||||
529 | void *QSGGeometry::indexData() | - | ||||||||||||
530 | { | - | ||||||||||||
531 | return m_index_data_offset < 0 executed 1106226 times by 68 tests: return m_index_data_offset < 0 ? nullptr : ((char *) m_data + m_index_data_offset); Executed by:
| 1106226 | ||||||||||||
532 | ? nullptr executed 1106226 times by 68 tests: return m_index_data_offset < 0 ? nullptr : ((char *) m_data + m_index_data_offset); Executed by:
| 1106226 | ||||||||||||
533 | : ((char *) m_data + m_index_data_offset); executed 1106226 times by 68 tests: return m_index_data_offset < 0 ? nullptr : ((char *) m_data + m_index_data_offset); Executed by:
| 1106226 | ||||||||||||
534 | } | - | ||||||||||||
535 | - | |||||||||||||
536 | /*! | - | ||||||||||||
537 | Returns a pointer to the raw index data of this geometry object. | - | ||||||||||||
538 | - | |||||||||||||
539 | \sa indexDataAsUShort(), indexDataAsUInt() | - | ||||||||||||
540 | */ | - | ||||||||||||
541 | const void *QSGGeometry::indexData() const | - | ||||||||||||
542 | { | - | ||||||||||||
543 | return m_index_data_offset < 0 never executed: return m_index_data_offset < 0 ? nullptr : ((char *) m_data + m_index_data_offset); | 0 | ||||||||||||
544 | ? nullptr never executed: return m_index_data_offset < 0 ? nullptr : ((char *) m_data + m_index_data_offset); | 0 | ||||||||||||
545 | : ((char *) m_data + m_index_data_offset); never executed: return m_index_data_offset < 0 ? nullptr : ((char *) m_data + m_index_data_offset); | 0 | ||||||||||||
546 | } | - | ||||||||||||
547 | - | |||||||||||||
548 | /*! | - | ||||||||||||
549 | \enum QSGGeometry::DrawingMode | - | ||||||||||||
550 | - | |||||||||||||
551 | The values correspond to OpenGL enum values like \c GL_POINTS, \c GL_LINES, | - | ||||||||||||
552 | etc. QSGGeometry provies its own type in order to be able to provide the | - | ||||||||||||
553 | same API with non-OpenGL backends as well. | - | ||||||||||||
554 | - | |||||||||||||
555 | \value DrawPoints | - | ||||||||||||
556 | \value DrawLines | - | ||||||||||||
557 | \value DrawLineLoop | - | ||||||||||||
558 | \value DrawLineStrip | - | ||||||||||||
559 | \value DrawTriangles | - | ||||||||||||
560 | \value DrawTriangleStrip | - | ||||||||||||
561 | \value DrawTriangleFan | - | ||||||||||||
562 | */ | - | ||||||||||||
563 | - | |||||||||||||
564 | /*! | - | ||||||||||||
565 | \enum QSGGeometry::Type | - | ||||||||||||
566 | - | |||||||||||||
567 | The values correspond to OpenGL type constants like \c GL_BYTE, \c | - | ||||||||||||
568 | GL_UNSIGNED_BYTE, etc. QSGGeometry provies its own type in order to be able | - | ||||||||||||
569 | to provide the same API with non-OpenGL backends as well. | - | ||||||||||||
570 | - | |||||||||||||
571 | \value ByteType | - | ||||||||||||
572 | \value UnsignedByteType | - | ||||||||||||
573 | \value ShortType | - | ||||||||||||
574 | \value UnsignedShortType | - | ||||||||||||
575 | \value IntType | - | ||||||||||||
576 | \value UnsignedIntType | - | ||||||||||||
577 | \value FloatType | - | ||||||||||||
578 | */ | - | ||||||||||||
579 | - | |||||||||||||
580 | /*! | - | ||||||||||||
581 | Sets the \a mode to be used for drawing this geometry. | - | ||||||||||||
582 | - | |||||||||||||
583 | The default value is QSGGeometry::DrawTriangleStrip. | - | ||||||||||||
584 | - | |||||||||||||
585 | \sa DrawingMode | - | ||||||||||||
586 | */ | - | ||||||||||||
587 | void QSGGeometry::setDrawingMode(unsigned int mode) | - | ||||||||||||
588 | { | - | ||||||||||||
589 | m_drawing_mode = mode; | - | ||||||||||||
590 | } executed 331930 times by 68 tests: end of block Executed by:
| 331930 | ||||||||||||
591 | - | |||||||||||||
592 | /*! | - | ||||||||||||
593 | Gets the current line or point width or to be used for this geometry. This | - | ||||||||||||
594 | property only applies to line width when the drawingMode is DrawLines, | - | ||||||||||||
595 | DarwLineStrip, or DrawLineLoop. For desktop OpenGL, it also applies to | - | ||||||||||||
596 | point size when the drawingMode is DrawPoints. | - | ||||||||||||
597 | - | |||||||||||||
598 | The default value is \c 1.0 | - | ||||||||||||
599 | - | |||||||||||||
600 | \note When not using OpenGL, support for point and line drawing may be | - | ||||||||||||
601 | limited. For example, some APIs do not support point sprites and so setting | - | ||||||||||||
602 | a size other than 1 is not possible. Some backends may be able implement | - | ||||||||||||
603 | support via geometry shaders, but this is not guaranteed to be always | - | ||||||||||||
604 | available. | - | ||||||||||||
605 | - | |||||||||||||
606 | \sa setLineWidth(), drawingMode() | - | ||||||||||||
607 | */ | - | ||||||||||||
608 | float QSGGeometry::lineWidth() const | - | ||||||||||||
609 | { | - | ||||||||||||
610 | return m_line_width; executed 3939 times by 21 tests: return m_line_width; Executed by:
| 3939 | ||||||||||||
611 | } | - | ||||||||||||
612 | - | |||||||||||||
613 | /*! | - | ||||||||||||
614 | Sets the line or point width to be used for this geometry to \a width. This | - | ||||||||||||
615 | property only applies to line width when the drawingMode is DrawLines, | - | ||||||||||||
616 | DrawLineStrip, or DrawLineLoop. For Desktop OpenGL, it also applies to | - | ||||||||||||
617 | point size when the drawingMode is DrawPoints. | - | ||||||||||||
618 | - | |||||||||||||
619 | \note How line width and point size are treated is implementation | - | ||||||||||||
620 | dependent: The application should not rely on these, but rather create | - | ||||||||||||
621 | triangles or similar to draw areas. On OpenGL ES, line width support is | - | ||||||||||||
622 | limited and point size is unsupported. | - | ||||||||||||
623 | - | |||||||||||||
624 | \sa lineWidth(), drawingMode() | - | ||||||||||||
625 | */ | - | ||||||||||||
626 | void QSGGeometry::setLineWidth(float width) | - | ||||||||||||
627 | { | - | ||||||||||||
628 | m_line_width = width; | - | ||||||||||||
629 | } never executed: end of block | 0 | ||||||||||||
630 | - | |||||||||||||
631 | /*! | - | ||||||||||||
632 | \fn int QSGGeometry::drawingMode() const | - | ||||||||||||
633 | - | |||||||||||||
634 | Returns the drawing mode of this geometry. | - | ||||||||||||
635 | - | |||||||||||||
636 | The default value is \c GL_TRIANGLE_STRIP. | - | ||||||||||||
637 | */ | - | ||||||||||||
638 | - | |||||||||||||
639 | /*! | - | ||||||||||||
640 | \fn int QSGGeometry::indexType() const | - | ||||||||||||
641 | - | |||||||||||||
642 | Returns the primitive type used for indices in this | - | ||||||||||||
643 | geometry object. | - | ||||||||||||
644 | */ | - | ||||||||||||
645 | - | |||||||||||||
646 | - | |||||||||||||
647 | /*! | - | ||||||||||||
648 | Resizes the vertex and index data of this geometry object to fit \a vertexCount | - | ||||||||||||
649 | vertices and \a indexCount indices. | - | ||||||||||||
650 | - | |||||||||||||
651 | Vertex and index data will be invalidated after this call and the caller must | - | ||||||||||||
652 | mark the associated geometry node as dirty, by calling | - | ||||||||||||
653 | node->markDirty(QSGNode::DirtyGeometry) to ensure that the renderer has | - | ||||||||||||
654 | a chance to update internal buffers. | - | ||||||||||||
655 | */ | - | ||||||||||||
656 | void QSGGeometry::allocate(int vertexCount, int indexCount) | - | ||||||||||||
657 | { | - | ||||||||||||
658 | if (vertexCount == m_vertex_count && indexCount == m_index_count)
| 0-519134 | ||||||||||||
659 | return; executed 336765 times by 69 tests: return; Executed by:
| 336765 | ||||||||||||
660 | - | |||||||||||||
661 | m_vertex_count = vertexCount; | - | ||||||||||||
662 | m_index_count = indexCount; | - | ||||||||||||
663 | - | |||||||||||||
664 | bool canUsePrealloc = m_index_count <= 0; | - | ||||||||||||
665 | int vertexByteSize = m_attributes.stride * m_vertex_count; | - | ||||||||||||
666 | - | |||||||||||||
667 | if (m_owns_data)
| 127-519007 | ||||||||||||
668 | free(m_data); executed 127 times by 3 tests: free(m_data); Executed by:
| 127 | ||||||||||||
669 | - | |||||||||||||
670 | if (canUsePrealloc && vertexByteSize <= (int) sizeof(m_prealloc)) {
| 165-313384 | ||||||||||||
671 | m_data = (void *) &m_prealloc[0]; | - | ||||||||||||
672 | m_index_data_offset = -1; | - | ||||||||||||
673 | m_owns_data = false; | - | ||||||||||||
674 | } else { executed 205585 times by 23 tests: end of block Executed by:
| 205585 | ||||||||||||
675 | Q_ASSERT(m_index_type == UnsignedIntType || m_index_type == UnsignedShortType); | - | ||||||||||||
676 | int indexByteSize = indexCount * (m_index_type == UnsignedShortType ? sizeof(quint16) : sizeof(quint32)); | - | ||||||||||||
677 | m_data = (void *) malloc(vertexByteSize + indexByteSize); | - | ||||||||||||
678 | Q_CHECK_PTR(m_data); never executed: qt_check_pointer(__FILE__,678);
| 0-313549 | ||||||||||||
679 | m_index_data_offset = vertexByteSize; | - | ||||||||||||
680 | m_owns_data = true; | - | ||||||||||||
681 | } executed 313549 times by 68 tests: end of block Executed by:
| 313549 | ||||||||||||
682 | - | |||||||||||||
683 | // If we have associated vbo data we could potentially crash later if | - | ||||||||||||
684 | // the old buffers are used with the new vertex and index count, so we force | - | ||||||||||||
685 | // an update in the renderer in that case. This is really the users responsibility | - | ||||||||||||
686 | // but it is cheap for us to enforce this, so why not... | - | ||||||||||||
687 | if (m_server_data) {
| 0-519134 | ||||||||||||
688 | markIndexDataDirty(); | - | ||||||||||||
689 | markVertexDataDirty(); | - | ||||||||||||
690 | } never executed: end of block | 0 | ||||||||||||
691 | - | |||||||||||||
692 | } executed 519134 times by 74 tests: end of block Executed by:
| 519134 | ||||||||||||
693 | - | |||||||||||||
694 | /*! | - | ||||||||||||
695 | Updates the geometry \a g with the coordinates in \a rect. | - | ||||||||||||
696 | - | |||||||||||||
697 | The function assumes the geometry object contains a single triangle strip | - | ||||||||||||
698 | of QSGGeometry::Point2D vertices | - | ||||||||||||
699 | */ | - | ||||||||||||
700 | void QSGGeometry::updateRectGeometry(QSGGeometry *g, const QRectF &rect) | - | ||||||||||||
701 | { | - | ||||||||||||
702 | Point2D *v = g->vertexDataAsPoint2D(); | - | ||||||||||||
703 | v[0].x = rect.left(); | - | ||||||||||||
704 | v[0].y = rect.top(); | - | ||||||||||||
705 | - | |||||||||||||
706 | v[1].x = rect.left(); | - | ||||||||||||
707 | v[1].y = rect.bottom(); | - | ||||||||||||
708 | - | |||||||||||||
709 | v[2].x = rect.right(); | - | ||||||||||||
710 | v[2].y = rect.top(); | - | ||||||||||||
711 | - | |||||||||||||
712 | v[3].x = rect.right(); | - | ||||||||||||
713 | v[3].y = rect.bottom(); | - | ||||||||||||
714 | } executed 400614 times by 12 tests: end of block Executed by:
| 400614 | ||||||||||||
715 | - | |||||||||||||
716 | /*! | - | ||||||||||||
717 | Updates the geometry \a g with the coordinates in \a rect and texture | - | ||||||||||||
718 | coordinates from \a textureRect. | - | ||||||||||||
719 | - | |||||||||||||
720 | \a textureRect should be in normalized coordinates. | - | ||||||||||||
721 | - | |||||||||||||
722 | \a g is assumed to be a triangle strip of four vertices of type | - | ||||||||||||
723 | QSGGeometry::TexturedPoint2D. | - | ||||||||||||
724 | */ | - | ||||||||||||
725 | void QSGGeometry::updateTexturedRectGeometry(QSGGeometry *g, const QRectF &rect, const QRectF &textureRect) | - | ||||||||||||
726 | { | - | ||||||||||||
727 | TexturedPoint2D *v = g->vertexDataAsTexturedPoint2D(); | - | ||||||||||||
728 | v[0].x = rect.left(); | - | ||||||||||||
729 | v[0].y = rect.top(); | - | ||||||||||||
730 | v[0].tx = textureRect.left(); | - | ||||||||||||
731 | v[0].ty = textureRect.top(); | - | ||||||||||||
732 | - | |||||||||||||
733 | v[1].x = rect.left(); | - | ||||||||||||
734 | v[1].y = rect.bottom(); | - | ||||||||||||
735 | v[1].tx = textureRect.left(); | - | ||||||||||||
736 | v[1].ty = textureRect.bottom(); | - | ||||||||||||
737 | - | |||||||||||||
738 | v[2].x = rect.right(); | - | ||||||||||||
739 | v[2].y = rect.top(); | - | ||||||||||||
740 | v[2].tx = textureRect.right(); | - | ||||||||||||
741 | v[2].ty = textureRect.top(); | - | ||||||||||||
742 | - | |||||||||||||
743 | v[3].x = rect.right(); | - | ||||||||||||
744 | v[3].y = rect.bottom(); | - | ||||||||||||
745 | v[3].tx = textureRect.right(); | - | ||||||||||||
746 | v[3].ty = textureRect.bottom(); | - | ||||||||||||
747 | } executed 5290 times by 14 tests: end of block Executed by:
| 5290 | ||||||||||||
748 | - | |||||||||||||
749 | /*! | - | ||||||||||||
750 | Updates the geometry \a g with the coordinates in \a rect. | - | ||||||||||||
751 | - | |||||||||||||
752 | The function assumes the geometry object contains a single triangle strip | - | ||||||||||||
753 | of QSGGeometry::ColoredPoint2D vertices | - | ||||||||||||
754 | */ | - | ||||||||||||
755 | void QSGGeometry::updateColoredRectGeometry(QSGGeometry *g, const QRectF &rect) | - | ||||||||||||
756 | { | - | ||||||||||||
757 | ColoredPoint2D *v = g->vertexDataAsColoredPoint2D(); | - | ||||||||||||
758 | v[0].x = rect.left(); | - | ||||||||||||
759 | v[0].y = rect.top(); | - | ||||||||||||
760 | - | |||||||||||||
761 | v[1].x = rect.left(); | - | ||||||||||||
762 | v[1].y = rect.bottom(); | - | ||||||||||||
763 | - | |||||||||||||
764 | v[2].x = rect.right(); | - | ||||||||||||
765 | v[2].y = rect.top(); | - | ||||||||||||
766 | - | |||||||||||||
767 | v[3].x = rect.right(); | - | ||||||||||||
768 | v[3].y = rect.bottom(); | - | ||||||||||||
769 | } never executed: end of block | 0 | ||||||||||||
770 | - | |||||||||||||
771 | /*! | - | ||||||||||||
772 | \enum QSGGeometry::AttributeType | - | ||||||||||||
773 | - | |||||||||||||
774 | This enum identifies several attribute types. | - | ||||||||||||
775 | - | |||||||||||||
776 | \value UnknownAttribute Don't care | - | ||||||||||||
777 | \value PositionAttribute Position | - | ||||||||||||
778 | \value ColorAttribute Color | - | ||||||||||||
779 | \value TexCoordAttribute Texture coordinate | - | ||||||||||||
780 | \value TexCoord1Attribute Texture coordinate 1 | - | ||||||||||||
781 | \value TexCoord2Attribute Texture coordinate 2 | - | ||||||||||||
782 | - | |||||||||||||
783 | */ | - | ||||||||||||
784 | - | |||||||||||||
785 | /*! | - | ||||||||||||
786 | \enum QSGGeometry::DataPattern | - | ||||||||||||
787 | - | |||||||||||||
788 | The DataPattern enum is used to specify the use pattern for the | - | ||||||||||||
789 | vertex and index data in a geometry object. | - | ||||||||||||
790 | - | |||||||||||||
791 | \value AlwaysUploadPattern The data is always uploaded. This means | - | ||||||||||||
792 | that the user does not need to explicitly mark index and vertex | - | ||||||||||||
793 | data as dirty after changing it. This is the default. | - | ||||||||||||
794 | - | |||||||||||||
795 | \value DynamicPattern The data is modified repeatedly and drawn | - | ||||||||||||
796 | many times. This is a hint that may provide better | - | ||||||||||||
797 | performance. When set the user must make sure to mark the data as | - | ||||||||||||
798 | dirty after changing it. | - | ||||||||||||
799 | - | |||||||||||||
800 | \value StaticPattern The data is modified once and drawn many | - | ||||||||||||
801 | times. This is a hint that may provide better performance. When | - | ||||||||||||
802 | set the user must make sure to mark the data as dirty after | - | ||||||||||||
803 | changing it. | - | ||||||||||||
804 | - | |||||||||||||
805 | \value StreamPattern The data is modified for almost every time it | - | ||||||||||||
806 | is drawn. This is a hint that may provide better performance. When | - | ||||||||||||
807 | set, the user must make sure to mark the data as dirty after | - | ||||||||||||
808 | changing it. | - | ||||||||||||
809 | */ | - | ||||||||||||
810 | - | |||||||||||||
811 | - | |||||||||||||
812 | /*! | - | ||||||||||||
813 | \fn QSGGeometry::DataPattern QSGGeometry::indexDataPattern() const | - | ||||||||||||
814 | - | |||||||||||||
815 | Returns the usage pattern for indices in this geometry. The default | - | ||||||||||||
816 | pattern is AlwaysUploadPattern. | - | ||||||||||||
817 | */ | - | ||||||||||||
818 | - | |||||||||||||
819 | /*! | - | ||||||||||||
820 | Sets the usage pattern for indices to \a p. | - | ||||||||||||
821 | - | |||||||||||||
822 | The default is AlwaysUploadPattern. When set to anything other than | - | ||||||||||||
823 | the default, the user must call markIndexDataDirty() after changing | - | ||||||||||||
824 | the index data, in addition to calling QSGNode::markDirty() with | - | ||||||||||||
825 | QSGNode::DirtyGeometry. | - | ||||||||||||
826 | */ | - | ||||||||||||
827 | - | |||||||||||||
828 | void QSGGeometry::setIndexDataPattern(DataPattern p) | - | ||||||||||||
829 | { | - | ||||||||||||
830 | m_index_usage_pattern = p; | - | ||||||||||||
831 | } executed 249203 times by 24 tests: end of block Executed by:
| 249203 | ||||||||||||
832 | - | |||||||||||||
833 | - | |||||||||||||
834 | - | |||||||||||||
835 | - | |||||||||||||
836 | /*! | - | ||||||||||||
837 | \fn QSGGeometry::DataPattern QSGGeometry::vertexDataPattern() const | - | ||||||||||||
838 | - | |||||||||||||
839 | Returns the usage pattern for vertices in this geometry. The default | - | ||||||||||||
840 | pattern is AlwaysUploadPattern. | - | ||||||||||||
841 | */ | - | ||||||||||||
842 | - | |||||||||||||
843 | /*! | - | ||||||||||||
844 | Sets the usage pattern for vertices to \a p. | - | ||||||||||||
845 | - | |||||||||||||
846 | The default is AlwaysUploadPattern. When set to anything other than | - | ||||||||||||
847 | the default, the user must call markVertexDataDirty() after changing | - | ||||||||||||
848 | the vertex data, in addition to calling QSGNode::markDirty() with | - | ||||||||||||
849 | QSGNode::DirtyGeometry. | - | ||||||||||||
850 | */ | - | ||||||||||||
851 | - | |||||||||||||
852 | void QSGGeometry::setVertexDataPattern(DataPattern p) | - | ||||||||||||
853 | { | - | ||||||||||||
854 | m_vertex_usage_pattern = p; | - | ||||||||||||
855 | } executed 249203 times by 24 tests: end of block Executed by:
| 249203 | ||||||||||||
856 | - | |||||||||||||
857 | - | |||||||||||||
858 | - | |||||||||||||
859 | - | |||||||||||||
860 | /*! | - | ||||||||||||
861 | Mark that the vertices in this geometry has changed and must be uploaded | - | ||||||||||||
862 | again. | - | ||||||||||||
863 | - | |||||||||||||
864 | This function only has an effect when the usage pattern for vertices is | - | ||||||||||||
865 | StaticData and the renderer that renders this geometry uploads the geometry | - | ||||||||||||
866 | into Vertex Buffer Objects (VBOs). | - | ||||||||||||
867 | */ | - | ||||||||||||
868 | void QSGGeometry::markIndexDataDirty() | - | ||||||||||||
869 | { | - | ||||||||||||
870 | m_dirty_index_data = true; | - | ||||||||||||
871 | } never executed: end of block | 0 | ||||||||||||
872 | - | |||||||||||||
873 | - | |||||||||||||
874 | - | |||||||||||||
875 | /*! | - | ||||||||||||
876 | Mark that the vertices in this geometry has changed and must be uploaded | - | ||||||||||||
877 | again. | - | ||||||||||||
878 | - | |||||||||||||
879 | This function only has an effect when the usage pattern for vertices is | - | ||||||||||||
880 | StaticData and the renderer that renders this geometry uploads the geometry | - | ||||||||||||
881 | into Vertex Buffer Objects (VBOs). | - | ||||||||||||
882 | */ | - | ||||||||||||
883 | void QSGGeometry::markVertexDataDirty() | - | ||||||||||||
884 | { | - | ||||||||||||
885 | m_dirty_vertex_data = true; | - | ||||||||||||
886 | } never executed: end of block | 0 | ||||||||||||
887 | - | |||||||||||||
888 | - | |||||||||||||
889 | QT_END_NAMESPACE | - | ||||||||||||
Source code | Switch to Preprocessed file |