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
qsgcurvefillnode.cpp
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
7
9
10QSGCurveFillNode::QSGCurveFillNode()
11{
12 setFlag(OwnsGeometry, true);
13 setFlag(UsePreprocess, true);
14 setGeometry(new QSGGeometry(attributes(), 0, 0));
15
16 updateMaterial();
17}
18
19void QSGCurveFillNode::updateMaterial()
20{
21 m_material.reset(new QSGCurveFillMaterial(this));
22 setMaterial(m_material.data());
23}
24
25void QSGCurveFillNode::cookGeometry()
26{
27 QSGGeometry *g = geometry();
28 if (g->indexType() != QSGGeometry::UnsignedIntType) {
29 g = new QSGGeometry(attributes(),
30 m_uncookedVertexes.size(),
31 m_uncookedIndexes.size(),
32 QSGGeometry::UnsignedIntType);
33 setGeometry(g);
34 } else {
35 g->allocate(m_uncookedVertexes.size(), m_uncookedIndexes.size());
36 }
37
38 g->setDrawingMode(QSGGeometry::DrawTriangles);
39 memcpy(g->vertexData(),
40 m_uncookedVertexes.constData(),
41 g->vertexCount() * g->sizeOfVertex());
42 memcpy(g->indexData(),
43 m_uncookedIndexes.constData(),
44 g->indexCount() * g->sizeOfIndex());
45
46 m_uncookedIndexes.clear();
47 m_uncookedIndexes.squeeze();
48 m_uncookedVertexes.clear();
49 m_uncookedVertexes.squeeze();
50}
51
52const QSGGeometry::AttributeSet &QSGCurveFillNode::attributes()
53{
54 static QSGGeometry::Attribute data[] = {
55 QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType, QSGGeometry::PositionAttribute),
56 QSGGeometry::Attribute::createWithAttributeType(1, 3, QSGGeometry::FloatType, QSGGeometry::TexCoordAttribute),
57 QSGGeometry::Attribute::createWithAttributeType(2, 4, QSGGeometry::FloatType, QSGGeometry::UnknownAttribute),
58 QSGGeometry::Attribute::createWithAttributeType(3, 2, QSGGeometry::FloatType, QSGGeometry::UnknownAttribute),
59 };
60 static QSGGeometry::AttributeSet attrs = { 4, sizeof(CurveNodeVertex), data };
61 return attrs;
62}
63
64QT_END_NAMESPACE
65
66#include "moc_qsgcurvefillnode_p.cpp"
Combined button and popup list for selecting options.