| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 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 QtOpenGL 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 "qglcustomshaderstage_p.h" | - | ||||||
| 35 | #include "qglengineshadermanager_p.h" | - | ||||||
| 36 | #include "qpaintengineex_opengl2_p.h" | - | ||||||
| 37 | #include <private/qpainter_p.h> | - | ||||||
| 38 | - | |||||||
| 39 | QT_BEGIN_NAMESPACE | - | ||||||
| 40 | - | |||||||
| 41 | class QGLCustomShaderStagePrivate | - | ||||||
| 42 | { | - | ||||||
| 43 | public: | - | ||||||
| 44 | QGLCustomShaderStagePrivate() : | - | ||||||
| 45 | m_manager(0) {} never executed: end of block | 0 | ||||||
| 46 | - | |||||||
| 47 | QPointer<QGLEngineShaderManager> m_manager; | - | ||||||
| 48 | QByteArray m_source; | - | ||||||
| 49 | }; | - | ||||||
| 50 | - | |||||||
| 51 | - | |||||||
| 52 | - | |||||||
| 53 | - | |||||||
| 54 | QGLCustomShaderStage::QGLCustomShaderStage() | - | ||||||
| 55 | : d_ptr(new QGLCustomShaderStagePrivate) | - | ||||||
| 56 | { | - | ||||||
| 57 | } never executed: end of block | 0 | ||||||
| 58 | - | |||||||
| 59 | QGLCustomShaderStage::~QGLCustomShaderStage() | - | ||||||
| 60 | { | - | ||||||
| 61 | Q_D(QGLCustomShaderStage); | - | ||||||
| 62 | if (d->m_manager) {
| 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 | - | |||||||
| 69 | void QGLCustomShaderStage::setUniformsDirty() | - | ||||||
| 70 | { | - | ||||||
| 71 | Q_D(QGLCustomShaderStage); | - | ||||||
| 72 | if (d->m_manager)
| 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 | - | |||||||
| 76 | bool QGLCustomShaderStage::setOnPainter(QPainter* p) | - | ||||||
| 77 | { | - | ||||||
| 78 | Q_D(QGLCustomShaderStage); | - | ||||||
| 79 | if (p->paintEngine()->type() != QPaintEngine::OpenGL2) {
| 0 | ||||||
| 80 | qWarning("QGLCustomShaderStage::setOnPainter() - paint engine not OpenGL2"); | - | ||||||
| 81 | return false; never executed: return false; | 0 | ||||||
| 82 | } | - | ||||||
| 83 | if (d->m_manager)
| 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 | QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx*>(p->paintEngine()); | - | ||||||
| 87 | d->m_manager = QGL2PaintEngineExPrivate::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 | - | |||||||
| 94 | void QGLCustomShaderStage::removeFromPainter(QPainter* p) | - | ||||||
| 95 | { | - | ||||||
| 96 | Q_D(QGLCustomShaderStage); | - | ||||||
| 97 | if (p->paintEngine()->type() != QPaintEngine::OpenGL2)
| 0 | ||||||
| 98 | return; never executed: return; | 0 | ||||||
| 99 | - | |||||||
| 100 | QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx*>(p->paintEngine()); | - | ||||||
| 101 | d->m_manager = QGL2PaintEngineExPrivate::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 | - | |||||||
| 111 | QByteArray QGLCustomShaderStage::source() const | - | ||||||
| 112 | { | - | ||||||
| 113 | Q_D(const QGLCustomShaderStage); | - | ||||||
| 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 | - | ||||||
| 119 | void QGLCustomShaderStage::setInactive() | - | ||||||
| 120 | { | - | ||||||
| 121 | Q_D(QGLCustomShaderStage); | - | ||||||
| 122 | d->m_manager = 0; | - | ||||||
| 123 | } never executed: end of block | 0 | ||||||
| 124 | - | |||||||
| 125 | void QGLCustomShaderStage::setSource(const QByteArray& s) | - | ||||||
| 126 | { | - | ||||||
| 127 | Q_D(QGLCustomShaderStage); | - | ||||||
| 128 | d->m_source = s; | - | ||||||
| 129 | } never executed: end of block | 0 | ||||||
| 130 | - | |||||||
| 131 | QT_END_NAMESPACE | - | ||||||
| Source code | Switch to Preprocessed file |