OpenCoverage

qsgshadersourcebuilder.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/util/qsgshadersourcebuilder.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qsgshadersourcebuilder_p.h"-
41-
42#include <QtGui/qopenglcontext.h>-
43#include <QtGui/qopenglshaderprogram.h>-
44-
45#include <QtCore/qdebug.h>-
46#include <QtCore/qfile.h>-
47-
48QT_BEGIN_NAMESPACE-
49-
50namespace QSGShaderParser {-
51-
52struct Tokenizer {-
53-
54 enum Token {-
55 Token_Invalid,-
56 Token_Void,-
57 Token_OpenBrace,-
58 Token_CloseBrace,-
59 Token_SemiColon,-
60 Token_Identifier,-
61 Token_Macro,-
62 Token_Version,-
63 Token_Extension,-
64 Token_SingleLineComment,-
65 Token_MultiLineCommentStart,-
66 Token_MultiLineCommentEnd,-
67 Token_NewLine,-
68 Token_Unspecified,-
69 Token_EOF-
70 };-
71-
72 static const char *NAMES[];-
73-
74 void initialize(const char *input);-
75 Token next();-
76-
77 const char *stream;-
78 const char *pos;-
79 const char *identifier;-
80};-
81-
82const char *Tokenizer::NAMES[] = {-
83 "Invalid",-
84 "Void",-
85 "OpenBrace",-
86 "CloseBrace",-
87 "SemiColon",-
88 "Identifier",-
89 "Macro",-
90 "Version",-
91 "Extension",-
92 "SingleLineComment",-
93 "MultiLineCommentStart",-
94 "MultiLineCommentEnd",-
95 "NewLine",-
96 "Unspecified",-
97 "EOF"-
98};-
99-
100void Tokenizer::initialize(const char *input)-
101{-
102 stream = input;-
103 pos = input;-
104 identifier = input;-
105}
executed 76 times by 3 tests: end of block
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
76
106-
107Tokenizer::Token Tokenizer::next()-
108{-
109 while (*pos != 0) {
*pos != 0Description
TRUEevaluated 18122 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-18122
110 char c = *pos++;-
111 switch (c) {-
112 case '/':
executed 532 times by 3 tests: case '/':
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
532
113 if (*pos == '/') {
*pos == '/'Description
TRUEevaluated 266 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 266 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
266
114 // '//' comment-
115 return Token_SingleLineComment;
executed 266 times by 3 tests: return Token_SingleLineComment;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
266
116 } else if (*pos == '*') {
*pos == '*'Description
TRUEnever evaluated
FALSEevaluated 266 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
0-266
117 // /* */ comment-
118 return Token_MultiLineCommentStart;
never executed: return Token_MultiLineCommentStart;
0
119 }-
120 break;
executed 266 times by 3 tests: break;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
266
121-
122 case '*':
never executed: case '*':
0
123 if (*pos == '/')
*pos == '/'Description
TRUEnever evaluated
FALSEnever evaluated
0
124 return Token_MultiLineCommentEnd;
never executed: return Token_MultiLineCommentEnd;
0
125 Q_FALLTHROUGH();-
126-
127 case '\n':
code before this statement never executed: case '\n':
executed 1710 times by 3 tests: case '\n':
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
0-1710
128 return Token_NewLine;
executed 1710 times by 3 tests: return Token_NewLine;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
1710
129-
130 case '\r':
never executed: case '\r':
0
131 if (*pos == '\n')
*pos == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
132 return Token_NewLine;
never executed: return Token_NewLine;
0
133 Q_FALLTHROUGH();-
134-
135 case '#': {
code before this statement never executed: case '#':
executed 1098 times by 3 tests: case '#':
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
0-1098
136 if (*pos == 'v' && pos[1] == 'e' && pos[2] == 'r' && pos[3] == 's'
*pos == 'v'Description
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 1022 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
pos[1] == 'e'Description
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
pos[2] == 'r'Description
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
pos[3] == 's'Description
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-1022
137 && pos[4] == 'i' && pos[5] == 'o' && pos[6] == 'n') {
pos[4] == 'i'Description
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
pos[5] == 'o'Description
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
pos[6] == 'n'Description
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-76
138 return Token_Version;
executed 76 times by 3 tests: return Token_Version;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
76
139 } else if (*pos == 'e' && pos[1] == 'x' && pos[2] == 't' && pos[3] == 'e'
*pos == 'e'Description
TRUEevaluated 570 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 452 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
pos[1] == 'x'Description
TRUEnever evaluated
FALSEevaluated 570 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
pos[2] == 't'Description
TRUEnever evaluated
FALSEnever evaluated
pos[3] == 'e'Description
TRUEnever evaluated
FALSEnever evaluated
0-570
140 && pos[4] == 'n' && pos[5] == 's' && pos[6] == 'i'&& pos[7] == 'o'
pos[4] == 'n'Description
TRUEnever evaluated
FALSEnever evaluated
pos[5] == 's'Description
TRUEnever evaluated
FALSEnever evaluated
pos[6] == 'i'Description
TRUEnever evaluated
FALSEnever evaluated
pos[7] == 'o'Description
TRUEnever evaluated
FALSEnever evaluated
0
141 && pos[8] == 'n') {
pos[8] == 'n'Description
TRUEnever evaluated
FALSEnever evaluated
0
142 return Token_Extension;
never executed: return Token_Extension;
0
143 } else {-
144 while (*pos != 0) {
*pos != 0Description
TRUEevaluated 12460 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-12460
145 if (*pos == '\n') {
*pos == '\n'Description
TRUEevaluated 1022 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 11438 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
1022-11438
146 ++pos;-
147 break;
executed 1022 times by 3 tests: break;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
1022
148 } else if (*pos == '\\') {
*pos == '\\'Description
TRUEnever evaluated
FALSEevaluated 11438 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
0-11438
149 ++pos;-
150 while (*pos != 0 && (*pos == ' ' || *pos == '\t'))
*pos != 0Description
TRUEnever evaluated
FALSEnever evaluated
*pos == ' 'Description
TRUEnever evaluated
FALSEnever evaluated
*pos == '\t'Description
TRUEnever evaluated
FALSEnever evaluated
0
151 ++pos;
never executed: ++pos;
0
152 if (*pos != 0 && (*pos == '\n' || (*pos == '\r' && pos[1] == '\n')))
*pos != 0Description
TRUEnever evaluated
FALSEnever evaluated
*pos == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
*pos == '\r'Description
TRUEnever evaluated
FALSEnever evaluated
pos[1] == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
153 pos+=2;
never executed: pos+=2;
0
154 } else {
never executed: end of block
0
155 ++pos;-
156 }
executed 11438 times by 3 tests: end of block
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
11438
157 }-
158 }
executed 1022 times by 3 tests: end of block
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
1022
159 break;
executed 1022 times by 3 tests: break;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
1022
160 }-
161-
162 case ';':
executed 1064 times by 3 tests: case ';':
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
1064
163 return Token_SemiColon;
executed 1064 times by 3 tests: return Token_SemiColon;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
1064
164-
165 case 0:
never executed: case 0:
0
166 return Token_EOF;
never executed: return Token_EOF;
0
167-
168 case '{':
never executed: case '{':
0
169 return Token_OpenBrace;
never executed: return Token_OpenBrace;
0
170-
171 case '}':
never executed: case '}':
0
172 return Token_CloseBrace;
never executed: return Token_CloseBrace;
0
173-
174 case ' ':
executed 5700 times by 3 tests: case ' ':
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
5700
175 break;
executed 5700 times by 3 tests: break;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
5700
176-
177 case 'v': {
executed 1672 times by 3 tests: case 'v':
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
1672
178 if (*pos == 'o' && pos[1] == 'i' && pos[2] == 'd') {
*pos == 'o'Description
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 1596 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
pos[1] == 'i'Description
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
pos[2] == 'd'Description
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-1596
179 pos += 3;-
180 return Token_Void;
executed 76 times by 3 tests: return Token_Void;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
76
181 }-
182 Q_FALLTHROUGH();-
183 }-
184 default:
code before this statement executed 1596 times by 3 tests: default:
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
executed 7942 times by 3 tests: default:
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
1596-7942
185 // Identifier...-
186 if ((c >= 'a' && c <= 'z' ) || (c >= 'A' && c <= 'Z' ) || c == '_') {
c >= 'a'Description
TRUEevaluated 6232 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 1710 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
c <= 'z'Description
TRUEevaluated 6232 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
c >= 'A'Description
TRUEevaluated 228 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 1482 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
c <= 'Z'Description
TRUEevaluated 38 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 190 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
c == '_'Description
TRUEevaluated 38 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 1634 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
0-6232
187 identifier = pos - 1;-
188 while (*pos != 0 && ((*pos >= 'a' && *pos <= 'z')
*pos != 0Description
TRUEevaluated 33516 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
*pos >= 'a'Description
TRUEevaluated 25194 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 8322 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
*pos <= 'z'Description
TRUEevaluated 25194 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-33516
189 || (*pos >= 'A' && *pos <= 'Z')
*pos >= 'A'Description
TRUEevaluated 1330 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 6992 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
*pos <= 'Z'Description
TRUEevaluated 1140 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 190 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
190-6992
190 || *pos == '_'
*pos == '_'Description
TRUEevaluated 114 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 7068 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
114-7068
191 || (*pos >= '0' && *pos <= '9'))) {
*pos >= '0'Description
TRUEevaluated 1824 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 5244 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
*pos <= '9'Description
TRUEevaluated 760 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 1064 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
760-5244
192 ++pos;-
193 }
executed 27208 times by 3 tests: end of block
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
27208
194 return Token_Identifier;
executed 6308 times by 3 tests: return Token_Identifier;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
6308
195 } else {-
196 return Token_Unspecified;
executed 1634 times by 3 tests: return Token_Unspecified;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
1634
197 }-
198 }-
199 }-
200-
201 return Token_Invalid;
never executed: return Token_Invalid;
0
202}-
203-
204} // namespace QSGShaderParser-
205-
206using namespace QSGShaderParser;-
207-
208QSGShaderSourceBuilder::QSGShaderSourceBuilder()-
209{-
210}-
211-
212void QSGShaderSourceBuilder::initializeProgramFromFiles(QOpenGLShaderProgram *program,-
213 const QString &vertexShader,-
214 const QString &fragmentShader)-
215{-
216 Q_ASSERT(program);-
217 program->removeAllShaders();-
218-
219 QSGShaderSourceBuilder builder;-
220-
221 builder.appendSourceFile(vertexShader);-
222 program->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, builder.source());-
223 builder.clear();-
224-
225 builder.appendSourceFile(fragmentShader);-
226 program->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, builder.source());-
227}
executed 2 times by 1 test: end of block
Executed by:
  • tst_rendernode
