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
6
8
9QSGCurveFillNode::QSGCurveFillNode()
10{
11 setFlag(OwnsGeometry, true);
12 setFlag(UsePreprocess, true);
13 setGeometry(new QSGGeometry(attributes(), 0, 0));
14
15 updateMaterial();
16}
17
18void QSGCurveFillNode::updateMaterial()
19{
20 m_material.reset(new QSGCurveFillMaterial(this));
21 setMaterial(m_material.data());
22}
23
24void 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(m_uncookedVertexes.size(), m_uncookedIndexes.size());
35 }
36
37 g->setDrawingMode(QSGGeometry::DrawTriangles);
38 memcpy(g->vertexData(),
39 m_uncookedVertexes.constData(),
40 g->vertexCount() * g->sizeOfVertex());
41 memcpy(g->indexData(),
42 m_uncookedIndexes.constData(),
43 g->indexCount() * g->sizeOfIndex());
44
45 m_uncookedIndexes.clear();
46 m_uncookedIndexes.squeeze();
47 m_uncookedVertexes.clear();
48 m_uncookedVertexes.squeeze();
49}
50
51const QSGGeometry::AttributeSet &QSGCurveFillNode::attributes()
52{
53 static QSGGeometry::Attribute data[] = {
54 QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType, QSGGeometry::PositionAttribute),
55 QSGGeometry::Attribute::createWithAttributeType(1, 3, QSGGeometry::FloatType, QSGGeometry::TexCoordAttribute),
56 QSGGeometry::Attribute::createWithAttributeType(2, 4, QSGGeometry::FloatType, QSGGeometry::UnknownAttribute),
57 QSGGeometry::Attribute::createWithAttributeType(3, 2, QSGGeometry::FloatType, QSGGeometry::UnknownAttribute),
58 };
59 static QSGGeometry::AttributeSet attrs = { 4, sizeof(CurveNodeVertex), data };
60 return attrs;
61}
62
63QT_END_NAMESPACE
64
65#include "moc_qsgcurvefillnode_p.cpp"