| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/util/qsgdefaultimagenode.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 "qsgdefaultimagenode_p.h" | - | ||||||||||||
| 41 | #include <private/qsgnode_p.h> | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | QSGDefaultImageNode::QSGDefaultImageNode() | - | ||||||||||||
| 46 | : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) | - | ||||||||||||
| 47 | , m_texCoordMode(QSGDefaultImageNode::NoTransform) | - | ||||||||||||
| 48 | , m_isAtlasTexture(false) | - | ||||||||||||
| 49 | , m_ownsTexture(false) | - | ||||||||||||
| 50 | { | - | ||||||||||||
| 51 | setGeometry(&m_geometry); | - | ||||||||||||
| 52 | setMaterial(&m_material); | - | ||||||||||||
| 53 | setOpaqueMaterial(&m_opaque_material); | - | ||||||||||||
| 54 | m_material.setMipmapFiltering(QSGTexture::None); | - | ||||||||||||
| 55 | m_opaque_material.setMipmapFiltering(QSGTexture::None); | - | ||||||||||||
| 56 | #ifdef QSG_RUNTIME_DESCRIPTION | - | ||||||||||||
| 57 | qsgnode_set_description(this, QLatin1String("image")); | - | ||||||||||||
| 58 | #endif | - | ||||||||||||
| 59 | } never executed: end of block | 0 | ||||||||||||
| 60 | - | |||||||||||||
| 61 | QSGDefaultImageNode::~QSGDefaultImageNode() | - | ||||||||||||
| 62 | { | - | ||||||||||||
| 63 | if (m_ownsTexture)
| 0 | ||||||||||||
| 64 | delete m_material.texture(); never executed: delete m_material.texture(); | 0 | ||||||||||||
| 65 | } never executed: end of block | 0 | ||||||||||||
| 66 | - | |||||||||||||
| 67 | void QSGDefaultImageNode::setFiltering(QSGTexture::Filtering filtering) | - | ||||||||||||
| 68 | { | - | ||||||||||||
| 69 | if (m_material.filtering() == filtering)
| 0 | ||||||||||||
| 70 | return; never executed: return; | 0 | ||||||||||||
| 71 | - | |||||||||||||
| 72 | m_material.setFiltering(filtering); | - | ||||||||||||
| 73 | m_opaque_material.setFiltering(filtering); | - | ||||||||||||
| 74 | markDirty(DirtyMaterial); | - | ||||||||||||
| 75 | } never executed: end of block | 0 | ||||||||||||
| 76 | - | |||||||||||||
| 77 | QSGTexture::Filtering QSGDefaultImageNode::filtering() const | - | ||||||||||||
| 78 | { | - | ||||||||||||
| 79 | return m_material.filtering(); never executed: return m_material.filtering(); | 0 | ||||||||||||
| 80 | } | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | void QSGDefaultImageNode::setMipmapFiltering(QSGTexture::Filtering filtering) | - | ||||||||||||
| 83 | { | - | ||||||||||||
| 84 | if (m_material.mipmapFiltering() == filtering)
| 0 | ||||||||||||
| 85 | return; never executed: return; | 0 | ||||||||||||
| 86 | - | |||||||||||||
| 87 | m_material.setMipmapFiltering(filtering); | - | ||||||||||||
| 88 | m_opaque_material.setMipmapFiltering(filtering); | - | ||||||||||||
| 89 | markDirty(DirtyMaterial); | - | ||||||||||||
| 90 | } never executed: end of block | 0 | ||||||||||||
| 91 | - | |||||||||||||
| 92 | QSGTexture::Filtering QSGDefaultImageNode::mipmapFiltering() const | - | ||||||||||||
| 93 | { | - | ||||||||||||
| 94 | return m_material.mipmapFiltering(); never executed: return m_material.mipmapFiltering(); | 0 | ||||||||||||
| 95 | } | - | ||||||||||||
| 96 | - | |||||||||||||
| 97 | void QSGDefaultImageNode::setAnisotropyLevel(QSGTexture::AnisotropyLevel level) | - | ||||||||||||
| 98 | { | - | ||||||||||||
| 99 | if (m_material.anisotropyLevel() == level)
| 0 | ||||||||||||
| 100 | return; never executed: return; | 0 | ||||||||||||
| 101 | - | |||||||||||||
| 102 | m_material.setAnisotropyLevel(level); | - | ||||||||||||
| 103 | m_opaque_material.setAnisotropyLevel(level); | - | ||||||||||||
| 104 | markDirty(DirtyMaterial); | - | ||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||
| 106 | - | |||||||||||||
| 107 | QSGTexture::AnisotropyLevel QSGDefaultImageNode::anisotropyLevel() const | - | ||||||||||||
| 108 | { | - | ||||||||||||
| 109 | return m_material.anisotropyLevel(); never executed: return m_material.anisotropyLevel(); | 0 | ||||||||||||
| 110 | } | - | ||||||||||||
| 111 | - | |||||||||||||
| 112 | void QSGDefaultImageNode::setRect(const QRectF &r) | - | ||||||||||||
| 113 | { | - | ||||||||||||
| 114 | if (m_rect == r)
| 0 | ||||||||||||
| 115 | return; never executed: return; | 0 | ||||||||||||
| 116 | - | |||||||||||||
| 117 | m_rect = r; | - | ||||||||||||
| 118 | rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode); | - | ||||||||||||
| 119 | markDirty(DirtyGeometry); | - | ||||||||||||
| 120 | } never executed: end of block | 0 | ||||||||||||
| 121 | - | |||||||||||||
| 122 | QRectF QSGDefaultImageNode::rect() const | - | ||||||||||||
| 123 | { | - | ||||||||||||
| 124 | return m_rect; never executed: return m_rect; | 0 | ||||||||||||
| 125 | } | - | ||||||||||||
| 126 | - | |||||||||||||
| 127 | void QSGDefaultImageNode::setSourceRect(const QRectF &r) | - | ||||||||||||
| 128 | { | - | ||||||||||||
| 129 | if (m_sourceRect == r)
| 0 | ||||||||||||
| 130 | return; never executed: return; | 0 | ||||||||||||
| 131 | - | |||||||||||||
| 132 | m_sourceRect = r; | - | ||||||||||||
| 133 | rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode); | - | ||||||||||||
| 134 | markDirty(DirtyGeometry); | - | ||||||||||||
| 135 | } never executed: end of block | 0 | ||||||||||||
| 136 | - | |||||||||||||
| 137 | QRectF QSGDefaultImageNode::sourceRect() const | - | ||||||||||||
| 138 | { | - | ||||||||||||
| 139 | return m_sourceRect; never executed: return m_sourceRect; | 0 | ||||||||||||
| 140 | } | - | ||||||||||||
| 141 | - | |||||||||||||
| 142 | void QSGDefaultImageNode::setTexture(QSGTexture *texture) | - | ||||||||||||
| 143 | { | - | ||||||||||||
| 144 | Q_ASSERT(texture); | - | ||||||||||||
| 145 | if (m_ownsTexture)
| 0 | ||||||||||||
| 146 | delete m_material.texture(); never executed: delete m_material.texture(); | 0 | ||||||||||||
| 147 | m_material.setTexture(texture); | - | ||||||||||||
| 148 | m_opaque_material.setTexture(texture); | - | ||||||||||||
| 149 | rebuildGeometry(&m_geometry, texture, m_rect, m_sourceRect, m_texCoordMode); | - | ||||||||||||
| 150 | - | |||||||||||||
| 151 | DirtyState dirty = DirtyMaterial; | - | ||||||||||||
| 152 | // It would be tempting to skip the extra bit here and instead use | - | ||||||||||||
| 153 | // m_material.texture to get the old state, but that texture could | - | ||||||||||||
| 154 | // have been deleted in the mean time. | - | ||||||||||||
| 155 | bool wasAtlas = m_isAtlasTexture; | - | ||||||||||||
| 156 | m_isAtlasTexture = texture->isAtlasTexture(); | - | ||||||||||||
| 157 | if (wasAtlas || m_isAtlasTexture)
| 0 | ||||||||||||
| 158 | dirty |= DirtyGeometry; never executed: dirty |= DirtyGeometry; | 0 | ||||||||||||
| 159 | markDirty(dirty); | - | ||||||||||||
| 160 | } never executed: end of block | 0 | ||||||||||||
| 161 | - | |||||||||||||
| 162 | QSGTexture *QSGDefaultImageNode::texture() const | - | ||||||||||||
| 163 | { | - | ||||||||||||
| 164 | return m_material.texture(); never executed: return m_material.texture(); | 0 | ||||||||||||
| 165 | } | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 | void QSGDefaultImageNode::setTextureCoordinatesTransform(TextureCoordinatesTransformMode mode) | - | ||||||||||||
| 168 | { | - | ||||||||||||
| 169 | if (m_texCoordMode == mode)
| 0 | ||||||||||||
| 170 | return; never executed: return; | 0 | ||||||||||||
| 171 | m_texCoordMode = mode; | - | ||||||||||||
| 172 | rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode); | - | ||||||||||||
| 173 | markDirty(DirtyMaterial); | - | ||||||||||||
| 174 | } never executed: end of block | 0 | ||||||||||||
| 175 | - | |||||||||||||
| 176 | QSGDefaultImageNode::TextureCoordinatesTransformMode QSGDefaultImageNode::textureCoordinatesTransform() const | - | ||||||||||||
| 177 | { | - | ||||||||||||
| 178 | return m_texCoordMode; never executed: return m_texCoordMode; | 0 | ||||||||||||
| 179 | } | - | ||||||||||||
| 180 | - | |||||||||||||
| 181 | void QSGDefaultImageNode::setOwnsTexture(bool owns) | - | ||||||||||||
| 182 | { | - | ||||||||||||
| 183 | m_ownsTexture = owns; | - | ||||||||||||
| 184 | } never executed: end of block | 0 | ||||||||||||
| 185 | - | |||||||||||||
| 186 | bool QSGDefaultImageNode::ownsTexture() const | - | ||||||||||||
| 187 | { | - | ||||||||||||
| 188 | return m_ownsTexture; never executed: return m_ownsTexture; | 0 | ||||||||||||
| 189 | } | - | ||||||||||||
| 190 | - | |||||||||||||
| 191 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |