| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 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 QtQuick 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 "qsgvertexcolormaterial.h" | - | ||||||
| 41 | #if QT_CONFIG(opengl) | - | ||||||
| 42 | # include <qopenglshaderprogram.h> | - | ||||||
| 43 | #endif | - | ||||||
| 44 | QT_BEGIN_NAMESPACE | - | ||||||
| 45 | - | |||||||
| 46 | class QSGVertexColorMaterialShader : public QSGMaterialShader | - | ||||||
| 47 | { | - | ||||||
| 48 | public: | - | ||||||
| 49 | QSGVertexColorMaterialShader(); | - | ||||||
| 50 | - | |||||||
| 51 | void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; | - | ||||||
| 52 | char const *const *attributeNames() const override; | - | ||||||
| 53 | - | |||||||
| 54 | static QSGMaterialType type; | - | ||||||
| 55 | - | |||||||
| 56 | private: | - | ||||||
| 57 | void initialize() override; | - | ||||||
| 58 | #if QT_CONFIG(opengl) | - | ||||||
| 59 | int m_matrix_id; | - | ||||||
| 60 | int m_opacity_id; | - | ||||||
| 61 | #endif | - | ||||||
| 62 | }; | - | ||||||
| 63 | - | |||||||
| 64 | QSGMaterialType QSGVertexColorMaterialShader::type; | - | ||||||
| 65 | - | |||||||
| 66 | QSGVertexColorMaterialShader::QSGVertexColorMaterialShader() | - | ||||||
| 67 | { | - | ||||||
| 68 | #if QT_CONFIG(opengl) | - | ||||||
| 69 | setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/vertexcolor.vert")); executed 2317 times by 65 tests: return qstring_literal_temp;Executed by:
| 2317 | ||||||
| 70 | setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/vertexcolor.frag")); executed 2317 times by 65 tests: return qstring_literal_temp;Executed by:
| 2317 | ||||||
| 71 | #endif | - | ||||||
| 72 | } executed 2317 times by 65 tests: end of blockExecuted by:
| 2317 | ||||||
| 73 | - | |||||||
| 74 | void QSGVertexColorMaterialShader::updateState(const RenderState &state, QSGMaterial * /*newEffect*/, QSGMaterial *) | - | ||||||
| 75 | { | - | ||||||
| 76 | #if QT_CONFIG(opengl) | - | ||||||
| 77 | if (state.isOpacityDirty())
| 6047-45079 | ||||||
| 78 | program()->setUniformValue(m_opacity_id, state.opacity()); executed 6047 times by 65 tests: program()->setUniformValue(m_opacity_id, state.opacity());Executed by:
| 6047 | ||||||
| 79 | - | |||||||
| 80 | if (state.isMatrixDirty())
| 0-51126 | ||||||
| 81 | program()->setUniformValue(m_matrix_id, state.combinedMatrix()); executed 51126 times by 65 tests: program()->setUniformValue(m_matrix_id, state.combinedMatrix());Executed by:
| 51126 | ||||||
| 82 | #else | - | ||||||
| 83 | Q_UNUSED(state) | - | ||||||
| 84 | #endif | - | ||||||
| 85 | } executed 51126 times by 65 tests: end of blockExecuted by:
| 51126 | ||||||
| 86 | - | |||||||
| 87 | char const *const *QSGVertexColorMaterialShader::attributeNames() const | - | ||||||
| 88 | { | - | ||||||
| 89 | static const char *const attr[] = { "vertexCoord", "vertexColor", nullptr }; | - | ||||||
| 90 | return attr; executed 147187 times by 65 tests: return attr;Executed by:
| 147187 | ||||||
| 91 | } | - | ||||||
| 92 | - | |||||||
| 93 | void QSGVertexColorMaterialShader::initialize() | - | ||||||
| 94 | { | - | ||||||
| 95 | #if QT_CONFIG(opengl) | - | ||||||
| 96 | m_matrix_id = program()->uniformLocation("matrix"); | - | ||||||
| 97 | m_opacity_id = program()->uniformLocation("opacity"); | - | ||||||
| 98 | #endif | - | ||||||
| 99 | } executed 2317 times by 65 tests: end of blockExecuted by:
| 2317 | ||||||
| 100 | - | |||||||
| 101 | - | |||||||
| 102 | /*! | - | ||||||
| 103 | \class QSGVertexColorMaterial | - | ||||||
| 104 | \brief The QSGVertexColorMaterial class provides a convenient way of rendering per-vertex | - | ||||||
| 105 | colored geometry in the scene graph. | - | ||||||
| 106 | - | |||||||
| 107 | \inmodule QtQuick | - | ||||||
| 108 | \ingroup qtquick-scenegraph-materials | - | ||||||
| 109 | - | |||||||
| 110 | \warning This utility class is only functional when running with the OpenGL | - | ||||||
| 111 | backend of the Qt Quick scenegraph. | - | ||||||
| 112 | - | |||||||
| 113 | The vertex color material will give each vertex in a geometry a color. Pixels between | - | ||||||
| 114 | vertices will be linearly interpolated. The colors can contain transparency. | - | ||||||
| 115 | - | |||||||
| 116 | The geometry to be rendered with vertex color must have the following layout. Attribute | - | ||||||
| 117 | position 0 must contain vertices. Attribute position 1 must contain colors, a tuple of | - | ||||||
| 118 | 4 values with RGBA layout. Both floats in the range of 0 to 1 and unsigned bytes in | - | ||||||
| 119 | the range 0 to 255 are valid for the color values. | - | ||||||
| 120 | - | |||||||
| 121 | \note The rendering pipeline expects pixels with premultiplied alpha. | - | ||||||
| 122 | - | |||||||
| 123 | QSGGeometry::defaultAttributes_ColoredPoint2D() can be used to construct an attribute | - | ||||||
| 124 | set that is compatible with this material. | - | ||||||
| 125 | - | |||||||
| 126 | The vertex color material respects both current opacity and current matrix when | - | ||||||
| 127 | updating it's rendering state. | - | ||||||
| 128 | */ | - | ||||||
| 129 | - | |||||||
| 130 | - | |||||||
| 131 | /*! | - | ||||||
| 132 | Creates a new vertex color material. | - | ||||||
| 133 | */ | - | ||||||
| 134 | - | |||||||
| 135 | QSGVertexColorMaterial::QSGVertexColorMaterial() | - | ||||||
| 136 | { | - | ||||||
| 137 | setFlag(Blending, true); | - | ||||||
| 138 | } executed 73402 times by 66 tests: end of blockExecuted by:
| 73402 | ||||||
| 139 | - | |||||||
| 140 | - | |||||||
| 141 | /*! | - | ||||||
| 142 | int QSGVertexColorMaterial::compare() const | - | ||||||
| 143 | - | |||||||
| 144 | As the vertex color material has all its state in the vertex attributes, | - | ||||||
| 145 | all materials will be equal. | - | ||||||
| 146 | - | |||||||
| 147 | \internal | - | ||||||
| 148 | */ | - | ||||||
| 149 | - | |||||||
| 150 | int QSGVertexColorMaterial::compare(const QSGMaterial * /* other */) const | - | ||||||
| 151 | { | - | ||||||
| 152 | return 0; executed 151701 times by 27 tests: return 0;Executed by:
| 151701 | ||||||
| 153 | } | - | ||||||
| 154 | - | |||||||
| 155 | /*! | - | ||||||
| 156 | \internal | - | ||||||
| 157 | */ | - | ||||||
| 158 | - | |||||||
| 159 | QSGMaterialType *QSGVertexColorMaterial::type() const | - | ||||||
| 160 | { | - | ||||||
| 161 | return &QSGVertexColorMaterialShader::type; executed 354530 times by 65 tests: return &QSGVertexColorMaterialShader::type;Executed by:
| 354530 | ||||||
| 162 | } | - | ||||||
| 163 | - | |||||||
| 164 | - | |||||||
| 165 | - | |||||||
| 166 | /*! | - | ||||||
| 167 | \internal | - | ||||||
| 168 | */ | - | ||||||
| 169 | - | |||||||
| 170 | QSGMaterialShader *QSGVertexColorMaterial::createShader() const | - | ||||||
| 171 | { | - | ||||||
| 172 | return new QSGVertexColorMaterialShader; executed 2317 times by 65 tests: return new QSGVertexColorMaterialShader;Executed by:
| 2317 | ||||||
| 173 | } | - | ||||||
| 174 | - | |||||||
| 175 | QT_END_NAMESPACE | - | ||||||
| Source code | Switch to Preprocessed file |