OpenCoverage

qsgninepatchnode.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/util/qsgninepatchnode.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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 "qsgninepatchnode.h"-
41-
42QT_BEGIN_NAMESPACE-
43-
44/*!-
45 \class QSGNinePatchNode-
46 \inmodule QtQuick-
47 \since 5.8-
48 \internal-
49 */-
50-
51/*!-
52 \fn void QSGNinePatchNode::setTexture(QSGTexture *texture)-
53 \internal-
54 */-
55-
56/*!-
57 \fn void QSGNinePatchNode::setBounds(const QRectF &bounds)-
58 \internal-
59 */-
60-
61/*!-
62 \fn void QSGNinePatchNode::setDevicePixelRatio(qreal ratio)-
63 \internal-
64 */-
65-
66/*!-
67 \fn void QSGNinePatchNode::setPadding(qreal left, qreal top, qreal right, qreal bottom)-
68 \internal-
69 */-
70-
71-
72/*!-
73 \fn void QSGNinePatchNode::update()-
74 \internal-
75 */-
76-
77void QSGNinePatchNode::rebuildGeometry(QSGTexture *texture, QSGGeometry *geometry, const QVector4D &padding,-
78 const QRectF &bounds, qreal dpr)-
79{-
80 if (padding.x() <= 0 && padding.y() <= 0 && padding.z() <= 0 && padding.w() <= 0) {
padding.x() <= 0Description
TRUEnever evaluated
FALSEnever evaluated
padding.y() <= 0Description
TRUEnever evaluated
FALSEnever evaluated
padding.z() <= 0Description
TRUEnever evaluated
FALSEnever evaluated
padding.w() <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
81 geometry->allocate(4, 0);-
82 QSGGeometry::updateTexturedRectGeometry(geometry, bounds, texture->normalizedTextureSubRect());-
83 return;
never executed: return;
0
84 }-
85-
86 QRectF tc = texture->normalizedTextureSubRect();-
87 QSize ts = texture->textureSize();-
88 ts.setHeight(ts.height() / dpr);-
89 ts.setWidth(ts.width() / dpr);-
90-
91 qreal invtw = tc.width() / ts.width();-
92 qreal invth = tc.height() / ts.height();-
93-
94 struct Coord { qreal p; qreal t; };-
95 Coord cx[4] = { { bounds.left(), tc.left() },-
96 { bounds.left() + padding.x(), tc.left() + padding.x() * invtw },-
97 { bounds.right() - padding.z(), tc.right() - padding.z() * invtw },-
98 { bounds.right(), tc.right() }-
99 };-
100 Coord cy[4] = { { bounds.top(), tc.top() },-
101 { bounds.top() + padding.y(), tc.top() + padding.y() * invth },-
102 { bounds.bottom() - padding.w(), tc.bottom() - padding.w() * invth },-
103 { bounds.bottom(), tc.bottom() }-
104 };-
105-
106 geometry->allocate(16, 28);-
107 QSGGeometry::TexturedPoint2D *v = geometry->vertexDataAsTexturedPoint2D();-
108 for (int y = 0; y < 4; ++y) {
y < 4Description
TRUEnever evaluated
FALSEnever evaluated
0
109 for (int x = 0; x < 4; ++x) {
x < 4Description
TRUEnever evaluated
FALSEnever evaluated
0
110 v->set(cx[x].p, cy[y].p, cx[x].t, cy[y].t);-
111 ++v;-
112 }
never executed: end of block
0
113 }
never executed: end of block
0
114-
115 quint16 *i = geometry->indexDataAsUShort();-
116 for (int r = 0; r < 3; ++r) {
r < 3Description
TRUEnever evaluated
FALSEnever evaluated
0
117 if (r > 0)
r > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
118 *i++ = 4 * r;
never executed: *i++ = 4 * r;
0
119 for (int c = 0; c < 4; ++c) {
c < 4Description
TRUEnever evaluated
FALSEnever evaluated
0
120 i[0] = 4 * r + c;-
121 i[1] = 4 * r + c + 4;-
122 i += 2;-
123 }
never executed: end of block
0
124 if (r < 2)
r < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
125 *i++ = 4 * r + 3 + 4;
never executed: *i++ = 4 * r + 3 + 4;
0
126 }
never executed: end of block
0
127}
never executed: end of block
0
128-
129QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0