Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickshadereffectmesh.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | static const char qt_position_attribute_name[] = "qt_Vertex"; | - | ||||||||||||
5 | static const char qt_texcoord_attribute_name[] = "qt_MultiTexCoord0"; | - | ||||||||||||
6 | - | |||||||||||||
7 | const char *qtPositionAttributeName() | - | ||||||||||||
8 | { | - | ||||||||||||
9 | return executed 238 times by 5 tests: qt_position_attribute_name;return qt_position_attribute_name; Executed by:
executed 238 times by 5 tests: return qt_position_attribute_name; Executed by:
| 238 | ||||||||||||
10 | } | - | ||||||||||||
11 | - | |||||||||||||
12 | const char *qtTexCoordAttributeName() | - | ||||||||||||
13 | { | - | ||||||||||||
14 | return executed 246 times by 5 tests: qt_texcoord_attribute_name;return qt_texcoord_attribute_name; Executed by:
executed 246 times by 5 tests: return qt_texcoord_attribute_name; Executed by:
| 246 | ||||||||||||
15 | } | - | ||||||||||||
16 | - | |||||||||||||
17 | QQuickShaderEffectMesh::QQuickShaderEffectMesh(QObject *parent) | - | ||||||||||||
18 | : QObject(parent) | - | ||||||||||||
19 | { | - | ||||||||||||
20 | } executed 110 times by 5 tests: end of block Executed by:
| 110 | ||||||||||||
21 | QQuickGridMesh::QQuickGridMesh(QObject *parent) | - | ||||||||||||
22 | : QQuickShaderEffectMesh(parent) | - | ||||||||||||
23 | , m_resolution(1, 1) | - | ||||||||||||
24 | { | - | ||||||||||||
25 | } executed 108 times by 5 tests: end of block Executed by:
| 108 | ||||||||||||
26 | - | |||||||||||||
27 | bool QQuickGridMesh::validateAttributes(const QVector<QByteArray> &attributes, int *posIndex) | - | ||||||||||||
28 | { | - | ||||||||||||
29 | const int attrCount = attributes.count(); | - | ||||||||||||
30 | int positionIndex = attributes.indexOf(qtPositionAttributeName()); | - | ||||||||||||
31 | int texCoordIndex = attributes.indexOf(qtTexCoordAttributeName()); | - | ||||||||||||
32 | - | |||||||||||||
33 | switch (attrCount) { | - | ||||||||||||
34 | case never executed: 0:case 0: never executed: case 0: | 0 | ||||||||||||
35 | m_log = QLatin1String("Error: No attributes specified."); | - | ||||||||||||
36 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
37 | case never executed: 1:case 1: never executed: case 1: | 0 | ||||||||||||
38 | if (positionIndex != 0
| 0 | ||||||||||||
39 | m_log = QLatin1String("Error: Missing \'") + QLatin1String(qtPositionAttributeName()) | - | ||||||||||||
40 | + QLatin1String("\' attribute.\n"); | - | ||||||||||||
41 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
42 | } | - | ||||||||||||
43 | break; never executed: break; | 0 | ||||||||||||
44 | case executed 62 times by 4 tests: 2:case 2: Executed by:
executed 62 times by 4 tests: case 2: Executed by:
| 62 | ||||||||||||
45 | if (positionIndex == -1
| 0-62 | ||||||||||||
46 | m_log.clear(); | - | ||||||||||||
47 | if (positionIndex == -1
| 0 | ||||||||||||
48 | m_log = QLatin1String("Error: Missing \'") + QLatin1String(qtPositionAttributeName()) | - | ||||||||||||
49 | + QLatin1String("\' attribute.\n"); | - | ||||||||||||
50 | } never executed: end of block | 0 | ||||||||||||
51 | if (texCoordIndex == -1
| 0 | ||||||||||||
52 | m_log += QLatin1String("Error: Missing \'") + QLatin1String(qtTexCoordAttributeName()) | - | ||||||||||||
53 | + QLatin1String("\' attribute.\n"); | - | ||||||||||||
54 | } never executed: end of block | 0 | ||||||||||||
55 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
56 | } | - | ||||||||||||
57 | break; executed 62 times by 4 tests: break; Executed by:
| 62 | ||||||||||||
58 | default never executed: :default: never executed: default: | 0 | ||||||||||||
59 | m_log = QLatin1String("Error: Too many attributes specified."); | - | ||||||||||||
60 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
61 | } | - | ||||||||||||
62 | - | |||||||||||||
63 | if (posIndex
| 0-62 | ||||||||||||
64 | * executed 62 times by 4 tests: posIndex = positionIndex;*posIndex = positionIndex; Executed by:
executed 62 times by 4 tests: *posIndex = positionIndex; Executed by:
| 62 | ||||||||||||
65 | - | |||||||||||||
66 | return executed 62 times by 4 tests: true;return true; Executed by:
executed 62 times by 4 tests: return true; Executed by:
| 62 | ||||||||||||
67 | } | - | ||||||||||||
68 | - | |||||||||||||
69 | QSGGeometry *QQuickGridMesh::updateGeometry(QSGGeometry *geometry, int attrCount, int posIndex, | - | ||||||||||||
70 | const QRectF &srcRect, const QRectF &dstRect) | - | ||||||||||||
71 | { | - | ||||||||||||
72 | int vmesh = m_resolution.height(); | - | ||||||||||||
73 | int hmesh = m_resolution.width(); | - | ||||||||||||
74 | - | |||||||||||||
75 | if (!geometry
| 0-62 | ||||||||||||
76 | ((attrCount == 1 || attrCount == 2) ? static_cast<void>(0) : qt_assert("attrCount == 1 || attrCount == 2", __FILE__, 135)); | - | ||||||||||||
77 | geometry = new QSGGeometry(attrCount == 1 | - | ||||||||||||
78 | ? QSGGeometry::defaultAttributes_Point2D() | - | ||||||||||||
79 | : QSGGeometry::defaultAttributes_TexturedPoint2D(), | - | ||||||||||||
80 | (vmesh + 1) * (hmesh + 1), vmesh * 2 * (hmesh + 2), | - | ||||||||||||
81 | QSGGeometry::UnsignedShortType); | - | ||||||||||||
82 | - | |||||||||||||
83 | } executed 62 times by 4 tests: else {end of block Executed by:
| 62 | ||||||||||||
84 | geometry->allocate((vmesh + 1) * (hmesh + 1), vmesh * 2 * (hmesh + 2)); | - | ||||||||||||
85 | } never executed: end of block | 0 | ||||||||||||
86 | - | |||||||||||||
87 | QSGGeometry::Point2D *vdata = static_cast<QSGGeometry::Point2D *>(geometry->vertexData()); | - | ||||||||||||
88 | - | |||||||||||||
89 | for (int iy = 0; iy <= vmesh
| 62-124 | ||||||||||||
90 | float fy = iy / float(vmesh); | - | ||||||||||||
91 | float y = float(dstRect.top()) + fy * float(dstRect.height()); | - | ||||||||||||
92 | float ty = float(srcRect.top()) + fy * float(srcRect.height()); | - | ||||||||||||
93 | for (int ix = 0; ix <= hmesh
| 124-248 | ||||||||||||
94 | float fx = ix / float(hmesh); | - | ||||||||||||
95 | for (int ia = 0; ia < attrCount
| 248-496 | ||||||||||||
96 | if (ia == posIndex
| 248 | ||||||||||||
97 | vdata->x = float(dstRect.left()) + fx * float(dstRect.width()); | - | ||||||||||||
98 | vdata->y = y; | - | ||||||||||||
99 | ++vdata; | - | ||||||||||||
100 | } executed 248 times by 4 tests: else {end of block Executed by:
| 248 | ||||||||||||
101 | vdata->x = float(srcRect.left()) + fx * float(srcRect.width()); | - | ||||||||||||
102 | vdata->y = ty; | - | ||||||||||||
103 | ++vdata; | - | ||||||||||||
104 | } executed 248 times by 4 tests: end of block Executed by:
| 248 | ||||||||||||
105 | } | - | ||||||||||||
106 | } executed 248 times by 4 tests: end of block Executed by:
| 248 | ||||||||||||
107 | } executed 124 times by 4 tests: end of block Executed by:
| 124 | ||||||||||||
108 | - | |||||||||||||
109 | quint16 *indices = (quint16 *)geometry->indexDataAsUShort(); | - | ||||||||||||
110 | int i = 0; | - | ||||||||||||
111 | for (int iy = 0; iy < vmesh
| 62 | ||||||||||||
112 | *(indices++) = i + hmesh + 1; | - | ||||||||||||
113 | for (int ix = 0; ix <= hmesh
| 62-124 | ||||||||||||
114 | *(indices++) = i + hmesh + 1; | - | ||||||||||||
115 | *(indices++) = i; | - | ||||||||||||
116 | } executed 124 times by 4 tests: end of block Executed by:
| 124 | ||||||||||||
117 | *(indices++) = i - 1; | - | ||||||||||||
118 | } executed 62 times by 4 tests: end of block Executed by:
| 62 | ||||||||||||
119 | - | |||||||||||||
120 | return executed 62 times by 4 tests: geometry;return geometry; Executed by:
executed 62 times by 4 tests: return geometry; Executed by:
| 62 | ||||||||||||
121 | } | - | ||||||||||||
122 | void QQuickGridMesh::setResolution(const QSize &res) | - | ||||||||||||
123 | { | - | ||||||||||||
124 | if (res == m_resolution
| 0 | ||||||||||||
125 | return; never executed: return; | 0 | ||||||||||||
126 | if (res.width() < 1
| 0 | ||||||||||||
127 | return; never executed: return; | 0 | ||||||||||||
128 | } | - | ||||||||||||
129 | m_resolution = res; | - | ||||||||||||
130 | resolutionChanged(); | - | ||||||||||||
131 | geometryChanged(); | - | ||||||||||||
132 | } never executed: end of block | 0 | ||||||||||||
133 | - | |||||||||||||
134 | QSize QQuickGridMesh::resolution() const | - | ||||||||||||
135 | { | - | ||||||||||||
136 | return never executed: m_resolution;return m_resolution; never executed: return m_resolution; | 0 | ||||||||||||
137 | } | - | ||||||||||||
138 | QQuickBorderImageMesh::QQuickBorderImageMesh(QObject *parent) | - | ||||||||||||
139 | : QQuickShaderEffectMesh(parent), m_border(new QQuickScaleGrid(this)), | - | ||||||||||||
140 | m_horizontalTileMode(QQuickBorderImageMesh::Stretch), | - | ||||||||||||
141 | m_verticalTileMode(QQuickBorderImageMesh::Stretch) | - | ||||||||||||
142 | { | - | ||||||||||||
143 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
144 | - | |||||||||||||
145 | bool QQuickBorderImageMesh::validateAttributes(const QVector<QByteArray> &attributes, int *posIndex) | - | ||||||||||||
146 | { | - | ||||||||||||
147 | (void)attributes;; | - | ||||||||||||
148 | (void)posIndex;; | - | ||||||||||||
149 | return executed 2 times by 1 test: true;return true; Executed by:
executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||
150 | } | - | ||||||||||||
151 | - | |||||||||||||
152 | QSGGeometry *QQuickBorderImageMesh::updateGeometry(QSGGeometry *geometry, int attrCount, int posIndex, | - | ||||||||||||
153 | const QRectF &srcRect, const QRectF &rect) | - | ||||||||||||
154 | { | - | ||||||||||||
155 | (void)attrCount;; | - | ||||||||||||
156 | (void)posIndex;; | - | ||||||||||||
157 | - | |||||||||||||
158 | QRectF innerSourceRect; | - | ||||||||||||
159 | QRectF targetRect; | - | ||||||||||||
160 | QRectF innerTargetRect; | - | ||||||||||||
161 | QRectF subSourceRect; | - | ||||||||||||
162 | - | |||||||||||||
163 | QQuickBorderImagePrivate::calculateRects(m_border, m_size, rect.size(), m_horizontalTileMode, m_verticalTileMode, | - | ||||||||||||
164 | 1, &targetRect, &innerTargetRect, &innerSourceRect, &subSourceRect); | - | ||||||||||||
165 | - | |||||||||||||
166 | QRectF sourceRect = srcRect; | - | ||||||||||||
167 | QRectF modifiedInnerSourceRect(sourceRect.x() + innerSourceRect.x() * sourceRect.width(), | - | ||||||||||||
168 | sourceRect.y() + innerSourceRect.y() * sourceRect.height(), | - | ||||||||||||
169 | innerSourceRect.width() * sourceRect.width(), | - | ||||||||||||
170 | innerSourceRect.height() * sourceRect.height()); | - | ||||||||||||
171 | - | |||||||||||||
172 | geometry = QSGBasicInternalImageNode::updateGeometry(targetRect, innerTargetRect, sourceRect, | - | ||||||||||||
173 | modifiedInnerSourceRect, subSourceRect, geometry); | - | ||||||||||||
174 | - | |||||||||||||
175 | return executed 2 times by 1 test: geometry;return geometry; Executed by:
executed 2 times by 1 test: return geometry; Executed by:
| 2 | ||||||||||||
176 | } | - | ||||||||||||
177 | QQuickScaleGrid *QQuickBorderImageMesh::border() const | - | ||||||||||||
178 | { | - | ||||||||||||
179 | return executed 2 times by 1 test: m_border;return m_border; Executed by:
executed 2 times by 1 test: return m_border; Executed by:
| 2 | ||||||||||||
180 | } | - | ||||||||||||
181 | - | |||||||||||||
182 | - | |||||||||||||
183 | - | |||||||||||||
184 | - | |||||||||||||
185 | - | |||||||||||||
186 | - | |||||||||||||
187 | - | |||||||||||||
188 | QSize QQuickBorderImageMesh::size() const | - | ||||||||||||
189 | { | - | ||||||||||||
190 | return never executed: m_size;return m_size; never executed: return m_size; | 0 | ||||||||||||
191 | } | - | ||||||||||||
192 | - | |||||||||||||
193 | void QQuickBorderImageMesh::setSize(const QSize &size) | - | ||||||||||||
194 | { | - | ||||||||||||
195 | if (size == m_size
| 0-4 | ||||||||||||
196 | return; never executed: return; | 0 | ||||||||||||
197 | m_size = size; | - | ||||||||||||
198 | sizeChanged(); | - | ||||||||||||
199 | geometryChanged(); | - | ||||||||||||
200 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||
201 | QQuickBorderImageMesh::TileMode QQuickBorderImageMesh::horizontalTileMode() const | - | ||||||||||||
202 | { | - | ||||||||||||
203 | return never executed: m_horizontalTileMode;return m_horizontalTileMode; never executed: return m_horizontalTileMode; | 0 | ||||||||||||
204 | } | - | ||||||||||||
205 | - | |||||||||||||
206 | void QQuickBorderImageMesh::setHorizontalTileMode(TileMode t) | - | ||||||||||||
207 | { | - | ||||||||||||
208 | if (t == m_horizontalTileMode
| 0 | ||||||||||||
209 | return; never executed: return; | 0 | ||||||||||||
210 | m_horizontalTileMode = t; | - | ||||||||||||
211 | horizontalTileModeChanged(); | - | ||||||||||||
212 | geometryChanged(); | - | ||||||||||||
213 | } never executed: end of block | 0 | ||||||||||||
214 | - | |||||||||||||
215 | QQuickBorderImageMesh::TileMode QQuickBorderImageMesh::verticalTileMode() const | - | ||||||||||||
216 | { | - | ||||||||||||
217 | return never executed: m_verticalTileMode;return m_verticalTileMode; never executed: return m_verticalTileMode; | 0 | ||||||||||||
218 | } | - | ||||||||||||
219 | - | |||||||||||||
220 | void QQuickBorderImageMesh::setVerticalTileMode(TileMode t) | - | ||||||||||||
221 | { | - | ||||||||||||
222 | if (t == m_verticalTileMode
| 0 | ||||||||||||
223 | return; never executed: return; | 0 | ||||||||||||
224 | - | |||||||||||||
225 | m_verticalTileMode = t; | - | ||||||||||||
226 | verticalTileModeChanged(); | - | ||||||||||||
227 | geometryChanged(); | - | ||||||||||||
228 | } never executed: end of block | 0 | ||||||||||||
229 | - | |||||||||||||
230 | - | |||||||||||||
231 | - | |||||||||||||
Switch to Source code | Preprocessed file |