| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.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 "qsgsoftwarerenderablenode_p.h" | - | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | #include "qsgsoftwareinternalimagenode_p.h" | - | ||||||||||||||||||
| 43 | #include "qsgsoftwareinternalrectanglenode_p.h" | - | ||||||||||||||||||
| 44 | #include "qsgsoftwareglyphnode_p.h" | - | ||||||||||||||||||
| 45 | #include "qsgsoftwarepublicnodes_p.h" | - | ||||||||||||||||||
| 46 | #include "qsgsoftwarepainternode_p.h" | - | ||||||||||||||||||
| 47 | #include "qsgsoftwarepixmaptexture_p.h" | - | ||||||||||||||||||
| 48 | #if QT_CONFIG(quick_sprite) | - | ||||||||||||||||||
| 49 | #include "qsgsoftwarespritenode_p.h" | - | ||||||||||||||||||
| 50 | #endif | - | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | #include <qsgsimplerectnode.h> | - | ||||||||||||||||||
| 53 | #include <qsgsimpletexturenode.h> | - | ||||||||||||||||||
| 54 | #include <private/qsgrendernode_p.h> | - | ||||||||||||||||||
| 55 | #include <private/qsgtexture_p.h> | - | ||||||||||||||||||
| 56 | - | |||||||||||||||||||
| 57 | #include <qmath.h> | - | ||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | Q_LOGGING_CATEGORY(lcRenderable, "qt.scenegraph.softwarecontext.renderable") executed 26 times by 1 test: return category;Executed by:
| 26 | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | // Largest subrectangle with integer coordinates | - | ||||||||||||||||||
| 64 | inline QRect toRectMin(const QRectF & r) | - | ||||||||||||||||||
| 65 | { | - | ||||||||||||||||||
| 66 | int x1 = qCeil(r.left()); | - | ||||||||||||||||||
| 67 | int x2 = qFloor(r.right()); | - | ||||||||||||||||||
| 68 | int y1 = qCeil(r.top()); | - | ||||||||||||||||||
| 69 | int y2 = qFloor(r.bottom()); | - | ||||||||||||||||||
| 70 | return QRect(x1, y1, x2 - x1, y2 - y1); executed 16 times by 1 test: return QRect(x1, y1, x2 - x1, y2 - y1);Executed by:
| 16 | ||||||||||||||||||
| 71 | } | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | // Smallest superrectangle with integer coordinates | - | ||||||||||||||||||
| 74 | inline QRect toRectMax(const QRectF & r) | - | ||||||||||||||||||
| 75 | { | - | ||||||||||||||||||
| 76 | return r.toAlignedRect(); executed 16 times by 1 test: return r.toAlignedRect();Executed by:
| 16 | ||||||||||||||||||
| 77 | } | - | ||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | QSGSoftwareRenderableNode::QSGSoftwareRenderableNode(NodeType type, QSGNode *node) | - | ||||||||||||||||||
| 80 | : m_nodeType(type) | - | ||||||||||||||||||
| 81 | , m_isOpaque(true) | - | ||||||||||||||||||
| 82 | , m_isDirty(true) | - | ||||||||||||||||||
| 83 | , m_hasClipRegion(false) | - | ||||||||||||||||||
| 84 | , m_opacity(1.0f) | - | ||||||||||||||||||
| 85 | { | - | ||||||||||||||||||
| 86 | switch (m_nodeType) { | - | ||||||||||||||||||
| 87 | case QSGSoftwareRenderableNode::SimpleRect: executed 8 times by 1 test: case QSGSoftwareRenderableNode::SimpleRect:Executed by:
| 8 | ||||||||||||||||||
| 88 | m_handle.simpleRectNode = static_cast<QSGSimpleRectNode*>(node); | - | ||||||||||||||||||
| 89 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||
| 90 | case QSGSoftwareRenderableNode::SimpleTexture: never executed: case QSGSoftwareRenderableNode::SimpleTexture: | 0 | ||||||||||||||||||
| 91 | m_handle.simpleTextureNode = static_cast<QSGSimpleTextureNode*>(node); | - | ||||||||||||||||||
| 92 | break; never executed: break; | 0 | ||||||||||||||||||
| 93 | case QSGSoftwareRenderableNode::Image: never executed: case QSGSoftwareRenderableNode::Image: | 0 | ||||||||||||||||||
| 94 | m_handle.imageNode = static_cast<QSGSoftwareInternalImageNode*>(node); | - | ||||||||||||||||||
| 95 | break; never executed: break; | 0 | ||||||||||||||||||
| 96 | case QSGSoftwareRenderableNode::Painter: never executed: case QSGSoftwareRenderableNode::Painter: | 0 | ||||||||||||||||||
| 97 | m_handle.painterNode = static_cast<QSGSoftwarePainterNode*>(node); | - | ||||||||||||||||||
| 98 | break; never executed: break; | 0 | ||||||||||||||||||
| 99 | case QSGSoftwareRenderableNode::Rectangle: never executed: case QSGSoftwareRenderableNode::Rectangle: | 0 | ||||||||||||||||||
| 100 | m_handle.rectangleNode = static_cast<QSGSoftwareInternalRectangleNode*>(node); | - | ||||||||||||||||||
| 101 | break; never executed: break; | 0 | ||||||||||||||||||
| 102 | case QSGSoftwareRenderableNode::Glyph: never executed: case QSGSoftwareRenderableNode::Glyph: | 0 | ||||||||||||||||||
| 103 | m_handle.glpyhNode = static_cast<QSGSoftwareGlyphNode*>(node); | - | ||||||||||||||||||
| 104 | break; never executed: break; | 0 | ||||||||||||||||||
| 105 | case QSGSoftwareRenderableNode::NinePatch: never executed: case QSGSoftwareRenderableNode::NinePatch: | 0 | ||||||||||||||||||
| 106 | m_handle.ninePatchNode = static_cast<QSGSoftwareNinePatchNode*>(node); | - | ||||||||||||||||||
| 107 | break; never executed: break; | 0 | ||||||||||||||||||
| 108 | case QSGSoftwareRenderableNode::SimpleRectangle: never executed: case QSGSoftwareRenderableNode::SimpleRectangle: | 0 | ||||||||||||||||||
| 109 | m_handle.simpleRectangleNode = static_cast<QSGRectangleNode*>(node); | - | ||||||||||||||||||
| 110 | break; never executed: break; | 0 | ||||||||||||||||||
| 111 | case QSGSoftwareRenderableNode::SimpleImage: never executed: case QSGSoftwareRenderableNode::SimpleImage: | 0 | ||||||||||||||||||
| 112 | m_handle.simpleImageNode = static_cast<QSGImageNode*>(node); | - | ||||||||||||||||||
| 113 | break; never executed: break; | 0 | ||||||||||||||||||
| 114 | #if QT_CONFIG(quick_sprite) | - | ||||||||||||||||||
| 115 | case QSGSoftwareRenderableNode::SpriteNode: never executed: case QSGSoftwareRenderableNode::SpriteNode: | 0 | ||||||||||||||||||
| 116 | m_handle.spriteNode = static_cast<QSGSoftwareSpriteNode*>(node); | - | ||||||||||||||||||
| 117 | break; never executed: break; | 0 | ||||||||||||||||||
| 118 | #endif | - | ||||||||||||||||||
| 119 | case QSGSoftwareRenderableNode::RenderNode: executed 8 times by 1 test: case QSGSoftwareRenderableNode::RenderNode:Executed by:
| 8 | ||||||||||||||||||
| 120 | m_handle.renderNode = static_cast<QSGRenderNode*>(node); | - | ||||||||||||||||||
| 121 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||
| 122 | case QSGSoftwareRenderableNode::Invalid: never executed: case QSGSoftwareRenderableNode::Invalid: | 0 | ||||||||||||||||||
| 123 | m_handle.simpleRectNode = nullptr; | - | ||||||||||||||||||
| 124 | break; never executed: break; | 0 | ||||||||||||||||||
| 125 | } | - | ||||||||||||||||||
| 126 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | QSGSoftwareRenderableNode::~QSGSoftwareRenderableNode() | - | ||||||||||||||||||
| 129 | { | - | ||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | } | - | ||||||||||||||||||
| 132 | - | |||||||||||||||||||
| 133 | void QSGSoftwareRenderableNode::update() | - | ||||||||||||||||||
| 134 | { | - | ||||||||||||||||||
| 135 | // Update the Node properties | - | ||||||||||||||||||
| 136 | m_isDirty = true; | - | ||||||||||||||||||
| 137 | m_isOpaque = false; | - | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | QRectF boundingRect; | - | ||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | switch (m_nodeType) { | - | ||||||||||||||||||
| 142 | case QSGSoftwareRenderableNode::SimpleRect: executed 8 times by 1 test: case QSGSoftwareRenderableNode::SimpleRect:Executed by:
| 8 | ||||||||||||||||||
| 143 | if (m_handle.simpleRectNode->color().alpha() == 255)
| 0-8 | ||||||||||||||||||
| 144 | m_isOpaque = true; executed 8 times by 1 test: m_isOpaque = true;Executed by:
| 8 | ||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 | boundingRect = m_handle.simpleRectNode->rect(); | - | ||||||||||||||||||
| 147 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||
| 148 | case QSGSoftwareRenderableNode::SimpleTexture: never executed: case QSGSoftwareRenderableNode::SimpleTexture: | 0 | ||||||||||||||||||
| 149 | if (!m_handle.simpleTextureNode->texture()->hasAlphaChannel())
| 0 | ||||||||||||||||||
| 150 | m_isOpaque = true; never executed: m_isOpaque = true; | 0 | ||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | boundingRect = m_handle.simpleTextureNode->rect(); | - | ||||||||||||||||||
| 153 | break; never executed: break; | 0 | ||||||||||||||||||
| 154 | case QSGSoftwareRenderableNode::Image: never executed: case QSGSoftwareRenderableNode::Image: | 0 | ||||||||||||||||||
| 155 | m_isOpaque = !m_handle.imageNode->pixmap().hasAlphaChannel(); | - | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | boundingRect = m_handle.imageNode->rect().toRect(); | - | ||||||||||||||||||
| 158 | break; never executed: break; | 0 | ||||||||||||||||||
| 159 | case QSGSoftwareRenderableNode::Painter: never executed: case QSGSoftwareRenderableNode::Painter: | 0 | ||||||||||||||||||
| 160 | if (m_handle.painterNode->opaquePainting())
| 0 | ||||||||||||||||||
| 161 | m_isOpaque = true; never executed: m_isOpaque = true; | 0 | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | boundingRect = QRectF(0, 0, m_handle.painterNode->size().width(), m_handle.painterNode->size().height()); | - | ||||||||||||||||||
| 164 | break; never executed: break; | 0 | ||||||||||||||||||
| 165 | case QSGSoftwareRenderableNode::Rectangle: never executed: case QSGSoftwareRenderableNode::Rectangle: | 0 | ||||||||||||||||||
| 166 | if (m_handle.rectangleNode->isOpaque())
| 0 | ||||||||||||||||||
| 167 | m_isOpaque = true; never executed: m_isOpaque = true; | 0 | ||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | boundingRect = m_handle.rectangleNode->rect(); | - | ||||||||||||||||||
| 170 | break; never executed: break; | 0 | ||||||||||||||||||
| 171 | case QSGSoftwareRenderableNode::Glyph: never executed: case QSGSoftwareRenderableNode::Glyph: | 0 | ||||||||||||||||||
| 172 | // Always has alpha | - | ||||||||||||||||||
| 173 | boundingRect = m_handle.glpyhNode->boundingRect(); | - | ||||||||||||||||||
| 174 | break; never executed: break; | 0 | ||||||||||||||||||
| 175 | case QSGSoftwareRenderableNode::NinePatch: never executed: case QSGSoftwareRenderableNode::NinePatch: | 0 | ||||||||||||||||||
| 176 | m_isOpaque = m_handle.ninePatchNode->isOpaque(); | - | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | boundingRect = m_handle.ninePatchNode->bounds(); | - | ||||||||||||||||||
| 179 | break; never executed: break; | 0 | ||||||||||||||||||
| 180 | case QSGSoftwareRenderableNode::SimpleRectangle: never executed: case QSGSoftwareRenderableNode::SimpleRectangle: | 0 | ||||||||||||||||||
| 181 | if (m_handle.simpleRectangleNode->color().alpha() == 255)
| 0 | ||||||||||||||||||
| 182 | m_isOpaque = true; never executed: m_isOpaque = true; | 0 | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | boundingRect = m_handle.simpleRectangleNode->rect(); | - | ||||||||||||||||||
| 185 | break; never executed: break; | 0 | ||||||||||||||||||
| 186 | case QSGSoftwareRenderableNode::SimpleImage: never executed: case QSGSoftwareRenderableNode::SimpleImage: | 0 | ||||||||||||||||||
| 187 | if (!m_handle.simpleImageNode->texture()->hasAlphaChannel())
| 0 | ||||||||||||||||||
| 188 | m_isOpaque = true; never executed: m_isOpaque = true; | 0 | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | boundingRect = m_handle.simpleImageNode->rect(); | - | ||||||||||||||||||
| 191 | break; never executed: break; | 0 | ||||||||||||||||||
| 192 | #if QT_CONFIG(quick_sprite) | - | ||||||||||||||||||
| 193 | case QSGSoftwareRenderableNode::SpriteNode: never executed: case QSGSoftwareRenderableNode::SpriteNode: | 0 | ||||||||||||||||||
| 194 | m_isOpaque = m_handle.spriteNode->isOpaque(); | - | ||||||||||||||||||
| 195 | boundingRect = m_handle.spriteNode->rect(); | - | ||||||||||||||||||
| 196 | break; never executed: break; | 0 | ||||||||||||||||||
| 197 | #endif | - | ||||||||||||||||||
| 198 | case QSGSoftwareRenderableNode::RenderNode: executed 8 times by 1 test: case QSGSoftwareRenderableNode::RenderNode:Executed by:
| 8 | ||||||||||||||||||
| 199 | if (m_handle.renderNode->flags().testFlag(QSGRenderNode::OpaqueRendering))
| 0-8 | ||||||||||||||||||
| 200 | m_isOpaque = true; never executed: m_isOpaque = true; | 0 | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | boundingRect = m_handle.renderNode->rect(); | - | ||||||||||||||||||
| 203 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||
| 204 | default: never executed: default: | 0 | ||||||||||||||||||
| 205 | break; never executed: break; | 0 | ||||||||||||||||||
| 206 | } | - | ||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | if (m_transform.isRotating())
| 0-16 | ||||||||||||||||||
| 209 | m_isOpaque = false; never executed: m_isOpaque = false; | 0 | ||||||||||||||||||
| 210 | - | |||||||||||||||||||
| 211 | const QRectF transformedRect = m_transform.mapRect(boundingRect); | - | ||||||||||||||||||
| 212 | m_boundingRectMin = toRectMin(transformedRect); | - | ||||||||||||||||||
| 213 | m_boundingRectMax = toRectMax(transformedRect); | - | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | if (m_hasClipRegion && m_clipRegion.rectCount() <= 1) {
| 0-16 | ||||||||||||||||||
| 216 | // If there is a clipRegion, and it is empty, the item wont be rendered | - | ||||||||||||||||||
| 217 | if (m_clipRegion.isEmpty()) {
| 0 | ||||||||||||||||||
| 218 | m_boundingRectMin = QRect(); | - | ||||||||||||||||||
| 219 | m_boundingRectMax = QRect(); | - | ||||||||||||||||||
| 220 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 221 | const auto rects = m_clipRegion.begin(); | - | ||||||||||||||||||
| 222 | m_boundingRectMin = m_boundingRectMin.intersected(rects[0]); | - | ||||||||||||||||||
| 223 | m_boundingRectMax = m_boundingRectMax.intersected(rects[0]); | - | ||||||||||||||||||
| 224 | } never executed: end of block | 0 | ||||||||||||||||||
| 225 | } | - | ||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | // Overrides | - | ||||||||||||||||||
| 228 | if (m_opacity < 1.0f)
| 0-16 | ||||||||||||||||||
| 229 | m_isOpaque = false; never executed: m_isOpaque = false; | 0 | ||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | m_dirtyRegion = QRegion(m_boundingRectMax); | - | ||||||||||||||||||
| 232 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | struct RenderNodeState : public QSGRenderNode::RenderState | - | ||||||||||||||||||
| 235 | { | - | ||||||||||||||||||
| 236 | const QMatrix4x4 *projectionMatrix() const override { return &ident; } never executed: return &ident; | 0 | ||||||||||||||||||
| 237 | QRect scissorRect() const override { return QRect(); } never executed: return QRect(); | 0 | ||||||||||||||||||
| 238 | bool scissorEnabled() const override { return false; } never executed: return false; | 0 | ||||||||||||||||||
| 239 | int stencilValue() const override { return 0; } never executed: return 0; | 0 | ||||||||||||||||||
| 240 | bool stencilEnabled() const override { return false; } never executed: return false; | 0 | ||||||||||||||||||
| 241 | const QRegion *clipRegion() const override { return &cr; } executed 8 times by 1 test: return &cr;Executed by:
| 8 | ||||||||||||||||||
| 242 | QMatrix4x4 ident; | - | ||||||||||||||||||
| 243 | QRegion cr; | - | ||||||||||||||||||
| 244 | }; | - | ||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | QRegion QSGSoftwareRenderableNode::renderNode(QPainter *painter, bool forceOpaquePainting) | - | ||||||||||||||||||
| 247 | { | - | ||||||||||||||||||
| 248 | Q_ASSERT(painter); | - | ||||||||||||||||||
| 249 | - | |||||||||||||||||||
| 250 | // Check for don't paint conditions | - | ||||||||||||||||||
| 251 | if (m_nodeType != RenderNode) {
| 24 | ||||||||||||||||||
| 252 | if (!m_isDirty || qFuzzyIsNull(m_opacity) || m_dirtyRegion.isEmpty()) {
| 0-16 | ||||||||||||||||||
| 253 | m_isDirty = false; | - | ||||||||||||||||||
| 254 | m_dirtyRegion = QRegion(); | - | ||||||||||||||||||
| 255 | return QRegion(); executed 16 times by 1 test: return QRegion();Executed by:
| 16 | ||||||||||||||||||
| 256 | } | - | ||||||||||||||||||
| 257 | } else { executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 258 | if (!m_isDirty || qFuzzyIsNull(m_opacity)) {
| 0-16 | ||||||||||||||||||
| 259 | m_isDirty = false; | - | ||||||||||||||||||
| 260 | m_dirtyRegion = QRegion(); | - | ||||||||||||||||||
| 261 | return QRegion(); executed 16 times by 1 test: return QRegion();Executed by:
| 16 | ||||||||||||||||||
| 262 | } else { | - | ||||||||||||||||||
| 263 | QSGRenderNodePrivate *rd = QSGRenderNodePrivate::get(m_handle.renderNode); | - | ||||||||||||||||||
| 264 | QMatrix4x4 m = m_transform; | - | ||||||||||||||||||
| 265 | rd->m_matrix = &m; | - | ||||||||||||||||||
| 266 | rd->m_opacity = m_opacity; | - | ||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | // all the clip region below is in world coordinates, taking m_transform into account already | - | ||||||||||||||||||
| 269 | QRegion cr = m_dirtyRegion; | - | ||||||||||||||||||
| 270 | if (m_clipRegion.rectCount() > 1)
| 0-8 | ||||||||||||||||||
| 271 | cr &= m_clipRegion; never executed: cr &= m_clipRegion; | 0 | ||||||||||||||||||
| 272 | - | |||||||||||||||||||
| 273 | painter->save(); | - | ||||||||||||||||||
| 274 | RenderNodeState rs; | - | ||||||||||||||||||
| 275 | rs.cr = cr; | - | ||||||||||||||||||
| 276 | m_handle.renderNode->render(&rs); | - | ||||||||||||||||||
| 277 | painter->restore(); | - | ||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | const QRect br = m_handle.renderNode->flags().testFlag(QSGRenderNode::BoundedRectRendering)
| 0-8 | ||||||||||||||||||
| 280 | ? m_boundingRectMax // already mapped to world | - | ||||||||||||||||||
| 281 | : QRect(0, 0, painter->device()->width(), painter->device()->height()); | - | ||||||||||||||||||
| 282 | m_previousDirtyRegion = QRegion(br); | - | ||||||||||||||||||
| 283 | m_isDirty = false; | - | ||||||||||||||||||
| 284 | m_dirtyRegion = QRegion(); | - | ||||||||||||||||||
| 285 | return br; executed 8 times by 1 test: return br;Executed by:
| 8 | ||||||||||||||||||
| 286 | } | - | ||||||||||||||||||
| 287 | } | - | ||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | painter->save(); | - | ||||||||||||||||||
| 290 | painter->setOpacity(m_opacity); | - | ||||||||||||||||||
| 291 | - | |||||||||||||||||||
| 292 | // Set clipRegion to m_dirtyRegion (in world coordinates, so must be done before the setTransform below) | - | ||||||||||||||||||
| 293 | // as m_dirtyRegion already accounts for clipRegion | - | ||||||||||||||||||
| 294 | painter->setClipRegion(m_dirtyRegion, Qt::ReplaceClip); | - | ||||||||||||||||||
| 295 | if (m_clipRegion.rectCount() > 1)
| 0-8 | ||||||||||||||||||
| 296 | painter->setClipRegion(m_clipRegion, Qt::IntersectClip); never executed: painter->setClipRegion(m_clipRegion, Qt::IntersectClip); | 0 | ||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | painter->setTransform(m_transform, false); //precalculated worldTransform | - | ||||||||||||||||||
| 299 | if (forceOpaquePainting || m_isOpaque)
| 0-8 | ||||||||||||||||||
| 300 | painter->setCompositionMode(QPainter::CompositionMode_Source); executed 8 times by 1 test: painter->setCompositionMode(QPainter::CompositionMode_Source);Executed by:
| 8 | ||||||||||||||||||
| 301 | - | |||||||||||||||||||
| 302 | switch (m_nodeType) { | - | ||||||||||||||||||
| 303 | case QSGSoftwareRenderableNode::SimpleRect: executed 8 times by 1 test: case QSGSoftwareRenderableNode::SimpleRect:Executed by:
| 8 | ||||||||||||||||||
| 304 | painter->fillRect(m_handle.simpleRectNode->rect(), m_handle.simpleRectNode->color()); | - | ||||||||||||||||||
| 305 | break; executed 8 times by 1 test: break;Executed by:
| 8 | ||||||||||||||||||
| 306 | case QSGSoftwareRenderableNode::SimpleTexture: never executed: case QSGSoftwareRenderableNode::SimpleTexture: | 0 | ||||||||||||||||||
| 307 | { | - | ||||||||||||||||||
| 308 | QSGTexture *texture = m_handle.simpleTextureNode->texture(); | - | ||||||||||||||||||
| 309 | if (QSGSoftwarePixmapTexture *pt = qobject_cast<QSGSoftwarePixmapTexture *>(texture)) {
| 0 | ||||||||||||||||||
| 310 | const QPixmap &pm = pt->pixmap(); | - | ||||||||||||||||||
| 311 | painter->drawPixmap(m_handle.simpleTextureNode->rect(), pm, m_handle.simpleTextureNode->sourceRect()); | - | ||||||||||||||||||
| 312 | } else if (QSGPlainTexture *pt = qobject_cast<QSGPlainTexture *>(texture)) { never executed: end of block
| 0 | ||||||||||||||||||
| 313 | const QImage &im = pt->image(); | - | ||||||||||||||||||
| 314 | painter->drawImage(m_handle.simpleTextureNode->rect(), im, m_handle.simpleTextureNode->sourceRect()); | - | ||||||||||||||||||
| 315 | } never executed: end of block | 0 | ||||||||||||||||||
| 316 | } | - | ||||||||||||||||||
| 317 | break; never executed: break; | 0 | ||||||||||||||||||
| 318 | case QSGSoftwareRenderableNode::Image: never executed: case QSGSoftwareRenderableNode::Image: | 0 | ||||||||||||||||||
| 319 | m_handle.imageNode->paint(painter); | - | ||||||||||||||||||
| 320 | break; never executed: break; | 0 | ||||||||||||||||||
| 321 | case QSGSoftwareRenderableNode::Painter: never executed: case QSGSoftwareRenderableNode::Painter: | 0 | ||||||||||||||||||
| 322 | m_handle.painterNode->paint(painter); | - | ||||||||||||||||||
| 323 | break; never executed: break; | 0 | ||||||||||||||||||
| 324 | case QSGSoftwareRenderableNode::Rectangle: never executed: case QSGSoftwareRenderableNode::Rectangle: | 0 | ||||||||||||||||||
| 325 | m_handle.rectangleNode->paint(painter); | - | ||||||||||||||||||
| 326 | break; never executed: break; | 0 | ||||||||||||||||||
| 327 | case QSGSoftwareRenderableNode::Glyph: never executed: case QSGSoftwareRenderableNode::Glyph: | 0 | ||||||||||||||||||
| 328 | m_handle.glpyhNode->paint(painter); | - | ||||||||||||||||||
| 329 | break; never executed: break; | 0 | ||||||||||||||||||
| 330 | case QSGSoftwareRenderableNode::NinePatch: never executed: case QSGSoftwareRenderableNode::NinePatch: | 0 | ||||||||||||||||||
| 331 | m_handle.ninePatchNode->paint(painter); | - | ||||||||||||||||||
| 332 | break; never executed: break; | 0 | ||||||||||||||||||
| 333 | case QSGSoftwareRenderableNode::SimpleRectangle: never executed: case QSGSoftwareRenderableNode::SimpleRectangle: | 0 | ||||||||||||||||||
| 334 | static_cast<QSGSoftwareRectangleNode *>(m_handle.simpleRectangleNode)->paint(painter); | - | ||||||||||||||||||
| 335 | break; never executed: break; | 0 | ||||||||||||||||||
| 336 | case QSGSoftwareRenderableNode::SimpleImage: never executed: case QSGSoftwareRenderableNode::SimpleImage: | 0 | ||||||||||||||||||
| 337 | static_cast<QSGSoftwareImageNode *>(m_handle.simpleImageNode)->paint(painter); | - | ||||||||||||||||||
| 338 | break; never executed: break; | 0 | ||||||||||||||||||
| 339 | #if QT_CONFIG(quick_sprite) | - | ||||||||||||||||||
| 340 | case QSGSoftwareRenderableNode::SpriteNode: never executed: case QSGSoftwareRenderableNode::SpriteNode: | 0 | ||||||||||||||||||
| 341 | static_cast<QSGSoftwareSpriteNode *>(m_handle.spriteNode)->paint(painter); | - | ||||||||||||||||||
| 342 | break; never executed: break; | 0 | ||||||||||||||||||
| 343 | #endif | - | ||||||||||||||||||
| 344 | default: never executed: default: | 0 | ||||||||||||||||||
| 345 | break; never executed: break; | 0 | ||||||||||||||||||
| 346 | } | - | ||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | painter->restore(); | - | ||||||||||||||||||
| 349 | - | |||||||||||||||||||
| 350 | QRegion areaToBeFlushed = m_dirtyRegion; | - | ||||||||||||||||||
| 351 | m_previousDirtyRegion = QRegion(m_boundingRectMax); | - | ||||||||||||||||||
| 352 | m_isDirty = false; | - | ||||||||||||||||||
| 353 | m_dirtyRegion = QRegion(); | - | ||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | return areaToBeFlushed; executed 8 times by 1 test: return areaToBeFlushed;Executed by:
| 8 | ||||||||||||||||||
| 356 | } | - | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | bool QSGSoftwareRenderableNode::isDirtyRegionEmpty() const | - | ||||||||||||||||||
| 359 | { | - | ||||||||||||||||||
| 360 | return m_dirtyRegion.isEmpty(); never executed: return m_dirtyRegion.isEmpty(); | 0 | ||||||||||||||||||
| 361 | } | - | ||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | void QSGSoftwareRenderableNode::setTransform(const QTransform &transform) | - | ||||||||||||||||||
| 364 | { | - | ||||||||||||||||||
| 365 | if (m_transform == transform)
| 0-8 | ||||||||||||||||||
| 366 | return; executed 8 times by 1 test: return;Executed by:
| 8 | ||||||||||||||||||
| 367 | m_transform = transform; | - | ||||||||||||||||||
| 368 | update(); | - | ||||||||||||||||||
| 369 | } never executed: end of block | 0 | ||||||||||||||||||
| 370 | - | |||||||||||||||||||
| 371 | void QSGSoftwareRenderableNode::setClipRegion(const QRegion &clipRect, bool hasClipRegion) | - | ||||||||||||||||||
| 372 | { | - | ||||||||||||||||||
| 373 | if (m_clipRegion == clipRect && m_hasClipRegion == hasClipRegion)
| 0-8 | ||||||||||||||||||
| 374 | return; executed 8 times by 1 test: return;Executed by:
| 8 | ||||||||||||||||||
| 375 | - | |||||||||||||||||||
| 376 | m_clipRegion = clipRect; | - | ||||||||||||||||||
| 377 | m_hasClipRegion = hasClipRegion; | - | ||||||||||||||||||
| 378 | update(); | - | ||||||||||||||||||
| 379 | } never executed: end of block | 0 | ||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 | void QSGSoftwareRenderableNode::setOpacity(float opacity) | - | ||||||||||||||||||
| 382 | { | - | ||||||||||||||||||
| 383 | if (qFuzzyCompare(m_opacity, opacity))
| 0-8 | ||||||||||||||||||
| 384 | return; executed 8 times by 1 test: return;Executed by:
| 8 | ||||||||||||||||||
| 385 | - | |||||||||||||||||||
| 386 | m_opacity = opacity; | - | ||||||||||||||||||
| 387 | update(); | - | ||||||||||||||||||
| 388 | } never executed: end of block | 0 | ||||||||||||||||||
| 389 | - | |||||||||||||||||||
| 390 | void QSGSoftwareRenderableNode::markGeometryDirty() | - | ||||||||||||||||||
| 391 | { | - | ||||||||||||||||||
| 392 | update(); | - | ||||||||||||||||||
| 393 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | void QSGSoftwareRenderableNode::markMaterialDirty() | - | ||||||||||||||||||
| 396 | { | - | ||||||||||||||||||
| 397 | update(); | - | ||||||||||||||||||
| 398 | } never executed: end of block | 0 | ||||||||||||||||||
| 399 | - | |||||||||||||||||||
| 400 | void QSGSoftwareRenderableNode::addDirtyRegion(const QRegion &dirtyRegion, bool forceDirty) | - | ||||||||||||||||||
| 401 | { | - | ||||||||||||||||||
| 402 | // Check if the dirty region applies to this node | - | ||||||||||||||||||
| 403 | QRegion prev = m_dirtyRegion; | - | ||||||||||||||||||
| 404 | if (dirtyRegion.intersects(m_boundingRectMax)) {
| 0-24 | ||||||||||||||||||
| 405 | if (forceDirty)
| 0-24 | ||||||||||||||||||
| 406 | m_isDirty = true; executed 24 times by 1 test: m_isDirty = true;Executed by:
| 24 | ||||||||||||||||||
| 407 | m_dirtyRegion += dirtyRegion.intersected(m_boundingRectMax); | - | ||||||||||||||||||
| 408 | } executed 24 times by 1 test: end of blockExecuted by:
| 24 | ||||||||||||||||||
| 409 | qCDebug(lcRenderable) << "addDirtyRegion: " << dirtyRegion << "old dirtyRegion: " << prev << "new dirtyRegion: " << m_dirtyRegion; never executed: QMessageLogger(__FILE__, 409, __PRETTY_FUNCTION__, lcRenderable().categoryName()).debug() << "addDirtyRegion: " << dirtyRegion << "old dirtyRegion: " << prev << "new dirtyRegion: " << m_dirtyRegion;
| 0-24 | ||||||||||||||||||
| 410 | } executed 24 times by 1 test: end of blockExecuted by:
| 24 | ||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | void QSGSoftwareRenderableNode::subtractDirtyRegion(const QRegion &dirtyRegion) | - | ||||||||||||||||||
| 413 | { | - | ||||||||||||||||||
| 414 | QRegion prev = m_dirtyRegion; | - | ||||||||||||||||||
| 415 | if (m_isDirty) {
| 0-2 | ||||||||||||||||||
| 416 | // Check if this rect concerns us | - | ||||||||||||||||||
| 417 | if (dirtyRegion.intersects(m_boundingRectMax)) {
| 0-2 | ||||||||||||||||||
| 418 | m_dirtyRegion -= dirtyRegion; | - | ||||||||||||||||||
| 419 | if (m_dirtyRegion.isEmpty())
| 0-2 | ||||||||||||||||||
| 420 | m_isDirty = false; never executed: m_isDirty = false; | 0 | ||||||||||||||||||
| 421 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 422 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 423 | qCDebug(lcRenderable) << "subtractDirtyRegion: " << dirtyRegion << "old dirtyRegion" << prev << "new dirtyRegion: " << m_dirtyRegion; never executed: QMessageLogger(__FILE__, 423, __PRETTY_FUNCTION__, lcRenderable().categoryName()).debug() << "subtractDirtyRegion: " << dirtyRegion << "old dirtyRegion" << prev << "new dirtyRegion: " << m_dirtyRegion;
| 0-2 | ||||||||||||||||||
| 424 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 425 | - | |||||||||||||||||||
| 426 | QRegion QSGSoftwareRenderableNode::previousDirtyRegion(bool wasRemoved) const | - | ||||||||||||||||||
| 427 | { | - | ||||||||||||||||||
| 428 | // When removing a node, the boundingRect shouldn't be subtracted | - | ||||||||||||||||||
| 429 | // because a deleted node has no valid boundingRect | - | ||||||||||||||||||
| 430 | if (wasRemoved)
| 8-16 | ||||||||||||||||||
| 431 | return m_previousDirtyRegion; executed 8 times by 1 test: return m_previousDirtyRegion;Executed by:
| 8 | ||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | return m_previousDirtyRegion.subtracted(QRegion(m_boundingRectMax)); executed 16 times by 1 test: return m_previousDirtyRegion.subtracted(QRegion(m_boundingRectMax));Executed by:
| 16 | ||||||||||||||||||
| 434 | } | - | ||||||||||||||||||
| 435 | - | |||||||||||||||||||
| 436 | QRegion QSGSoftwareRenderableNode::dirtyRegion() const | - | ||||||||||||||||||
| 437 | { | - | ||||||||||||||||||
| 438 | return m_dirtyRegion; executed 66 times by 1 test: return m_dirtyRegion;Executed by:
| 66 | ||||||||||||||||||
| 439 | } | - | ||||||||||||||||||
| 440 | - | |||||||||||||||||||
| 441 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |