qopenglcustomshaderstage.cpp

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

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