2
228-
229QByteArray QSGShaderSourceBuilder::source() const-
230{-
231 return m_source;
executed 8969 times by 70 tests: return m_source;
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgridview
  • tst_qquickgroupgoal
  • ...
8969
232}-
233-
234void QSGShaderSourceBuilder::clear()-
235{-
236 m_source.clear();-
237}
executed 76 times by 25 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemlayer
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
  • tst_rendernode
76
238-
239void QSGShaderSourceBuilder::appendSource(const QByteArray &source)-
240{-
241 m_source += source;-
242}
never executed: end of block
0
243-
244void QSGShaderSourceBuilder::appendSourceFile(const QString &fileName)-
245{-
246 const QString resolvedFileName = resolveShaderPath(fileName);-
247 QFile f(resolvedFileName);-
248 if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
!f.open(QIODev...ODevice::Text)Description
TRUEnever evaluated
FALSEevaluated 8973 times by 70 tests
Evaluated by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgridview
  • tst_qquickgroupgoal
  • ...
0-8973
249 qWarning() << "Failed to find shader" << resolvedFileName;-
250 return;
never executed: return;
0
251 }-
252 m_source += f.readAll();-
253}
executed 8973 times by 70 tests: end of block
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgridview
  • tst_qquickgroupgoal
  • ...
