qopenglengineshadermanager.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopenglengineshadermanager.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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 QtGui 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 "qopenglengineshadermanager_p.h"-
41#include "qopenglengineshadersource_p.h"-
42#include "qopenglpaintengine_p.h"-
43#include "qopenglshadercache_p.h"-
44-
45#include <QtGui/private/qopenglcontext_p.h>-
46#include <QtCore/qthreadstorage.h>-
47-
48#include <algorithm>-
49-
50#if defined(QT_DEBUG)-
51#include <QMetaEnum>-
52#endif-
53-
54// #define QT_GL_SHARED_SHADER_DEBUG-
55-
56QT_BEGIN_NAMESPACE-
57-
58class QOpenGLEngineSharedShadersResource : public QOpenGLSharedResource-
59{-
60public:-
61 QOpenGLEngineSharedShadersResource(QOpenGLContext *ctx)-
62 : QOpenGLSharedResource(ctx->shareGroup())-
63 , m_shaders(new QOpenGLEngineSharedShaders(ctx))-
64 {-
65 }
never executed: end of block
0
66-
67 ~QOpenGLEngineSharedShadersResource()-
68 {-
69 delete m_shaders;-
70 }
never executed: end of block
0
71-
72 void invalidateResource() Q_DECL_OVERRIDE-
73 {-
74 delete m_shaders;-
75 m_shaders = 0;-
76 }
never executed: end of block
0
77-
78 void freeResource(QOpenGLContext *) Q_DECL_OVERRIDE-
79 {-
80 }-
81-
82 QOpenGLEngineSharedShaders *shaders() const { return m_shaders; }
never executed: return m_shaders;
0
83-
84private:-
85 QOpenGLEngineSharedShaders *m_shaders;-
86};-
87-
88class QOpenGLShaderStorage-
89{-
90public:-
91 QOpenGLEngineSharedShaders *shadersForThread(QOpenGLContext *context) {-
92 QOpenGLMultiGroupSharedResource *&shaders = m_storage.localData();-
93 if (!shaders)
!shadersDescription
TRUEnever evaluated
FALSEnever evaluated
0
94 shaders = new QOpenGLMultiGroupSharedResource;
never executed: shaders = new QOpenGLMultiGroupSharedResource;
0
95 QOpenGLEngineSharedShadersResource *resource =-
96 shaders->value<QOpenGLEngineSharedShadersResource>(context);-
97 return resource ? resource->shaders() : 0;
never executed: return resource ? resource->shaders() : 0;
0
98 }-
99-
100private:-
101 QThreadStorage<QOpenGLMultiGroupSharedResource *> m_storage;-
102};-
103-
104Q_GLOBAL_STATIC(QOpenGLShaderStorage, qt_shader_storage);
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
105-
106QOpenGLEngineSharedShaders *QOpenGLEngineSharedShaders::shadersForContext(QOpenGLContext *context)-
107{-
108 return qt_shader_storage()->shadersForThread(context);
never executed: return qt_shader_storage()->shadersForThread(context);
0
109}-
110-
111const char* QOpenGLEngineSharedShaders::qShaderSnippets[] = {-
112 0,0,0,0,0,0,0,0,0,0,-
113 0,0,0,0,0,0,0,0,0,0,-
114 0,0,0,0,0,0,0,0,0,0,-
115 0,0,0,0,0-
116};-
117-
118QOpenGLEngineSharedShaders::QOpenGLEngineSharedShaders(QOpenGLContext* context)-
119 : blitShaderProg(0)-
120 , simpleShaderProg(0)-
121{-
122-
123/*-
124 Rather than having the shader source array statically initialised, it is initialised-
125 here instead. This is to allow new shader names to be inserted or existing names moved-
126 around without having to change the order of the glsl strings. It is hoped this will-
127 make future hard-to-find runtime bugs more obvious and generally give more solid code.-
128*/-
129 static bool snippetsPopulated = false;-
130 if (!snippetsPopulated) {
!snippetsPopulatedDescription
TRUEnever evaluated
FALSEnever evaluated
0
131-
132 const char** code = qShaderSnippets; // shortcut-
133-
134 code[MainVertexShader] = qopenglslMainVertexShader;-
135 code[MainWithTexCoordsVertexShader] = qopenglslMainWithTexCoordsVertexShader;-
136 code[MainWithTexCoordsAndOpacityVertexShader] = qopenglslMainWithTexCoordsAndOpacityVertexShader;-
137-
138 code[UntransformedPositionVertexShader] = qopenglslUntransformedPositionVertexShader;-
139 code[PositionOnlyVertexShader] = qopenglslPositionOnlyVertexShader;-
140 code[ComplexGeometryPositionOnlyVertexShader] = qopenglslComplexGeometryPositionOnlyVertexShader;-
141 code[PositionWithPatternBrushVertexShader] = qopenglslPositionWithPatternBrushVertexShader;-
142 code[PositionWithLinearGradientBrushVertexShader] = qopenglslPositionWithLinearGradientBrushVertexShader;-
143 code[PositionWithConicalGradientBrushVertexShader] = qopenglslPositionWithConicalGradientBrushVertexShader;-
144 code[PositionWithRadialGradientBrushVertexShader] = qopenglslPositionWithRadialGradientBrushVertexShader;-
145 code[PositionWithTextureBrushVertexShader] = qopenglslPositionWithTextureBrushVertexShader;-
146 code[AffinePositionWithPatternBrushVertexShader] = qopenglslAffinePositionWithPatternBrushVertexShader;-
147 code[AffinePositionWithLinearGradientBrushVertexShader] = qopenglslAffinePositionWithLinearGradientBrushVertexShader;-
148 code[AffinePositionWithConicalGradientBrushVertexShader] = qopenglslAffinePositionWithConicalGradientBrushVertexShader;-
149 code[AffinePositionWithRadialGradientBrushVertexShader] = qopenglslAffinePositionWithRadialGradientBrushVertexShader;-
150 code[AffinePositionWithTextureBrushVertexShader] = qopenglslAffinePositionWithTextureBrushVertexShader;-
151-
152 code[MainFragmentShader_CMO] = qopenglslMainFragmentShader_CMO;-
153 code[MainFragmentShader_CM] = qopenglslMainFragmentShader_CM;-
154 code[MainFragmentShader_MO] = qopenglslMainFragmentShader_MO;-
155 code[MainFragmentShader_M] = qopenglslMainFragmentShader_M;-
156 code[MainFragmentShader_CO] = qopenglslMainFragmentShader_CO;-
157 code[MainFragmentShader_C] = qopenglslMainFragmentShader_C;-
158 code[MainFragmentShader_O] = qopenglslMainFragmentShader_O;-
159 code[MainFragmentShader] = qopenglslMainFragmentShader;-
160 code[MainFragmentShader_ImageArrays] = qopenglslMainFragmentShader_ImageArrays;-
161-
162 code[ImageSrcFragmentShader] = qopenglslImageSrcFragmentShader;-
163 code[ImageSrcWithPatternFragmentShader] = qopenglslImageSrcWithPatternFragmentShader;-
164 code[NonPremultipliedImageSrcFragmentShader] = qopenglslNonPremultipliedImageSrcFragmentShader;-
165 code[GrayscaleImageSrcFragmentShader] = qopenglslGrayscaleImageSrcFragmentShader;-
166 code[AlphaImageSrcFragmentShader] = qopenglslAlphaImageSrcFragmentShader;-
167 code[CustomImageSrcFragmentShader] = qopenglslCustomSrcFragmentShader; // Calls "customShader", which must be appended-
168 code[SolidBrushSrcFragmentShader] = qopenglslSolidBrushSrcFragmentShader;-
169 if (context->isOpenGLES())
context->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
170 code[TextureBrushSrcFragmentShader] = qopenglslTextureBrushSrcFragmentShader_ES;
never executed: code[TextureBrushSrcFragmentShader] = qopenglslTextureBrushSrcFragmentShader_ES;
0
171 else-
172 code[TextureBrushSrcFragmentShader] = qopenglslTextureBrushSrcFragmentShader_desktop;
never executed: code[TextureBrushSrcFragmentShader] = qopenglslTextureBrushSrcFragmentShader_desktop;
0
173 code[TextureBrushSrcWithPatternFragmentShader] = qopenglslTextureBrushSrcWithPatternFragmentShader;-
174 code[PatternBrushSrcFragmentShader] = qopenglslPatternBrushSrcFragmentShader;-
175 code[LinearGradientBrushSrcFragmentShader] = qopenglslLinearGradientBrushSrcFragmentShader;-
176 code[RadialGradientBrushSrcFragmentShader] = qopenglslRadialGradientBrushSrcFragmentShader;-
177 code[ConicalGradientBrushSrcFragmentShader] = qopenglslConicalGradientBrushSrcFragmentShader;-
178 code[ShockingPinkSrcFragmentShader] = qopenglslShockingPinkSrcFragmentShader;-
179-
180 code[NoMaskFragmentShader] = "";-
181 code[MaskFragmentShader] = qopenglslMaskFragmentShader;-
182 code[RgbMaskFragmentShaderPass1] = qopenglslRgbMaskFragmentShaderPass1;-
183 code[RgbMaskFragmentShaderPass2] = qopenglslRgbMaskFragmentShaderPass2;-
184 code[RgbMaskWithGammaFragmentShader] = ""; //###-
185-
186 code[NoCompositionModeFragmentShader] = "";-
187 code[MultiplyCompositionModeFragmentShader] = ""; //###-
188 code[ScreenCompositionModeFragmentShader] = ""; //###-
189 code[OverlayCompositionModeFragmentShader] = ""; //###-
190 code[DarkenCompositionModeFragmentShader] = ""; //###-
191 code[LightenCompositionModeFragmentShader] = ""; //###-
192 code[ColorDodgeCompositionModeFragmentShader] = ""; //###-
193 code[ColorBurnCompositionModeFragmentShader] = ""; //###-
194 code[HardLightCompositionModeFragmentShader] = ""; //###-
195 code[SoftLightCompositionModeFragmentShader] = ""; //###-
196 code[DifferenceCompositionModeFragmentShader] = ""; //###-
197 code[ExclusionCompositionModeFragmentShader] = ""; //###-
198-
199#if defined(QT_DEBUG)-
200 // Check that all the elements have been filled:-
201 for (int i = 0; i < TotalSnippetCount; ++i) {
i < TotalSnippetCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
202 if (Q_UNLIKELY(!qShaderSnippets[i])) {
__builtin_expe...ts[i]), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
203 qFatal("Shader snippet for %s (#%d) is missing!",-
204 snippetNameStr(SnippetName(i)).constData(), i);-
205 }
never executed: end of block
0
206 }
never executed: end of block
0
207#endif-
208 snippetsPopulated = true;-
209 }
never executed: end of block
0
210-
211 QOpenGLShader* fragShader;-
212 QOpenGLShader* vertexShader;-
213 QByteArray vertexSource;-
214 QByteArray fragSource;-
215-
216 // Compile up the simple shader:-
217 vertexSource.append(qShaderSnippets[MainVertexShader]);-
218 vertexSource.append(qShaderSnippets[PositionOnlyVertexShader]);-
219-
220 fragSource.append(qShaderSnippets[MainFragmentShader]);-
221 fragSource.append(qShaderSnippets[ShockingPinkSrcFragmentShader]);-
222-
223 simpleShaderProg = new QOpenGLShaderProgram;-
224-
225 CachedShader simpleShaderCache(fragSource, vertexSource);-
226-
227 bool inCache = simpleShaderCache.load(simpleShaderProg, context);-
228-
229 if (!inCache) {
!inCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
230 vertexShader = new QOpenGLShader(QOpenGLShader::Vertex);-
231 shaders.append(vertexShader);-
232 if (!vertexShader->compileSourceCode(vertexSource))
!vertexShader-...(vertexSource)Description
TRUEnever evaluated
FALSEnever evaluated
0
233 qWarning("Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile");
never executed: QMessageLogger(__FILE__, 233, __PRETTY_FUNCTION__).warning("Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile");
0
234-
235 fragShader = new QOpenGLShader(QOpenGLShader::Fragment);-
236 shaders.append(fragShader);-
237 if (!fragShader->compileSourceCode(fragSource))
!fragShader->c...de(fragSource)Description
TRUEnever evaluated
FALSEnever evaluated
0
238 qWarning("Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile");
never executed: QMessageLogger(__FILE__, 238, __PRETTY_FUNCTION__).warning("Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile");
0
239-
240 simpleShaderProg->addShader(vertexShader);-
241 simpleShaderProg->addShader(fragShader);-
242-
243 simpleShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);-
244 simpleShaderProg->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR);-
245 simpleShaderProg->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR);-
246 simpleShaderProg->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR);-
247 }
never executed: end of block
0
248-
249 simpleShaderProg->link();-
250-
251 if (Q_UNLIKELY(!simpleShaderProg->isLinked())) {
__builtin_expe...ked()), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
252 qCritical("Errors linking simple shader: %s", qPrintable(simpleShaderProg->log()));-
253 } else {
never executed: end of block
0
254 if (!inCache)
!inCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
255 simpleShaderCache.store(simpleShaderProg, context);
never executed: simpleShaderCache.store(simpleShaderProg, context);
0
256 }
never executed: end of block
0
257-
258 // Compile the blit shader:-
259 vertexSource.clear();-
260 vertexSource.append(qShaderSnippets[MainWithTexCoordsVertexShader]);-
261 vertexSource.append(qShaderSnippets[UntransformedPositionVertexShader]);-
262-
263 fragSource.clear();-
264 fragSource.append(qShaderSnippets[MainFragmentShader]);-
265 fragSource.append(qShaderSnippets[ImageSrcFragmentShader]);-
266-
267 blitShaderProg = new QOpenGLShaderProgram;-
268-
269 CachedShader blitShaderCache(fragSource, vertexSource);-
270-
271 inCache = blitShaderCache.load(blitShaderProg, context);-
272-
273 if (!inCache) {
!inCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
274 vertexShader = new QOpenGLShader(QOpenGLShader::Vertex);-
275 shaders.append(vertexShader);-
276 if (!vertexShader->compileSourceCode(vertexSource))
!vertexShader-...(vertexSource)Description
TRUEnever evaluated
FALSEnever evaluated
0
277 qWarning("Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile");
never executed: QMessageLogger(__FILE__, 277, __PRETTY_FUNCTION__).warning("Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile");
0
278-
279 fragShader = new QOpenGLShader(QOpenGLShader::Fragment);-
280 shaders.append(fragShader);-
281 if (!fragShader->compileSourceCode(fragSource))
!fragShader->c...de(fragSource)Description
TRUEnever evaluated
FALSEnever evaluated
0
282 qWarning("Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile");
never executed: QMessageLogger(__FILE__, 282, __PRETTY_FUNCTION__).warning("Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile");
0
283-
284 blitShaderProg->addShader(vertexShader);-
285 blitShaderProg->addShader(fragShader);-
286-
287 blitShaderProg->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);-
288 blitShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);-
289 }
never executed: end of block
0
290-
291 blitShaderProg->link();-
292 if (Q_UNLIKELY(!blitShaderProg->isLinked())) {
__builtin_expe...ked()), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
293 qCritical("Errors linking blit shader: %s", qPrintable(blitShaderProg->log()));-
294 } else {
never executed: end of block
0
295 if (!inCache)
!inCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
296 blitShaderCache.store(blitShaderProg, context);
never executed: blitShaderCache.store(blitShaderProg, context);
0
297 }
never executed: end of block
0
298-
299#ifdef QT_GL_SHARED_SHADER_DEBUG-
300 qDebug(" -> QOpenGLEngineSharedShaders() %p for thread %p.", this, QThread::currentThread());-
301#endif-
302}-
303-
304QOpenGLEngineSharedShaders::~QOpenGLEngineSharedShaders()-
305{-
306#ifdef QT_GL_SHARED_SHADER_DEBUG-
307 qDebug(" -> ~QOpenGLEngineSharedShaders() %p for thread %p.", this, QThread::currentThread());-
308#endif-
309 qDeleteAll(shaders);-
310 shaders.clear();-
311-
312 qDeleteAll(cachedPrograms);-
313 cachedPrograms.clear();-
314-
315 if (blitShaderProg) {
blitShaderProgDescription
TRUEnever evaluated
FALSEnever evaluated
0
316 delete blitShaderProg;-
317 blitShaderProg = 0;-
318 }
never executed: end of block
0
319-
320 if (simpleShaderProg) {
simpleShaderProgDescription
TRUEnever evaluated
FALSEnever evaluated
0
321 delete simpleShaderProg;-
322 simpleShaderProg = 0;-
323 }
never executed: end of block
0
324}
never executed: end of block
0
325-
326#if defined (QT_DEBUG)-
327QByteArray QOpenGLEngineSharedShaders::snippetNameStr(SnippetName name)-
328{-
329 QMetaEnum m = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("SnippetName"));-
330 return QByteArray(m.valueToKey(name));
never executed: return QByteArray(m.valueToKey(name));
0
331}-
332#endif-
333-
334// The address returned here will only be valid until next time this function is called.-
335// The program is return bound.-
336QOpenGLEngineShaderProg *QOpenGLEngineSharedShaders::findProgramInCache(const QOpenGLEngineShaderProg &prog)-
337{-
338 for (int i = 0; i < cachedPrograms.size(); ++i) {
i < cachedPrograms.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
339 QOpenGLEngineShaderProg *cachedProg = cachedPrograms[i];-
340 if (*cachedProg == prog) {
*cachedProg == progDescription
TRUEnever evaluated
FALSEnever evaluated
0
341 // Move the program to the top of the list as a poor-man's cache algo-
342 cachedPrograms.move(i, 0);-
343 cachedProg->program->bind();-
344 return cachedProg;
never executed: return cachedProg;
0
345 }-
346 }
never executed: end of block
0
347-
348 QScopedPointer<QOpenGLEngineShaderProg> newProg;-
349-
350 do {-
351 QByteArray fragSource;-
352 // Insert the custom stage before the srcPixel shader to work around an ATI driver bug-
353 // where you cannot forward declare a function that takes a sampler as argument.-
354 if (prog.srcPixelFragShader == CustomImageSrcFragmentShader)
prog.srcPixelF...FragmentShaderDescription
TRUEnever evaluated
FALSEnever evaluated
0
355 fragSource.append(prog.customStageSource);
never executed: fragSource.append(prog.customStageSource);
0
356 fragSource.append(qShaderSnippets[prog.mainFragShader]);-
357 fragSource.append(qShaderSnippets[prog.srcPixelFragShader]);-
358 if (prog.compositionFragShader)
prog.compositionFragShaderDescription
TRUEnever evaluated
FALSEnever evaluated
0
359 fragSource.append(qShaderSnippets[prog.compositionFragShader]);
never executed: fragSource.append(qShaderSnippets[prog.compositionFragShader]);
0
360 if (prog.maskFragShader)
prog.maskFragShaderDescription
TRUEnever evaluated
FALSEnever evaluated
0
361 fragSource.append(qShaderSnippets[prog.maskFragShader]);
never executed: fragSource.append(qShaderSnippets[prog.maskFragShader]);
0
362-
363 QByteArray vertexSource;-
364 vertexSource.append(qShaderSnippets[prog.mainVertexShader]);-
365 vertexSource.append(qShaderSnippets[prog.positionVertexShader]);-
366-
367 QScopedPointer<QOpenGLShaderProgram> shaderProgram(new QOpenGLShaderProgram);-
368-
369 CachedShader shaderCache(fragSource, vertexSource);-
370 bool inCache = shaderCache.load(shaderProgram.data(), QOpenGLContext::currentContext());-
371-
372 if (!inCache) {
!inCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
373-
374 QScopedPointer<QOpenGLShader> fragShader(new QOpenGLShader(QOpenGLShader::Fragment));-
375 QByteArray description;-
376#if defined(QT_DEBUG)-
377 // Name the shader for easier debugging-
378 description.append("Fragment shader: main=");-
379 description.append(snippetNameStr(prog.mainFragShader));-
380 description.append(", srcPixel=");-
381 description.append(snippetNameStr(prog.srcPixelFragShader));-
382 if (prog.compositionFragShader) {
prog.compositionFragShaderDescription
TRUEnever evaluated
FALSEnever evaluated
0
383 description.append(", composition=");-
384 description.append(snippetNameStr(prog.compositionFragShader));-
385 }
never executed: end of block
0
386 if (prog.maskFragShader) {
prog.maskFragShaderDescription
TRUEnever evaluated
FALSEnever evaluated
0
387 description.append(", mask=");-
388 description.append(snippetNameStr(prog.maskFragShader));-
389 }
never executed: end of block
0
390 fragShader->setObjectName(QString::fromLatin1(description));-
391#endif-
392 if (!fragShader->compileSourceCode(fragSource)) {
!fragShader->c...de(fragSource)Description
TRUEnever evaluated
FALSEnever evaluated
0
393 qWarning() << "Warning:" << description << "failed to compile!";-
394 break;
never executed: break;
0
395 }-
396-
397 QScopedPointer<QOpenGLShader> vertexShader(new QOpenGLShader(QOpenGLShader::Vertex));-
398#if defined(QT_DEBUG)-
399 // Name the shader for easier debugging-
400 description.clear();-
401 description.append("Vertex shader: main=");-
402 description.append(snippetNameStr(prog.mainVertexShader));-
403 description.append(", position=");-
404 description.append(snippetNameStr(prog.positionVertexShader));-
405 vertexShader->setObjectName(QString::fromLatin1(description));-
406#endif-
407 if (!vertexShader->compileSourceCode(vertexSource)) {
!vertexShader-...(vertexSource)Description
TRUEnever evaluated
FALSEnever evaluated
0
408 qWarning() << "Warning:" << description << "failed to compile!";-
409 break;
never executed: break;
0
410 }-
411-
412 shaders.append(vertexShader.data());-
413 shaders.append(fragShader.data());-
414 shaderProgram->addShader(vertexShader.take());-
415 shaderProgram->addShader(fragShader.take());-
416-
417 // We have to bind the vertex attribute names before the program is linked:-
418 shaderProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);-
419 if (prog.useTextureCoords)
prog.useTextureCoordsDescription
TRUEnever evaluated
FALSEnever evaluated
0
420 shaderProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
never executed: shaderProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
0
421 if (prog.useOpacityAttribute)
prog.useOpacityAttributeDescription
TRUEnever evaluated
FALSEnever evaluated
0
422 shaderProgram->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR);
never executed: shaderProgram->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR);
0
423 if (prog.usePmvMatrixAttribute) {
prog.usePmvMatrixAttributeDescription
TRUEnever evaluated
FALSEnever evaluated
0
424 shaderProgram->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR);-
425 shaderProgram->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR);-
426 shaderProgram->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR);-
427 }
never executed: end of block
0
428 }
never executed: end of block
0
429-
430 newProg.reset(new QOpenGLEngineShaderProg(prog));-
431 newProg->program = shaderProgram.take();-
432-
433 newProg->program->link();-
434 if (newProg->program->isLinked()) {
newProg->program->isLinked()Description
TRUEnever evaluated
FALSEnever evaluated
0
435 if (!inCache)
!inCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
436 shaderCache.store(newProg->program, QOpenGLContext::currentContext());
never executed: shaderCache.store(newProg->program, QOpenGLContext::currentContext());
0
437 } else {
never executed: end of block
0
438 QString error;-
439 error = QLatin1String("Shader program failed to link,");-
440#if defined(QT_DEBUG)-
441 QLatin1String br("\n");-
442 error += QLatin1String("\n Shaders Used:\n");-
443 for (int i = 0; i < newProg->program->shaders().count(); ++i) {
i < newProg->p...ders().count()Description
TRUEnever evaluated
FALSEnever evaluated
0
444 QOpenGLShader *shader = newProg->program->shaders().at(i);-
445 error += QLatin1String(" ") + shader->objectName() + QLatin1String(": \n")-
446 + QLatin1String(shader->sourceCode()) + br;-
447 }
never executed: end of block
0
448#endif-
449 error += QLatin1String(" Error Log:\n")-
450 + QLatin1String(" ") + newProg->program->log();-
451 qWarning() << error;-
452 break;
never executed: break;
0
453 }-
454-
455 newProg->program->bind();-
456-
457 if (newProg->maskFragShader != QOpenGLEngineSharedShaders::NoMaskFragmentShader) {
newProg->maskF...FragmentShaderDescription
TRUEnever evaluated
FALSEnever evaluated
0
458 GLuint location = newProg->program->uniformLocation("maskTexture");-
459 newProg->program->setUniformValue(location, QT_MASK_TEXTURE_UNIT);-
460 }
never executed: end of block
0
461-
462 if (cachedPrograms.count() > 30) {
cachedPrograms.count() > 30Description
TRUEnever evaluated
FALSEnever evaluated
0
463 // The cache is full, so delete the last 5 programs in the list.-
464 // These programs will be least used, as a program us bumped to-
465 // the top of the list when it's used.-
466 for (int i = 0; i < 5; ++i) {
i < 5Description
TRUEnever evaluated
FALSEnever evaluated
0
467 delete cachedPrograms.last();-
468 cachedPrograms.removeLast();-
469 }
never executed: end of block
0
470 }
never executed: end of block
0
471-
472 cachedPrograms.insert(0, newProg.data());-
473 } while (false);-
474-
475 return newProg.take();
never executed: return newProg.take();
0
476}-
477-
478void QOpenGLEngineSharedShaders::cleanupCustomStage(QOpenGLCustomShaderStage* stage)-
479{-
480 auto hasStageAsCustomShaderSouce = [stage](QOpenGLEngineShaderProg *cachedProg) -> bool {-
481 if (cachedProg->customStageSource == stage->source()) {
cachedProg->cu...tage->source()Description
TRUEnever evaluated
FALSEnever evaluated
0
482 delete cachedProg;-
483 return true;
never executed: return true;
0
484 }-
485 return false;
never executed: return false;
0
486 };-
487 cachedPrograms.erase(std::remove_if(cachedPrograms.begin(), cachedPrograms.end(),-
488 hasStageAsCustomShaderSouce),-
489 cachedPrograms.end());-
490}
never executed: end of block
0
491-
492-
493QOpenGLEngineShaderManager::QOpenGLEngineShaderManager(QOpenGLContext* context)-
494 : ctx(context),-
495 shaderProgNeedsChanging(true),-
496 complexGeometry(false),-
497 srcPixelType(Qt::NoBrush),-
498 opacityMode(NoOpacity),-
499 maskType(NoMask),-
500 compositionMode(QPainter::CompositionMode_SourceOver),-
501 customSrcStage(0),-
502 currentShaderProg(0)-
503{-
504 sharedShaders = QOpenGLEngineSharedShaders::shadersForContext(context);-
505}
never executed: end of block
0
506-
507QOpenGLEngineShaderManager::~QOpenGLEngineShaderManager()-
508{-
509 //###-
510 removeCustomStage();-
511}
never executed: end of block
0
512-
513GLuint QOpenGLEngineShaderManager::getUniformLocation(Uniform id)-
514{-
515 if (!currentShaderProg)
!currentShaderProgDescription
TRUEnever evaluated
FALSEnever evaluated
0
516 return 0;
never executed: return 0;
0
517-
518 QVector<uint> &uniformLocations = currentShaderProg->uniformLocations;-
519 if (uniformLocations.isEmpty())
uniformLocations.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
520 uniformLocations.fill(GLuint(-1), NumUniforms);
never executed: uniformLocations.fill(GLuint(-1), NumUniforms);
0
521-
522 static const char *const uniformNames[] = {-
523 "imageTexture",-
524 "patternColor",-
525 "globalOpacity",-
526 "depth",-
527 "maskTexture",-
528 "fragmentColor",-
529 "linearData",-
530 "angle",-
531 "halfViewportSize",-
532 "fmp",-
533 "fmp2_m_radius2",-
534 "inverse_2_fmp2_m_radius2",-
535 "sqrfr",-
536 "bradius",-
537 "invertedTextureSize",-
538 "brushTransform",-
539 "brushTexture",-
540 "matrix"-
541 };-
542-
543 if (uniformLocations.at(id) == GLuint(-1))
uniformLocatio... == GLuint(-1)Description
TRUEnever evaluated
FALSEnever evaluated
0
544 uniformLocations[id] = currentShaderProg->program->uniformLocation(uniformNames[id]);
never executed: uniformLocations[id] = currentShaderProg->program->uniformLocation(uniformNames[id]);
0
545-
546 return uniformLocations.at(id);
never executed: return uniformLocations.at(id);
0
547}-
548-
549-
550void QOpenGLEngineShaderManager::optimiseForBrushTransform(QTransform::TransformationType transformType)-
551{-
552 Q_UNUSED(transformType); // Currently ignored-
553}
never executed: end of block
0
554-
555void QOpenGLEngineShaderManager::setDirty()-
556{-
557 shaderProgNeedsChanging = true;-
558}
never executed: end of block
0
559-
560void QOpenGLEngineShaderManager::setSrcPixelType(Qt::BrushStyle style)-
561{-
562 Q_ASSERT(style != Qt::NoBrush);-
563 if (srcPixelType == PixelSrcType(style))
srcPixelType =...SrcType(style)Description
TRUEnever evaluated
FALSEnever evaluated
0
564 return;
never executed: return;
0
565-
566 srcPixelType = style;-
567 shaderProgNeedsChanging = true; //###-
568}
never executed: end of block
0
569-
570void QOpenGLEngineShaderManager::setSrcPixelType(PixelSrcType type)-
571{-
572 if (srcPixelType == type)
srcPixelType == typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
573 return;
never executed: return;
0
574-
575 srcPixelType = type;-
576 shaderProgNeedsChanging = true; //###-
577}
never executed: end of block
0
578-
579void QOpenGLEngineShaderManager::setOpacityMode(OpacityMode mode)-
580{-
581 if (opacityMode == mode)
opacityMode == modeDescription
TRUEnever evaluated
FALSEnever evaluated
0
582 return;
never executed: return;
0
583-
584 opacityMode = mode;-
585 shaderProgNeedsChanging = true; //###-
586}
never executed: end of block
0
587-
588void QOpenGLEngineShaderManager::setMaskType(MaskType type)-
589{-
590 if (maskType == type)
maskType == typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
591 return;
never executed: return;
0
592-
593 maskType = type;-
594 shaderProgNeedsChanging = true; //###-
595}
never executed: end of block
0
596-
597void QOpenGLEngineShaderManager::setCompositionMode(QPainter::CompositionMode mode)-
598{-
599 if (compositionMode == mode)
compositionMode == modeDescription
TRUEnever evaluated
FALSEnever evaluated
0
600 return;
never executed: return;
0
601-
602 compositionMode = mode;-
603 shaderProgNeedsChanging = true; //###-
604}
never executed: end of block
0
605-
606void QOpenGLEngineShaderManager::setCustomStage(QOpenGLCustomShaderStage* stage)-
607{-
608 if (customSrcStage)
customSrcStageDescription
TRUEnever evaluated
FALSEnever evaluated
0
609 removeCustomStage();
never executed: removeCustomStage();
0
610 customSrcStage = stage;-
611 shaderProgNeedsChanging = true;-
612}
never executed: end of block
0
613-
614void QOpenGLEngineShaderManager::removeCustomStage()-
615{-
616 if (customSrcStage)
customSrcStageDescription
TRUEnever evaluated
FALSEnever evaluated
0
617 customSrcStage->setInactive();
never executed: customSrcStage->setInactive();
0
618 customSrcStage = 0;-
619 shaderProgNeedsChanging = true;-
620}
never executed: end of block
0
621-
622QOpenGLShaderProgram* QOpenGLEngineShaderManager::currentProgram()-
623{-
624 if (currentShaderProg)
currentShaderProgDescription
TRUEnever evaluated
FALSEnever evaluated
0
625 return currentShaderProg->program;
never executed: return currentShaderProg->program;
0
626 else-
627 return sharedShaders->simpleProgram();
never executed: return sharedShaders->simpleProgram();
0
628}-
629-
630void QOpenGLEngineShaderManager::useSimpleProgram()-
631{-
632 sharedShaders->simpleProgram()->bind();-
633 QOpenGLContextPrivate* ctx_d = ctx->d_func();-
634 Q_UNUSED(ctx_d);-
635-
636 QOpenGL2PaintEngineEx *active_engine = static_cast<QOpenGL2PaintEngineEx *>(ctx_d->active_engine);-
637-
638 active_engine->d_func()->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true);-
639 active_engine->d_func()->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, false);-
640 active_engine->d_func()->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false);-
641-
642 shaderProgNeedsChanging = true;-
643}
never executed: end of block
0
644-
645void QOpenGLEngineShaderManager::useBlitProgram()-
646{-
647 sharedShaders->blitProgram()->bind();-
648 QOpenGLContextPrivate* ctx_d = ctx->d_func();-
649 QOpenGL2PaintEngineEx *active_engine = static_cast<QOpenGL2PaintEngineEx *>(ctx_d->active_engine);-
650 active_engine->d_func()->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true);-
651 active_engine->d_func()->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, true);-
652 active_engine->d_func()->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false);-
653 shaderProgNeedsChanging = true;-
654}
never executed: end of block
0
655-
656QOpenGLShaderProgram* QOpenGLEngineShaderManager::simpleProgram()-
657{-
658 return sharedShaders->simpleProgram();
never executed: return sharedShaders->simpleProgram();
0
659}-
660-
661QOpenGLShaderProgram* QOpenGLEngineShaderManager::blitProgram()-
662{-
663 return sharedShaders->blitProgram();
never executed: return sharedShaders->blitProgram();
0
664}-
665-
666-
667-
668// Select & use the correct shader program using the current state.-
669// Returns \c true if program needed changing.-
670bool QOpenGLEngineShaderManager::useCorrectShaderProg()-
671{-
672 if (!shaderProgNeedsChanging)
!shaderProgNeedsChangingDescription
TRUEnever evaluated
FALSEnever evaluated
0
673 return false;
never executed: return false;
0
674-
675 bool useCustomSrc = customSrcStage != 0;-
676 if (useCustomSrc && srcPixelType != QOpenGLEngineShaderManager::ImageSrc && srcPixelType != Qt::TexturePattern) {
useCustomSrcDescription
TRUEnever evaluated
FALSEnever evaluated
srcPixelType !...ager::ImageSrcDescription
TRUEnever evaluated
FALSEnever evaluated
srcPixelType !...TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
677 useCustomSrc = false;-
678 qWarning("QOpenGLEngineShaderManager - Ignoring custom shader stage for non image src");-
679 }
never executed: end of block
0
680-
681 QOpenGLEngineShaderProg requiredProgram;-
682-
683 bool texCoords = false;-
684-
685 // Choose vertex shader shader position function (which typically also sets-
686 // varyings) and the source pixel (srcPixel) fragment shader function:-
687 requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::InvalidSnippetName;-
688 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::InvalidSnippetName;-
689 bool isAffine = brushTransform.isAffine();-
690 if ( (srcPixelType >= Qt::Dense1Pattern) && (srcPixelType <= Qt::DiagCrossPattern) ) {
(srcPixelType ...Dense1Pattern)Description
TRUEnever evaluated
FALSEnever evaluated
(srcPixelType ...gCrossPattern)Description
TRUEnever evaluated
FALSEnever evaluated
0
691 if (isAffine)
isAffineDescription
TRUEnever evaluated
FALSEnever evaluated
0
692 requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::AffinePositionWithPatternBrushVertexShader;
never executed: requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::AffinePositionWithPatternBrushVertexShader;
0
693 else-
694 requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::PositionWithPatternBrushVertexShader;
never executed: requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::PositionWithPatternBrushVertexShader;
0
695-
696 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::PatternBrushSrcFragmentShader;-
697 }
never executed: end of block
0
698 else switch (srcPixelType) {-
699 default:
never executed: default:
0
700 case Qt::NoBrush:
never executed: case Qt::NoBrush:
0
701 qFatal("QOpenGLEngineShaderManager::useCorrectShaderProg() - Qt::NoBrush style is set");-
702 break;
never executed: break;
0
703 case QOpenGLEngineShaderManager::ImageSrc:
never executed: case QOpenGLEngineShaderManager::ImageSrc:
0
704 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::ImageSrcFragmentShader;-
705 requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::PositionOnlyVertexShader;-
706 texCoords = true;-
707 break;
never executed: break;
0
708 case QOpenGLEngineShaderManager::NonPremultipliedImageSrc:
never executed: case QOpenGLEngineShaderManager::NonPremultipliedImageSrc:
0
709 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::NonPremultipliedImageSrcFragmentShader;-
710 requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::PositionOnlyVertexShader;-
711 texCoords = true;-
712 break;
never executed: break;
0
713 case QOpenGLEngineShaderManager::GrayscaleImageSrc:
never executed: case QOpenGLEngineShaderManager::GrayscaleImageSrc:
0
714 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::GrayscaleImageSrcFragmentShader;-
715 requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::PositionOnlyVertexShader;-
716 texCoords = true;-
717 break;
never executed: break;
0
718 case QOpenGLEngineShaderManager::AlphaImageSrc:
never executed: case QOpenGLEngineShaderManager::AlphaImageSrc:
0
719 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::AlphaImageSrcFragmentShader;-
720 requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::PositionOnlyVertexShader;-
721 texCoords = true;-
722 break;
never executed: break;
0
723 case QOpenGLEngineShaderManager::PatternSrc:
never executed: case QOpenGLEngineShaderManager::PatternSrc:
0
724 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::ImageSrcWithPatternFragmentShader;-
725 requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::PositionOnlyVertexShader;-
726 texCoords = true;-
727 break;
never executed: break;
0
728 case QOpenGLEngineShaderManager::TextureSrcWithPattern:
never executed: case QOpenGLEngineShaderManager::TextureSrcWithPattern:
0
729 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::TextureBrushSrcWithPatternFragmentShader;-
730 requiredProgram.positionVertexShader = isAffine ? QOpenGLEngineSharedShaders::AffinePositionWithTextureBrushVertexShader
isAffineDescription
TRUEnever evaluated
FALSEnever evaluated
0
731 : QOpenGLEngineSharedShaders::PositionWithTextureBrushVertexShader;-
732 break;
never executed: break;
0
733 case Qt::SolidPattern:
never executed: case Qt::SolidPattern:
0
734 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::SolidBrushSrcFragmentShader;-
735 requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::PositionOnlyVertexShader;-
736 break;
never executed: break;
0
737 case Qt::LinearGradientPattern:
never executed: case Qt::LinearGradientPattern:
0
738 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::LinearGradientBrushSrcFragmentShader;-
739 requiredProgram.positionVertexShader = isAffine ? QOpenGLEngineSharedShaders::AffinePositionWithLinearGradientBrushVertexShader
isAffineDescription
TRUEnever evaluated
FALSEnever evaluated
0
740 : QOpenGLEngineSharedShaders::PositionWithLinearGradientBrushVertexShader;-
741 break;
never executed: break;
0
742 case Qt::ConicalGradientPattern:
never executed: case Qt::ConicalGradientPattern:
0
743 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::ConicalGradientBrushSrcFragmentShader;-
744 requiredProgram.positionVertexShader = isAffine ? QOpenGLEngineSharedShaders::AffinePositionWithConicalGradientBrushVertexShader
isAffineDescription
TRUEnever evaluated
FALSEnever evaluated
0
745 : QOpenGLEngineSharedShaders::PositionWithConicalGradientBrushVertexShader;-
746 break;
never executed: break;
0
747 case Qt::RadialGradientPattern:
never executed: case Qt::RadialGradientPattern:
0
748 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::RadialGradientBrushSrcFragmentShader;-
749 requiredProgram.positionVertexShader = isAffine ? QOpenGLEngineSharedShaders::AffinePositionWithRadialGradientBrushVertexShader
isAffineDescription
TRUEnever evaluated
FALSEnever evaluated
0
750 : QOpenGLEngineSharedShaders::PositionWithRadialGradientBrushVertexShader;-
751 break;
never executed: break;
0
752 case Qt::TexturePattern:
never executed: case Qt::TexturePattern:
0
753 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::TextureBrushSrcFragmentShader;-
754 requiredProgram.positionVertexShader = isAffine ? QOpenGLEngineSharedShaders::AffinePositionWithTextureBrushVertexShader
isAffineDescription
TRUEnever evaluated
FALSEnever evaluated
0
755 : QOpenGLEngineSharedShaders::PositionWithTextureBrushVertexShader;-
756 break;
never executed: break;
0
757 };-
758-
759 if (useCustomSrc) {
useCustomSrcDescription
TRUEnever evaluated
FALSEnever evaluated
0
760 requiredProgram.srcPixelFragShader = QOpenGLEngineSharedShaders::CustomImageSrcFragmentShader;-
761 requiredProgram.customStageSource = customSrcStage->source();-
762 }
never executed: end of block
0
763-
764 const bool hasCompose = compositionMode > QPainter::CompositionMode_Plus;-
765 const bool hasMask = maskType != QOpenGLEngineShaderManager::NoMask;-
766-
767 // Choose fragment shader main function:-
768 if (opacityMode == AttributeOpacity) {
opacityMode ==...tributeOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
769 Q_ASSERT(!hasCompose && !hasMask);-
770 requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_ImageArrays;-
771 } else {
never executed: end of block
0
772 bool useGlobalOpacity = (opacityMode == UniformOpacity);-
773 if (hasCompose && hasMask && useGlobalOpacity)
hasComposeDescription
TRUEnever evaluated
FALSEnever evaluated
hasMaskDescription
TRUEnever evaluated
FALSEnever evaluated
useGlobalOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
774 requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_CMO;
never executed: requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_CMO;
0
775 if (hasCompose && hasMask && !useGlobalOpacity)
hasComposeDescription
TRUEnever evaluated
FALSEnever evaluated
hasMaskDescription
TRUEnever evaluated
FALSEnever evaluated
!useGlobalOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
776 requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_CM;
never executed: requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_CM;
0
777 if (!hasCompose && hasMask && useGlobalOpacity)
!hasComposeDescription
TRUEnever evaluated
FALSEnever evaluated
hasMaskDescription
TRUEnever evaluated
FALSEnever evaluated
useGlobalOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
778 requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_MO;
never executed: requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_MO;
0
779 if (!hasCompose && hasMask && !useGlobalOpacity)
!hasComposeDescription
TRUEnever evaluated
FALSEnever evaluated
hasMaskDescription
TRUEnever evaluated
FALSEnever evaluated
!useGlobalOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
780 requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_M;
never executed: requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_M;
0
781 if (hasCompose && !hasMask && useGlobalOpacity)
hasComposeDescription
TRUEnever evaluated
FALSEnever evaluated
!hasMaskDescription
TRUEnever evaluated
FALSEnever evaluated
useGlobalOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
782 requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_CO;
never executed: requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_CO;
0
783 if (hasCompose && !hasMask && !useGlobalOpacity)
hasComposeDescription
TRUEnever evaluated
FALSEnever evaluated
!hasMaskDescription
TRUEnever evaluated
FALSEnever evaluated
!useGlobalOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
784 requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_C;
never executed: requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_C;
0
785 if (!hasCompose && !hasMask && useGlobalOpacity)
!hasComposeDescription
TRUEnever evaluated
FALSEnever evaluated
!hasMaskDescription
TRUEnever evaluated
FALSEnever evaluated
useGlobalOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
786 requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_O;
never executed: requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader_O;
0
787 if (!hasCompose && !hasMask && !useGlobalOpacity)
!hasComposeDescription
TRUEnever evaluated
FALSEnever evaluated
!hasMaskDescription
TRUEnever evaluated
FALSEnever evaluated
!useGlobalOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
788 requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader;
never executed: requiredProgram.mainFragShader = QOpenGLEngineSharedShaders::MainFragmentShader;
0
789 }
never executed: end of block
0
790-
791 if (hasMask) {
hasMaskDescription
TRUEnever evaluated
FALSEnever evaluated
0
792 if (maskType == PixelMask) {
maskType == PixelMaskDescription
TRUEnever evaluated
FALSEnever evaluated
0
793 requiredProgram.maskFragShader = QOpenGLEngineSharedShaders::MaskFragmentShader;-
794 texCoords = true;-
795 } else if (maskType == SubPixelMaskPass1) {
never executed: end of block
maskType == SubPixelMaskPass1Description
TRUEnever evaluated
FALSEnever evaluated
0
796 requiredProgram.maskFragShader = QOpenGLEngineSharedShaders::RgbMaskFragmentShaderPass1;-
797 texCoords = true;-
798 } else if (maskType == SubPixelMaskPass2) {
never executed: end of block
maskType == SubPixelMaskPass2Description
TRUEnever evaluated
FALSEnever evaluated
0
799 requiredProgram.maskFragShader = QOpenGLEngineSharedShaders::RgbMaskFragmentShaderPass2;-
800 texCoords = true;-
801 } else if (maskType == SubPixelWithGammaMask) {
never executed: end of block
maskType == Su...lWithGammaMaskDescription
TRUEnever evaluated
FALSEnever evaluated
0
802 requiredProgram.maskFragShader = QOpenGLEngineSharedShaders::RgbMaskWithGammaFragmentShader;-
803 texCoords = true;-
804 } else {
never executed: end of block
0
805 qCritical("QOpenGLEngineShaderManager::useCorrectShaderProg() - Unknown mask type");-
806 }
never executed: end of block
0
807 } else {-
808 requiredProgram.maskFragShader = QOpenGLEngineSharedShaders::NoMaskFragmentShader;-
809 }
never executed: end of block
0
810-
811 if (hasCompose) {
hasComposeDescription
TRUEnever evaluated
FALSEnever evaluated
0
812 switch (compositionMode) {-
813 case QPainter::CompositionMode_Multiply:
never executed: case QPainter::CompositionMode_Multiply:
0
814 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::MultiplyCompositionModeFragmentShader;-
815 break;
never executed: break;
0
816 case QPainter::CompositionMode_Screen:
never executed: case QPainter::CompositionMode_Screen:
0
817 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::ScreenCompositionModeFragmentShader;-
818 break;
never executed: break;
0
819 case QPainter::CompositionMode_Overlay:
never executed: case QPainter::CompositionMode_Overlay:
0
820 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::OverlayCompositionModeFragmentShader;-
821 break;
never executed: break;
0
822 case QPainter::CompositionMode_Darken:
never executed: case QPainter::CompositionMode_Darken:
0
823 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::DarkenCompositionModeFragmentShader;-
824 break;
never executed: break;
0
825 case QPainter::CompositionMode_Lighten:
never executed: case QPainter::CompositionMode_Lighten:
0
826 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::LightenCompositionModeFragmentShader;-
827 break;
never executed: break;
0
828 case QPainter::CompositionMode_ColorDodge:
never executed: case QPainter::CompositionMode_ColorDodge:
0
829 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::ColorDodgeCompositionModeFragmentShader;-
830 break;
never executed: break;
0
831 case QPainter::CompositionMode_ColorBurn:
never executed: case QPainter::CompositionMode_ColorBurn:
0
832 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::ColorBurnCompositionModeFragmentShader;-
833 break;
never executed: break;
0
834 case QPainter::CompositionMode_HardLight:
never executed: case QPainter::CompositionMode_HardLight:
0
835 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::HardLightCompositionModeFragmentShader;-
836 break;
never executed: break;
0
837 case QPainter::CompositionMode_SoftLight:
never executed: case QPainter::CompositionMode_SoftLight:
0
838 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::SoftLightCompositionModeFragmentShader;-
839 break;
never executed: break;
0
840 case QPainter::CompositionMode_Difference:
never executed: case QPainter::CompositionMode_Difference:
0
841 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::DifferenceCompositionModeFragmentShader;-
842 break;
never executed: break;
0
843 case QPainter::CompositionMode_Exclusion:
never executed: case QPainter::CompositionMode_Exclusion:
0
844 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::ExclusionCompositionModeFragmentShader;-
845 break;
never executed: break;
0
846 default:
never executed: default:
0
847 qWarning("QOpenGLEngineShaderManager::useCorrectShaderProg() - Unsupported composition mode");-
848 }
never executed: end of block
0
849 } else {-
850 requiredProgram.compositionFragShader = QOpenGLEngineSharedShaders::NoCompositionModeFragmentShader;-
851 }
never executed: end of block
0
852-
853 // Choose vertex shader main function-
854 if (opacityMode == AttributeOpacity) {
opacityMode ==...tributeOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
855 Q_ASSERT(texCoords);-
856 requiredProgram.mainVertexShader = QOpenGLEngineSharedShaders::MainWithTexCoordsAndOpacityVertexShader;-
857 } else if (texCoords) {
never executed: end of block
texCoordsDescription
TRUEnever evaluated
FALSEnever evaluated
0
858 requiredProgram.mainVertexShader = QOpenGLEngineSharedShaders::MainWithTexCoordsVertexShader;-
859 } else {
never executed: end of block
0
860 requiredProgram.mainVertexShader = QOpenGLEngineSharedShaders::MainVertexShader;-
861 }
never executed: end of block
0
862 requiredProgram.useTextureCoords = texCoords;-
863 requiredProgram.useOpacityAttribute = (opacityMode == AttributeOpacity);-
864 if (complexGeometry && srcPixelType == Qt::SolidPattern) {
complexGeometryDescription
TRUEnever evaluated
FALSEnever evaluated
srcPixelType =...::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
865 requiredProgram.positionVertexShader = QOpenGLEngineSharedShaders::ComplexGeometryPositionOnlyVertexShader;-
866 requiredProgram.usePmvMatrixAttribute = false;-
867 } else {
never executed: end of block
0
868 requiredProgram.usePmvMatrixAttribute = true;-
869-
870 // Force complexGeometry off, since we currently don't support that mode for-
871 // non-solid brushes-
872 complexGeometry = false;-
873 }
never executed: end of block
0
874-
875 // At this point, requiredProgram is fully populated so try to find the program in the cache-
876 currentShaderProg = sharedShaders->findProgramInCache(requiredProgram);-
877-
878 if (currentShaderProg && useCustomSrc) {
currentShaderProgDescription
TRUEnever evaluated
FALSEnever evaluated
useCustomSrcDescription
TRUEnever evaluated
FALSEnever evaluated
0
879 customSrcStage->setUniforms(currentShaderProg->program);-
880 }
never executed: end of block
0
881-
882 // Make sure all the vertex attribute arrays the program uses are enabled (and the ones it-
883 // doesn't use are disabled)-
884 QOpenGLContextPrivate* ctx_d = ctx->d_func();-
885 QOpenGL2PaintEngineEx *active_engine = static_cast<QOpenGL2PaintEngineEx *>(ctx_d->active_engine);-
886 active_engine->d_func()->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true);-
887 active_engine->d_func()->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg && currentShaderProg->useTextureCoords);-
888 active_engine->d_func()->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg && currentShaderProg->useOpacityAttribute);-
889-
890 shaderProgNeedsChanging = false;-
891 return true;
never executed: return true;
0
892}-
893-
894QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9