OpenCoverage

qglcustomshaderstage.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/opengl/gl2paintengineex/qglcustomshaderstage.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 QtOpenGL 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 "qglcustomshaderstage_p.h"-
41#include "qglengineshadermanager_p.h"-
42#include "qpaintengineex_opengl2_p.h"-
43#include <private/qpainter_p.h>-
44-
45QT_BEGIN_NAMESPACE-
46-
47class QGLCustomShaderStagePrivate-
48{-
49public:-
50 QGLCustomShaderStagePrivate() :-
51 m_manager(0) {}
never executed: end of block
0
52-
53 QPointer<QGLEngineShaderManager> m_manager;-
54 QByteArray m_source;-
55};-
56-
57-
58-
59-
60QGLCustomShaderStage::QGLCustomShaderStage()-
61 : d_ptr(new QGLCustomShaderStagePrivate)-
62{-
63}
never executed: end of block
0
64-
65QGLCustomShaderStage::~QGLCustomShaderStage()-
66{-
67 Q_D(QGLCustomShaderStage);-
68 if (d->m_manager) {
d->m_managerDescription
TRUEnever evaluated
FALSEnever evaluated
0
69 d->m_manager->removeCustomStage();-
70 d->m_manager->sharedShaders->cleanupCustomStage(this);-
71 }
never executed: end of block
0
72 delete d_ptr;-
73}
never executed: end of block
0
74-
75void QGLCustomShaderStage::setUniformsDirty()-
76{-
77 Q_D(QGLCustomShaderStage);-
78 if (d->m_manager)
d->m_managerDescription
TRUEnever evaluated
FALSEnever evaluated
0
79 d->m_manager->setDirty(); // ### Probably a bit overkill!
never executed: d->m_manager->setDirty();
0
80}
never executed: end of block
0
81-
82bool QGLCustomShaderStage::setOnPainter(QPainter* p)-
83{-
84 Q_D(QGLCustomShaderStage);-
85 if (p->paintEngine()->type() != QPaintEngine::OpenGL2) {
p->paintEngine...ngine::OpenGL2Description
TRUEnever evaluated
FALSEnever evaluated
0
86 qWarning("QGLCustomShaderStage::setOnPainter() - paint engine not OpenGL2");-
87 return false;
never executed: return false;
0
88 }-
89 if (d->m_manager)
d->m_managerDescription
TRUEnever evaluated
FALSEnever evaluated
0
90 qWarning("Custom shader is already set on a painter");
never executed: QMessageLogger(__FILE__, 90, __PRETTY_FUNCTION__).warning("Custom shader is already set on a painter");
0
91-
92 QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx*>(p->paintEngine());-
93 d->m_manager = QGL2PaintEngineExPrivate::shaderManagerForEngine(engine);-
94 Q_ASSERT(d->m_manager);-
95-
96 d->m_manager->setCustomStage(this);-
97 return true;
never executed: return true;
0
98}-
99-
100void QGLCustomShaderStage::removeFromPainter(QPainter* p)-
101{-
102 Q_D(QGLCustomShaderStage);-
103 if (p->paintEngine()->type() != QPaintEngine::OpenGL2)
p->paintEngine...ngine::OpenGL2Description
TRUEnever evaluated
FALSEnever evaluated
0
104 return;
never executed: return;
0
105-
106 QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx*>(p->paintEngine());-
107 d->m_manager = QGL2PaintEngineExPrivate::shaderManagerForEngine(engine);-
108 Q_ASSERT(d->m_manager);-
109-
110 // Just set the stage to null, don't call removeCustomStage().-
111 // This should leave the program in a compiled/linked state-
112 // if the next custom shader stage is this one again.-
113 d->m_manager->setCustomStage(0);-
114 d->m_manager = 0;-
115}
never executed: end of block
0
116-
117QByteArray QGLCustomShaderStage::source() const-
118{-
119 Q_D(const QGLCustomShaderStage);-
120 return d->m_source;
never executed: return d->m_source;
0
121}-
122-
123// Called by the shader manager if another custom shader is attached or-
124// the manager is deleted-
125void QGLCustomShaderStage::setInactive()-
126{-
127 Q_D(QGLCustomShaderStage);-
128 d->m_manager = 0;-
129}
never executed: end of block
0
130-
131void QGLCustomShaderStage::setSource(const QByteArray& s)-
132{-
133 Q_D(QGLCustomShaderStage);-
134 d->m_source = s;-
135}
never executed: end of block
0
136-
137QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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