Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
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 Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qopenglcustomshaderstage_p.h" | - |
43 | #include "qopenglengineshadermanager_p.h" | - |
44 | #include "qopenglpaintengine_p.h" | - |
45 | #include <private/qpainter_p.h> | - |
46 | | - |
47 | QT_BEGIN_NAMESPACE | - |
48 | | - |
49 | class QOpenGLCustomShaderStagePrivate | - |
50 | { | - |
51 | public: | - |
52 | QOpenGLCustomShaderStagePrivate() : | - |
53 | m_manager(0) {} | 0 |
54 | | - |
55 | QPointer<QOpenGLEngineShaderManager> m_manager; | - |
56 | QByteArray m_source; | - |
57 | }; | - |
58 | | - |
59 | | - |
60 | | - |
61 | | - |
62 | QOpenGLCustomShaderStage::QOpenGLCustomShaderStage() | - |
63 | : d_ptr(new QOpenGLCustomShaderStagePrivate) | - |
64 | { | - |
65 | } | 0 |
66 | | - |
67 | QOpenGLCustomShaderStage::~QOpenGLCustomShaderStage() | - |
68 | { | - |
69 | Q_D(QOpenGLCustomShaderStage); never executed (the execution status of this line is deduced): QOpenGLCustomShaderStagePrivate * const d = d_func(); | - |
70 | if (d->m_manager) { never evaluated: d->m_manager | 0 |
71 | d->m_manager->removeCustomStage(); never executed (the execution status of this line is deduced): d->m_manager->removeCustomStage(); | - |
72 | d->m_manager->sharedShaders->cleanupCustomStage(this); never executed (the execution status of this line is deduced): d->m_manager->sharedShaders->cleanupCustomStage(this); | - |
73 | } | 0 |
74 | } | 0 |
75 | | - |
76 | void QOpenGLCustomShaderStage::setUniformsDirty() | - |
77 | { | - |
78 | Q_D(QOpenGLCustomShaderStage); never executed (the execution status of this line is deduced): QOpenGLCustomShaderStagePrivate * const d = d_func(); | - |
79 | if (d->m_manager) never evaluated: d->m_manager | 0 |
80 | d->m_manager->setDirty(); // ### Probably a bit overkill! never executed: d->m_manager->setDirty(); | 0 |
81 | } | 0 |
82 | | - |
83 | bool QOpenGLCustomShaderStage::setOnPainter(QPainter* p) | - |
84 | { | - |
85 | Q_D(QOpenGLCustomShaderStage); never executed (the execution status of this line is deduced): QOpenGLCustomShaderStagePrivate * const d = d_func(); | - |
86 | if (p->paintEngine()->type() != QPaintEngine::OpenGL2) { never evaluated: p->paintEngine()->type() != QPaintEngine::OpenGL2 | 0 |
87 | qWarning("QOpenGLCustomShaderStage::setOnPainter() - paint engine not OpenGL2"); never executed (the execution status of this line is deduced): QMessageLogger("opengl/qopenglcustomshaderstage.cpp", 87, __PRETTY_FUNCTION__).warning("QOpenGLCustomShaderStage::setOnPainter() - paint engine not OpenGL2"); | - |
88 | return false; never executed: return false; | 0 |
89 | } | - |
90 | if (d->m_manager) never evaluated: d->m_manager | 0 |
91 | qWarning("Custom shader is already set on a painter"); never executed: QMessageLogger("opengl/qopenglcustomshaderstage.cpp", 91, __PRETTY_FUNCTION__).warning("Custom shader is already set on a painter"); | 0 |
92 | | - |
93 | QOpenGL2PaintEngineEx *engine = static_cast<QOpenGL2PaintEngineEx*>(p->paintEngine()); never executed (the execution status of this line is deduced): QOpenGL2PaintEngineEx *engine = static_cast<QOpenGL2PaintEngineEx*>(p->paintEngine()); | - |
94 | d->m_manager = QOpenGL2PaintEngineExPrivate::shaderManagerForEngine(engine); never executed (the execution status of this line is deduced): d->m_manager = QOpenGL2PaintEngineExPrivate::shaderManagerForEngine(engine); | - |
95 | Q_ASSERT(d->m_manager); never executed (the execution status of this line is deduced): qt_noop(); | - |
96 | | - |
97 | d->m_manager->setCustomStage(this); never executed (the execution status of this line is deduced): d->m_manager->setCustomStage(this); | - |
98 | return true; never executed: return true; | 0 |
99 | } | - |
100 | | - |
101 | void QOpenGLCustomShaderStage::removeFromPainter(QPainter* p) | - |
102 | { | - |
103 | Q_D(QOpenGLCustomShaderStage); never executed (the execution status of this line is deduced): QOpenGLCustomShaderStagePrivate * const d = d_func(); | - |
104 | if (p->paintEngine()->type() != QPaintEngine::OpenGL2) never evaluated: p->paintEngine()->type() != QPaintEngine::OpenGL2 | 0 |
105 | return; | 0 |
106 | | - |
107 | QOpenGL2PaintEngineEx *engine = static_cast<QOpenGL2PaintEngineEx*>(p->paintEngine()); never executed (the execution status of this line is deduced): QOpenGL2PaintEngineEx *engine = static_cast<QOpenGL2PaintEngineEx*>(p->paintEngine()); | - |
108 | d->m_manager = QOpenGL2PaintEngineExPrivate::shaderManagerForEngine(engine); never executed (the execution status of this line is deduced): d->m_manager = QOpenGL2PaintEngineExPrivate::shaderManagerForEngine(engine); | - |
109 | Q_ASSERT(d->m_manager); never executed (the execution status of this line is deduced): qt_noop(); | - |
110 | | - |
111 | // Just set the stage to null, don't call removeCustomStage(). | - |
112 | // This should leave the program in a compiled/linked state | - |
113 | // if the next custom shader stage is this one again. | - |
114 | d->m_manager->setCustomStage(0); never executed (the execution status of this line is deduced): d->m_manager->setCustomStage(0); | - |
115 | d->m_manager = 0; never executed (the execution status of this line is deduced): d->m_manager = 0; | - |
116 | } | 0 |
117 | | - |
118 | QByteArray QOpenGLCustomShaderStage::source() const | - |
119 | { | - |
120 | Q_D(const QOpenGLCustomShaderStage); never executed (the execution status of this line is deduced): const QOpenGLCustomShaderStagePrivate * const d = d_func(); | - |
121 | return d->m_source; never executed: return d->m_source; | 0 |
122 | } | - |
123 | | - |
124 | // Called by the shader manager if another custom shader is attached or | - |
125 | // the manager is deleted | - |
126 | void QOpenGLCustomShaderStage::setInactive() | - |
127 | { | - |
128 | Q_D(QOpenGLCustomShaderStage); never executed (the execution status of this line is deduced): QOpenGLCustomShaderStagePrivate * const d = d_func(); | - |
129 | d->m_manager = 0; never executed (the execution status of this line is deduced): d->m_manager = 0; | - |
130 | } | 0 |
131 | | - |
132 | void QOpenGLCustomShaderStage::setSource(const QByteArray& s) | - |
133 | { | - |
134 | Q_D(QOpenGLCustomShaderStage); never executed (the execution status of this line is deduced): QOpenGLCustomShaderStagePrivate * const d = d_func(); | - |
135 | d->m_source = s; never executed (the execution status of this line is deduced): d->m_source = s; | - |
136 | } | 0 |
137 | | - |
138 | QT_END_NAMESPACE | - |
139 | | - |
| | |