| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/coreapi/qsgnodeupdater.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 "qsgnodeupdater_p.h" | - | ||||||||||||
| 41 | #include "qsgnode.h" | - | ||||||||||||
| 42 | #include "qsgrendernode_p.h" | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 45 | - | |||||||||||||
| 46 | // #define QSG_UPDATER_DEBUG | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | QSGNodeUpdater::QSGNodeUpdater() | - | ||||||||||||
| 49 | : m_combined_matrix_stack(64) | - | ||||||||||||
| 50 | , m_opacity_stack(64) | - | ||||||||||||
| 51 | , m_current_clip(nullptr) | - | ||||||||||||
| 52 | , m_force_update(0) | - | ||||||||||||
| 53 | { | - | ||||||||||||
| 54 | m_opacity_stack.add(1); | - | ||||||||||||
| 55 | } executed 3593 times by 77 tests: end of blockExecuted by:
| 3593 | ||||||||||||
| 56 | - | |||||||||||||
| 57 | QSGNodeUpdater::~QSGNodeUpdater() | - | ||||||||||||
| 58 | { | - | ||||||||||||
| 59 | } | - | ||||||||||||
| 60 | - | |||||||||||||
| 61 | void QSGNodeUpdater::updateStates(QSGNode *n) | - | ||||||||||||
| 62 | { | - | ||||||||||||
| 63 | m_current_clip = nullptr; | - | ||||||||||||
| 64 | m_force_update = 0; | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | Q_ASSERT(m_opacity_stack.size() == 1); // The one we added in the constructr... | - | ||||||||||||
| 67 | Q_ASSERT(m_combined_matrix_stack.isEmpty()); | - | ||||||||||||
| 68 | - | |||||||||||||
| 69 | visitNode(n); | - | ||||||||||||
| 70 | } executed 24 times by 1 test: end of blockExecuted by:
| 24 | ||||||||||||
| 71 | - | |||||||||||||
| 72 | - | |||||||||||||
| 73 | /*! | - | ||||||||||||
| 74 | Returns true if \a node is has something that blocks it in the chain from | - | ||||||||||||
| 75 | \a node to \a root doing a full state update pass. | - | ||||||||||||
| 76 | - | |||||||||||||
| 77 | This function does not process dirty states, simply does a simple traversion | - | ||||||||||||
| 78 | up to the top. | - | ||||||||||||
| 79 | - | |||||||||||||
| 80 | The function assumes that \a root exists in the parent chain of \a node. | - | ||||||||||||
| 81 | */ | - | ||||||||||||
| 82 | - | |||||||||||||
| 83 | bool QSGNodeUpdater::isNodeBlocked(QSGNode *node, QSGNode *root) const | - | ||||||||||||
| 84 | { | - | ||||||||||||
| 85 | while (node != root && node != nullptr) {
| 0-7646172 | ||||||||||||
| 86 | if (node->isSubtreeBlocked())
| 87965-7558207 | ||||||||||||
| 87 | return true; executed 87965 times by 12 tests: return true;Executed by:
| 87965 | ||||||||||||
| 88 | node = node->parent(); | - | ||||||||||||
| 89 | } executed 7558207 times by 76 tests: end of blockExecuted by:
| 7558207 | ||||||||||||
| 90 | return false; executed 920412 times by 76 tests: return false;Executed by:
| 920412 | ||||||||||||
| 91 | } | - | ||||||||||||
| 92 | - | |||||||||||||
| 93 | - | |||||||||||||
| 94 | void QSGNodeUpdater::enterTransformNode(QSGTransformNode *t) | - | ||||||||||||
| 95 | { | - | ||||||||||||
| 96 | #ifdef QSG_UPDATER_DEBUG | - | ||||||||||||
| 97 | qDebug() << "enter transform:" << t << "force=" << m_force_update; | - | ||||||||||||
| 98 | #endif | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | if (!t->matrix().isIdentity()) {
| 0 | ||||||||||||
| 101 | if (!m_combined_matrix_stack.isEmpty()) {
| 0 | ||||||||||||
| 102 | t->setCombinedMatrix(*m_combined_matrix_stack.last() * t->matrix()); | - | ||||||||||||
| 103 | } else { never executed: end of block | 0 | ||||||||||||
| 104 | t->setCombinedMatrix(t->matrix()); | - | ||||||||||||
| 105 | } never executed: end of block | 0 | ||||||||||||
| 106 | m_combined_matrix_stack.add(&t->combinedMatrix()); | - | ||||||||||||
| 107 | } else { never executed: end of block | 0 | ||||||||||||
| 108 | if (!m_combined_matrix_stack.isEmpty()) {
| 0 | ||||||||||||
| 109 | t->setCombinedMatrix(*m_combined_matrix_stack.last()); | - | ||||||||||||
| 110 | } else { never executed: end of block | 0 | ||||||||||||
| 111 | t->setCombinedMatrix(QMatrix4x4()); | - | ||||||||||||
| 112 | } never executed: end of block | 0 | ||||||||||||
| 113 | } | - | ||||||||||||
| 114 | } | - | ||||||||||||
| 115 | - | |||||||||||||
| 116 | - | |||||||||||||
| 117 | void QSGNodeUpdater::leaveTransformNode(QSGTransformNode *t) | - | ||||||||||||
| 118 | { | - | ||||||||||||
| 119 | #ifdef QSG_UPDATER_DEBUG | - | ||||||||||||
| 120 | qDebug() << "leave transform:" << t; | - | ||||||||||||
| 121 | #endif | - | ||||||||||||
| 122 | - | |||||||||||||
| 123 | if (!t->matrix().isIdentity()) {
| 0 | ||||||||||||
| 124 | m_combined_matrix_stack.pop_back(); | - | ||||||||||||
| 125 | } never executed: end of block | 0 | ||||||||||||
| 126 | - | |||||||||||||
| 127 | } never executed: end of block | 0 | ||||||||||||
| 128 | - | |||||||||||||
| 129 | - | |||||||||||||
| 130 | void QSGNodeUpdater::enterClipNode(QSGClipNode *c) | - | ||||||||||||
| 131 | { | - | ||||||||||||
| 132 | #ifdef QSG_UPDATER_DEBUG | - | ||||||||||||
| 133 | qDebug() << "enter clip:" << c; | - | ||||||||||||
| 134 | #endif | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | c->m_matrix = m_combined_matrix_stack.isEmpty() ? 0 : m_combined_matrix_stack.last();
| 0 | ||||||||||||
| 137 | c->m_clip_list = m_current_clip; | - | ||||||||||||
| 138 | m_current_clip = c; | - | ||||||||||||
| 139 | } never executed: end of block | 0 | ||||||||||||
| 140 | - | |||||||||||||
| 141 | - | |||||||||||||
| 142 | void QSGNodeUpdater::leaveClipNode(QSGClipNode *c) | - | ||||||||||||
| 143 | { | - | ||||||||||||
| 144 | #ifdef QSG_UPDATER_DEBUG | - | ||||||||||||
| 145 | qDebug() << "leave clip:" << c; | - | ||||||||||||
| 146 | #endif | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | m_current_clip = c->m_clip_list; | - | ||||||||||||
| 149 | } never executed: end of block | 0 | ||||||||||||
| 150 | - | |||||||||||||
| 151 | - | |||||||||||||
| 152 | void QSGNodeUpdater::enterGeometryNode(QSGGeometryNode *g) | - | ||||||||||||
| 153 | { | - | ||||||||||||
| 154 | #ifdef QSG_UPDATER_DEBUG | - | ||||||||||||
| 155 | qDebug() << "enter geometry:" << g; | - | ||||||||||||
| 156 | #endif | - | ||||||||||||
| 157 | - | |||||||||||||
| 158 | g->m_matrix = m_combined_matrix_stack.isEmpty() ? 0 : m_combined_matrix_stack.last();
| 0 | ||||||||||||
| 159 | g->m_clip_list = m_current_clip; | - | ||||||||||||
| 160 | g->setInheritedOpacity(m_opacity_stack.last()); | - | ||||||||||||
| 161 | } never executed: end of block | 0 | ||||||||||||
| 162 | - | |||||||||||||
| 163 | void QSGNodeUpdater::leaveGeometryNode(QSGGeometryNode *g) | - | ||||||||||||
| 164 | { | - | ||||||||||||
| 165 | #ifdef QSG_UPDATER_DEBUG | - | ||||||||||||
| 166 | qDebug() << "leave geometry" << g; | - | ||||||||||||
| 167 | #else | - | ||||||||||||
| 168 | Q_UNUSED(g) | - | ||||||||||||
| 169 | #endif | - | ||||||||||||
| 170 | } never executed: end of block | 0 | ||||||||||||
| 171 | - | |||||||||||||
| 172 | void QSGNodeUpdater::enterRenderNode(QSGRenderNode *r) | - | ||||||||||||
| 173 | { | - | ||||||||||||
| 174 | #ifdef QSG_UPDATER_DEBUG | - | ||||||||||||
| 175 | qDebug() << "enter render:" << r; | - | ||||||||||||
| 176 | #endif | - | ||||||||||||
| 177 | - | |||||||||||||
| 178 | QSGRenderNodePrivate *rd = QSGRenderNodePrivate::get(r); | - | ||||||||||||
| 179 | rd->m_matrix = m_combined_matrix_stack.isEmpty() ? 0 : m_combined_matrix_stack.last();
| 0 | ||||||||||||
| 180 | rd->m_clip_list = m_current_clip; | - | ||||||||||||
| 181 | rd->m_opacity = m_opacity_stack.last(); | - | ||||||||||||
| 182 | } never executed: end of block | 0 | ||||||||||||
| 183 | - | |||||||||||||
| 184 | void QSGNodeUpdater::leaveRenderNode(QSGRenderNode *r) | - | ||||||||||||
| 185 | { | - | ||||||||||||
| 186 | #ifdef QSG_UPDATER_DEBUG | - | ||||||||||||
| 187 | qDebug() << "leave render" << r; | - | ||||||||||||
| 188 | #else | - | ||||||||||||
| 189 | Q_UNUSED(r) | - | ||||||||||||
| 190 | #endif | - | ||||||||||||
| 191 | } never executed: end of block | 0 | ||||||||||||
| 192 | - | |||||||||||||
| 193 | void QSGNodeUpdater::enterOpacityNode(QSGOpacityNode *o) | - | ||||||||||||
| 194 | { | - | ||||||||||||
| 195 | qreal opacity = m_opacity_stack.last() * o->opacity(); | - | ||||||||||||
| 196 | o->setCombinedOpacity(opacity); | - | ||||||||||||
| 197 | m_opacity_stack.add(opacity); | - | ||||||||||||
| 198 | - | |||||||||||||
| 199 | #ifdef QSG_UPDATER_DEBUG | - | ||||||||||||
| 200 | qDebug() << "enter opacity" << o; | - | ||||||||||||
| 201 | #endif | - | ||||||||||||
| 202 | } never executed: end of block | 0 | ||||||||||||
| 203 | - | |||||||||||||
| 204 | void QSGNodeUpdater::leaveOpacityNode(QSGOpacityNode *o) | - | ||||||||||||
| 205 | { | - | ||||||||||||
| 206 | #ifdef QSG_UPDATER_DEBUG | - | ||||||||||||
| 207 | qDebug() << "leave opacity" << o; | - | ||||||||||||
| 208 | #endif | - | ||||||||||||
| 209 | if (o->flags() & QSGNode::DirtyOpacity)
| 0 | ||||||||||||
| 210 | --m_force_update; never executed: --m_force_update; | 0 | ||||||||||||
| 211 | - | |||||||||||||
| 212 | m_opacity_stack.pop_back(); | - | ||||||||||||
| 213 | } never executed: end of block | 0 | ||||||||||||
| 214 | - | |||||||||||||
| 215 | void QSGNodeUpdater::visitChildren(QSGNode *n) | - | ||||||||||||
| 216 | { | - | ||||||||||||
| 217 | for (QSGNode *c = n->firstChild(); c; c = c->nextSibling())
| 0 | ||||||||||||
| 218 | visitNode(c); never executed: visitNode(c); | 0 | ||||||||||||
| 219 | } never executed: end of block | 0 | ||||||||||||
| 220 | - | |||||||||||||
| 221 | void QSGNodeUpdater::visitNode(QSGNode *n) | - | ||||||||||||
| 222 | { | - | ||||||||||||
| 223 | #ifdef QSG_UPDATER_DEBUG | - | ||||||||||||
| 224 | qDebug() << "enter:" << n; | - | ||||||||||||
| 225 | #endif | - | ||||||||||||
| 226 | - | |||||||||||||
| 227 | if (!m_force_update)
| 0-24 | ||||||||||||
| 228 | return; executed 24 times by 1 test: return;Executed by:
| 24 | ||||||||||||
| 229 | if (n->isSubtreeBlocked())
| 0 | ||||||||||||
| 230 | return; never executed: return; | 0 | ||||||||||||
| 231 | - | |||||||||||||
| 232 | switch (n->type()) { | - | ||||||||||||
| 233 | case QSGNode::TransformNodeType: { never executed: case QSGNode::TransformNodeType: | 0 | ||||||||||||
| 234 | QSGTransformNode *t = static_cast<QSGTransformNode *>(n); | - | ||||||||||||
| 235 | enterTransformNode(t); | - | ||||||||||||
| 236 | visitChildren(t); | - | ||||||||||||
| 237 | leaveTransformNode(t); | - | ||||||||||||
| 238 | break; } never executed: break; | 0 | ||||||||||||
| 239 | case QSGNode::GeometryNodeType: { never executed: case QSGNode::GeometryNodeType: | 0 | ||||||||||||
| 240 | QSGGeometryNode *g = static_cast<QSGGeometryNode *>(n); | - | ||||||||||||
| 241 | enterGeometryNode(g); | - | ||||||||||||
| 242 | visitChildren(g); | - | ||||||||||||
| 243 | leaveGeometryNode(g); | - | ||||||||||||
| 244 | break; } never executed: break; | 0 | ||||||||||||
| 245 | case QSGNode::RenderNodeType: { never executed: case QSGNode::RenderNodeType: | 0 | ||||||||||||
| 246 | QSGRenderNode *r = static_cast<QSGRenderNode *>(n); | - | ||||||||||||
| 247 | enterRenderNode(r); | - | ||||||||||||
| 248 | visitChildren(r); | - | ||||||||||||
| 249 | leaveRenderNode(r); | - | ||||||||||||
| 250 | break; } never executed: break; | 0 | ||||||||||||
| 251 | case QSGNode::ClipNodeType: { never executed: case QSGNode::ClipNodeType: | 0 | ||||||||||||
| 252 | QSGClipNode *c = static_cast<QSGClipNode *>(n); | - | ||||||||||||
| 253 | enterClipNode(c); | - | ||||||||||||
| 254 | visitChildren(c); | - | ||||||||||||
| 255 | leaveClipNode(c); | - | ||||||||||||
| 256 | break; } never executed: break; | 0 | ||||||||||||
| 257 | case QSGNode::OpacityNodeType: { never executed: case QSGNode::OpacityNodeType: | 0 | ||||||||||||
| 258 | QSGOpacityNode *o = static_cast<QSGOpacityNode *>(n); | - | ||||||||||||
| 259 | enterOpacityNode(o); | - | ||||||||||||
| 260 | visitChildren(o); | - | ||||||||||||
| 261 | leaveOpacityNode(o); | - | ||||||||||||
| 262 | break; } never executed: break; | 0 | ||||||||||||
| 263 | default: never executed: default: | 0 | ||||||||||||
| 264 | visitChildren(n); | - | ||||||||||||
| 265 | break; never executed: break; | 0 | ||||||||||||
| 266 | } | - | ||||||||||||
| 267 | } | - | ||||||||||||
| 268 | - | |||||||||||||
| 269 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |