| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes.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 "qsgsoftwarepublicnodes_p.h" | - | ||||||
| 41 | #include "qsgsoftwarepixmaptexture_p.h" | - | ||||||
| 42 | #include "qsgsoftwareinternalimagenode_p.h" | - | ||||||
| 43 | - | |||||||
| 44 | QT_BEGIN_NAMESPACE | - | ||||||
| 45 | - | |||||||
| 46 | QSGSoftwareRectangleNode::QSGSoftwareRectangleNode() | - | ||||||
| 47 | : m_color(QColor(255, 255, 255)) | - | ||||||
| 48 | { | - | ||||||
| 49 | setMaterial((QSGMaterial*)1); | - | ||||||
| 50 | setGeometry((QSGGeometry*)1); | - | ||||||
| 51 | } never executed: end of block | 0 | ||||||
| 52 | - | |||||||
| 53 | void QSGSoftwareRectangleNode::paint(QPainter *painter) | - | ||||||
| 54 | { | - | ||||||
| 55 | painter->fillRect(m_rect, m_color); | - | ||||||
| 56 | } never executed: end of block | 0 | ||||||
| 57 | - | |||||||
| 58 | QSGSoftwareImageNode::QSGSoftwareImageNode() | - | ||||||
| 59 | : m_texture(nullptr), | - | ||||||
| 60 | m_owns(false), | - | ||||||
| 61 | m_filtering(QSGTexture::None), | - | ||||||
| 62 | m_transformMode(NoTransform), | - | ||||||
| 63 | m_cachedMirroredPixmapIsDirty(false) | - | ||||||
| 64 | { | - | ||||||
| 65 | setMaterial((QSGMaterial*)1); | - | ||||||
| 66 | setGeometry((QSGGeometry*)1); | - | ||||||
| 67 | } never executed: end of block | 0 | ||||||
| 68 | - | |||||||
| 69 | QSGSoftwareImageNode::~QSGSoftwareImageNode() | - | ||||||
| 70 | { | - | ||||||
| 71 | if (m_owns)
| 0 | ||||||
| 72 | delete m_texture; never executed: delete m_texture; | 0 | ||||||
| 73 | } never executed: end of block | 0 | ||||||
| 74 | - | |||||||
| 75 | void QSGSoftwareImageNode::setTexture(QSGTexture *texture) | - | ||||||
| 76 | { | - | ||||||
| 77 | if (m_owns)
| 0 | ||||||
| 78 | delete m_texture; never executed: delete m_texture; | 0 | ||||||
| 79 | - | |||||||
| 80 | m_texture = texture; markDirty(DirtyMaterial); | - | ||||||
| 81 | m_cachedMirroredPixmapIsDirty = true; | - | ||||||
| 82 | } never executed: end of block | 0 | ||||||
| 83 | - | |||||||
| 84 | void QSGSoftwareImageNode::setTextureCoordinatesTransform(QSGImageNode::TextureCoordinatesTransformMode transformNode) | - | ||||||
| 85 | { | - | ||||||
| 86 | if (m_transformMode == transformNode)
| 0 | ||||||
| 87 | return; never executed: return; | 0 | ||||||
| 88 | - | |||||||
| 89 | m_transformMode = transformNode; | - | ||||||
| 90 | m_cachedMirroredPixmapIsDirty = true; | - | ||||||
| 91 | - | |||||||
| 92 | markDirty(DirtyGeometry); | - | ||||||
| 93 | } never executed: end of block | 0 | ||||||
| 94 | - | |||||||
| 95 | void QSGSoftwareImageNode::paint(QPainter *painter) | - | ||||||
| 96 | { | - | ||||||
| 97 | if (m_cachedMirroredPixmapIsDirty)
| 0 | ||||||
| 98 | updateCachedMirroredPixmap(); never executed: updateCachedMirroredPixmap(); | 0 | ||||||
| 99 | - | |||||||
| 100 | painter->setRenderHint(QPainter::SmoothPixmapTransform, (m_filtering == QSGTexture::Linear)); | - | ||||||
| 101 | - | |||||||
| 102 | if (!m_cachedPixmap.isNull()) {
| 0 | ||||||
| 103 | painter->drawPixmap(m_rect, m_cachedPixmap, m_sourceRect); | - | ||||||
| 104 | } else if (QSGSoftwarePixmapTexture *pt = qobject_cast<QSGSoftwarePixmapTexture *>(m_texture)) { never executed: end of block
| 0 | ||||||
| 105 | const QPixmap &pm = pt->pixmap(); | - | ||||||
| 106 | painter->drawPixmap(m_rect, pm, m_sourceRect); | - | ||||||
| 107 | } else if (QSGPlainTexture *pt = qobject_cast<QSGPlainTexture *>(m_texture)) { never executed: end of block
| 0 | ||||||
| 108 | const QImage &im = pt->image(); | - | ||||||
| 109 | painter->drawImage(m_rect, im, m_sourceRect); | - | ||||||
| 110 | } never executed: end of block | 0 | ||||||
| 111 | } never executed: end of block | 0 | ||||||
| 112 | - | |||||||
| 113 | void QSGSoftwareImageNode::updateCachedMirroredPixmap() | - | ||||||
| 114 | { | - | ||||||
| 115 | if (m_transformMode == NoTransform) {
| 0 | ||||||
| 116 | m_cachedPixmap = QPixmap(); | - | ||||||
| 117 | } else { never executed: end of block | 0 | ||||||
| 118 | - | |||||||
| 119 | if (QSGSoftwarePixmapTexture *pt = qobject_cast<QSGSoftwarePixmapTexture *>(m_texture)) {
| 0 | ||||||
| 120 | QTransform mirrorTransform; | - | ||||||
| 121 | if (m_transformMode.testFlag(MirrorVertically))
| 0 | ||||||
| 122 | mirrorTransform = mirrorTransform.scale(1, -1); never executed: mirrorTransform = mirrorTransform.scale(1, -1); | 0 | ||||||
| 123 | if (m_transformMode.testFlag(MirrorHorizontally))
| 0 | ||||||
| 124 | mirrorTransform = mirrorTransform.scale(-1, 1); never executed: mirrorTransform = mirrorTransform.scale(-1, 1); | 0 | ||||||
| 125 | m_cachedPixmap = pt->pixmap().transformed(mirrorTransform); | - | ||||||
| 126 | } else if (QSGPlainTexture *pt = qobject_cast<QSGPlainTexture *>(m_texture)) { never executed: end of block
| 0 | ||||||
| 127 | m_cachedPixmap = QPixmap::fromImage(pt->image().mirrored(m_transformMode.testFlag(MirrorHorizontally), m_transformMode.testFlag(MirrorVertically))); | - | ||||||
| 128 | } else { never executed: end of block | 0 | ||||||
| 129 | m_cachedPixmap = QPixmap(); | - | ||||||
| 130 | } never executed: end of block | 0 | ||||||
| 131 | } | - | ||||||
| 132 | - | |||||||
| 133 | m_cachedMirroredPixmapIsDirty = false; | - | ||||||
| 134 | } never executed: end of block | 0 | ||||||
| 135 | - | |||||||
| 136 | QSGSoftwareNinePatchNode::QSGSoftwareNinePatchNode() | - | ||||||
| 137 | { | - | ||||||
| 138 | setMaterial((QSGMaterial*)1); | - | ||||||
| 139 | setGeometry((QSGGeometry*)1); | - | ||||||
| 140 | } never executed: end of block | 0 | ||||||
| 141 | - | |||||||
| 142 | void QSGSoftwareNinePatchNode::setTexture(QSGTexture *texture) | - | ||||||
| 143 | { | - | ||||||
| 144 | QSGSoftwarePixmapTexture *pt = qobject_cast<QSGSoftwarePixmapTexture*>(texture); | - | ||||||
| 145 | if (!pt) {
| 0 | ||||||
| 146 | qWarning() << "Image used with invalid texture format."; | - | ||||||
| 147 | return; never executed: return; | 0 | ||||||
| 148 | } | - | ||||||
| 149 | m_pixmap = pt->pixmap(); | - | ||||||
| 150 | markDirty(DirtyMaterial); | - | ||||||
| 151 | } never executed: end of block | 0 | ||||||
| 152 | - | |||||||
| 153 | void QSGSoftwareNinePatchNode::setBounds(const QRectF &bounds) | - | ||||||
| 154 | { | - | ||||||
| 155 | if (m_bounds == bounds)
| 0 | ||||||
| 156 | return; never executed: return; | 0 | ||||||
| 157 | - | |||||||
| 158 | m_bounds = bounds; | - | ||||||
| 159 | markDirty(DirtyGeometry); | - | ||||||
| 160 | } never executed: end of block | 0 | ||||||
| 161 | - | |||||||
| 162 | void QSGSoftwareNinePatchNode::setDevicePixelRatio(qreal ratio) | - | ||||||
| 163 | { | - | ||||||
| 164 | if (m_pixelRatio == ratio)
| 0 | ||||||
| 165 | return; never executed: return; | 0 | ||||||
| 166 | - | |||||||
| 167 | m_pixelRatio = ratio; | - | ||||||
| 168 | markDirty(DirtyGeometry); | - | ||||||
| 169 | } never executed: end of block | 0 | ||||||
| 170 | - | |||||||
| 171 | void QSGSoftwareNinePatchNode::setPadding(qreal left, qreal top, qreal right, qreal bottom) | - | ||||||
| 172 | { | - | ||||||
| 173 | QMargins margins(qRound(left), qRound(top), qRound(right), qRound(bottom)); | - | ||||||
| 174 | if (m_margins == margins)
| 0 | ||||||
| 175 | return; never executed: return; | 0 | ||||||
| 176 | - | |||||||
| 177 | m_margins = QMargins(qRound(left), qRound(top), qRound(right), qRound(bottom)); | - | ||||||
| 178 | markDirty(DirtyGeometry); | - | ||||||
| 179 | } never executed: end of block | 0 | ||||||
| 180 | - | |||||||
| 181 | void QSGSoftwareNinePatchNode::update() | - | ||||||
| 182 | { | - | ||||||
| 183 | } | - | ||||||
| 184 | - | |||||||
| 185 | void QSGSoftwareNinePatchNode::paint(QPainter *painter) | - | ||||||
| 186 | { | - | ||||||
| 187 | if (m_margins.isNull())
| 0 | ||||||
| 188 | painter->drawPixmap(m_bounds, m_pixmap, QRectF(0, 0, m_pixmap.width(), m_pixmap.height())); never executed: painter->drawPixmap(m_bounds, m_pixmap, QRectF(0, 0, m_pixmap.width(), m_pixmap.height())); | 0 | ||||||
| 189 | else | - | ||||||
| 190 | QSGSoftwareHelpers::qDrawBorderPixmap(painter, m_bounds.toRect(), m_margins, m_pixmap, QRect(0, 0, m_pixmap.width(), m_pixmap.height()), never executed: QSGSoftwareHelpers::qDrawBorderPixmap(painter, m_bounds.toRect(), m_margins, m_pixmap, QRect(0, 0, m_pixmap.width(), m_pixmap.height()), m_margins, Qt::StretchTile, QSGSoftwareHelpers::QDrawBorderPixmap::DrawingHints(nullptr)); | 0 | ||||||
| 191 | m_margins, Qt::StretchTile, QSGSoftwareHelpers::QDrawBorderPixmap::DrawingHints(nullptr)); never executed: QSGSoftwareHelpers::qDrawBorderPixmap(painter, m_bounds.toRect(), m_margins, m_pixmap, QRect(0, 0, m_pixmap.width(), m_pixmap.height()), m_margins, Qt::StretchTile, QSGSoftwareHelpers::QDrawBorderPixmap::DrawingHints(nullptr)); | 0 | ||||||
| 192 | } | - | ||||||
| 193 | - | |||||||
| 194 | QRectF QSGSoftwareNinePatchNode::bounds() const | - | ||||||
| 195 | { | - | ||||||
| 196 | return m_bounds; never executed: return m_bounds; | 0 | ||||||
| 197 | } | - | ||||||
| 198 | - | |||||||
| 199 | QT_END_NAMESPACE | - | ||||||
| Source code | Switch to Preprocessed file |