Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/util/qsgflatcolormaterial.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | class FlatColorMaterialShader : public QSGMaterialShader | - | ||||||||||||||||||
7 | { | - | ||||||||||||||||||
8 | public: | - | ||||||||||||||||||
9 | FlatColorMaterialShader(); | - | ||||||||||||||||||
10 | - | |||||||||||||||||||
11 | void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; | - | ||||||||||||||||||
12 | char const *const *attributeNames() const override; | - | ||||||||||||||||||
13 | - | |||||||||||||||||||
14 | static QSGMaterialType type; | - | ||||||||||||||||||
15 | - | |||||||||||||||||||
16 | private: | - | ||||||||||||||||||
17 | void initialize() override; | - | ||||||||||||||||||
18 | - | |||||||||||||||||||
19 | int m_matrix_id; | - | ||||||||||||||||||
20 | int m_color_id; | - | ||||||||||||||||||
21 | - | |||||||||||||||||||
22 | }; | - | ||||||||||||||||||
23 | - | |||||||||||||||||||
24 | QSGMaterialType FlatColorMaterialShader::type; | - | ||||||||||||||||||
25 | - | |||||||||||||||||||
26 | FlatColorMaterialShader::FlatColorMaterialShader() | - | ||||||||||||||||||
27 | : QSGMaterialShader(*new QSGMaterialShaderPrivate) | - | ||||||||||||||||||
28 | { | - | ||||||||||||||||||
29 | - | |||||||||||||||||||
30 | setShaderSourceFile(QOpenGLShader::Vertex, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/scenegraph/shaders/flatcolor.vert")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/scenegraph/shaders/flatcolor.vert" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 6 times by 2 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 6 times by 2 tests: }()));return qstring_literal_temp; Executed by:
| 6 | ||||||||||||||||||
31 | setShaderSourceFile(QOpenGLShader::Fragment, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/scenegraph/shaders/flatcolor.frag")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/scenegraph/shaders/flatcolor.frag" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 6 times by 2 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 6 times by 2 tests: }()));return qstring_literal_temp; Executed by:
| 6 | ||||||||||||||||||
32 | - | |||||||||||||||||||
33 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
34 | - | |||||||||||||||||||
35 | void FlatColorMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) | - | ||||||||||||||||||
36 | { | - | ||||||||||||||||||
37 | - | |||||||||||||||||||
38 | ((oldEffect == nullptr || newEffect->type() == oldEffect->type()) ? static_cast<void>(0) : qt_assert("oldEffect == nullptr || newEffect->type() == oldEffect->type()", __FILE__, 80)); | - | ||||||||||||||||||
39 | QSGFlatColorMaterial *oldMaterial = static_cast<QSGFlatColorMaterial *>(oldEffect); | - | ||||||||||||||||||
40 | QSGFlatColorMaterial *newMaterial = static_cast<QSGFlatColorMaterial *>(newEffect); | - | ||||||||||||||||||
41 | - | |||||||||||||||||||
42 | const QColor &c = newMaterial->color(); | - | ||||||||||||||||||
43 | - | |||||||||||||||||||
44 | if (oldMaterial == nullptr
| 0-78 | ||||||||||||||||||
45 | float opacity = state.opacity() * c.alphaF(); | - | ||||||||||||||||||
46 | QVector4D v(c.redF() * opacity, | - | ||||||||||||||||||
47 | c.greenF() * opacity, | - | ||||||||||||||||||
48 | c.blueF() * opacity, | - | ||||||||||||||||||
49 | opacity); | - | ||||||||||||||||||
50 | program()->setUniformValue(m_color_id, v); | - | ||||||||||||||||||
51 | } executed 110 times by 2 tests: end of block Executed by:
| 110 | ||||||||||||||||||
52 | - | |||||||||||||||||||
53 | if (state.isMatrixDirty()
| 0-130 | ||||||||||||||||||
54 | program()->setUniformValue(m_matrix_id, state.combinedMatrix()); executed 130 times by 2 tests: program()->setUniformValue(m_matrix_id, state.combinedMatrix()); Executed by:
| 130 | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | - | |||||||||||||||||||
57 | - | |||||||||||||||||||
58 | - | |||||||||||||||||||
59 | - | |||||||||||||||||||
60 | } executed 130 times by 2 tests: end of block Executed by:
| 130 | ||||||||||||||||||
61 | - | |||||||||||||||||||
62 | char const *const *FlatColorMaterialShader::attributeNames() const | - | ||||||||||||||||||
63 | { | - | ||||||||||||||||||
64 | static char const *const attr[] = { "vCoord", nullptr }; | - | ||||||||||||||||||
65 | return executed 292 times by 2 tests: attr;return attr; Executed by:
executed 292 times by 2 tests: return attr; Executed by:
| 292 | ||||||||||||||||||
66 | } | - | ||||||||||||||||||
67 | - | |||||||||||||||||||
68 | void FlatColorMaterialShader::initialize() | - | ||||||||||||||||||
69 | { | - | ||||||||||||||||||
70 | - | |||||||||||||||||||
71 | m_matrix_id = program()->uniformLocation("matrix"); | - | ||||||||||||||||||
72 | m_color_id = program()->uniformLocation("color"); | - | ||||||||||||||||||
73 | - | |||||||||||||||||||
74 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
75 | QSGFlatColorMaterial::QSGFlatColorMaterial() : m_color(QColor(255, 255, 255)) | - | ||||||||||||||||||
76 | { | - | ||||||||||||||||||
77 | } executed 200024 times by 4 tests: end of block Executed by:
| 200024 | ||||||||||||||||||
78 | void QSGFlatColorMaterial::setColor(const QColor &color) | - | ||||||||||||||||||
79 | { | - | ||||||||||||||||||
80 | m_color = color; | - | ||||||||||||||||||
81 | setFlag(Blending, m_color.alpha() != 0xff); | - | ||||||||||||||||||
82 | } executed 200014 times by 2 tests: end of block Executed by:
| 200014 | ||||||||||||||||||
83 | - | |||||||||||||||||||
84 | - | |||||||||||||||||||
85 | - | |||||||||||||||||||
86 | - | |||||||||||||||||||
87 | - | |||||||||||||||||||
88 | - | |||||||||||||||||||
89 | - | |||||||||||||||||||
90 | QSGMaterialType *QSGFlatColorMaterial::type() const | - | ||||||||||||||||||
91 | { | - | ||||||||||||||||||
92 | return executed 1800194 times by 2 tests: &FlatColorMaterialShader::type;return &FlatColorMaterialShader::type; Executed by:
executed 1800194 times by 2 tests: return &FlatColorMaterialShader::type; Executed by:
| 1800194 | ||||||||||||||||||
93 | } | - | ||||||||||||||||||
94 | - | |||||||||||||||||||
95 | - | |||||||||||||||||||
96 | - | |||||||||||||||||||
97 | - | |||||||||||||||||||
98 | - | |||||||||||||||||||
99 | - | |||||||||||||||||||
100 | - | |||||||||||||||||||
101 | QSGMaterialShader *QSGFlatColorMaterial::createShader() const | - | ||||||||||||||||||
102 | { | - | ||||||||||||||||||
103 | return executed 6 times by 2 tests: new FlatColorMaterialShader;return new FlatColorMaterialShader; Executed by:
executed 6 times by 2 tests: return new FlatColorMaterialShader; Executed by:
| 6 | ||||||||||||||||||
104 | } | - | ||||||||||||||||||
105 | - | |||||||||||||||||||
106 | - | |||||||||||||||||||
107 | - | |||||||||||||||||||
108 | - | |||||||||||||||||||
109 | - | |||||||||||||||||||
110 | - | |||||||||||||||||||
111 | int QSGFlatColorMaterial::compare(const QSGMaterial *other) const | - | ||||||||||||||||||
112 | { | - | ||||||||||||||||||
113 | const QSGFlatColorMaterial *flat = static_cast<const QSGFlatColorMaterial *>(other); | - | ||||||||||||||||||
114 | return executed 899990 times by 2 tests: m_color.rgba() - flat->color().rgba();return m_color.rgba() - flat->color().rgba(); Executed by:
executed 899990 times by 2 tests: return m_color.rgba() - flat->color().rgba(); Executed by:
| 899990 | ||||||||||||||||||
115 | - | |||||||||||||||||||
116 | } | - | ||||||||||||||||||
117 | - | |||||||||||||||||||
118 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |