About
Contact
QtCreator
KDevelop
Solarized
line #s on
1
// Copyright (C) 2023 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
"qsgcurvefillnode_p.h"
5
#include
"qsgcurvefillnode_p_p.h"
6
7
QT_BEGIN_NAMESPACE
8
9
QSGCurveFillNode
::
QSGCurveFillNode
()
10
{
11
setFlag
(
OwnsGeometry
,
true
);
12
setFlag
(
UsePreprocess
,
true
);
13
setGeometry
(
new
QSGGeometry
(
attributes
(),
0
,
0
));
14
15
updateMaterial
();
16
}
17
18
void
QSGCurveFillNode
::
updateMaterial
()
19
{
20
m_material
.
reset
(
other:
new
QSGCurveFillMaterial
(
this
));
21
setMaterial
(
m_material
.
data
());
22
}
23
24
void
QSGCurveFillNode
::
cookGeometry
()
25
{
26
QSGGeometry
*
g
=
geometry
();
27
if
(
g
->
indexType
() !=
QSGGeometry
::
UnsignedIntType
) {
28
g
=
new
QSGGeometry
(
attributes
(),
29
m_uncookedVertexes
.
size
(),
30
m_uncookedIndexes
.
size
(),
31
QSGGeometry
::
UnsignedIntType
);
32
setGeometry
(
g
);
33
}
else
{
34
g
->
allocate
(
vertexCount:
m_uncookedVertexes
.
size
(),
indexCount:
m_uncookedIndexes
.
size
());
35
}
36
37
g
->
setDrawingMode
(
QSGGeometry
::
DrawTriangles
);
38
memcpy
(
dest:
g
->
vertexData
(),
39
src:
m_uncookedVertexes
.
constData
(),
40
n:
g
->
vertexCount
() *
g
->
sizeOfVertex
());
41
memcpy
(
dest:
g
->
indexData
(),
42
src:
m_uncookedIndexes
.
constData
(),
43
n:
g
->
indexCount
() *
g
->
sizeOfIndex
());
44
45
m_uncookedIndexes
.
clear
();
46
m_uncookedIndexes
.
squeeze
();
47
m_uncookedVertexes
.
clear
();
48
m_uncookedVertexes
.
squeeze
();
49
}
50
51
const
QSGGeometry
::
AttributeSet
&
QSGCurveFillNode
::
attributes
()
52
{
53
static
QSGGeometry
::
Attribute
data
[] = {
54
QSGGeometry
::
Attribute
::
createWithAttributeType
(
pos:
0
,
tupleSize:
2
,
primitiveType:
QSGGeometry
::
FloatType
,
attributeType:
QSGGeometry
::
PositionAttribute
),
55
QSGGeometry
::
Attribute
::
createWithAttributeType
(
pos:
1
,
tupleSize:
3
,
primitiveType:
QSGGeometry
::
FloatType
,
attributeType:
QSGGeometry
::
TexCoordAttribute
),
56
QSGGeometry
::
Attribute
::
createWithAttributeType
(
pos:
2
,
tupleSize:
4
,
primitiveType:
QSGGeometry
::
FloatType
,
attributeType:
QSGGeometry
::
UnknownAttribute
),
57
QSGGeometry
::
Attribute
::
createWithAttributeType
(
pos:
3
,
tupleSize:
2
,
primitiveType:
QSGGeometry
::
FloatType
,
attributeType:
QSGGeometry
::
UnknownAttribute
),
58
};
59
static
QSGGeometry
::
AttributeSet
attrs
= {
.count:
4
,
.stride:
sizeof
(
CurveNodeVertex
),
.attributes:
data
};
60
return
attrs
;
61
}
62
63
QT_END_NAMESPACE
64
Definitions
QSGCurveFillNode
updateMaterial
cookGeometry
Start learning QML with our Intro Training
Find out more