Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickopenglshadereffect.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | - | |||||||||||||||||||
9 | namespace { | - | ||||||||||||||||||
10 | - | |||||||||||||||||||
11 | enum VariableQualifier { | - | ||||||||||||||||||
12 | AttributeQualifier, | - | ||||||||||||||||||
13 | UniformQualifier | - | ||||||||||||||||||
14 | }; | - | ||||||||||||||||||
15 | - | |||||||||||||||||||
16 | inline bool qt_isalpha(char c) | - | ||||||||||||||||||
17 | { | - | ||||||||||||||||||
18 | char ch = c | 0x20; | - | ||||||||||||||||||
19 | return executed 19442 times by 4 tests: (ch >= 'a' && ch <= 'z') || c == '_';return (ch >= 'a' && ch <= 'z') || c == '_'; Executed by:
executed 19442 times by 4 tests: return (ch >= 'a' && ch <= 'z') || c == '_'; Executed by:
| 19442 | ||||||||||||||||||
20 | } | - | ||||||||||||||||||
21 | - | |||||||||||||||||||
22 | inline bool qt_isalnum(char c) | - | ||||||||||||||||||
23 | { | - | ||||||||||||||||||
24 | return executed 14798 times by 4 tests: qt_isalpha(c) || (c >= '0' && c <= '9');return qt_isalpha(c) || (c >= '0' && c <= '9'); Executed by:
executed 14798 times by 4 tests: return qt_isalpha(c) || (c >= '0' && c <= '9'); Executed by:
| 14798 | ||||||||||||||||||
25 | } | - | ||||||||||||||||||
26 | - | |||||||||||||||||||
27 | inline bool qt_isspace(char c) | - | ||||||||||||||||||
28 | { | - | ||||||||||||||||||
29 | return executed 16856 times by 4 tests: c == ' ' || (c >= 0x09 && c <= 0x0d);return c == ' ' || (c >= 0x09 && c <= 0x0d); Executed by:
executed 16856 times by 4 tests: return c == ' ' || (c >= 0x09 && c <= 0x0d); Executed by:
| 16856 | ||||||||||||||||||
30 | } | - | ||||||||||||||||||
31 | - | |||||||||||||||||||
32 | - | |||||||||||||||||||
33 | int qt_search_for_variable(const char *s, int length, int index, VariableQualifier &decl, | - | ||||||||||||||||||
34 | int &typeIndex, int &typeLength, | - | ||||||||||||||||||
35 | int &nameIndex, int &nameLength, | - | ||||||||||||||||||
36 | QQuickOpenGLShaderEffectCommon::Key::ShaderType shaderType) | - | ||||||||||||||||||
37 | { | - | ||||||||||||||||||
38 | enum Identifier { | - | ||||||||||||||||||
39 | QualifierIdentifier, | - | ||||||||||||||||||
40 | PrecisionIdentifier, | - | ||||||||||||||||||
41 | TypeIdentifier, | - | ||||||||||||||||||
42 | NameIdentifier | - | ||||||||||||||||||
43 | }; | - | ||||||||||||||||||
44 | Identifier expected = QualifierIdentifier; | - | ||||||||||||||||||
45 | bool compilerDirectiveExpected = index == 0; | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | while (index < length
| 146-4644 | ||||||||||||||||||
48 | - | |||||||||||||||||||
49 | while (qt_isspace(s[index])
| 4644-12212 | ||||||||||||||||||
50 | compilerDirectiveExpected |= s[index] == '\n'; | - | ||||||||||||||||||
51 | ++index; | - | ||||||||||||||||||
52 | } executed 12212 times by 4 tests: end of block Executed by:
| 12212 | ||||||||||||||||||
53 | - | |||||||||||||||||||
54 | if (qt_isalpha(s[index])
| 2264-2380 | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | int idIndex = index; | - | ||||||||||||||||||
57 | ++index; | - | ||||||||||||||||||
58 | while (qt_isalnum(s[index])
| 2264-12534 | ||||||||||||||||||
59 | ++ executed 12534 times by 4 tests: index;++index; Executed by:
executed 12534 times by 4 tests: ++index; Executed by:
| 12534 | ||||||||||||||||||
60 | int idLength = index - idIndex; | - | ||||||||||||||||||
61 | - | |||||||||||||||||||
62 | const int attrLen = sizeof("attribute") - 1; | - | ||||||||||||||||||
63 | const int inLen = sizeof("in") - 1; | - | ||||||||||||||||||
64 | const int uniLen = sizeof("uniform") - 1; | - | ||||||||||||||||||
65 | const int loLen = sizeof("lowp") - 1; | - | ||||||||||||||||||
66 | const int medLen = sizeof("mediump") - 1; | - | ||||||||||||||||||
67 | const int hiLen = sizeof("highp") - 1; | - | ||||||||||||||||||
68 | - | |||||||||||||||||||
69 | switch (expected) { | - | ||||||||||||||||||
70 | case executed 1678 times by 4 tests: QualifierIdentifier:case QualifierIdentifier: Executed by:
executed 1678 times by 4 tests: case QualifierIdentifier: Executed by:
| 1678 | ||||||||||||||||||
71 | if (idLength == attrLen
| 46-1530 | ||||||||||||||||||
72 | decl = AttributeQualifier; | - | ||||||||||||||||||
73 | expected = PrecisionIdentifier; | - | ||||||||||||||||||
74 | } executed 46 times by 1 test: else if (shaderType == QQuickOpenGLShaderEffectCommon::Key::VertexShaderend of block Executed by:
| 46-1188 | ||||||||||||||||||
75 | && idLength == inLen
| 0-438 | ||||||||||||||||||
76 | decl = AttributeQualifier; | - | ||||||||||||||||||
77 | expected = PrecisionIdentifier; | - | ||||||||||||||||||
78 | } never executed: else if (idLength == uniLenend of block
| 0-1350 | ||||||||||||||||||
79 | decl = UniformQualifier; | - | ||||||||||||||||||
80 | expected = PrecisionIdentifier; | - | ||||||||||||||||||
81 | } executed 168 times by 3 tests: end of block Executed by:
| 168 | ||||||||||||||||||
82 | break; executed 1678 times by 4 tests: break; Executed by:
| 1678 | ||||||||||||||||||
83 | case executed 214 times by 3 tests: PrecisionIdentifier:case PrecisionIdentifier: Executed by:
executed 214 times by 3 tests: case PrecisionIdentifier: Executed by:
| 214 | ||||||||||||||||||
84 | if ((idLength == loLen
| 6-110 | ||||||||||||||||||
85 | || (idLength == medLen
| 0-112 | ||||||||||||||||||
86 | || (idLength == hiLen
| 0-60 | ||||||||||||||||||
87 | { | - | ||||||||||||||||||
88 | expected = TypeIdentifier; | - | ||||||||||||||||||
89 | break; executed 162 times by 3 tests: break; Executed by:
| 162 | ||||||||||||||||||
90 | } | - | ||||||||||||||||||
91 | (void)0; | - | ||||||||||||||||||
92 | case executed 162 times by 3 tests: TypeIdentifier:case TypeIdentifier: Executed by:
executed 162 times by 3 tests: case TypeIdentifier: Executed by:
code before this statement executed 52 times by 3 tests: case TypeIdentifier: Executed by:
| 52-162 | ||||||||||||||||||
93 | typeIndex = idIndex; | - | ||||||||||||||||||
94 | typeLength = idLength; | - | ||||||||||||||||||
95 | expected = NameIdentifier; | - | ||||||||||||||||||
96 | break; executed 214 times by 3 tests: break; Executed by:
| 214 | ||||||||||||||||||
97 | case executed 210 times by 3 tests: NameIdentifier:case NameIdentifier: Executed by:
executed 210 times by 3 tests: case NameIdentifier: Executed by:
| 210 | ||||||||||||||||||
98 | nameIndex = idIndex; | - | ||||||||||||||||||
99 | nameLength = idLength; | - | ||||||||||||||||||
100 | return executed 210 times by 3 tests: index;return index; Executed by:
executed 210 times by 3 tests: return index; Executed by:
| 210 | ||||||||||||||||||
101 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||
102 | break; never executed: break; | 0 | ||||||||||||||||||
103 | } | - | ||||||||||||||||||
104 | } else if (s[index] == '#'
| 0-2352 | ||||||||||||||||||
105 | - | |||||||||||||||||||
106 | ++index; | - | ||||||||||||||||||
107 | while (index < length
| 4-348 | ||||||||||||||||||
108 | ++ executed 324 times by 1 test: index;++index; Executed by:
executed 324 times by 1 test: ++index; Executed by:
| 324 | ||||||||||||||||||
109 | } executed 28 times by 1 test: else if (s[index] == '/'end of block Executed by:
| 28-2264 | ||||||||||||||||||
110 | - | |||||||||||||||||||
111 | index += 2; | - | ||||||||||||||||||
112 | while (index < length
| 4-1078 | ||||||||||||||||||
113 | ++ executed 1040 times by 2 tests: index;++index; Executed by:
executed 1040 times by 2 tests: ++index; Executed by:
| 1040 | ||||||||||||||||||
114 | } executed 42 times by 2 tests: else if (s[index] == '/'end of block Executed by:
| 14-2264 | ||||||||||||||||||
115 | - | |||||||||||||||||||
116 | index += 2; | - | ||||||||||||||||||
117 | while (index < length
| 0-342 | ||||||||||||||||||
118 | ++ executed 310 times by 1 test: index;++index; Executed by:
executed 310 times by 1 test: ++index; Executed by:
| 310 | ||||||||||||||||||
119 | if (index < length
| 0-32 | ||||||||||||||||||
120 | index += 2; executed 32 times by 1 test: index += 2; Executed by:
| 32 | ||||||||||||||||||
121 | } executed 32 times by 1 test: else {end of block Executed by:
| 32 | ||||||||||||||||||
122 | expected = QualifierIdentifier; | - | ||||||||||||||||||
123 | ++index; | - | ||||||||||||||||||
124 | } executed 2278 times by 4 tests: end of block Executed by:
| 2278 | ||||||||||||||||||
125 | compilerDirectiveExpected = false; | - | ||||||||||||||||||
126 | } executed 4434 times by 4 tests: end of block Executed by:
| 4434 | ||||||||||||||||||
127 | return executed 146 times by 4 tests: -1;return -1; Executed by:
executed 146 times by 4 tests: return -1; Executed by:
| 146 | ||||||||||||||||||
128 | } | - | ||||||||||||||||||
129 | } | - | ||||||||||||||||||
130 | - | |||||||||||||||||||
131 | namespace QtPrivate { | - | ||||||||||||||||||
132 | class MappedSlotObject: public QtPrivate::QSlotObjectBase | - | ||||||||||||||||||
133 | { | - | ||||||||||||||||||
134 | public: | - | ||||||||||||||||||
135 | typedef std::function<void()> PropChangedFunc; | - | ||||||||||||||||||
136 | - | |||||||||||||||||||
137 | explicit MappedSlotObject(PropChangedFunc func) | - | ||||||||||||||||||
138 | : QSlotObjectBase(&impl), _signalIndex(-1), func(func) | - | ||||||||||||||||||
139 | { ref(); } executed 124 times by 5 tests: end of block Executed by:
| 124 | ||||||||||||||||||
140 | - | |||||||||||||||||||
141 | void setSignalIndex(int idx) { _signalIndex = idx; } executed 98 times by 5 tests: end of block Executed by:
| 98 | ||||||||||||||||||
142 | int signalIndex() const { return executed 106 times by 3 tests: _signalIndex;return _signalIndex; Executed by:
executed 106 times by 3 tests: }return _signalIndex; Executed by:
| 106 | ||||||||||||||||||
143 | - | |||||||||||||||||||
144 | private: | - | ||||||||||||||||||
145 | int _signalIndex; | - | ||||||||||||||||||
146 | PropChangedFunc func; | - | ||||||||||||||||||
147 | - | |||||||||||||||||||
148 | static void impl(int which, QSlotObjectBase *this_, QObject *, void **a, bool *ret) | - | ||||||||||||||||||
149 | { | - | ||||||||||||||||||
150 | auto thiz = static_cast<MappedSlotObject*>(this_); | - | ||||||||||||||||||
151 | switch (which) { | - | ||||||||||||||||||
152 | case executed 96 times by 4 tests: Destroy:case Destroy: Executed by:
executed 96 times by 4 tests: case Destroy: Executed by:
| 96 | ||||||||||||||||||
153 | delete thiz; | - | ||||||||||||||||||
154 | break; executed 96 times by 4 tests: break; Executed by:
| 96 | ||||||||||||||||||
155 | case executed 16 times by 4 tests: Call:case Call: Executed by:
executed 16 times by 4 tests: case Call: Executed by:
| 16 | ||||||||||||||||||
156 | thiz->func(); | - | ||||||||||||||||||
157 | break; executed 16 times by 4 tests: break; Executed by:
| 16 | ||||||||||||||||||
158 | case executed 4 times by 1 test: Compare:case Compare: Executed by:
executed 4 times by 1 test: case Compare: Executed by:
| 4 | ||||||||||||||||||
159 | *ret = thiz == reinterpret_cast<MappedSlotObject *>(a[0]); | - | ||||||||||||||||||
160 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||
161 | case never executed: NumOperations:case NumOperations: never executed: ;case NumOperations: | 0 | ||||||||||||||||||
162 | } never executed: end of block | 0 | ||||||||||||||||||
163 | } executed 116 times by 4 tests: end of block Executed by:
| 116 | ||||||||||||||||||
164 | }; | - | ||||||||||||||||||
165 | } | - | ||||||||||||||||||
166 | - | |||||||||||||||||||
167 | QQuickOpenGLShaderEffectCommon::~QQuickOpenGLShaderEffectCommon() | - | ||||||||||||||||||
168 | { | - | ||||||||||||||||||
169 | for (int shaderType = 0; shaderType < Key::ShaderTypeCount
| 116-232 | ||||||||||||||||||
170 | clearSignalMappers(shaderType); executed 232 times by 5 tests: clearSignalMappers(shaderType); Executed by:
| 232 | ||||||||||||||||||
171 | } executed 116 times by 5 tests: end of block Executed by:
| 116 | ||||||||||||||||||
172 | - | |||||||||||||||||||
173 | void QQuickOpenGLShaderEffectCommon::disconnectPropertySignals(QQuickItem *item, Key::ShaderType shaderType) | - | ||||||||||||||||||
174 | { | - | ||||||||||||||||||
175 | for (int i = 0; i < uniformData[shaderType].size()
| 230-444 | ||||||||||||||||||
176 | if (signalMappers[shaderType].at(i) == 0
| 106-124 | ||||||||||||||||||
177 | continue; executed 124 times by 4 tests: continue; Executed by:
| 124 | ||||||||||||||||||
178 | const UniformData &d = uniformData[shaderType].at(i); | - | ||||||||||||||||||
179 | auto mapper = signalMappers[shaderType].at(i); | - | ||||||||||||||||||
180 | void *a = mapper; | - | ||||||||||||||||||
181 | QObjectPrivate::disconnect(item, mapper->signalIndex(), &a); | - | ||||||||||||||||||
182 | if (d.specialType == UniformData::Sampler
| 0-72 | ||||||||||||||||||
183 | QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(d.value)); | - | ||||||||||||||||||
184 | if (source
| 15-57 | ||||||||||||||||||
185 | if (item->window()
| 4-11 | ||||||||||||||||||
186 | QQuickItemPrivate::get(source)->derefWindow(); executed 4 times by 1 test: QQuickItemPrivate::get(source)->derefWindow(); Executed by:
| 4 | ||||||||||||||||||
187 | QObject::disconnect(source, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "238"), host, qFlagLocation("1""sourceDestroyed(QObject*)" "\0" __FILE__ ":" "238")); | - | ||||||||||||||||||
188 | } executed 15 times by 3 tests: end of block Executed by:
| 15 | ||||||||||||||||||
189 | } executed 72 times by 3 tests: end of block Executed by:
| 72 | ||||||||||||||||||
190 | } executed 106 times by 3 tests: end of block Executed by:
| 106 | ||||||||||||||||||
191 | } executed 444 times by 6 tests: end of block Executed by:
| 444 | ||||||||||||||||||
192 | - | |||||||||||||||||||
193 | void QQuickOpenGLShaderEffectCommon::connectPropertySignals(QQuickItem *item, | - | ||||||||||||||||||
194 | const QMetaObject *itemMetaObject, | - | ||||||||||||||||||
195 | Key::ShaderType shaderType) | - | ||||||||||||||||||
196 | { | - | ||||||||||||||||||
197 | QQmlPropertyCache *propCache = QQmlData::ensurePropertyCache(qmlEngine(item), item); | - | ||||||||||||||||||
198 | for (int i = 0; i < uniformData[shaderType].size()
| 232-282 | ||||||||||||||||||
199 | if (signalMappers[shaderType].at(i) == 0
| 124-158 | ||||||||||||||||||
200 | continue; executed 158 times by 6 tests: continue; Executed by:
| 158 | ||||||||||||||||||
201 | const UniformData &d = uniformData[shaderType].at(i); | - | ||||||||||||||||||
202 | QQmlPropertyData *pd = propCache->property(QString::fromUtf8(d.name), nullptr, nullptr); | - | ||||||||||||||||||
203 | if (pd
| 0-98 | ||||||||||||||||||
204 | if (pd->notifyIndex() == -1
| 0-98 | ||||||||||||||||||
205 | QMessageLogger(__FILE__, 256, __PRETTY_FUNCTION__).warning("QQuickOpenGLShaderEffect: property '%s' does not have notification method!", d.name.constData()); | - | ||||||||||||||||||
206 | } never executed: else {end of block | 0 | ||||||||||||||||||
207 | auto *mapper = signalMappers[shaderType].at(i); | - | ||||||||||||||||||
208 | mapper->setSignalIndex(itemMetaObject->property(d.propertyIndex).notifySignal().methodIndex()); | - | ||||||||||||||||||
209 | ((item->metaObject() == itemMetaObject) ? static_cast<void>(0) : qt_assert("item->metaObject() == itemMetaObject", __FILE__, 260)); | - | ||||||||||||||||||
210 | bool ok = QObjectPrivate::connectImpl(item, pd->notifyIndex(), item, nullptr, mapper, | - | ||||||||||||||||||
211 | Qt::AutoConnection, nullptr, itemMetaObject); | - | ||||||||||||||||||
212 | if (!ok
| 0-98 | ||||||||||||||||||
213 | QMessageLogger(__FILE__, 264, __PRETTY_FUNCTION__).warning() << "Failed to connect to property" << itemMetaObject->property(d.propertyIndex).name() never executed: QMessageLogger(__FILE__, 264, __PRETTY_FUNCTION__).warning() << "Failed to connect to property" << itemMetaObject->property(d.propertyIndex).name() << "(" << d.propertyIndex << ", signal index" << pd->notifyIndex() << ") of item" << item; | 0 | ||||||||||||||||||
214 | << "(" << d.propertyIndex << ", signal index" << pd->notifyIndex() never executed: QMessageLogger(__FILE__, 264, __PRETTY_FUNCTION__).warning() << "Failed to connect to property" << itemMetaObject->property(d.propertyIndex).name() << "(" << d.propertyIndex << ", signal index" << pd->notifyIndex() << ") of item" << item; | 0 | ||||||||||||||||||
215 | << ") of item" << item; never executed: QMessageLogger(__FILE__, 264, __PRETTY_FUNCTION__).warning() << "Failed to connect to property" << itemMetaObject->property(d.propertyIndex).name() << "(" << d.propertyIndex << ", signal index" << pd->notifyIndex() << ") of item" << item; | 0 | ||||||||||||||||||
216 | } executed 98 times by 5 tests: end of block Executed by:
| 98 | ||||||||||||||||||
217 | } else { | - | ||||||||||||||||||
218 | - | |||||||||||||||||||
219 | - | |||||||||||||||||||
220 | if (!item->property(d.name).isValid()
| 0-26 | ||||||||||||||||||
221 | QMessageLogger(__FILE__, 272, __PRETTY_FUNCTION__).warning("QQuickOpenGLShaderEffect: '%s' does not have a matching property!", d.name.constData()); never executed: QMessageLogger(__FILE__, 272, __PRETTY_FUNCTION__).warning("QQuickOpenGLShaderEffect: '%s' does not have a matching property!", d.name.constData()); | 0 | ||||||||||||||||||
222 | } executed 26 times by 2 tests: end of block Executed by:
| 26 | ||||||||||||||||||
223 | - | |||||||||||||||||||
224 | if (d.specialType == UniformData::Sampler
| 0-86 | ||||||||||||||||||
225 | QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(d.value)); | - | ||||||||||||||||||
226 | if (source
| 18-68 | ||||||||||||||||||
227 | if (item->window()
| 2-66 | ||||||||||||||||||
228 | QQuickItemPrivate::get(source)->refWindow(item->window()); executed 66 times by 4 tests: QQuickItemPrivate::get(source)->refWindow(item->window()); Executed by:
| 66 | ||||||||||||||||||
229 | QObject::connect(source, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "280"), host, qFlagLocation("1""sourceDestroyed(QObject*)" "\0" __FILE__ ":" "280")); | - | ||||||||||||||||||
230 | } executed 68 times by 5 tests: end of block Executed by:
| 68 | ||||||||||||||||||
231 | } executed 86 times by 5 tests: end of block Executed by:
| 86 | ||||||||||||||||||
232 | } executed 124 times by 5 tests: end of block Executed by:
| 124 | ||||||||||||||||||
233 | } executed 232 times by 6 tests: end of block Executed by:
| 232 | ||||||||||||||||||
234 | - | |||||||||||||||||||
235 | void QQuickOpenGLShaderEffectCommon::updateParseLog(bool ignoreAttributes) | - | ||||||||||||||||||
236 | { | - | ||||||||||||||||||
237 | parseLog.clear(); | - | ||||||||||||||||||
238 | if (!ignoreAttributes
| 2-88 | ||||||||||||||||||
239 | if (!attributes.contains(qtPositionAttributeName())
| 20-68 | ||||||||||||||||||
240 | parseLog += QLatin1String("Warning: Missing reference to \'") | - | ||||||||||||||||||
241 | + QLatin1String(qtPositionAttributeName()) | - | ||||||||||||||||||
242 | + QLatin1String("\'.\n"); | - | ||||||||||||||||||
243 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||
244 | if (!attributes.contains(qtTexCoordAttributeName())
| 28-60 | ||||||||||||||||||
245 | parseLog += QLatin1String("Warning: Missing reference to \'") | - | ||||||||||||||||||
246 | + QLatin1String(qtTexCoordAttributeName()) | - | ||||||||||||||||||
247 | + QLatin1String("\'.\n"); | - | ||||||||||||||||||
248 | } executed 28 times by 1 test: end of block Executed by:
| 28 | ||||||||||||||||||
249 | } executed 88 times by 4 tests: end of block Executed by:
| 88 | ||||||||||||||||||
250 | bool respectsMatrix = false; | - | ||||||||||||||||||
251 | bool respectsOpacity = false; | - | ||||||||||||||||||
252 | for (int i = 0; i < uniformData[Key::VertexShader].size()
| 74-90 | ||||||||||||||||||
253 | respectsMatrix |= uniformData[Key::VertexShader].at(i).specialType == UniformData::Matrix; executed 74 times by 5 tests: respectsMatrix |= uniformData[Key::VertexShader].at(i).specialType == UniformData::Matrix; Executed by:
| 74 | ||||||||||||||||||
254 | for (int shaderType = 0; shaderType < Key::ShaderTypeCount
| 90-180 | ||||||||||||||||||
255 | for (int i = 0; i < uniformData[shaderType].size()
| 180-188 | ||||||||||||||||||
256 | respectsOpacity |= uniformData[shaderType].at(i).specialType == UniformData::Opacity; executed 188 times by 5 tests: respectsOpacity |= uniformData[shaderType].at(i).specialType == UniformData::Opacity; Executed by:
| 188 | ||||||||||||||||||
257 | } executed 180 times by 5 tests: end of block Executed by:
| 180 | ||||||||||||||||||
258 | if (!respectsMatrix
| 24-66 | ||||||||||||||||||
259 | parseLog += QLatin1String("Warning: Vertex shader is missing reference to \'qt_Matrix\'.\n"); executed 24 times by 1 test: parseLog += QLatin1String("Warning: Vertex shader is missing reference to \'qt_Matrix\'.\n"); Executed by:
| 24 | ||||||||||||||||||
260 | if (!respectsOpacity
| 32-58 | ||||||||||||||||||
261 | parseLog += QLatin1String("Warning: Shaders are missing reference to \'qt_Opacity\'.\n"); executed 58 times by 4 tests: parseLog += QLatin1String("Warning: Shaders are missing reference to \'qt_Opacity\'.\n"); Executed by:
| 58 | ||||||||||||||||||
262 | } executed 90 times by 5 tests: end of block Executed by:
| 90 | ||||||||||||||||||
263 | - | |||||||||||||||||||
264 | void QQuickOpenGLShaderEffectCommon::lookThroughShaderCode(QQuickItem *item, | - | ||||||||||||||||||
265 | const QMetaObject *itemMetaObject, | - | ||||||||||||||||||
266 | Key::ShaderType shaderType, | - | ||||||||||||||||||
267 | const QByteArray &code) | - | ||||||||||||||||||
268 | { | - | ||||||||||||||||||
269 | QQmlPropertyCache *propCache = QQmlData::ensurePropertyCache(qmlEngine(item), item); | - | ||||||||||||||||||
270 | int index = 0; | - | ||||||||||||||||||
271 | int typeIndex = -1; | - | ||||||||||||||||||
272 | int typeLength = 0; | - | ||||||||||||||||||
273 | int nameIndex = -1; | - | ||||||||||||||||||
274 | int nameLength = 0; | - | ||||||||||||||||||
275 | const char *s = code.constData(); | - | ||||||||||||||||||
276 | VariableQualifier decl = AttributeQualifier; | - | ||||||||||||||||||
277 | while ((
| 146-210 | ||||||||||||||||||
278 | nameIndex, nameLength, shaderType)) != -1
| 146-210 | ||||||||||||||||||
279 | { | - | ||||||||||||||||||
280 | if (decl == AttributeQualifier
| 44-166 | ||||||||||||||||||
281 | if (shaderType == Key::VertexShader
| 0-44 | ||||||||||||||||||
282 | attributes.append(QByteArray(s + nameIndex, nameLength)); executed 44 times by 1 test: attributes.append(QByteArray(s + nameIndex, nameLength)); Executed by:
| 44 | ||||||||||||||||||
283 | } executed 44 times by 1 test: else {end of block Executed by:
| 44 | ||||||||||||||||||
284 | ((decl == UniformQualifier) ? static_cast<void>(0) : qt_assert("decl == UniformQualifier", __FILE__, 335)); | - | ||||||||||||||||||
285 | - | |||||||||||||||||||
286 | const int sampLen = sizeof("sampler2D") - 1; | - | ||||||||||||||||||
287 | const int sampExtLen = sizeof("samplerExternalOES") - 1; | - | ||||||||||||||||||
288 | const int opLen = sizeof("qt_Opacity") - 1; | - | ||||||||||||||||||
289 | const int matLen = sizeof("qt_Matrix") - 1; | - | ||||||||||||||||||
290 | const int srLen = sizeof("qt_SubRect_") - 1; | - | ||||||||||||||||||
291 | - | |||||||||||||||||||
292 | UniformData d; | - | ||||||||||||||||||
293 | QtPrivate::MappedSlotObject *mapper = nullptr; | - | ||||||||||||||||||
294 | d.name = QByteArray(s + nameIndex, nameLength); | - | ||||||||||||||||||
295 | if (nameLength == opLen
| 2-120 | ||||||||||||||||||
296 | d.specialType = UniformData::Opacity; | - | ||||||||||||||||||
297 | } executed 44 times by 3 tests: else if (nameLength == matLenend of block Executed by:
| 6-104 | ||||||||||||||||||
298 | d.specialType = UniformData::Matrix; | - | ||||||||||||||||||
299 | } executed 12 times by 1 test: else if (nameLength > srLenend of block Executed by:
| 0-106 | ||||||||||||||||||
300 | d.specialType = UniformData::SubRect; | - | ||||||||||||||||||
301 | } never executed: else {end of block | 0 | ||||||||||||||||||
302 | if (QQmlPropertyData *pd = propCache->property(QString::fromUtf8(d.name), nullptr, nullptr)
| 24-86 | ||||||||||||||||||
303 | if (!pd->isFunction()
| 0-86 | ||||||||||||||||||
304 | d.propertyIndex = pd->coreIndex(); executed 86 times by 3 tests: d.propertyIndex = pd->coreIndex(); Executed by:
| 86 | ||||||||||||||||||
305 | } executed 86 times by 3 tests: end of block Executed by:
| 86 | ||||||||||||||||||
306 | const int mappedId = uniformData[shaderType].size() | (shaderType << 16); | - | ||||||||||||||||||
307 | mapper = new QtPrivate::MappedSlotObject([this, mappedId](){ | - | ||||||||||||||||||
308 | this->mappedPropertyChanged(mappedId); | - | ||||||||||||||||||
309 | } executed 8 times by 2 tests: );end of block Executed by:
| 8 | ||||||||||||||||||
310 | if (typeLength == sampLen
| 0-72 | ||||||||||||||||||
311 | d.specialType = UniformData::Sampler; executed 72 times by 3 tests: d.specialType = UniformData::Sampler; Executed by:
| 72 | ||||||||||||||||||
312 | else if (typeLength == sampExtLen
| 0-38 | ||||||||||||||||||
313 | d.specialType = UniformData::SamplerExternal; never executed: d.specialType = UniformData::SamplerExternal; | 0 | ||||||||||||||||||
314 | else | - | ||||||||||||||||||
315 | d.specialType = UniformData::None; executed 38 times by 2 tests: d.specialType = UniformData::None; Executed by:
| 38 | ||||||||||||||||||
316 | d.setValueFromProperty(item, itemMetaObject); | - | ||||||||||||||||||
317 | } executed 110 times by 3 tests: end of block Executed by:
| 110 | ||||||||||||||||||
318 | uniformData[shaderType].append(d); | - | ||||||||||||||||||
319 | signalMappers[shaderType].append(mapper); | - | ||||||||||||||||||
320 | } executed 166 times by 3 tests: end of block Executed by:
| 166 | ||||||||||||||||||
321 | } | - | ||||||||||||||||||
322 | } executed 146 times by 4 tests: end of block Executed by:
| 146 | ||||||||||||||||||
323 | - | |||||||||||||||||||
324 | void QQuickOpenGLShaderEffectCommon::updateShader(QQuickItem *item, | - | ||||||||||||||||||
325 | const QMetaObject *itemMetaObject, | - | ||||||||||||||||||
326 | Key::ShaderType shaderType) | - | ||||||||||||||||||
327 | { | - | ||||||||||||||||||
328 | disconnectPropertySignals(item, shaderType); | - | ||||||||||||||||||
329 | uniformData[shaderType].clear(); | - | ||||||||||||||||||
330 | clearSignalMappers(shaderType); | - | ||||||||||||||||||
331 | if (shaderType == Key::VertexShader
| 104-118 | ||||||||||||||||||
332 | attributes.clear(); executed 104 times by 5 tests: attributes.clear(); Executed by:
| 104 | ||||||||||||||||||
333 | - | |||||||||||||||||||
334 | - | |||||||||||||||||||
335 | QUrl srcUrl(QString::fromUtf8(source.sourceCode[shaderType])); | - | ||||||||||||||||||
336 | if (!srcUrl.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive)
| 0-222 | ||||||||||||||||||
337 | if (!fileSelector
| 0 | ||||||||||||||||||
338 | fileSelector = new QFileSelector(item); | - | ||||||||||||||||||
339 | - | |||||||||||||||||||
340 | - | |||||||||||||||||||
341 | if (item->window()
| 0 | ||||||||||||||||||
342 | && item->window()->requestedFormat().profile() == QSurfaceFormat::CoreProfile
| 0 | ||||||||||||||||||
343 | fileSelector->setExtraSelectors(QStringList() << ([]() noexcept -> QString { enum { Size = sizeof(u"" "glslcore")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "glslcore" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
344 | } never executed: end of block | 0 | ||||||||||||||||||
345 | } never executed: end of block | 0 | ||||||||||||||||||
346 | const QString fn = fileSelector->select(QQmlFile::urlToLocalFileOrQrc(srcUrl)); | - | ||||||||||||||||||
347 | QFile f(fn); | - | ||||||||||||||||||
348 | if (f.open(QIODevice::ReadOnly | QIODevice::Text)
| 0 | ||||||||||||||||||
349 | source.sourceCode[shaderType] = f.readAll(); | - | ||||||||||||||||||
350 | f.close(); | - | ||||||||||||||||||
351 | } never executed: else {end of block | 0 | ||||||||||||||||||
352 | QMessageLogger(__FILE__, 403, __PRETTY_FUNCTION__).warning("ShaderEffect: Failed to read %s", QtPrivate::asString(fn).toLocal8Bit().constData()); | - | ||||||||||||||||||
353 | source.sourceCode[shaderType] = QByteArray(); | - | ||||||||||||||||||
354 | } never executed: end of block | 0 | ||||||||||||||||||
355 | } | - | ||||||||||||||||||
356 | - | |||||||||||||||||||
357 | const QByteArray &code = source.sourceCode[shaderType]; | - | ||||||||||||||||||
358 | if (code.isEmpty()
| 82-140 | ||||||||||||||||||
359 | - | |||||||||||||||||||
360 | if (shaderType == Key::VertexShader
| 14-68 | ||||||||||||||||||
361 | attributes.append(QByteArray(qtPositionAttributeName())); | - | ||||||||||||||||||
362 | attributes.append(QByteArray(qtTexCoordAttributeName())); | - | ||||||||||||||||||
363 | UniformData d; | - | ||||||||||||||||||
364 | d.name = "qt_Matrix"; | - | ||||||||||||||||||
365 | d.specialType = UniformData::Matrix; | - | ||||||||||||||||||
366 | uniformData[Key::VertexShader].append(d); | - | ||||||||||||||||||
367 | signalMappers[Key::VertexShader].append(0); | - | ||||||||||||||||||
368 | } executed 68 times by 5 tests: else if (shaderType == Key::FragmentShaderend of block Executed by:
| 0-68 | ||||||||||||||||||
369 | UniformData d; | - | ||||||||||||||||||
370 | d.name = "qt_Opacity"; | - | ||||||||||||||||||
371 | d.specialType = UniformData::Opacity; | - | ||||||||||||||||||
372 | uniformData[Key::FragmentShader].append(d); | - | ||||||||||||||||||
373 | signalMappers[Key::FragmentShader].append(0); | - | ||||||||||||||||||
374 | auto mapper = new QtPrivate::MappedSlotObject([this](){ | - | ||||||||||||||||||
375 | mappedPropertyChanged(1 | (Key::FragmentShader << 16)); | - | ||||||||||||||||||
376 | } executed 8 times by 3 tests: );end of block Executed by:
| 8 | ||||||||||||||||||
377 | const char *sourceName = "source"; | - | ||||||||||||||||||
378 | d.name = sourceName; | - | ||||||||||||||||||
379 | d.setValueFromProperty(item, itemMetaObject); | - | ||||||||||||||||||
380 | d.specialType = UniformData::Sampler; | - | ||||||||||||||||||
381 | uniformData[Key::FragmentShader].append(d); | - | ||||||||||||||||||
382 | signalMappers[Key::FragmentShader].append(mapper); | - | ||||||||||||||||||
383 | } executed 14 times by 4 tests: end of block Executed by:
| 14 | ||||||||||||||||||
384 | } executed 82 times by 6 tests: else {end of block Executed by:
| 82 | ||||||||||||||||||
385 | lookThroughShaderCode(item, itemMetaObject, shaderType, code); | - | ||||||||||||||||||
386 | } executed 140 times by 4 tests: end of block Executed by:
| 140 | ||||||||||||||||||
387 | - | |||||||||||||||||||
388 | connectPropertySignals(item, itemMetaObject, shaderType); | - | ||||||||||||||||||
389 | } executed 222 times by 6 tests: end of block Executed by:
| 222 | ||||||||||||||||||
390 | - | |||||||||||||||||||
391 | void QQuickOpenGLShaderEffectCommon::updateMaterial(QQuickOpenGLShaderEffectNode *node, | - | ||||||||||||||||||
392 | QQuickOpenGLShaderEffectMaterial *material, | - | ||||||||||||||||||
393 | bool updateUniforms, bool updateUniformValues, | - | ||||||||||||||||||
394 | bool updateTextureProviders) | - | ||||||||||||||||||
395 | { | - | ||||||||||||||||||
396 | if (updateUniforms
| 73-278 | ||||||||||||||||||
397 | for (int i = 0; i < material->textureProviders.size()
| 0-73 | ||||||||||||||||||
398 | QSGTextureProvider *t = material->textureProviders.at(i); | - | ||||||||||||||||||
399 | if (t
| 0 | ||||||||||||||||||
400 | QObject::disconnect(t, qFlagLocation("2""textureChanged()" "\0" __FILE__ ":" "451"), node, qFlagLocation("1""markDirtyTexture()" "\0" __FILE__ ":" "451")); | - | ||||||||||||||||||
401 | QObject::disconnect(t, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "452"), node, qFlagLocation("1""textureProviderDestroyed(QObject*)" "\0" __FILE__ ":" "452")); | - | ||||||||||||||||||
402 | } never executed: end of block | 0 | ||||||||||||||||||
403 | } never executed: end of block | 0 | ||||||||||||||||||
404 | - | |||||||||||||||||||
405 | - | |||||||||||||||||||
406 | int textureProviderCount = 0; | - | ||||||||||||||||||
407 | for (int shaderType = 0; shaderType < Key::ShaderTypeCount
| 73-146 | ||||||||||||||||||
408 | for (int i = 0; i < uniformData[shaderType].size()
| 146-213 | ||||||||||||||||||
409 | if (uniformData[shaderType].at(i).specialType == UniformData::Sampler
| 66-147 | ||||||||||||||||||
410 | uniformData[shaderType].at(i).specialType == UniformData::SamplerExternal
| 0-147 | ||||||||||||||||||
411 | ++ executed 66 times by 5 tests: textureProviderCount;++textureProviderCount; Executed by:
executed 66 times by 5 tests: ++textureProviderCount; Executed by:
| 66 | ||||||||||||||||||
412 | } executed 213 times by 6 tests: end of block Executed by:
| 213 | ||||||||||||||||||
413 | material->uniforms[shaderType] = uniformData[shaderType]; | - | ||||||||||||||||||
414 | } executed 146 times by 6 tests: end of block Executed by:
| 146 | ||||||||||||||||||
415 | material->textureProviders.fill(0, textureProviderCount); | - | ||||||||||||||||||
416 | updateUniformValues = false; | - | ||||||||||||||||||
417 | updateTextureProviders = true; | - | ||||||||||||||||||
418 | } executed 73 times by 6 tests: end of block Executed by:
| 73 | ||||||||||||||||||
419 | - | |||||||||||||||||||
420 | if (updateUniformValues
| 73-278 | ||||||||||||||||||
421 | for (int shaderType = 0; shaderType < Key::ShaderTypeCount
| 278-556 | ||||||||||||||||||
422 | ((uniformData[shaderType].size() == material->uniforms[shaderType].size()) ? static_cast<void>(0) : qt_assert("uniformData[shaderType].size() == material->uniforms[shaderType].size()", __FILE__, 473)); | - | ||||||||||||||||||
423 | for (int i = 0; i < uniformData[shaderType].size()
| 556-1112 | ||||||||||||||||||
424 | material->uniforms[shaderType][i].value = uniformData[shaderType].at(i).value; executed 1112 times by 1 test: material->uniforms[shaderType][i].value = uniformData[shaderType].at(i).value; Executed by:
| 1112 | ||||||||||||||||||
425 | } executed 556 times by 1 test: end of block Executed by:
| 556 | ||||||||||||||||||
426 | } executed 278 times by 1 test: end of block Executed by:
| 278 | ||||||||||||||||||
427 | - | |||||||||||||||||||
428 | if (updateTextureProviders
| 73-278 | ||||||||||||||||||
429 | int index = 0; | - | ||||||||||||||||||
430 | for (int shaderType = 0; shaderType < Key::ShaderTypeCount
| 73-146 | ||||||||||||||||||
431 | for (int i = 0; i < uniformData[shaderType].size()
| 146-213 | ||||||||||||||||||
432 | const UniformData &d = uniformData[shaderType].at(i); | - | ||||||||||||||||||
433 | if (d.specialType != UniformData::Sampler
| 0-147 | ||||||||||||||||||
434 | continue; executed 147 times by 6 tests: continue; Executed by:
| 147 | ||||||||||||||||||
435 | QSGTextureProvider *oldProvider = material->textureProviders.at(index); | - | ||||||||||||||||||
436 | QSGTextureProvider *newProvider = nullptr; | - | ||||||||||||||||||
437 | QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(d.value)); | - | ||||||||||||||||||
438 | if (source
| 0-62 | ||||||||||||||||||
439 | newProvider = source->textureProvider(); executed 62 times by 5 tests: newProvider = source->textureProvider(); Executed by:
| 62 | ||||||||||||||||||
440 | if (newProvider != oldProvider
| 4-62 | ||||||||||||||||||
441 | if (oldProvider
| 0-62 | ||||||||||||||||||
442 | QObject::disconnect(oldProvider, qFlagLocation("2""textureChanged()" "\0" __FILE__ ":" "493"), node, qFlagLocation("1""markDirtyTexture()" "\0" __FILE__ ":" "493")); | - | ||||||||||||||||||
443 | QObject::disconnect(oldProvider, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "494"), node, qFlagLocation("1""textureProviderDestroyed(QObject*)" "\0" __FILE__ ":" "494")); | - | ||||||||||||||||||
444 | } never executed: end of block | 0 | ||||||||||||||||||
445 | if (newProvider
| 0-62 | ||||||||||||||||||
446 | ((newProvider->thread() == QThread::currentThread()) ? static_cast<void>(0) : qt_assert_x("QQuickOpenGLShaderEffect::updatePaintNode", "Texture provider must belong to the rendering thread", | - | ||||||||||||||||||
447 | - | |||||||||||||||||||
448 | __FILE__ | - | ||||||||||||||||||
449 | , | - | ||||||||||||||||||
450 | - | |||||||||||||||||||
451 | 499 | - | ||||||||||||||||||
452 | )) | - | ||||||||||||||||||
453 | - | |||||||||||||||||||
454 | ; | - | ||||||||||||||||||
455 | QObject::connect(newProvider, qFlagLocation("2""textureChanged()" "\0" __FILE__ ":" "500"), node, qFlagLocation("1""markDirtyTexture()" "\0" __FILE__ ":" "500")); | - | ||||||||||||||||||
456 | QObject::connect(newProvider, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "501"), node, qFlagLocation("1""textureProviderDestroyed(QObject*)" "\0" __FILE__ ":" "501")); | - | ||||||||||||||||||
457 | } executed 62 times by 5 tests: else {end of block Executed by:
| 62 | ||||||||||||||||||
458 | const char *typeName = source
| 0 | ||||||||||||||||||
459 | QMessageLogger(__FILE__, 504, __PRETTY_FUNCTION__).warning("ShaderEffect: Property '%s' is not assigned a valid texture provider (%s).", | - | ||||||||||||||||||
460 | d.name.constData(), typeName); | - | ||||||||||||||||||
461 | } never executed: end of block | 0 | ||||||||||||||||||
462 | material->textureProviders[index] = newProvider; | - | ||||||||||||||||||
463 | } executed 62 times by 5 tests: end of block Executed by:
| 62 | ||||||||||||||||||
464 | ++index; | - | ||||||||||||||||||
465 | } executed 66 times by 5 tests: end of block Executed by:
| 66 | ||||||||||||||||||
466 | } executed 146 times by 6 tests: end of block Executed by:
| 146 | ||||||||||||||||||
467 | ((index == material->textureProviders.size()) ? static_cast<void>(0) : qt_assert("index == material->textureProviders.size()", __FILE__, 512)); | - | ||||||||||||||||||
468 | } executed 73 times by 6 tests: end of block Executed by:
| 73 | ||||||||||||||||||
469 | } executed 351 times by 6 tests: end of block Executed by:
| 351 | ||||||||||||||||||
470 | - | |||||||||||||||||||
471 | void QQuickOpenGLShaderEffectCommon::updateWindow(QQuickWindow *window) | - | ||||||||||||||||||
472 | { | - | ||||||||||||||||||
473 | - | |||||||||||||||||||
474 | if (window
| 77-79 | ||||||||||||||||||
475 | for (int shaderType = 0; shaderType < Key::ShaderTypeCount
| 79-158 | ||||||||||||||||||
476 | for (int i = 0; i < uniformData[shaderType].size()
| 16-158 | ||||||||||||||||||
477 | const UniformData &d = uniformData[shaderType].at(i); | - | ||||||||||||||||||
478 | if (d.specialType == UniformData::Sampler
| 0-12 | ||||||||||||||||||
479 | QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(d.value)); | - | ||||||||||||||||||
480 | if (source
| 2 | ||||||||||||||||||
481 | QQuickItemPrivate::get(source)->refWindow(window); executed 2 times by 1 test: QQuickItemPrivate::get(source)->refWindow(window); Executed by:
| 2 | ||||||||||||||||||
482 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
483 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||
484 | } executed 158 times by 6 tests: end of block Executed by:
| 158 | ||||||||||||||||||
485 | } executed 79 times by 6 tests: else {end of block Executed by:
| 79 | ||||||||||||||||||
486 | for (int shaderType = 0; shaderType < Key::ShaderTypeCount
| 77-154 | ||||||||||||||||||
487 | for (int i = 0; i < uniformData[shaderType].size()
| 154-224 | ||||||||||||||||||
488 | const UniformData &d = uniformData[shaderType].at(i); | - | ||||||||||||||||||
489 | if (d.specialType == UniformData::Sampler
| 0-154 | ||||||||||||||||||
490 | QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(d.value)); | - | ||||||||||||||||||
491 | if (source
| 4-66 | ||||||||||||||||||
492 | QQuickItemPrivate::get(source)->derefWindow(); executed 66 times by 4 tests: QQuickItemPrivate::get(source)->derefWindow(); Executed by:
| 66 | ||||||||||||||||||
493 | } executed 70 times by 4 tests: end of block Executed by:
| 70 | ||||||||||||||||||
494 | } executed 224 times by 5 tests: end of block Executed by:
| 224 | ||||||||||||||||||
495 | } executed 154 times by 5 tests: end of block Executed by:
| 154 | ||||||||||||||||||
496 | } executed 77 times by 5 tests: end of block Executed by:
| 77 | ||||||||||||||||||
497 | } | - | ||||||||||||||||||
498 | - | |||||||||||||||||||
499 | void QQuickOpenGLShaderEffectCommon::sourceDestroyed(QObject *object) | - | ||||||||||||||||||
500 | { | - | ||||||||||||||||||
501 | for (int shaderType = 0; shaderType < Key::ShaderTypeCount
| 47-94 | ||||||||||||||||||
502 | for (int i = 0; i < uniformData[shaderType].size()
| 94-140 | ||||||||||||||||||
503 | UniformData &d = uniformData[shaderType][i]; | - | ||||||||||||||||||
504 | if ((d.specialType == UniformData::Sampler
| 0-87 | ||||||||||||||||||
505 | if (qvariant_cast<QObject *>(d.value) == object
| 4-47 | ||||||||||||||||||
506 | d.value = QVariant(); executed 47 times by 3 tests: d.value = QVariant(); Executed by:
| 47 | ||||||||||||||||||
507 | } executed 51 times by 3 tests: end of block Executed by:
| 51 | ||||||||||||||||||
508 | } executed 140 times by 3 tests: end of block Executed by:
| 140 | ||||||||||||||||||
509 | } executed 94 times by 3 tests: end of block Executed by:
| 94 | ||||||||||||||||||
510 | } executed 47 times by 3 tests: end of block Executed by:
| 47 | ||||||||||||||||||
511 | - | |||||||||||||||||||
512 | static bool qquick_uniqueInUniformData(QQuickItem *source, const QVector<QQuickOpenGLShaderEffectMaterial::UniformData> *uniformData, int typeToSkip, int indexToSkip) | - | ||||||||||||||||||
513 | { | - | ||||||||||||||||||
514 | for (int s=0; s<QQuickOpenGLShaderEffectMaterialKey::ShaderTypeCount
| 0 | ||||||||||||||||||
515 | for (int i=0; i<uniformData[s].size()
| 0 | ||||||||||||||||||
516 | if (s == typeToSkip
| 0 | ||||||||||||||||||
517 | continue; never executed: continue; | 0 | ||||||||||||||||||
518 | const QQuickOpenGLShaderEffectMaterial::UniformData &d = uniformData[s][i]; | - | ||||||||||||||||||
519 | if ((d.specialType == QQuickOpenGLShaderEffectMaterial::UniformData::Sampler
| 0 | ||||||||||||||||||
520 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||||||||
521 | } never executed: end of block | 0 | ||||||||||||||||||
522 | } never executed: end of block | 0 | ||||||||||||||||||
523 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||||||||
524 | } | - | ||||||||||||||||||
525 | - | |||||||||||||||||||
526 | void QQuickOpenGLShaderEffectCommon::propertyChanged(QQuickItem *item, | - | ||||||||||||||||||
527 | const QMetaObject *itemMetaObject, | - | ||||||||||||||||||
528 | int mappedId, bool *textureProviderChanged) | - | ||||||||||||||||||
529 | { | - | ||||||||||||||||||
530 | Key::ShaderType shaderType = Key::ShaderType(mappedId >> 16); | - | ||||||||||||||||||
531 | int index = mappedId & 0xffff; | - | ||||||||||||||||||
532 | UniformData &d = uniformData[shaderType][index]; | - | ||||||||||||||||||
533 | if (d.specialType == UniformData::Sampler
| 0-12 | ||||||||||||||||||
534 | QQuickItem *source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(d.value)); | - | ||||||||||||||||||
535 | if (source
| 0-12 | ||||||||||||||||||
536 | if (item->window()
| 0 | ||||||||||||||||||
537 | QQuickItemPrivate::get(source)->derefWindow(); never executed: QQuickItemPrivate::get(source)->derefWindow(); | 0 | ||||||||||||||||||
538 | - | |||||||||||||||||||
539 | - | |||||||||||||||||||
540 | - | |||||||||||||||||||
541 | - | |||||||||||||||||||
542 | - | |||||||||||||||||||
543 | if (qquick_uniqueInUniformData(source, uniformData, shaderType, index)
| 0 | ||||||||||||||||||
544 | QObject::disconnect(source, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "589"), host, qFlagLocation("1""sourceDestroyed(QObject*)" "\0" __FILE__ ":" "589")); never executed: QObject::disconnect(source, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "589"), host, qFlagLocation("1""sourceDestroyed(QObject*)" "\0" __FILE__ ":" "589")); | 0 | ||||||||||||||||||
545 | } never executed: end of block | 0 | ||||||||||||||||||
546 | - | |||||||||||||||||||
547 | d.setValueFromProperty(item, itemMetaObject); | - | ||||||||||||||||||
548 | - | |||||||||||||||||||
549 | source = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(d.value)); | - | ||||||||||||||||||
550 | if (source
| 6 | ||||||||||||||||||
551 | - | |||||||||||||||||||
552 | - | |||||||||||||||||||
553 | - | |||||||||||||||||||
554 | - | |||||||||||||||||||
555 | if (item->window()
| 0-6 | ||||||||||||||||||
556 | QQuickItemPrivate::get(source)->refWindow(item->window()); executed 6 times by 2 tests: QQuickItemPrivate::get(source)->refWindow(item->window()); Executed by:
| 6 | ||||||||||||||||||
557 | QObject::connect(source, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "602"), host, qFlagLocation("1""sourceDestroyed(QObject*)" "\0" __FILE__ ":" "602")); | - | ||||||||||||||||||
558 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
559 | if (textureProviderChanged
| 0-12 | ||||||||||||||||||
560 | * executed 12 times by 4 tests: textureProviderChanged = true;*textureProviderChanged = true; Executed by:
executed 12 times by 4 tests: *textureProviderChanged = true; Executed by:
| 12 | ||||||||||||||||||
561 | } executed 12 times by 4 tests: else {end of block Executed by:
| 12 | ||||||||||||||||||
562 | d.setValueFromProperty(item, itemMetaObject); | - | ||||||||||||||||||
563 | if (textureProviderChanged
| 0-4 | ||||||||||||||||||
564 | * executed 4 times by 1 test: textureProviderChanged = false;*textureProviderChanged = false; Executed by:
executed 4 times by 1 test: *textureProviderChanged = false; Executed by:
| 4 | ||||||||||||||||||
565 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
566 | } | - | ||||||||||||||||||
567 | - | |||||||||||||||||||
568 | void QQuickOpenGLShaderEffectCommon::clearSignalMappers(int shader) | - | ||||||||||||||||||
569 | { | - | ||||||||||||||||||
570 | for (auto mapper : qAsConst(signalMappers[shader])) { | - | ||||||||||||||||||
571 | if (mapper
| 122-154 | ||||||||||||||||||
572 | mapper->destroyIfLastRef(); executed 122 times by 4 tests: mapper->destroyIfLastRef(); Executed by:
| 122 | ||||||||||||||||||
573 | } executed 276 times by 5 tests: end of block Executed by:
| 276 | ||||||||||||||||||
574 | signalMappers[shader].clear(); | - | ||||||||||||||||||
575 | } executed 464 times by 6 tests: end of block Executed by:
| 464 | ||||||||||||||||||
576 | - | |||||||||||||||||||
577 | QQuickOpenGLShaderEffect::QQuickOpenGLShaderEffect(QQuickShaderEffect *item, QObject *parent) | - | ||||||||||||||||||
578 | : QObject(parent) | - | ||||||||||||||||||
579 | , m_item(item) | - | ||||||||||||||||||
580 | , m_itemMetaObject(nullptr) | - | ||||||||||||||||||
581 | , m_meshResolution(1, 1) | - | ||||||||||||||||||
582 | , m_mesh(nullptr) | - | ||||||||||||||||||
583 | , m_cullMode(QQuickShaderEffect::NoCulling) | - | ||||||||||||||||||
584 | , m_status(QQuickShaderEffect::Uncompiled) | - | ||||||||||||||||||
585 | , m_common(this, [this](int mappedId){this->propertyChanged(mappedId);}) | - | ||||||||||||||||||
586 | , m_blending(true) | - | ||||||||||||||||||
587 | , m_dirtyUniforms(true) | - | ||||||||||||||||||
588 | , m_dirtyUniformValues(true) | - | ||||||||||||||||||
589 | , m_dirtyTextureProviders(true) | - | ||||||||||||||||||
590 | , m_dirtyProgram(true) | - | ||||||||||||||||||
591 | , m_dirtyParseLog(true) | - | ||||||||||||||||||
592 | , m_dirtyMesh(true) | - | ||||||||||||||||||
593 | , m_dirtyGeometry(true) | - | ||||||||||||||||||
594 | , m_customVertexShader(false) | - | ||||||||||||||||||
595 | , m_supportsAtlasTextures(false) | - | ||||||||||||||||||
596 | , m_vertNeedsUpdate(true) | - | ||||||||||||||||||
597 | , m_fragNeedsUpdate(true) | - | ||||||||||||||||||
598 | { | - | ||||||||||||||||||
599 | } executed 108 times by 5 tests: end of block Executed by:
| 108 | ||||||||||||||||||
600 | - | |||||||||||||||||||
601 | QQuickOpenGLShaderEffect::~QQuickOpenGLShaderEffect() | - | ||||||||||||||||||
602 | { | - | ||||||||||||||||||
603 | for (int shaderType = 0; shaderType < Key::ShaderTypeCount
| 106-212 | ||||||||||||||||||
604 | m_common.disconnectPropertySignals(m_item, Key::ShaderType(shaderType)); executed 212 times by 4 tests: m_common.disconnectPropertySignals(m_item, Key::ShaderType(shaderType)); Executed by:
| 212 | ||||||||||||||||||
605 | } executed 106 times by 4 tests: end of block Executed by:
| 106 | ||||||||||||||||||
606 | - | |||||||||||||||||||
607 | void QQuickOpenGLShaderEffect::setFragmentShader(const QByteArray &code) | - | ||||||||||||||||||
608 | { | - | ||||||||||||||||||
609 | if (m_common.source.sourceCode[Key::FragmentShader].constData() == code.constData()
| 0-100 | ||||||||||||||||||
610 | return; never executed: return; | 0 | ||||||||||||||||||
611 | m_common.source.sourceCode[Key::FragmentShader] = code; | - | ||||||||||||||||||
612 | m_dirtyProgram = true; | - | ||||||||||||||||||
613 | m_dirtyParseLog = true; | - | ||||||||||||||||||
614 | - | |||||||||||||||||||
615 | m_fragNeedsUpdate = true; | - | ||||||||||||||||||
616 | if (m_item->isComponentComplete()
| 40-60 | ||||||||||||||||||
617 | maybeUpdateShaders(); executed 40 times by 1 test: maybeUpdateShaders(); Executed by:
| 40 | ||||||||||||||||||
618 | - | |||||||||||||||||||
619 | m_item->update(); | - | ||||||||||||||||||
620 | if (m_status != QQuickShaderEffect::Uncompiled
| 0-100 | ||||||||||||||||||
621 | m_status = QQuickShaderEffect::Uncompiled; | - | ||||||||||||||||||
622 | m_item->statusChanged(); | - | ||||||||||||||||||
623 | } never executed: end of block | 0 | ||||||||||||||||||
624 | m_item->fragmentShaderChanged(); | - | ||||||||||||||||||
625 | } executed 100 times by 4 tests: end of block Executed by:
| 100 | ||||||||||||||||||
626 | - | |||||||||||||||||||
627 | void QQuickOpenGLShaderEffect::setVertexShader(const QByteArray &code) | - | ||||||||||||||||||
628 | { | - | ||||||||||||||||||
629 | if (m_common.source.sourceCode[Key::VertexShader].constData() == code.constData()
| 0-36 | ||||||||||||||||||
630 | return; never executed: return; | 0 | ||||||||||||||||||
631 | m_common.source.sourceCode[Key::VertexShader] = code; | - | ||||||||||||||||||
632 | m_dirtyProgram = true; | - | ||||||||||||||||||
633 | m_dirtyParseLog = true; | - | ||||||||||||||||||
634 | m_customVertexShader = true; | - | ||||||||||||||||||
635 | - | |||||||||||||||||||
636 | m_vertNeedsUpdate = true; | - | ||||||||||||||||||
637 | if (m_item->isComponentComplete()
| 0-36 | ||||||||||||||||||
638 | maybeUpdateShaders(); executed 36 times by 1 test: maybeUpdateShaders(); Executed by:
| 36 | ||||||||||||||||||
639 | - | |||||||||||||||||||
640 | m_item->update(); | - | ||||||||||||||||||
641 | if (m_status != QQuickShaderEffect::Uncompiled
| 0-36 | ||||||||||||||||||
642 | m_status = QQuickShaderEffect::Uncompiled; | - | ||||||||||||||||||
643 | m_item->statusChanged(); | - | ||||||||||||||||||
644 | } never executed: end of block | 0 | ||||||||||||||||||
645 | m_item->vertexShaderChanged(); | - | ||||||||||||||||||
646 | } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||||||||||||||
647 | - | |||||||||||||||||||
648 | void QQuickOpenGLShaderEffect::setBlending(bool enable) | - | ||||||||||||||||||
649 | { | - | ||||||||||||||||||
650 | if (blending() == enable
| 0 | ||||||||||||||||||
651 | return; never executed: return; | 0 | ||||||||||||||||||
652 | - | |||||||||||||||||||
653 | m_blending = enable; | - | ||||||||||||||||||
654 | m_item->update(); | - | ||||||||||||||||||
655 | - | |||||||||||||||||||
656 | m_item->blendingChanged(); | - | ||||||||||||||||||
657 | } never executed: end of block | 0 | ||||||||||||||||||
658 | - | |||||||||||||||||||
659 | QVariant QQuickOpenGLShaderEffect::mesh() const | - | ||||||||||||||||||
660 | { | - | ||||||||||||||||||
661 | return never executed: m_mesh ? qVariantFromValue(static_cast<QObject *>(m_mesh))return m_mesh ? qVariantFromValue(static_cast<QObject *>(m_mesh)) : qVariantFromValue(m_meshResolution); never executed: return m_mesh ? qVariantFromValue(static_cast<QObject *>(m_mesh)) : qVariantFromValue(m_meshResolution); | 0 | ||||||||||||||||||
662 | : qVariantFromValue(m_meshResolution); never executed: return m_mesh ? qVariantFromValue(static_cast<QObject *>(m_mesh)) : qVariantFromValue(m_meshResolution); | 0 | ||||||||||||||||||
663 | } | - | ||||||||||||||||||
664 | - | |||||||||||||||||||
665 | void QQuickOpenGLShaderEffect::setMesh(const QVariant &mesh) | - | ||||||||||||||||||
666 | { | - | ||||||||||||||||||
667 | QQuickShaderEffectMesh *newMesh = qobject_cast<QQuickShaderEffectMesh *>(qvariant_cast<QObject *>(mesh)); | - | ||||||||||||||||||
668 | if (newMesh
| 0-2 | ||||||||||||||||||
669 | return; never executed: return; | 0 | ||||||||||||||||||
670 | if (m_mesh
| 0-2 | ||||||||||||||||||
671 | disconnect(m_mesh, qFlagLocation("2""geometryChanged()" "\0" __FILE__ ":" "716"), this, nullptr); never executed: disconnect(m_mesh, qFlagLocation("2""geometryChanged()" "\0" __FILE__ ":" "716"), this, nullptr); | 0 | ||||||||||||||||||
672 | m_mesh = newMesh; | - | ||||||||||||||||||
673 | if (m_mesh
| 0-2 | ||||||||||||||||||
674 | connect(m_mesh, qFlagLocation("2""geometryChanged()" "\0" __FILE__ ":" "719"), this, qFlagLocation("1""updateGeometry()" "\0" __FILE__ ":" "719")); | - | ||||||||||||||||||
675 | } executed 2 times by 1 test: else {end of block Executed by:
| 2 | ||||||||||||||||||
676 | if (mesh.canConvert<QSize>()
| 0 | ||||||||||||||||||
677 | m_meshResolution = mesh.toSize(); | - | ||||||||||||||||||
678 | } never executed: else {end of block | 0 | ||||||||||||||||||
679 | QList<QByteArray> res = mesh.toByteArray().split('x'); | - | ||||||||||||||||||
680 | bool ok = res.size() == 2; | - | ||||||||||||||||||
681 | if (ok
| 0 | ||||||||||||||||||
682 | int w = res.at(0).toInt(&ok); | - | ||||||||||||||||||
683 | if (ok
| 0 | ||||||||||||||||||
684 | int h = res.at(1).toInt(&ok); | - | ||||||||||||||||||
685 | if (ok
| 0 | ||||||||||||||||||
686 | m_meshResolution = QSize(w, h); never executed: m_meshResolution = QSize(w, h); | 0 | ||||||||||||||||||
687 | } never executed: end of block | 0 | ||||||||||||||||||
688 | } never executed: end of block | 0 | ||||||||||||||||||
689 | if (!ok
| 0 | ||||||||||||||||||
690 | QMessageLogger(__FILE__, 735, __PRETTY_FUNCTION__).warning("ShaderEffect: mesh property must be size or object deriving from QQuickShaderEffectMesh."); never executed: QMessageLogger(__FILE__, 735, __PRETTY_FUNCTION__).warning("ShaderEffect: mesh property must be size or object deriving from QQuickShaderEffectMesh."); | 0 | ||||||||||||||||||
691 | } never executed: end of block | 0 | ||||||||||||||||||
692 | m_defaultMesh.setResolution(m_meshResolution); | - | ||||||||||||||||||
693 | } never executed: end of block | 0 | ||||||||||||||||||
694 | - | |||||||||||||||||||
695 | m_dirtyMesh = true; | - | ||||||||||||||||||
696 | m_dirtyParseLog = true; | - | ||||||||||||||||||
697 | m_item->update(); | - | ||||||||||||||||||
698 | m_item->meshChanged(); | - | ||||||||||||||||||
699 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
700 | - | |||||||||||||||||||
701 | void QQuickOpenGLShaderEffect::setCullMode(QQuickShaderEffect::CullMode face) | - | ||||||||||||||||||
702 | { | - | ||||||||||||||||||
703 | if (face == m_cullMode
| 0 | ||||||||||||||||||
704 | return; never executed: return; | 0 | ||||||||||||||||||
705 | m_cullMode = face; | - | ||||||||||||||||||
706 | m_item->update(); | - | ||||||||||||||||||
707 | m_item->cullModeChanged(); | - | ||||||||||||||||||
708 | } never executed: end of block | 0 | ||||||||||||||||||
709 | - | |||||||||||||||||||
710 | void QQuickOpenGLShaderEffect::setSupportsAtlasTextures(bool supports) | - | ||||||||||||||||||
711 | { | - | ||||||||||||||||||
712 | if (supports == m_supportsAtlasTextures
| 0-4 | ||||||||||||||||||
713 | return; never executed: return; | 0 | ||||||||||||||||||
714 | m_supportsAtlasTextures = supports; | - | ||||||||||||||||||
715 | updateGeometry(); | - | ||||||||||||||||||
716 | m_item->supportsAtlasTexturesChanged(); | - | ||||||||||||||||||
717 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
718 | - | |||||||||||||||||||
719 | QString QQuickOpenGLShaderEffect::parseLog() | - | ||||||||||||||||||
720 | { | - | ||||||||||||||||||
721 | maybeUpdateShaders(true); | - | ||||||||||||||||||
722 | - | |||||||||||||||||||
723 | if (m_dirtyParseLog
| 0-90 | ||||||||||||||||||
724 | m_common.updateParseLog(m_mesh != nullptr); | - | ||||||||||||||||||
725 | m_dirtyParseLog = false; | - | ||||||||||||||||||
726 | } executed 90 times by 5 tests: end of block Executed by:
| 90 | ||||||||||||||||||
727 | return executed 90 times by 5 tests: m_common.parseLog;return m_common.parseLog; Executed by:
executed 90 times by 5 tests: return m_common.parseLog; Executed by:
| 90 | ||||||||||||||||||
728 | } | - | ||||||||||||||||||
729 | - | |||||||||||||||||||
730 | void QQuickOpenGLShaderEffect::handleEvent(QEvent *event) | - | ||||||||||||||||||
731 | { | - | ||||||||||||||||||
732 | if (event->type() == QEvent::DynamicPropertyChange
| 0-32 | ||||||||||||||||||
733 | QDynamicPropertyChangeEvent *e = static_cast<QDynamicPropertyChangeEvent *>(event); | - | ||||||||||||||||||
734 | for (int shaderType = 0; shaderType < Key::ShaderTypeCount
| 32-64 | ||||||||||||||||||
735 | for (int i = 0; i < m_common.uniformData[shaderType].size()
| 0-64 | ||||||||||||||||||
736 | if (m_common.uniformData[shaderType].at(i).name == e->propertyName()
| 0 | ||||||||||||||||||
737 | bool textureProviderChanged; | - | ||||||||||||||||||
738 | m_common.propertyChanged(m_item, m_itemMetaObject, | - | ||||||||||||||||||
739 | (shaderType << 16) | i, &textureProviderChanged); | - | ||||||||||||||||||
740 | m_dirtyTextureProviders |= textureProviderChanged; | - | ||||||||||||||||||
741 | m_dirtyUniformValues = true; | - | ||||||||||||||||||
742 | m_item->update(); | - | ||||||||||||||||||
743 | } never executed: end of block | 0 | ||||||||||||||||||
744 | } never executed: end of block | 0 | ||||||||||||||||||
745 | } executed 64 times by 2 tests: end of block Executed by:
| 64 | ||||||||||||||||||
746 | } executed 32 times by 2 tests: end of block Executed by:
| 32 | ||||||||||||||||||
747 | } executed 32 times by 2 tests: end of block Executed by:
| 32 | ||||||||||||||||||
748 | - | |||||||||||||||||||
749 | void QQuickOpenGLShaderEffect::updateGeometry() | - | ||||||||||||||||||
750 | { | - | ||||||||||||||||||
751 | m_dirtyGeometry = true; | - | ||||||||||||||||||
752 | m_item->update(); | - | ||||||||||||||||||
753 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
754 | - | |||||||||||||||||||
755 | void QQuickOpenGLShaderEffect::updateGeometryIfAtlased() | - | ||||||||||||||||||
756 | { | - | ||||||||||||||||||
757 | if (m_supportsAtlasTextures
| 0-236 | ||||||||||||||||||
758 | updateGeometry(); never executed: updateGeometry(); | 0 | ||||||||||||||||||
759 | } executed 236 times by 2 tests: end of block Executed by:
| 236 | ||||||||||||||||||
760 | - | |||||||||||||||||||
761 | void QQuickOpenGLShaderEffect::updateLogAndStatus(const QString &log, int status) | - | ||||||||||||||||||
762 | { | - | ||||||||||||||||||
763 | m_log = parseLog() + log; | - | ||||||||||||||||||
764 | m_status = QQuickShaderEffect::Status(status); | - | ||||||||||||||||||
765 | m_item->logChanged(); | - | ||||||||||||||||||
766 | m_item->statusChanged(); | - | ||||||||||||||||||
767 | } executed 54 times by 5 tests: end of block Executed by:
| 54 | ||||||||||||||||||
768 | - | |||||||||||||||||||
769 | void QQuickOpenGLShaderEffect::sourceDestroyed(QObject *object) | - | ||||||||||||||||||
770 | { | - | ||||||||||||||||||
771 | m_common.sourceDestroyed(object); | - | ||||||||||||||||||
772 | } executed 45 times by 3 tests: end of block Executed by:
| 45 | ||||||||||||||||||
773 | - | |||||||||||||||||||
774 | void QQuickOpenGLShaderEffect::propertyChanged(int mappedId) | - | ||||||||||||||||||
775 | { | - | ||||||||||||||||||
776 | bool textureProviderChanged; | - | ||||||||||||||||||
777 | m_common.propertyChanged(m_item, m_itemMetaObject, mappedId, &textureProviderChanged); | - | ||||||||||||||||||
778 | m_dirtyTextureProviders |= textureProviderChanged; | - | ||||||||||||||||||
779 | m_dirtyUniformValues = true; | - | ||||||||||||||||||
780 | m_item->update(); | - | ||||||||||||||||||
781 | } executed 14 times by 3 tests: end of block Executed by:
| 14 | ||||||||||||||||||
782 | - | |||||||||||||||||||
783 | void QQuickOpenGLShaderEffect::handleGeometryChanged(const QRectF &, const QRectF &) | - | ||||||||||||||||||
784 | { | - | ||||||||||||||||||
785 | m_dirtyGeometry = true; | - | ||||||||||||||||||
786 | } executed 122 times by 5 tests: end of block Executed by:
| 122 | ||||||||||||||||||
787 | - | |||||||||||||||||||
788 | QSGNode *QQuickOpenGLShaderEffect::handleUpdatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) | - | ||||||||||||||||||
789 | { | - | ||||||||||||||||||
790 | QQuickOpenGLShaderEffectNode *node = static_cast<QQuickOpenGLShaderEffectNode *>(oldNode); | - | ||||||||||||||||||
791 | - | |||||||||||||||||||
792 | - | |||||||||||||||||||
793 | if (m_common.attributes.isEmpty()
| 0-72 | ||||||||||||||||||
794 | if (node
| 0-8 | ||||||||||||||||||
795 | delete node; never executed: delete node; | 0 | ||||||||||||||||||
796 | return executed 8 times by 1 test: nullptr;return nullptr; Executed by:
executed 8 times by 1 test: return nullptr; Executed by:
| 8 | ||||||||||||||||||
797 | } | - | ||||||||||||||||||
798 | - | |||||||||||||||||||
799 | if (!node
| 0-64 | ||||||||||||||||||
800 | node = new QQuickOpenGLShaderEffectNode; | - | ||||||||||||||||||
801 | node->setMaterial(new QQuickOpenGLShaderEffectMaterial(node)); | - | ||||||||||||||||||
802 | node->setFlag(QSGNode::OwnsMaterial, true); | - | ||||||||||||||||||
803 | m_dirtyProgram = true; | - | ||||||||||||||||||
804 | m_dirtyUniforms = true; | - | ||||||||||||||||||
805 | m_dirtyGeometry = true; | - | ||||||||||||||||||
806 | connect(node, qFlagLocation("2""logAndStatusChanged(QString,int)" "\0" __FILE__ ":" "851"), this, qFlagLocation("1""updateLogAndStatus(QString,int)" "\0" __FILE__ ":" "851")); | - | ||||||||||||||||||
807 | connect(node, &QQuickOpenGLShaderEffectNode::dirtyTexture, | - | ||||||||||||||||||
808 | this, &QQuickOpenGLShaderEffect::updateGeometryIfAtlased); | - | ||||||||||||||||||
809 | } executed 64 times by 5 tests: end of block Executed by:
| 64 | ||||||||||||||||||
810 | - | |||||||||||||||||||
811 | QQuickOpenGLShaderEffectMaterial *material = static_cast<QQuickOpenGLShaderEffectMaterial *>(node->material()); | - | ||||||||||||||||||
812 | - | |||||||||||||||||||
813 | - | |||||||||||||||||||
814 | if (bool(material->flags() & QSGMaterial::Blending) != m_blending
| 0-64 | ||||||||||||||||||
815 | material->setFlag(QSGMaterial::Blending, m_blending); | - | ||||||||||||||||||
816 | node->markDirty(QSGNode::DirtyMaterial); | - | ||||||||||||||||||
817 | } never executed: end of block | 0 | ||||||||||||||||||
818 | - | |||||||||||||||||||
819 | if (int(material->cullMode) != int(m_cullMode)
| 0-64 | ||||||||||||||||||
820 | material->cullMode = QQuickShaderEffect::CullMode(m_cullMode); | - | ||||||||||||||||||
821 | node->markDirty(QSGNode::DirtyMaterial); | - | ||||||||||||||||||
822 | } never executed: end of block | 0 | ||||||||||||||||||
823 | - | |||||||||||||||||||
824 | if (m_dirtyProgram
| 0-64 | ||||||||||||||||||
825 | Key s = m_common.source; | - | ||||||||||||||||||
826 | QSGShaderSourceBuilder builder; | - | ||||||||||||||||||
827 | if (s.sourceCode[Key::FragmentShader].isEmpty()
| 6-58 | ||||||||||||||||||
828 | builder.appendSourceFile(([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/items/shaders/shadereffect.frag")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/items/shaders/shadereffect.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 | ||||||||||||||||||
829 | s.sourceCode[Key::FragmentShader] = builder.source(); | - | ||||||||||||||||||
830 | builder.clear(); | - | ||||||||||||||||||
831 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
832 | if (s.sourceCode[Key::VertexShader].isEmpty()
| 0-64 | ||||||||||||||||||
833 | builder.appendSourceFile(([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/items/shaders/shadereffect.vert")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/items/shaders/shadereffect.vert" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 64 times by 5 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 64 times by 5 tests: }()));return qstring_literal_temp; Executed by:
| 64 | ||||||||||||||||||
834 | s.sourceCode[Key::VertexShader] = builder.source(); | - | ||||||||||||||||||
835 | } executed 64 times by 5 tests: end of block Executed by:
| 64 | ||||||||||||||||||
836 | - | |||||||||||||||||||
837 | material->setProgramSource(s); | - | ||||||||||||||||||
838 | material->attributes = m_common.attributes; | - | ||||||||||||||||||
839 | node->markDirty(QSGNode::DirtyMaterial); | - | ||||||||||||||||||
840 | m_dirtyProgram = false; | - | ||||||||||||||||||
841 | m_dirtyUniforms = true; | - | ||||||||||||||||||
842 | } executed 64 times by 5 tests: end of block Executed by:
| 64 | ||||||||||||||||||
843 | - | |||||||||||||||||||
844 | if (m_dirtyUniforms
| 0-64 | ||||||||||||||||||
845 | m_common.updateMaterial(node, material, m_dirtyUniforms, m_dirtyUniformValues, | - | ||||||||||||||||||
846 | m_dirtyTextureProviders); | - | ||||||||||||||||||
847 | node->markDirty(QSGNode::DirtyMaterial); | - | ||||||||||||||||||
848 | m_dirtyUniforms = m_dirtyUniformValues = m_dirtyTextureProviders = false; | - | ||||||||||||||||||
849 | } executed 64 times by 5 tests: end of block Executed by:
| 64 | ||||||||||||||||||
850 | - | |||||||||||||||||||
851 | QRectF srcRect(0, 0, 1, 1); | - | ||||||||||||||||||
852 | bool geometryUsesTextureSubRect = false; | - | ||||||||||||||||||
853 | if (m_supportsAtlasTextures
| 0-60 | ||||||||||||||||||
854 | QSGTextureProvider *provider = material->textureProviders.at(0); | - | ||||||||||||||||||
855 | if (provider
| 0-2 | ||||||||||||||||||
856 | srcRect = provider->texture()->normalizedTextureSubRect(); | - | ||||||||||||||||||
857 | geometryUsesTextureSubRect = true; | - | ||||||||||||||||||
858 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
859 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
860 | - | |||||||||||||||||||
861 | if (bool(material->flags() & QSGMaterial::RequiresFullMatrix) != m_customVertexShader
| 0-64 | ||||||||||||||||||
862 | material->setFlag(QSGMaterial::RequiresFullMatrix, m_customVertexShader); | - | ||||||||||||||||||
863 | node->markDirty(QSGNode::DirtyMaterial); | - | ||||||||||||||||||
864 | } executed 64 times by 5 tests: end of block Executed by:
| 64 | ||||||||||||||||||
865 | - | |||||||||||||||||||
866 | if (material->geometryUsesTextureSubRect != geometryUsesTextureSubRect
| 2-62 | ||||||||||||||||||
867 | material->geometryUsesTextureSubRect = geometryUsesTextureSubRect; | - | ||||||||||||||||||
868 | node->markDirty(QSGNode::DirtyMaterial); | - | ||||||||||||||||||
869 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
870 | - | |||||||||||||||||||
871 | if (m_dirtyMesh
| 0-64 | ||||||||||||||||||
872 | node->setGeometry(nullptr); | - | ||||||||||||||||||
873 | m_dirtyMesh = false; | - | ||||||||||||||||||
874 | m_dirtyGeometry = true; | - | ||||||||||||||||||
875 | } executed 64 times by 5 tests: end of block Executed by:
| 64 | ||||||||||||||||||
876 | - | |||||||||||||||||||
877 | if (m_dirtyGeometry
| 0-64 | ||||||||||||||||||
878 | node->setFlag(QSGNode::OwnsGeometry, false); | - | ||||||||||||||||||
879 | QSGGeometry *geometry = node->geometry(); | - | ||||||||||||||||||
880 | QRectF rect(0, 0, m_item->width(), m_item->height()); | - | ||||||||||||||||||
881 | QQuickShaderEffectMesh *mesh = m_mesh
| 2-62 | ||||||||||||||||||
882 | - | |||||||||||||||||||
883 | int posIndex = 0; | - | ||||||||||||||||||
884 | if (!mesh->validateAttributes(m_common.attributes, &posIndex)
| 0-64 | ||||||||||||||||||
885 | QString log = mesh->log(); | - | ||||||||||||||||||
886 | if (!log.isNull()
| 0 | ||||||||||||||||||
887 | m_log = parseLog() + QLatin1String("*** Mesh ***\n") + log; | - | ||||||||||||||||||
888 | m_status = QQuickShaderEffect::Error; | - | ||||||||||||||||||
889 | m_item->logChanged(); | - | ||||||||||||||||||
890 | m_item->statusChanged(); | - | ||||||||||||||||||
891 | } never executed: end of block | 0 | ||||||||||||||||||
892 | delete node; | - | ||||||||||||||||||
893 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||
894 | } | - | ||||||||||||||||||
895 | - | |||||||||||||||||||
896 | geometry = mesh->updateGeometry(geometry, m_common.attributes.count(), posIndex, srcRect, rect); | - | ||||||||||||||||||
897 | - | |||||||||||||||||||
898 | node->setGeometry(geometry); | - | ||||||||||||||||||
899 | node->setFlag(QSGNode::OwnsGeometry, true); | - | ||||||||||||||||||
900 | - | |||||||||||||||||||
901 | m_dirtyGeometry = false; | - | ||||||||||||||||||
902 | } executed 64 times by 5 tests: end of block Executed by:
| 64 | ||||||||||||||||||
903 | - | |||||||||||||||||||
904 | return executed 64 times by 5 tests: node;return node; Executed by:
executed 64 times by 5 tests: return node; Executed by:
| 64 | ||||||||||||||||||
905 | } | - | ||||||||||||||||||
906 | - | |||||||||||||||||||
907 | void QQuickOpenGLShaderEffect::maybeUpdateShaders(bool force) | - | ||||||||||||||||||
908 | { | - | ||||||||||||||||||
909 | if (!m_itemMetaObject
| 108-206 | ||||||||||||||||||
910 | m_itemMetaObject = m_item->metaObject(); executed 108 times by 5 tests: m_itemMetaObject = m_item->metaObject(); Executed by:
| 108 | ||||||||||||||||||
911 | - | |||||||||||||||||||
912 | - | |||||||||||||||||||
913 | - | |||||||||||||||||||
914 | - | |||||||||||||||||||
915 | if (!m_item->window()
| 36-188 | ||||||||||||||||||
916 | m_item->polish(); | - | ||||||||||||||||||
917 | return; executed 152 times by 5 tests: return; Executed by:
| 152 | ||||||||||||||||||
918 | } | - | ||||||||||||||||||
919 | - | |||||||||||||||||||
920 | if (m_vertNeedsUpdate
| 58-104 | ||||||||||||||||||
921 | m_vertNeedsUpdate = false; | - | ||||||||||||||||||
922 | m_common.updateShader(m_item, m_itemMetaObject, Key::VertexShader); | - | ||||||||||||||||||
923 | } executed 104 times by 5 tests: end of block Executed by:
| 104 | ||||||||||||||||||
924 | - | |||||||||||||||||||
925 | if (m_fragNeedsUpdate
| 54-108 | ||||||||||||||||||
926 | m_fragNeedsUpdate = false; | - | ||||||||||||||||||
927 | m_common.updateShader(m_item, m_itemMetaObject, Key::FragmentShader); | - | ||||||||||||||||||
928 | } executed 108 times by 5 tests: end of block Executed by:
| 108 | ||||||||||||||||||
929 | } executed 162 times by 5 tests: end of block Executed by:
| 162 | ||||||||||||||||||
930 | - | |||||||||||||||||||
931 | void QQuickOpenGLShaderEffect::handleItemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) | - | ||||||||||||||||||
932 | { | - | ||||||||||||||||||
933 | if (change == QQuickItem::ItemSceneChange
| 136-156 | ||||||||||||||||||
934 | m_common.updateWindow(value.window); executed 136 times by 5 tests: m_common.updateWindow(value.window); Executed by:
| 136 | ||||||||||||||||||
935 | } executed 292 times by 5 tests: end of block Executed by:
| 292 | ||||||||||||||||||
936 | - | |||||||||||||||||||
937 | - | |||||||||||||||||||
938 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |