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
qsgcurvestrokenode_p_p.h
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
4#ifndef QSGCURVESTROKENODE_P_P_H
5#define QSGCURVESTROKENODE_P_P_H
6
7#include <QtQuick/qtquickexports.h>
8#include <QtQuick/qsgmaterial.h>
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists for the convenience
15// of a number of Qt sources files. This header file may change from
16// version to version without notice, or even be removed.
17//
18// We mean it.
19//
20
22
23using namespace Qt::StringLiterals;
24
25class QSGCurveStrokeNode;
26class QSGCurveStrokeMaterial;
27
28class Q_QUICK_EXPORT QSGCurveStrokeMaterialShader : public QSGMaterialShader
29{
30public:
31 enum class Variant { // flags
32 Default = 0,
33 Expanding = 0x01,
34 Derivatives = 0x02
35 };
36
37 QSGCurveStrokeMaterialShader(int variant, int viewCount)
38 {
39 static constexpr auto baseName = u":/qt-project.org/scenegraph/shaders_ng/shapestroke"_sv;
40 setShaderFileName(VertexStage, baseName +
41 (variant & int(Variant::Expanding) ? u"_expanding"_sv : u""_sv)
42 + u".vert.qsb"_sv, viewCount);
43 setShaderFileName(FragmentStage, baseName +
44 (variant & int(Variant::Derivatives) ? u"_derivatives"_sv : u""_sv)
45 + u".frag.qsb"_sv, viewCount);
46 }
47
48 bool updateUniformData(RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
49};
50
51
52class Q_QUICK_EXPORT QSGCurveStrokeMaterial : public QSGMaterial
53{
54public:
55 QSGCurveStrokeMaterial(QSGCurveStrokeNode *node, bool strokeExpanding = false)
56 : m_node(node), m_strokeExpanding(strokeExpanding)
57 {
58 setFlag(Blending, true);
59 }
60
61 int compare(const QSGMaterial *other) const override;
62
63 QSGCurveStrokeNode *node() const
64 {
65 return m_node;
66 }
67
68protected:
69 QSGMaterialType *type() const override
70 {
71 static QSGMaterialType legacyType;
72 static QSGMaterialType strokeExpandingType;
73 return m_strokeExpanding ? &strokeExpandingType : &legacyType;
74 }
75 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override
76 {
77 int variant = int(QSGCurveStrokeMaterialShader::Variant::Default);
78 if (m_strokeExpanding)
79 variant |= int(QSGCurveStrokeMaterialShader::Variant::Expanding);
80 if (renderMode == QSGRendererInterface::RenderMode3D)
81 variant |= int(QSGCurveStrokeMaterialShader::Variant::Derivatives);
82 return new QSGCurveStrokeMaterialShader(variant, viewCount());
83 }
84
85 QSGCurveStrokeNode *m_node;
86 bool m_strokeExpanding = false;
87};
88
89QT_END_NAMESPACE
90
91#endif // QSGCURVESTROKENODE_P_P_H