8973
254-
255void QSGShaderSourceBuilder::addDefinition(const QByteArray &definition)-
256{-
257 if (definition.isEmpty())
definition.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
0-76
258 return;
never executed: return;
0
259-
260 Tokenizer tok;-
261 const char *input = m_source.constData();-
262 tok.initialize(input);-
263-
264 // First find #version, #extension's and "void main() { ... "-
265 const char *versionPos = nullptr;-
266 const char *extensionPos = nullptr;-
267 bool inSingleLineComment = false;-
268 bool inMultiLineComment = false;-
269 bool foundVersionStart = false;-
270 bool foundExtensionStart = false;-
271-
272 Tokenizer::Token lt = Tokenizer::Token_Unspecified;-
273 Tokenizer::Token t = tok.next();-
274 while (t != Tokenizer::Token_EOF) {
t != Tokenizer::Token_EOFDescription
TRUEevaluated 11134 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-11134
275 // Handle comment blocks-
276 if (t == Tokenizer::Token_MultiLineCommentStart )
t == Tokenizer...neCommentStartDescription
TRUEnever evaluated
FALSEevaluated 11134 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
0-11134
277 inMultiLineComment = true;
never executed: inMultiLineComment = true;
0
278 if (t == Tokenizer::Token_MultiLineCommentEnd)
t == Tokenizer...LineCommentEndDescription
TRUEnever evaluated
FALSEevaluated 11134 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
0-11134
279 inMultiLineComment = false;
never executed: inMultiLineComment = false;
0
280 if (t == Tokenizer::Token_SingleLineComment)
t == Tokenizer...gleLineCommentDescription
TRUEevaluated 266 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 10868 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
266-10868
281 inSingleLineComment = true;
executed 266 times by 3 tests: inSingleLineComment = true;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
266
282 if (t == Tokenizer::Token_NewLine && inSingleLineComment && !inMultiLineComment)
t == Tokenizer::Token_NewLineDescription
TRUEevaluated 1710 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 9424 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
inSingleLineCommentDescription
TRUEevaluated 266 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 1444 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
!inMultiLineCommentDescription
TRUEevaluated 266 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-9424
283 inSingleLineComment = false;
executed 266 times by 3 tests: inSingleLineComment = false;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
266
284-
285 // Have we found #version, #extension or void main()?-
286 if (t == Tokenizer::Token_Version && !inSingleLineComment && !inMultiLineComment)
t == Tokenizer::Token_VersionDescription
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 11058 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
!inSingleLineCommentDescription
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
!inMultiLineCommentDescription
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-11058
287 foundVersionStart = true;
executed 76 times by 3 tests: foundVersionStart = true;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
76
288-
289 if (t == Tokenizer::Token_Extension && !inSingleLineComment && !inMultiLineComment)
t == Tokenizer...oken_ExtensionDescription
TRUEnever evaluated
FALSEevaluated 11134 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
!inSingleLineCommentDescription
TRUEnever evaluated
FALSEnever evaluated
!inMultiLineCommentDescription
TRUEnever evaluated
FALSEnever evaluated
0-11134
290 foundExtensionStart = true;
never executed: foundExtensionStart = true;
0
291-
292 if (foundVersionStart && t == Tokenizer::Token_NewLine) {
foundVersionStartDescription
TRUEevaluated 456 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 10678 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
t == Tokenizer::Token_NewLineDescription
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 380 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
76-10678
293 versionPos = tok.pos;-
294 foundVersionStart = false;-
295 } else if (foundExtensionStart && t == Tokenizer::Token_NewLine) {
executed 76 times by 3 tests: end of block
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
foundExtensionStartDescription
TRUEnever evaluated
FALSEevaluated 11058 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
t == Tokenizer::Token_NewLineDescription
TRUEnever evaluated
FALSEnever evaluated
0-11058
296 extensionPos = tok.pos;-
297 foundExtensionStart = false;-
298 } else if (lt == Tokenizer::Token_Void && t == Tokenizer::Token_Identifier) {
never executed: end of block
lt == Tokenizer::Token_VoidDescription
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEevaluated 10982 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
t == Tokenizer...ken_IdentifierDescription
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-10982
299 if (qstrncmp("main", tok.identifier, 4) == 0)
qstrncmp("main...ifier, 4) == 0Description
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-76
300 break;
executed 76 times by 3 tests: break;
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
76
301 }
never executed: end of block
0
302-
303 // Scan to next token-
304 lt = t;-
305 t = tok.next();-
306 }
executed 11058 times by 3 tests: end of block
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
11058
307-
308 // Determine where to insert the definition.-
309 // If we found #extension directives, insert after last one,-
310 // else, if we found #version insert after #version-
311 // otherwise, insert at beginning.-
312 const char *insertionPos = extensionPos ? extensionPos : (versionPos ? versionPos : input);
extensionPosDescription
TRUEnever evaluated
FALSEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
versionPosDescription
TRUEevaluated 76 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
FALSEnever evaluated
0-76
313-
314 // Construct a new shader string, inserting the definition-
315 QByteArray newSource = QByteArray::fromRawData(input, insertionPos - input)-
316 + "#define " + definition + '\n'-
317 + QByteArray::fromRawData(insertionPos, m_source.size() - (insertionPos - input));-
318 m_source = std::move(newSource);-
319}
executed 76 times by 3 tests: end of block
Executed by:
  • tst_qquickcustomaffector
  • tst_qquickimageparticle
  • tst_qquickspritegoal
76
320-
321void QSGShaderSourceBuilder::removeVersion()-
322{-
323 Tokenizer tok;-
324 const char *input = m_source.constData();-
325 tok.initialize(input);-
326-
327 // First find #version beginning and end (if present)-
328 const char *versionStartPos = nullptr;-
329 const char *versionEndPos = nullptr;-
330 bool inSingleLineComment = false;-
331 bool inMultiLineComment = false;-
332 bool foundVersionStart = false;-
333-
334 Tokenizer::Token lt = Tokenizer::Token_Unspecified;-
335 Tokenizer::Token t = tok.next();-
336 while (t != Tokenizer::Token_EOF) {
t != Tokenizer::Token_EOFDescription
TRUEnever evaluated
FALSEnever evaluated
0
337 // Handle comment blocks-
338 if (t == Tokenizer::Token_MultiLineCommentStart )
t == Tokenizer...neCommentStartDescription
TRUEnever evaluated
FALSEnever evaluated
0
339 inMultiLineComment = true;
never executed: inMultiLineComment = true;
0
340 if (t == Tokenizer::Token_MultiLineCommentEnd)
t == Tokenizer...LineCommentEndDescription
TRUEnever evaluated
FALSEnever evaluated
0
341 inMultiLineComment = false;
never executed: inMultiLineComment = false;
0
342 if (t == Tokenizer::Token_SingleLineComment)
t == Tokenizer...gleLineCommentDescription
TRUEnever evaluated
FALSEnever evaluated
0
343 inSingleLineComment = true;
never executed: inSingleLineComment = true;
0
344 if (t == Tokenizer::Token_NewLine && inSingleLineComment && !inMultiLineComment)
t == Tokenizer::Token_NewLineDescription
TRUEnever evaluated
FALSEnever evaluated
inSingleLineCommentDescription
TRUEnever evaluated
FALSEnever evaluated
!inMultiLineCommentDescription
TRUEnever evaluated
FALSEnever evaluated
0
345 inSingleLineComment = false;
never executed: inSingleLineComment = false;
0
346-
347 // Have we found #version, #extension or void main()?-
348 if (t == Tokenizer::Token_Version && !inSingleLineComment && !inMultiLineComment) {
t == Tokenizer::Token_VersionDescription
TRUEnever evaluated
FALSEnever evaluated
!inSingleLineCommentDescription
TRUEnever evaluated
FALSEnever evaluated
!inMultiLineCommentDescription
TRUEnever evaluated
FALSEnever evaluated
0
349 versionStartPos = tok.pos - 1;-
350 foundVersionStart = true;-
351 } else if (foundVersionStart && t == Tokenizer::Token_NewLine) {
never executed: end of block
foundVersionStartDescription
TRUEnever evaluated
FALSEnever evaluated
t == Tokenizer::Token_NewLineDescription
TRUEnever evaluated
FALSEnever evaluated
0
352 versionEndPos = tok.pos;-
353 break;
never executed: break;
0
354 } else if (lt == Tokenizer::Token_Void && t == Tokenizer::Token_Identifier) {
lt == Tokenizer::Token_VoidDescription
TRUEnever evaluated
FALSEnever evaluated
t == Tokenizer...ken_IdentifierDescription
TRUEnever evaluated
FALSEnever evaluated
0
355 if (qstrncmp("main", tok.identifier, 4) == 0)
qstrncmp("main...ifier, 4) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
356 break;
never executed: break;
0
357 }
never executed: end of block
0
358-
359 // Scan to next token-
360 lt = t;-
361 t = tok.next();-
362 }
never executed: end of block
0
363-
364 if (versionStartPos == nullptr)
versionStartPos == nullptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
365 return;
never executed: return;
0
366-
367 // Construct a new shader string, inserting the definition-
368 QByteArray newSource;-
369 newSource.reserve(m_source.size() - (versionEndPos - versionStartPos));-
370 newSource += QByteArray::fromRawData(input, versionStartPos - input);-
371 newSource += QByteArray::fromRawData(versionEndPos, m_source.size() - (versionEndPos - versionStartPos));-
372-
373 m_source = newSource;-
374}
never executed: end of block
0
375-
376QString QSGShaderSourceBuilder::resolveShaderPath(const QString &path) const-
377{-
378 if (contextProfile() != QSurfaceFormat::CoreProfile) {
contextProfile...t::CoreProfileDescription
TRUEevaluated 8973 times by 70 tests
Evaluated by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgridview
  • tst_qquickgroupgoal
  • ...
FALSEnever evaluated
0-8973
379 return path;
executed 8973 times by 70 tests: return path;
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgridview
  • tst_qquickgroupgoal
  • ...
8973
380 } else {-
381 int idx = path.lastIndexOf(QLatin1Char('.'));-
382 QString resolvedPath;-
383 if (idx != -1)
idx != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
384 resolvedPath = path.leftRef(idx)
never executed: resolvedPath = path.leftRef(idx) + QLatin1String("_core") + path.rightRef(path.length() - idx);
0
385 + QLatin1String("_core")
never executed: resolvedPath = path.leftRef(idx) + QLatin1String("_core") + path.rightRef(path.length() - idx);
0
386 + path.rightRef(path.length() - idx);
never executed: resolvedPath = path.leftRef(idx) + QLatin1String("_core") + path.rightRef(path.length() - idx);
0
387 return resolvedPath;
never executed: return resolvedPath;
0
388 }-
389}-
390-
391QSurfaceFormat::OpenGLContextProfile QSGShaderSourceBuilder::contextProfile() const-
392{-
393 QOpenGLContext *context = QOpenGLContext::currentContext();-
394 QSurfaceFormat::OpenGLContextProfile profile = QSurfaceFormat::NoProfile;-
395 if (context)
contextDescription
TRUEevaluated 8973 times by 70 tests
Evaluated by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgridview
  • tst_qquickgroupgoal
  • ...
FALSEnever evaluated
0-8973
396 profile = context->format().profile();
executed 8973 times by 70 tests: profile = context->format().profile();
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgridview
  • tst_qquickgroupgoal
  • ...
8973
397 return profile;
executed 8973 times by 70 tests: return profile;
Executed by:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmltypeloader
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickborderimage
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickdraghandler
  • tst_qquickellipseextruder
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickfontloader
  • tst_qquickfontloader_static
  • tst_qquickframebufferobject
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgridview
  • tst_qquickgroupgoal
  • ...
8973
398}-
399-
400QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0