Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/util/qsgtexturematerial.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
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 "qsgtexturematerial_p.h" | - | ||||||||||||
41 | #include "qsgtexture_p.h" | - | ||||||||||||
42 | #if QT_CONFIG(opengl) | - | ||||||||||||
43 | # include <QtGui/qopenglshaderprogram.h> | - | ||||||||||||
44 | # include <QtGui/qopenglfunctions.h> | - | ||||||||||||
45 | #endif | - | ||||||||||||
46 | - | |||||||||||||
47 | QT_BEGIN_NAMESPACE | - | ||||||||||||
48 | - | |||||||||||||
49 | #if QT_CONFIG(opengl) | - | ||||||||||||
50 | inline static bool isPowerOfTwo(int x) | - | ||||||||||||
51 | { | - | ||||||||||||
52 | // Assumption: x >= 1 | - | ||||||||||||
53 | return x == (x & -x); never executed: return x == (x & -x); | 0 | ||||||||||||
54 | } | - | ||||||||||||
55 | #endif | - | ||||||||||||
56 | - | |||||||||||||
57 | QSGMaterialType QSGOpaqueTextureMaterialShader::type; | - | ||||||||||||
58 | - | |||||||||||||
59 | QSGOpaqueTextureMaterialShader::QSGOpaqueTextureMaterialShader() | - | ||||||||||||
60 | { | - | ||||||||||||
61 | #if QT_CONFIG(opengl) | - | ||||||||||||
62 | setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.vert")); executed 203 times by 12 tests: return qstring_literal_temp; Executed by:
| 203 | ||||||||||||
63 | setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.frag")); executed 203 times by 12 tests: return qstring_literal_temp; Executed by:
| 203 | ||||||||||||
64 | #endif | - | ||||||||||||
65 | } executed 203 times by 12 tests: end of block Executed by:
| 203 | ||||||||||||
66 | - | |||||||||||||
67 | char const *const *QSGOpaqueTextureMaterialShader::attributeNames() const | - | ||||||||||||
68 | { | - | ||||||||||||
69 | static char const *const attr[] = { "qt_VertexPosition", "qt_VertexTexCoord", nullptr }; | - | ||||||||||||
70 | return attr; executed 24511 times by 12 tests: return attr; Executed by:
| 24511 | ||||||||||||
71 | } | - | ||||||||||||
72 | - | |||||||||||||
73 | void QSGOpaqueTextureMaterialShader::initialize() | - | ||||||||||||
74 | { | - | ||||||||||||
75 | #if QT_CONFIG(opengl) | - | ||||||||||||
76 | m_matrix_id = program()->uniformLocation("qt_Matrix"); | - | ||||||||||||
77 | #endif | - | ||||||||||||
78 | } executed 203 times by 12 tests: end of block Executed by:
| 203 | ||||||||||||
79 | - | |||||||||||||
80 | void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) | - | ||||||||||||
81 | { | - | ||||||||||||
82 | Q_ASSERT(oldEffect == nullptr || newEffect->type() == oldEffect->type()); | - | ||||||||||||
83 | QSGOpaqueTextureMaterial *tx = static_cast<QSGOpaqueTextureMaterial *>(newEffect); | - | ||||||||||||
84 | QSGOpaqueTextureMaterial *oldTx = static_cast<QSGOpaqueTextureMaterial *>(oldEffect); | - | ||||||||||||
85 | - | |||||||||||||
86 | QSGTexture *t = tx->texture(); | - | ||||||||||||
87 | - | |||||||||||||
88 | #ifndef QT_NO_DEBUG | - | ||||||||||||
89 | if (!qsg_safeguard_texture(t))
| 0-20802 | ||||||||||||
90 | return; never executed: return; | 0 | ||||||||||||
91 | #endif | - | ||||||||||||
92 | - | |||||||||||||
93 | t->setFiltering(tx->filtering()); | - | ||||||||||||
94 | - | |||||||||||||
95 | t->setHorizontalWrapMode(tx->horizontalWrapMode()); | - | ||||||||||||
96 | t->setVerticalWrapMode(tx->verticalWrapMode()); | - | ||||||||||||
97 | #if QT_CONFIG(opengl) | - | ||||||||||||
98 | bool npotSupported = const_cast<QOpenGLContext *>(state.context()) | - | ||||||||||||
99 | ->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat); | - | ||||||||||||
100 | if (!npotSupported) {
| 0-20802 | ||||||||||||
101 | QSize size = t->textureSize(); | - | ||||||||||||
102 | const bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height());
| 0 | ||||||||||||
103 | if (isNpot) {
| 0 | ||||||||||||
104 | t->setHorizontalWrapMode(QSGTexture::ClampToEdge); | - | ||||||||||||
105 | t->setVerticalWrapMode(QSGTexture::ClampToEdge); | - | ||||||||||||
106 | } never executed: end of block | 0 | ||||||||||||
107 | } never executed: end of block | 0 | ||||||||||||
108 | #else | - | ||||||||||||
109 | Q_UNUSED(state) | - | ||||||||||||
110 | #endif | - | ||||||||||||
111 | t->setMipmapFiltering(tx->mipmapFiltering()); | - | ||||||||||||
112 | t->setAnisotropyLevel(tx->anisotropyLevel()); | - | ||||||||||||
113 | - | |||||||||||||
114 | if (oldTx == nullptr || oldTx->texture()->textureId() != t->textureId())
| 260-19049 | ||||||||||||
115 | t->bind(); executed 2013 times by 12 tests: t->bind(); Executed by:
| 2013 | ||||||||||||
116 | else | - | ||||||||||||
117 | t->updateBindOptions(); executed 18789 times by 3 tests: t->updateBindOptions(); Executed by:
| 18789 | ||||||||||||
118 | #if QT_CONFIG(opengl) | - | ||||||||||||
119 | if (state.isMatrixDirty())
| 0-20802 | ||||||||||||
120 | program()->setUniformValue(m_matrix_id, state.combinedMatrix()); executed 20802 times by 12 tests: program()->setUniformValue(m_matrix_id, state.combinedMatrix()); Executed by:
| 20802 | ||||||||||||
121 | #endif | - | ||||||||||||
122 | } executed 20802 times by 12 tests: end of block Executed by:
| 20802 | ||||||||||||
123 | - | |||||||||||||
124 | - | |||||||||||||
125 | /*! | - | ||||||||||||
126 | \class QSGOpaqueTextureMaterial | - | ||||||||||||
127 | \brief The QSGOpaqueTextureMaterial class provides a convenient way of | - | ||||||||||||
128 | rendering textured geometry in the scene graph. | - | ||||||||||||
129 | \inmodule QtQuick | - | ||||||||||||
130 | \ingroup qtquick-scenegraph-materials | - | ||||||||||||
131 | - | |||||||||||||
132 | \warning This utility class is only functional when running with the OpenGL | - | ||||||||||||
133 | backend of the Qt Quick scenegraph. | - | ||||||||||||
134 | - | |||||||||||||
135 | The opaque textured material will fill every pixel in a geometry with | - | ||||||||||||
136 | the supplied texture. The material does not respect the opacity of the | - | ||||||||||||
137 | QSGMaterialShader::RenderState, so opacity nodes in the parent chain | - | ||||||||||||
138 | of nodes using this material, have no effect. | - | ||||||||||||
139 | - | |||||||||||||
140 | The geometry to be rendered with an opaque texture material requires | - | ||||||||||||
141 | vertices in attribute location 0 and texture coordinates in attribute | - | ||||||||||||
142 | location 1. The texture coordinate is a 2-dimensional floating-point | - | ||||||||||||
143 | tuple. The QSGGeometry::defaultAttributes_TexturedPoint2D returns an | - | ||||||||||||
144 | attribute set compatible with this material. | - | ||||||||||||
145 | - | |||||||||||||
146 | The texture to be rendered can be set using setTexture(). How the | - | ||||||||||||
147 | texture should be rendered can be specified using setMipmapFiltering(), | - | ||||||||||||
148 | setFiltering(), setHorizontalWrapMode() and setVerticalWrapMode(). | - | ||||||||||||
149 | The rendering state is set on the texture instance just before it | - | ||||||||||||
150 | is bound. | - | ||||||||||||
151 | - | |||||||||||||
152 | The opaque textured material respects the current matrix and the alpha | - | ||||||||||||
153 | channel of the texture. It will disregard the accumulated opacity in | - | ||||||||||||
154 | the scenegraph. | - | ||||||||||||
155 | - | |||||||||||||
156 | A texture material must have a texture set before it is used as | - | ||||||||||||
157 | a material in the scene graph. | - | ||||||||||||
158 | */ | - | ||||||||||||
159 | - | |||||||||||||
160 | - | |||||||||||||
161 | - | |||||||||||||
162 | /*! | - | ||||||||||||
163 | Creates a new QSGOpaqueTextureMaterial. | - | ||||||||||||
164 | - | |||||||||||||
165 | The default mipmap filtering and filtering mode is set to | - | ||||||||||||
166 | QSGTexture::Nearest. The default wrap modes is set to | - | ||||||||||||
167 | \c QSGTexture::ClampToEdge. | - | ||||||||||||
168 | - | |||||||||||||
169 | */ | - | ||||||||||||
170 | QSGOpaqueTextureMaterial::QSGOpaqueTextureMaterial() | - | ||||||||||||
171 | : m_texture(nullptr) | - | ||||||||||||
172 | , m_filtering(QSGTexture::Nearest) | - | ||||||||||||
173 | , m_mipmap_filtering(QSGTexture::None) | - | ||||||||||||
174 | , m_horizontal_wrap(QSGTexture::ClampToEdge) | - | ||||||||||||
175 | , m_vertical_wrap(QSGTexture::ClampToEdge) | - | ||||||||||||
176 | , m_anisotropy_level(QSGTexture::AnisotropyNone) | - | ||||||||||||
177 | { | - | ||||||||||||
178 | } executed 15635 times by 13 tests: end of block Executed by:
| 15635 | ||||||||||||
179 | - | |||||||||||||
180 | - | |||||||||||||
181 | /*! | - | ||||||||||||
182 | \internal | - | ||||||||||||
183 | */ | - | ||||||||||||
184 | QSGMaterialType *QSGOpaqueTextureMaterial::type() const | - | ||||||||||||
185 | { | - | ||||||||||||
186 | return &QSGOpaqueTextureMaterialShader::type; executed 95881 times by 12 tests: return &QSGOpaqueTextureMaterialShader::type; Executed by:
| 95881 | ||||||||||||
187 | } | - | ||||||||||||
188 | - | |||||||||||||
189 | /*! | - | ||||||||||||
190 | \internal | - | ||||||||||||
191 | */ | - | ||||||||||||
192 | QSGMaterialShader *QSGOpaqueTextureMaterial::createShader() const | - | ||||||||||||
193 | { | - | ||||||||||||
194 | return new QSGOpaqueTextureMaterialShader; executed 187 times by 12 tests: return new QSGOpaqueTextureMaterialShader; Executed by:
| 187 | ||||||||||||
195 | } | - | ||||||||||||
196 | - | |||||||||||||
197 | - | |||||||||||||
198 | - | |||||||||||||
199 | /*! | - | ||||||||||||
200 | \fn QSGTexture *QSGOpaqueTextureMaterial::texture() const | - | ||||||||||||
201 | - | |||||||||||||
202 | Returns this texture material's texture. | - | ||||||||||||
203 | */ | - | ||||||||||||
204 | - | |||||||||||||
205 | - | |||||||||||||
206 | - | |||||||||||||
207 | /*! | - | ||||||||||||
208 | Sets the texture of this material to \a texture. | - | ||||||||||||
209 | - | |||||||||||||
210 | The material does not take ownership of the texture. | - | ||||||||||||
211 | */ | - | ||||||||||||
212 | - | |||||||||||||
213 | void QSGOpaqueTextureMaterial::setTexture(QSGTexture *texture) | - | ||||||||||||
214 | { | - | ||||||||||||
215 | m_texture = texture; | - | ||||||||||||
216 | setFlag(Blending, m_texture ? m_texture->hasAlphaChannel() : false); | - | ||||||||||||
217 | } executed 10610 times by 13 tests: end of block Executed by:
| 10610 | ||||||||||||
218 | - | |||||||||||||
219 | - | |||||||||||||
220 | - | |||||||||||||
221 | /*! | - | ||||||||||||
222 | \fn void QSGOpaqueTextureMaterial::setMipmapFiltering(QSGTexture::Filtering filtering) | - | ||||||||||||
223 | - | |||||||||||||
224 | Sets the mipmap mode to \a filtering. | - | ||||||||||||
225 | - | |||||||||||||
226 | The mipmap filtering mode is set on the texture instance just before the | - | ||||||||||||
227 | texture is bound for rendering. | - | ||||||||||||
228 | - | |||||||||||||
229 | If the texture does not have mipmapping support, enabling mipmapping has no | - | ||||||||||||
230 | effect. | - | ||||||||||||
231 | */ | - | ||||||||||||
232 | - | |||||||||||||
233 | - | |||||||||||||
234 | - | |||||||||||||
235 | /*! | - | ||||||||||||
236 | \fn QSGTexture::Filtering QSGOpaqueTextureMaterial::mipmapFiltering() const | - | ||||||||||||
237 | - | |||||||||||||
238 | Returns this material's mipmap filtering mode. | - | ||||||||||||
239 | - | |||||||||||||
240 | The default mipmap mode is \c QSGTexture::Nearest. | - | ||||||||||||
241 | */ | - | ||||||||||||
242 | - | |||||||||||||
243 | - | |||||||||||||
244 | - | |||||||||||||
245 | /*! | - | ||||||||||||
246 | \fn void QSGOpaqueTextureMaterial::setFiltering(QSGTexture::Filtering filtering) | - | ||||||||||||
247 | - | |||||||||||||
248 | Sets the filtering to \a filtering. | - | ||||||||||||
249 | - | |||||||||||||
250 | The filtering mode is set on the texture instance just before the texture | - | ||||||||||||
251 | is bound for rendering. | - | ||||||||||||
252 | */ | - | ||||||||||||
253 | - | |||||||||||||
254 | - | |||||||||||||
255 | - | |||||||||||||
256 | /*! | - | ||||||||||||
257 | \fn QSGTexture::Filtering QSGOpaqueTextureMaterial::filtering() const | - | ||||||||||||
258 | - | |||||||||||||
259 | Returns this material's filtering mode. | - | ||||||||||||
260 | - | |||||||||||||
261 | The default filtering is \c QSGTexture::Nearest. | - | ||||||||||||
262 | */ | - | ||||||||||||
263 | - | |||||||||||||
264 | - | |||||||||||||
265 | - | |||||||||||||
266 | /*! | - | ||||||||||||
267 | \fn void QSGOpaqueTextureMaterial::setHorizontalWrapMode(QSGTexture::WrapMode mode) | - | ||||||||||||
268 | - | |||||||||||||
269 | Sets the horizontal wrap mode to \a mode. | - | ||||||||||||
270 | - | |||||||||||||
271 | The horizontal wrap mode is set on the texture instance just before the texture | - | ||||||||||||
272 | is bound for rendering. | - | ||||||||||||
273 | */ | - | ||||||||||||
274 | - | |||||||||||||
275 | - | |||||||||||||
276 | - | |||||||||||||
277 | /*! | - | ||||||||||||
278 | \fn QSGTexture::WrapMode QSGOpaqueTextureMaterial::horizontalWrapMode() const | - | ||||||||||||
279 | - | |||||||||||||
280 | Returns this material's horizontal wrap mode. | - | ||||||||||||
281 | - | |||||||||||||
282 | The default horizontal wrap mode is \c QSGTexture::ClampToEdge. | - | ||||||||||||
283 | */ | - | ||||||||||||
284 | - | |||||||||||||
285 | - | |||||||||||||
286 | - | |||||||||||||
287 | /*! | - | ||||||||||||
288 | \fn void QSGOpaqueTextureMaterial::setVerticalWrapMode(QSGTexture::WrapMode mode) | - | ||||||||||||
289 | - | |||||||||||||
290 | Sets the vertical wrap mode to \a mode. | - | ||||||||||||
291 | - | |||||||||||||
292 | The vertical wrap mode is set on the texture instance just before the texture | - | ||||||||||||
293 | is bound for rendering. | - | ||||||||||||
294 | */ | - | ||||||||||||
295 | - | |||||||||||||
296 | - | |||||||||||||
297 | - | |||||||||||||
298 | /*! | - | ||||||||||||
299 | \fn QSGTexture::WrapMode QSGOpaqueTextureMaterial::verticalWrapMode() const | - | ||||||||||||
300 | - | |||||||||||||
301 | Returns this material's vertical wrap mode. | - | ||||||||||||
302 | - | |||||||||||||
303 | The default vertical wrap mode is \c QSGTexture::ClampToEdge. | - | ||||||||||||
304 | */ | - | ||||||||||||
305 | - | |||||||||||||
306 | /*! | - | ||||||||||||
307 | \fn void QSGOpaqueTextureMaterial::setAnisotropyLevel(QSGTexture::AnisotropyLevel level) | - | ||||||||||||
308 | - | |||||||||||||
309 | Sets this material's anistropy level to \a level. | - | ||||||||||||
310 | */ | - | ||||||||||||
311 | - | |||||||||||||
312 | /*! | - | ||||||||||||
313 | \fn QSGTexture::AnisotropyLevel QSGOpaqueTextureMaterial::anisotropyLevel() const | - | ||||||||||||
314 | - | |||||||||||||
315 | Returns this material's anistropy level. | - | ||||||||||||
316 | */ | - | ||||||||||||
317 | - | |||||||||||||
318 | /*! | - | ||||||||||||
319 | \internal | - | ||||||||||||
320 | */ | - | ||||||||||||
321 | - | |||||||||||||
322 | int QSGOpaqueTextureMaterial::compare(const QSGMaterial *o) const | - | ||||||||||||
323 | { | - | ||||||||||||
324 | Q_ASSERT(o && type() == o->type()); | - | ||||||||||||
325 | const QSGOpaqueTextureMaterial *other = static_cast<const QSGOpaqueTextureMaterial *>(o); | - | ||||||||||||
326 | if (int diff = m_texture->textureId() - other->texture()->textureId())
| 270-24420 | ||||||||||||
327 | return diff; executed 270 times by 4 tests: return diff; Executed by:
| 270 | ||||||||||||
328 | return int(m_filtering) - int(other->m_filtering); executed 24420 times by 3 tests: return int(m_filtering) - int(other->m_filtering); Executed by:
| 24420 | ||||||||||||
329 | } | - | ||||||||||||
330 | - | |||||||||||||
331 | - | |||||||||||||
332 | - | |||||||||||||
333 | /*! | - | ||||||||||||
334 | \class QSGTextureMaterial | - | ||||||||||||
335 | \brief The QSGTextureMaterial class provides a convenient way of | - | ||||||||||||
336 | rendering textured geometry in the scene graph. | - | ||||||||||||
337 | \inmodule QtQuick | - | ||||||||||||
338 | \ingroup qtquick-scenegraph-materials | - | ||||||||||||
339 | - | |||||||||||||
340 | \warning This utility class is only functional when running with the OpenGL | - | ||||||||||||
341 | backend of the Qt Quick scenegraph. | - | ||||||||||||
342 | - | |||||||||||||
343 | The textured material will fill every pixel in a geometry with | - | ||||||||||||
344 | the supplied texture. | - | ||||||||||||
345 | - | |||||||||||||
346 | The geometry to be rendered with a texture material requires | - | ||||||||||||
347 | vertices in attribute location 0 and texture coordinates in attribute | - | ||||||||||||
348 | location 1. The texture coordinate is a 2-dimensional floating-point | - | ||||||||||||
349 | tuple. The QSGGeometry::defaultAttributes_TexturedPoint2D returns an | - | ||||||||||||
350 | attribute set compatible with this material. | - | ||||||||||||
351 | - | |||||||||||||
352 | The texture to be rendered can be set using setTexture(). How the | - | ||||||||||||
353 | texture should be rendered can be specified using setMipmapFiltering(), | - | ||||||||||||
354 | setFiltering(), setHorizontalWrapMode() and setVerticalWrapMode(). | - | ||||||||||||
355 | The rendering state is set on the texture instance just before it | - | ||||||||||||
356 | is bound. | - | ||||||||||||
357 | - | |||||||||||||
358 | The textured material respects the current matrix and the alpha | - | ||||||||||||
359 | channel of the texture. It will also respect the accumulated opacity | - | ||||||||||||
360 | in the scenegraph. | - | ||||||||||||
361 | - | |||||||||||||
362 | A texture material must have a texture set before it is used as | - | ||||||||||||
363 | a material in the scene graph. | - | ||||||||||||
364 | */ | - | ||||||||||||
365 | - | |||||||||||||
366 | QSGMaterialType QSGTextureMaterialShader::type; | - | ||||||||||||
367 | - | |||||||||||||
368 | - | |||||||||||||
369 | - | |||||||||||||
370 | /*! | - | ||||||||||||
371 | \internal | - | ||||||||||||
372 | */ | - | ||||||||||||
373 | - | |||||||||||||
374 | QSGMaterialType *QSGTextureMaterial::type() const | - | ||||||||||||
375 | { | - | ||||||||||||
376 | return &QSGTextureMaterialShader::type; executed 98909 times by 5 tests: return &QSGTextureMaterialShader::type; Executed by:
| 98909 | ||||||||||||
377 | } | - | ||||||||||||
378 | - | |||||||||||||
379 | - | |||||||||||||
380 | - | |||||||||||||
381 | /*! | - | ||||||||||||
382 | \internal | - | ||||||||||||
383 | */ | - | ||||||||||||
384 | - | |||||||||||||
385 | QSGMaterialShader *QSGTextureMaterial::createShader() const | - | ||||||||||||
386 | { | - | ||||||||||||
387 | return new QSGTextureMaterialShader; executed 16 times by 5 tests: return new QSGTextureMaterialShader; Executed by:
| 16 | ||||||||||||
388 | } | - | ||||||||||||
389 | - | |||||||||||||
390 | QSGTextureMaterialShader::QSGTextureMaterialShader() | - | ||||||||||||
391 | : QSGOpaqueTextureMaterialShader() | - | ||||||||||||
392 | { | - | ||||||||||||
393 | #if QT_CONFIG(opengl) | - | ||||||||||||
394 | setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/texture.frag")); executed 16 times by 5 tests: return qstring_literal_temp; Executed by:
| 16 | ||||||||||||
395 | #endif | - | ||||||||||||
396 | } executed 16 times by 5 tests: end of block Executed by:
| 16 | ||||||||||||
397 | - | |||||||||||||
398 | void QSGTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) | - | ||||||||||||
399 | { | - | ||||||||||||
400 | Q_ASSERT(oldEffect == nullptr || newEffect->type() == oldEffect->type()); | - | ||||||||||||
401 | #if QT_CONFIG(opengl) | - | ||||||||||||
402 | if (state.isOpacityDirty())
| 181-18968 | ||||||||||||
403 | program()->setUniformValue(m_opacity_id, state.opacity()); executed 18968 times by 5 tests: program()->setUniformValue(m_opacity_id, state.opacity()); Executed by:
| 18968 | ||||||||||||
404 | #endif | - | ||||||||||||
405 | QSGOpaqueTextureMaterialShader::updateState(state, newEffect, oldEffect); | - | ||||||||||||
406 | } executed 19149 times by 5 tests: end of block Executed by:
| 19149 | ||||||||||||
407 | - | |||||||||||||
408 | void QSGTextureMaterialShader::initialize() | - | ||||||||||||
409 | { | - | ||||||||||||
410 | QSGOpaqueTextureMaterialShader::initialize(); | - | ||||||||||||
411 | #if QT_CONFIG(opengl) | - | ||||||||||||
412 | m_opacity_id = program()->uniformLocation("opacity"); | - | ||||||||||||
413 | #endif | - | ||||||||||||
414 | } executed 16 times by 5 tests: end of block Executed by:
| 16 | ||||||||||||
415 | - | |||||||||||||
416 | QT_END_NAMESPACE | - | ||||||||||||
Source code | Switch to Preprocessed file |