Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | namespace QSGSoftwareHelpers { | - | ||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | static inline QMargins normalizedMargins(const QMargins &m) | - | ||||||||||||||||||||||||
9 | { | - | ||||||||||||||||||||||||
10 | return never executed: QMargins(qMax(m.left(), 0), qMax(m.top(), 0), qMax(m.right(), 0), qMax(m.bottom(), 0));return QMargins(qMax(m.left(), 0), qMax(m.top(), 0), qMax(m.right(), 0), qMax(m.bottom(), 0)); never executed: return QMargins(qMax(m.left(), 0), qMax(m.top(), 0), qMax(m.right(), 0), qMax(m.bottom(), 0)); | 0 | ||||||||||||||||||||||||
11 | } | - | ||||||||||||||||||||||||
12 | - | |||||||||||||||||||||||||
13 | void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMarginsIn, | - | ||||||||||||||||||||||||
14 | const QPixmap &pixmap, const QRect &sourceRect, const QMargins &sourceMarginsIn, | - | ||||||||||||||||||||||||
15 | const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints) | - | ||||||||||||||||||||||||
16 | { | - | ||||||||||||||||||||||||
17 | QPainter::PixmapFragment d; | - | ||||||||||||||||||||||||
18 | d.opacity = 1.0; | - | ||||||||||||||||||||||||
19 | d.rotation = 0.0; | - | ||||||||||||||||||||||||
20 | - | |||||||||||||||||||||||||
21 | QPixmapFragmentsArray opaqueData; | - | ||||||||||||||||||||||||
22 | QPixmapFragmentsArray translucentData; | - | ||||||||||||||||||||||||
23 | - | |||||||||||||||||||||||||
24 | QMargins sourceMargins = normalizedMargins(sourceMarginsIn); | - | ||||||||||||||||||||||||
25 | QMargins targetMargins = normalizedMargins(targetMarginsIn); | - | ||||||||||||||||||||||||
26 | - | |||||||||||||||||||||||||
27 | const qreal sourceDpr = pixmap.devicePixelRatioF(); | - | ||||||||||||||||||||||||
28 | sourceMargins *= sourceDpr; | - | ||||||||||||||||||||||||
29 | - | |||||||||||||||||||||||||
30 | - | |||||||||||||||||||||||||
31 | const int sourceCenterTop = sourceRect.top() + sourceMargins.top(); | - | ||||||||||||||||||||||||
32 | const int sourceCenterLeft = sourceRect.left() + sourceMargins.left(); | - | ||||||||||||||||||||||||
33 | const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1; | - | ||||||||||||||||||||||||
34 | const int sourceCenterRight = sourceRect.right() - sourceMargins.right() + 1; | - | ||||||||||||||||||||||||
35 | const int sourceCenterWidth = sourceCenterRight - sourceCenterLeft; | - | ||||||||||||||||||||||||
36 | const int sourceCenterHeight = sourceCenterBottom - sourceCenterTop; | - | ||||||||||||||||||||||||
37 | - | |||||||||||||||||||||||||
38 | const int targetCenterTop = targetRect.top() + targetMargins.top(); | - | ||||||||||||||||||||||||
39 | const int targetCenterLeft = targetRect.left() + targetMargins.left(); | - | ||||||||||||||||||||||||
40 | const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1; | - | ||||||||||||||||||||||||
41 | const int targetCenterRight = targetRect.right() - targetMargins.right() + 1; | - | ||||||||||||||||||||||||
42 | const int targetCenterWidth = targetCenterRight - targetCenterLeft; | - | ||||||||||||||||||||||||
43 | const int targetCenterHeight = targetCenterBottom - targetCenterTop; | - | ||||||||||||||||||||||||
44 | - | |||||||||||||||||||||||||
45 | QVarLengthArray<qreal, 16> xTarget; | - | ||||||||||||||||||||||||
46 | QVarLengthArray<qreal, 16> yTarget; | - | ||||||||||||||||||||||||
47 | - | |||||||||||||||||||||||||
48 | int columns = 3; | - | ||||||||||||||||||||||||
49 | int rows = 3; | - | ||||||||||||||||||||||||
50 | if (rules.horizontal != Qt::StretchTile
| 0 | ||||||||||||||||||||||||
51 | columns = qMax(3, 2 + qCeil((targetCenterWidth * sourceDpr) / qreal(sourceCenterWidth))); never executed: columns = qMax(3, 2 + qCeil((targetCenterWidth * sourceDpr) / qreal(sourceCenterWidth))); | 0 | ||||||||||||||||||||||||
52 | if (rules.vertical != Qt::StretchTile
| 0 | ||||||||||||||||||||||||
53 | rows = qMax(3, 2 + qCeil((targetCenterHeight * sourceDpr) / qreal(sourceCenterHeight))); never executed: rows = qMax(3, 2 + qCeil((targetCenterHeight * sourceDpr) / qreal(sourceCenterHeight))); | 0 | ||||||||||||||||||||||||
54 | - | |||||||||||||||||||||||||
55 | xTarget.resize(columns + 1); | - | ||||||||||||||||||||||||
56 | yTarget.resize(rows + 1); | - | ||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | bool oldAA = painter->testRenderHint(QPainter::Antialiasing); | - | ||||||||||||||||||||||||
59 | if (painter->paintEngine()->type() != QPaintEngine::OpenGL
| 0 | ||||||||||||||||||||||||
60 | && painter->paintEngine()->type() != QPaintEngine::OpenGL2
| 0 | ||||||||||||||||||||||||
61 | && oldAA
| 0 | ||||||||||||||||||||||||
62 | painter->setRenderHint(QPainter::Antialiasing, false); | - | ||||||||||||||||||||||||
63 | } never executed: end of block | 0 | ||||||||||||||||||||||||
64 | - | |||||||||||||||||||||||||
65 | xTarget[0] = targetRect.left(); | - | ||||||||||||||||||||||||
66 | xTarget[1] = targetCenterLeft; | - | ||||||||||||||||||||||||
67 | xTarget[columns - 1] = targetCenterRight; | - | ||||||||||||||||||||||||
68 | xTarget[columns] = targetRect.left() + targetRect.width(); | - | ||||||||||||||||||||||||
69 | - | |||||||||||||||||||||||||
70 | yTarget[0] = targetRect.top(); | - | ||||||||||||||||||||||||
71 | yTarget[1] = targetCenterTop; | - | ||||||||||||||||||||||||
72 | yTarget[rows - 1] = targetCenterBottom; | - | ||||||||||||||||||||||||
73 | yTarget[rows] = targetRect.top() + targetRect.height(); | - | ||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||
75 | qreal dx = targetCenterWidth; | - | ||||||||||||||||||||||||
76 | qreal dy = targetCenterHeight; | - | ||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | switch (rules.horizontal) { | - | ||||||||||||||||||||||||
79 | case never executed: Qt::StretchTile:case Qt::StretchTile: never executed: case Qt::StretchTile: | 0 | ||||||||||||||||||||||||
80 | dx = targetCenterWidth; | - | ||||||||||||||||||||||||
81 | break; never executed: break; | 0 | ||||||||||||||||||||||||
82 | case never executed: Qt::RepeatTile:case Qt::RepeatTile: never executed: case Qt::RepeatTile: | 0 | ||||||||||||||||||||||||
83 | dx = sourceCenterWidth / sourceDpr; | - | ||||||||||||||||||||||||
84 | break; never executed: break; | 0 | ||||||||||||||||||||||||
85 | case never executed: Qt::RoundTile:case Qt::RoundTile: never executed: case Qt::RoundTile: | 0 | ||||||||||||||||||||||||
86 | dx = targetCenterWidth / qreal(columns - 2); | - | ||||||||||||||||||||||||
87 | break; never executed: break; | 0 | ||||||||||||||||||||||||
88 | } | - | ||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||
90 | for (int i = 2; i < columns - 1
| 0 | ||||||||||||||||||||||||
91 | xTarget[i] = xTarget[i - 1] + dx; never executed: xTarget[i] = xTarget[i - 1] + dx; | 0 | ||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||
93 | switch (rules.vertical) { | - | ||||||||||||||||||||||||
94 | case never executed: Qt::StretchTile:case Qt::StretchTile: never executed: case Qt::StretchTile: | 0 | ||||||||||||||||||||||||
95 | dy = targetCenterHeight; | - | ||||||||||||||||||||||||
96 | break; never executed: break; | 0 | ||||||||||||||||||||||||
97 | case never executed: Qt::RepeatTile:case Qt::RepeatTile: never executed: case Qt::RepeatTile: | 0 | ||||||||||||||||||||||||
98 | dy = sourceCenterHeight / sourceDpr; | - | ||||||||||||||||||||||||
99 | break; never executed: break; | 0 | ||||||||||||||||||||||||
100 | case never executed: Qt::RoundTile:case Qt::RoundTile: never executed: case Qt::RoundTile: | 0 | ||||||||||||||||||||||||
101 | dy = targetCenterHeight / qreal(rows - 2); | - | ||||||||||||||||||||||||
102 | break; never executed: break; | 0 | ||||||||||||||||||||||||
103 | } | - | ||||||||||||||||||||||||
104 | - | |||||||||||||||||||||||||
105 | for (int i = 2; i < rows - 1
| 0 | ||||||||||||||||||||||||
106 | yTarget[i] = yTarget[i - 1] + dy; never executed: yTarget[i] = yTarget[i - 1] + dy; | 0 | ||||||||||||||||||||||||
107 | - | |||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||
109 | if (targetMargins.top() > 0
| 0 | ||||||||||||||||||||||||
110 | d.x = (0.5 * (xTarget[1] + xTarget[0])); | - | ||||||||||||||||||||||||
111 | d.y = (0.5 * (yTarget[1] + yTarget[0])); | - | ||||||||||||||||||||||||
112 | d.sourceLeft = sourceRect.left(); | - | ||||||||||||||||||||||||
113 | d.sourceTop = sourceRect.top(); | - | ||||||||||||||||||||||||
114 | d.width = sourceMargins.left(); | - | ||||||||||||||||||||||||
115 | d.height = sourceMargins.top(); | - | ||||||||||||||||||||||||
116 | d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width; | - | ||||||||||||||||||||||||
117 | d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height; | - | ||||||||||||||||||||||||
118 | if (hints & QDrawBorderPixmap::OpaqueTopLeft
| 0 | ||||||||||||||||||||||||
119 | opaqueData.append(d); never executed: opaqueData.append(d); | 0 | ||||||||||||||||||||||||
120 | else | - | ||||||||||||||||||||||||
121 | translucentData.append(d); never executed: translucentData.append(d); | 0 | ||||||||||||||||||||||||
122 | } | - | ||||||||||||||||||||||||
123 | if (targetMargins.top() > 0
| 0 | ||||||||||||||||||||||||
124 | d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1])); | - | ||||||||||||||||||||||||
125 | d.y = (0.5 * (yTarget[1] + yTarget[0])); | - | ||||||||||||||||||||||||
126 | d.sourceLeft = sourceCenterRight; | - | ||||||||||||||||||||||||
127 | d.sourceTop = sourceRect.top(); | - | ||||||||||||||||||||||||
128 | d.width = sourceMargins.right(); | - | ||||||||||||||||||||||||
129 | d.height = sourceMargins.top(); | - | ||||||||||||||||||||||||
130 | d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width; | - | ||||||||||||||||||||||||
131 | d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height; | - | ||||||||||||||||||||||||
132 | if (hints & QDrawBorderPixmap::OpaqueTopRight
| 0 | ||||||||||||||||||||||||
133 | opaqueData.append(d); never executed: opaqueData.append(d); | 0 | ||||||||||||||||||||||||
134 | else | - | ||||||||||||||||||||||||
135 | translucentData.append(d); never executed: translucentData.append(d); | 0 | ||||||||||||||||||||||||
136 | } | - | ||||||||||||||||||||||||
137 | if (targetMargins.bottom() > 0
| 0 | ||||||||||||||||||||||||
138 | d.x = (0.5 * (xTarget[1] + xTarget[0])); | - | ||||||||||||||||||||||||
139 | d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1])); | - | ||||||||||||||||||||||||
140 | d.sourceLeft = sourceRect.left(); | - | ||||||||||||||||||||||||
141 | d.sourceTop = sourceCenterBottom; | - | ||||||||||||||||||||||||
142 | d.width = sourceMargins.left(); | - | ||||||||||||||||||||||||
143 | d.height = sourceMargins.bottom(); | - | ||||||||||||||||||||||||
144 | d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width; | - | ||||||||||||||||||||||||
145 | d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height; | - | ||||||||||||||||||||||||
146 | if (hints & QDrawBorderPixmap::OpaqueBottomLeft
| 0 | ||||||||||||||||||||||||
147 | opaqueData.append(d); never executed: opaqueData.append(d); | 0 | ||||||||||||||||||||||||
148 | else | - | ||||||||||||||||||||||||
149 | translucentData.append(d); never executed: translucentData.append(d); | 0 | ||||||||||||||||||||||||
150 | } | - | ||||||||||||||||||||||||
151 | if (targetMargins.bottom() > 0
| 0 | ||||||||||||||||||||||||
152 | d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1])); | - | ||||||||||||||||||||||||
153 | d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1])); | - | ||||||||||||||||||||||||
154 | d.sourceLeft = sourceCenterRight; | - | ||||||||||||||||||||||||
155 | d.sourceTop = sourceCenterBottom; | - | ||||||||||||||||||||||||
156 | d.width = sourceMargins.right(); | - | ||||||||||||||||||||||||
157 | d.height = sourceMargins.bottom(); | - | ||||||||||||||||||||||||
158 | d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width; | - | ||||||||||||||||||||||||
159 | d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height; | - | ||||||||||||||||||||||||
160 | if (hints & QDrawBorderPixmap::OpaqueBottomRight
| 0 | ||||||||||||||||||||||||
161 | opaqueData.append(d); never executed: opaqueData.append(d); | 0 | ||||||||||||||||||||||||
162 | else | - | ||||||||||||||||||||||||
163 | translucentData.append(d); never executed: translucentData.append(d); | 0 | ||||||||||||||||||||||||
164 | } | - | ||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||
166 | - | |||||||||||||||||||||||||
167 | if (targetCenterWidth > 0
| 0 | ||||||||||||||||||||||||
168 | if (targetMargins.top() > 0
| 0 | ||||||||||||||||||||||||
169 | QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueTop
| 0 | ||||||||||||||||||||||||
170 | d.sourceLeft = sourceCenterLeft; | - | ||||||||||||||||||||||||
171 | d.sourceTop = sourceRect.top(); | - | ||||||||||||||||||||||||
172 | d.width = sourceCenterWidth; | - | ||||||||||||||||||||||||
173 | d.height = sourceMargins.top(); | - | ||||||||||||||||||||||||
174 | d.y = (0.5 * (yTarget[1] + yTarget[0])); | - | ||||||||||||||||||||||||
175 | d.scaleX = dx / d.width; | - | ||||||||||||||||||||||||
176 | d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height; | - | ||||||||||||||||||||||||
177 | for (int i = 1; i < columns - 1
| 0 | ||||||||||||||||||||||||
178 | d.x = (0.5 * (xTarget[i + 1] + xTarget[i])); | - | ||||||||||||||||||||||||
179 | data.append(d); | - | ||||||||||||||||||||||||
180 | } never executed: end of block | 0 | ||||||||||||||||||||||||
181 | if (rules.horizontal == Qt::RepeatTile
| 0 | ||||||||||||||||||||||||
182 | data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX); never executed: data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX); | 0 | ||||||||||||||||||||||||
183 | } never executed: end of block | 0 | ||||||||||||||||||||||||
184 | if (targetMargins.bottom() > 0
| 0 | ||||||||||||||||||||||||
185 | QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueBottom
| 0 | ||||||||||||||||||||||||
186 | d.sourceLeft = sourceCenterLeft; | - | ||||||||||||||||||||||||
187 | d.sourceTop = sourceCenterBottom; | - | ||||||||||||||||||||||||
188 | d.width = sourceCenterWidth; | - | ||||||||||||||||||||||||
189 | d.height = sourceMargins.bottom(); | - | ||||||||||||||||||||||||
190 | d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1])); | - | ||||||||||||||||||||||||
191 | d.scaleX = dx / d.width; | - | ||||||||||||||||||||||||
192 | d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height; | - | ||||||||||||||||||||||||
193 | for (int i = 1; i < columns - 1
| 0 | ||||||||||||||||||||||||
194 | d.x = (0.5 * (xTarget[i + 1] + xTarget[i])); | - | ||||||||||||||||||||||||
195 | data.append(d); | - | ||||||||||||||||||||||||
196 | } never executed: end of block | 0 | ||||||||||||||||||||||||
197 | if (rules.horizontal == Qt::RepeatTile
| 0 | ||||||||||||||||||||||||
198 | data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX); never executed: data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX); | 0 | ||||||||||||||||||||||||
199 | } never executed: end of block | 0 | ||||||||||||||||||||||||
200 | } never executed: end of block | 0 | ||||||||||||||||||||||||
201 | - | |||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||
203 | if (targetCenterHeight > 0
| 0 | ||||||||||||||||||||||||
204 | if (targetMargins.left() > 0
| 0 | ||||||||||||||||||||||||
205 | QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueLeft
| 0 | ||||||||||||||||||||||||
206 | d.sourceLeft = sourceRect.left(); | - | ||||||||||||||||||||||||
207 | d.sourceTop = sourceCenterTop; | - | ||||||||||||||||||||||||
208 | d.width = sourceMargins.left(); | - | ||||||||||||||||||||||||
209 | d.height = sourceCenterHeight; | - | ||||||||||||||||||||||||
210 | d.x = (0.5 * (xTarget[1] + xTarget[0])); | - | ||||||||||||||||||||||||
211 | d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width; | - | ||||||||||||||||||||||||
212 | d.scaleY = dy / d.height; | - | ||||||||||||||||||||||||
213 | for (int i = 1; i < rows - 1
| 0 | ||||||||||||||||||||||||
214 | d.y = (0.5 * (yTarget[i + 1] + yTarget[i])); | - | ||||||||||||||||||||||||
215 | data.append(d); | - | ||||||||||||||||||||||||
216 | } never executed: end of block | 0 | ||||||||||||||||||||||||
217 | if (rules.vertical == Qt::RepeatTile
| 0 | ||||||||||||||||||||||||
218 | data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY); never executed: data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY); | 0 | ||||||||||||||||||||||||
219 | } never executed: end of block | 0 | ||||||||||||||||||||||||
220 | if (targetMargins.right() > 0
| 0 | ||||||||||||||||||||||||
221 | QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueRight
| 0 | ||||||||||||||||||||||||
222 | d.sourceLeft = sourceCenterRight; | - | ||||||||||||||||||||||||
223 | d.sourceTop = sourceCenterTop; | - | ||||||||||||||||||||||||
224 | d.width = sourceMargins.right(); | - | ||||||||||||||||||||||||
225 | d.height = sourceCenterHeight; | - | ||||||||||||||||||||||||
226 | d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1])); | - | ||||||||||||||||||||||||
227 | d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width; | - | ||||||||||||||||||||||||
228 | d.scaleY = dy / d.height; | - | ||||||||||||||||||||||||
229 | for (int i = 1; i < rows - 1
| 0 | ||||||||||||||||||||||||
230 | d.y = (0.5 * (yTarget[i + 1] + yTarget[i])); | - | ||||||||||||||||||||||||
231 | data.append(d); | - | ||||||||||||||||||||||||
232 | } never executed: end of block | 0 | ||||||||||||||||||||||||
233 | if (rules.vertical == Qt::RepeatTile
| 0 | ||||||||||||||||||||||||
234 | data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY); never executed: data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY); | 0 | ||||||||||||||||||||||||
235 | } never executed: end of block | 0 | ||||||||||||||||||||||||
236 | } never executed: end of block | 0 | ||||||||||||||||||||||||
237 | - | |||||||||||||||||||||||||
238 | - | |||||||||||||||||||||||||
239 | if (targetCenterWidth > 0
| 0 | ||||||||||||||||||||||||
240 | QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueCenter
| 0 | ||||||||||||||||||||||||
241 | d.sourceLeft = sourceCenterLeft; | - | ||||||||||||||||||||||||
242 | d.sourceTop = sourceCenterTop; | - | ||||||||||||||||||||||||
243 | d.width = sourceCenterWidth; | - | ||||||||||||||||||||||||
244 | d.height = sourceCenterHeight; | - | ||||||||||||||||||||||||
245 | d.scaleX = dx / d.width; | - | ||||||||||||||||||||||||
246 | d.scaleY = dy / d.height; | - | ||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
248 | qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX; | - | ||||||||||||||||||||||||
249 | qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY; | - | ||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||
251 | for (int j = 1; j < rows - 1
| 0 | ||||||||||||||||||||||||
252 | d.y = (0.5 * (yTarget[j + 1] + yTarget[j])); | - | ||||||||||||||||||||||||
253 | for (int i = 1; i < columns - 1
| 0 | ||||||||||||||||||||||||
254 | d.x = (0.5 * (xTarget[i + 1] + xTarget[i])); | - | ||||||||||||||||||||||||
255 | data.append(d); | - | ||||||||||||||||||||||||
256 | } never executed: end of block | 0 | ||||||||||||||||||||||||
257 | if (rules.horizontal == Qt::RepeatTile
| 0 | ||||||||||||||||||||||||
258 | data[data.size() - 1].width = repeatWidth; never executed: data[data.size() - 1].width = repeatWidth; | 0 | ||||||||||||||||||||||||
259 | } never executed: end of block | 0 | ||||||||||||||||||||||||
260 | if (rules.vertical == Qt::RepeatTile
| 0 | ||||||||||||||||||||||||
261 | for (int i = 1; i < columns - 1
| 0 | ||||||||||||||||||||||||
262 | data[data.size() - i].height = repeatHeight; never executed: data[data.size() - i].height = repeatHeight; | 0 | ||||||||||||||||||||||||
263 | } never executed: end of block | 0 | ||||||||||||||||||||||||
264 | } never executed: end of block | 0 | ||||||||||||||||||||||||
265 | - | |||||||||||||||||||||||||
266 | if (opaqueData.size()
| 0 | ||||||||||||||||||||||||
267 | painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint); never executed: painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint); | 0 | ||||||||||||||||||||||||
268 | if (translucentData.size()
| 0 | ||||||||||||||||||||||||
269 | painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap); never executed: painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap); | 0 | ||||||||||||||||||||||||
270 | - | |||||||||||||||||||||||||
271 | if (oldAA
| 0 | ||||||||||||||||||||||||
272 | painter->setRenderHint(QPainter::Antialiasing, true); never executed: painter->setRenderHint(QPainter::Antialiasing, true); | 0 | ||||||||||||||||||||||||
273 | } never executed: end of block | 0 | ||||||||||||||||||||||||
274 | - | |||||||||||||||||||||||||
275 | } | - | ||||||||||||||||||||||||
276 | - | |||||||||||||||||||||||||
277 | QSGSoftwareInternalImageNode::QSGSoftwareInternalImageNode() | - | ||||||||||||||||||||||||
278 | : m_innerSourceRect(0, 0, 1, 1) | - | ||||||||||||||||||||||||
279 | , m_subSourceRect(0, 0, 1, 1) | - | ||||||||||||||||||||||||
280 | , m_texture(nullptr) | - | ||||||||||||||||||||||||
281 | , m_mirror(false) | - | ||||||||||||||||||||||||
282 | , m_textureIsLayer(false) | - | ||||||||||||||||||||||||
283 | , m_smooth(true) | - | ||||||||||||||||||||||||
284 | , m_tileHorizontal(false) | - | ||||||||||||||||||||||||
285 | , m_tileVertical(false) | - | ||||||||||||||||||||||||
286 | , m_cachedMirroredPixmapIsDirty(false) | - | ||||||||||||||||||||||||
287 | { | - | ||||||||||||||||||||||||
288 | setMaterial((QSGMaterial*)1); | - | ||||||||||||||||||||||||
289 | setGeometry((QSGGeometry*)1); | - | ||||||||||||||||||||||||
290 | } never executed: end of block | 0 | ||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||
292 | - | |||||||||||||||||||||||||
293 | void QSGSoftwareInternalImageNode::setTargetRect(const QRectF &rect) | - | ||||||||||||||||||||||||
294 | { | - | ||||||||||||||||||||||||
295 | if (rect == m_targetRect
| 0 | ||||||||||||||||||||||||
296 | return; never executed: return; | 0 | ||||||||||||||||||||||||
297 | m_targetRect = rect; | - | ||||||||||||||||||||||||
298 | markDirty(DirtyGeometry); | - | ||||||||||||||||||||||||
299 | } never executed: end of block | 0 | ||||||||||||||||||||||||
300 | - | |||||||||||||||||||||||||
301 | void QSGSoftwareInternalImageNode::setInnerTargetRect(const QRectF &rect) | - | ||||||||||||||||||||||||
302 | { | - | ||||||||||||||||||||||||
303 | if (rect == m_innerTargetRect
| 0 | ||||||||||||||||||||||||
304 | return; never executed: return; | 0 | ||||||||||||||||||||||||
305 | m_innerTargetRect = rect; | - | ||||||||||||||||||||||||
306 | markDirty(DirtyGeometry); | - | ||||||||||||||||||||||||
307 | } never executed: end of block | 0 | ||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||
309 | void QSGSoftwareInternalImageNode::setInnerSourceRect(const QRectF &rect) | - | ||||||||||||||||||||||||
310 | { | - | ||||||||||||||||||||||||
311 | if (rect == m_innerSourceRect
| 0 | ||||||||||||||||||||||||
312 | return; never executed: return; | 0 | ||||||||||||||||||||||||
313 | m_innerSourceRect = rect; | - | ||||||||||||||||||||||||
314 | markDirty(DirtyGeometry); | - | ||||||||||||||||||||||||
315 | } never executed: end of block | 0 | ||||||||||||||||||||||||
316 | - | |||||||||||||||||||||||||
317 | void QSGSoftwareInternalImageNode::setSubSourceRect(const QRectF &rect) | - | ||||||||||||||||||||||||
318 | { | - | ||||||||||||||||||||||||
319 | if (rect == m_subSourceRect
| 0 | ||||||||||||||||||||||||
320 | return; never executed: return; | 0 | ||||||||||||||||||||||||
321 | m_subSourceRect = rect; | - | ||||||||||||||||||||||||
322 | markDirty(DirtyGeometry); | - | ||||||||||||||||||||||||
323 | } never executed: end of block | 0 | ||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||
325 | void QSGSoftwareInternalImageNode::setTexture(QSGTexture *texture) | - | ||||||||||||||||||||||||
326 | { | - | ||||||||||||||||||||||||
327 | m_texture = texture; | - | ||||||||||||||||||||||||
328 | m_cachedMirroredPixmapIsDirty = true; | - | ||||||||||||||||||||||||
329 | m_textureIsLayer = static_cast<bool>(qobject_cast<QSGSoftwareLayer*>(texture)); | - | ||||||||||||||||||||||||
330 | markDirty(DirtyMaterial); | - | ||||||||||||||||||||||||
331 | } never executed: end of block | 0 | ||||||||||||||||||||||||
332 | - | |||||||||||||||||||||||||
333 | void QSGSoftwareInternalImageNode::setMirror(bool mirror) | - | ||||||||||||||||||||||||
334 | { | - | ||||||||||||||||||||||||
335 | if (m_mirror != mirror
| 0 | ||||||||||||||||||||||||
336 | m_mirror = mirror; | - | ||||||||||||||||||||||||
337 | m_cachedMirroredPixmapIsDirty = true; | - | ||||||||||||||||||||||||
338 | markDirty(DirtyMaterial); | - | ||||||||||||||||||||||||
339 | } never executed: end of block | 0 | ||||||||||||||||||||||||
340 | } never executed: end of block | 0 | ||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||
342 | void QSGSoftwareInternalImageNode::setMipmapFiltering(QSGTexture::Filtering ) | - | ||||||||||||||||||||||||
343 | { | - | ||||||||||||||||||||||||
344 | } | - | ||||||||||||||||||||||||
345 | - | |||||||||||||||||||||||||
346 | void QSGSoftwareInternalImageNode::setFiltering(QSGTexture::Filtering filtering) | - | ||||||||||||||||||||||||
347 | { | - | ||||||||||||||||||||||||
348 | bool smooth = (filtering == QSGTexture::Linear); | - | ||||||||||||||||||||||||
349 | if (smooth == m_smooth
| 0 | ||||||||||||||||||||||||
350 | return; never executed: return; | 0 | ||||||||||||||||||||||||
351 | - | |||||||||||||||||||||||||
352 | m_smooth = smooth; | - | ||||||||||||||||||||||||
353 | markDirty(DirtyMaterial); | - | ||||||||||||||||||||||||
354 | } never executed: end of block | 0 | ||||||||||||||||||||||||
355 | - | |||||||||||||||||||||||||
356 | void QSGSoftwareInternalImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) | - | ||||||||||||||||||||||||
357 | { | - | ||||||||||||||||||||||||
358 | bool tileHorizontal = (wrapMode == QSGTexture::Repeat); | - | ||||||||||||||||||||||||
359 | if (tileHorizontal == m_tileHorizontal
| 0 | ||||||||||||||||||||||||
360 | return; never executed: return; | 0 | ||||||||||||||||||||||||
361 | - | |||||||||||||||||||||||||
362 | m_tileHorizontal = tileHorizontal; | - | ||||||||||||||||||||||||
363 | markDirty(DirtyMaterial); | - | ||||||||||||||||||||||||
364 | } never executed: end of block | 0 | ||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | void QSGSoftwareInternalImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode) | - | ||||||||||||||||||||||||
367 | { | - | ||||||||||||||||||||||||
368 | bool tileVertical = (wrapMode == QSGTexture::Repeat); | - | ||||||||||||||||||||||||
369 | if (tileVertical == m_tileVertical
| 0 | ||||||||||||||||||||||||
370 | return; never executed: return; | 0 | ||||||||||||||||||||||||
371 | - | |||||||||||||||||||||||||
372 | m_tileVertical = (wrapMode == QSGTexture::Repeat); | - | ||||||||||||||||||||||||
373 | markDirty(DirtyMaterial); | - | ||||||||||||||||||||||||
374 | } never executed: end of block | 0 | ||||||||||||||||||||||||
375 | - | |||||||||||||||||||||||||
376 | void QSGSoftwareInternalImageNode::update() | - | ||||||||||||||||||||||||
377 | { | - | ||||||||||||||||||||||||
378 | if (m_cachedMirroredPixmapIsDirty
| 0 | ||||||||||||||||||||||||
379 | if (m_mirror
| 0 | ||||||||||||||||||||||||
380 | QTransform transform( | - | ||||||||||||||||||||||||
381 | (m_mirror ? -1 : 1), 0, | - | ||||||||||||||||||||||||
382 | 0 , (m_textureIsLayer ? -1 :1), | - | ||||||||||||||||||||||||
383 | 0 , 0 | - | ||||||||||||||||||||||||
384 | ); | - | ||||||||||||||||||||||||
385 | m_cachedMirroredPixmap = pixmap().transformed(transform); | - | ||||||||||||||||||||||||
386 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||
388 | if (!m_cachedMirroredPixmap.isNull()
| 0 | ||||||||||||||||||||||||
389 | m_cachedMirroredPixmap = QPixmap(); never executed: m_cachedMirroredPixmap = QPixmap(); | 0 | ||||||||||||||||||||||||
390 | } never executed: end of block | 0 | ||||||||||||||||||||||||
391 | m_cachedMirroredPixmapIsDirty = false; | - | ||||||||||||||||||||||||
392 | } never executed: end of block | 0 | ||||||||||||||||||||||||
393 | } never executed: end of block | 0 | ||||||||||||||||||||||||
394 | - | |||||||||||||||||||||||||
395 | void QSGSoftwareInternalImageNode::preprocess() | - | ||||||||||||||||||||||||
396 | { | - | ||||||||||||||||||||||||
397 | bool doDirty = false; | - | ||||||||||||||||||||||||
398 | QSGLayer *t = qobject_cast<QSGLayer *>(m_texture); | - | ||||||||||||||||||||||||
399 | if (t
| 0 | ||||||||||||||||||||||||
400 | doDirty = t->updateTexture(); | - | ||||||||||||||||||||||||
401 | markDirty(DirtyGeometry); | - | ||||||||||||||||||||||||
402 | } never executed: end of block | 0 | ||||||||||||||||||||||||
403 | if (doDirty
| 0 | ||||||||||||||||||||||||
404 | markDirty(DirtyMaterial); never executed: markDirty(DirtyMaterial); | 0 | ||||||||||||||||||||||||
405 | m_cachedMirroredPixmapIsDirty = doDirty; | - | ||||||||||||||||||||||||
406 | } never executed: end of block | 0 | ||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||
408 | static Qt::TileRule getTileRule(qreal factor) | - | ||||||||||||||||||||||||
409 | { | - | ||||||||||||||||||||||||
410 | int ifactor = qRound(factor); | - | ||||||||||||||||||||||||
411 | if (qFuzzyCompare(factor, ifactor )
| 0 | ||||||||||||||||||||||||
412 | if (ifactor == 1
| 0 | ||||||||||||||||||||||||
413 | return never executed: Qt::StretchTile;return Qt::StretchTile; never executed: return Qt::StretchTile; | 0 | ||||||||||||||||||||||||
414 | return never executed: Qt::RoundTile;return Qt::RoundTile; never executed: return Qt::RoundTile; | 0 | ||||||||||||||||||||||||
415 | } | - | ||||||||||||||||||||||||
416 | return never executed: Qt::RepeatTile;return Qt::RepeatTile; never executed: return Qt::RepeatTile; | 0 | ||||||||||||||||||||||||
417 | } | - | ||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||
419 | - | |||||||||||||||||||||||||
420 | void QSGSoftwareInternalImageNode::paint(QPainter *painter) | - | ||||||||||||||||||||||||
421 | { | - | ||||||||||||||||||||||||
422 | painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth); | - | ||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | const QPixmap &pm = m_mirror
| 0 | ||||||||||||||||||||||||
425 | - | |||||||||||||||||||||||||
426 | if (m_innerTargetRect != m_targetRect
| 0 | ||||||||||||||||||||||||
427 | - | |||||||||||||||||||||||||
428 | QMargins margins(m_innerTargetRect.left() - m_targetRect.left(), m_innerTargetRect.top() - m_targetRect.top(), | - | ||||||||||||||||||||||||
429 | m_targetRect.right() - m_innerTargetRect.right(), m_targetRect.bottom() - m_innerTargetRect.bottom()); | - | ||||||||||||||||||||||||
430 | QSGSoftwareHelpers::QTileRules tilerules(getTileRule(m_subSourceRect.width()), getTileRule(m_subSourceRect.height())); | - | ||||||||||||||||||||||||
431 | QSGSoftwareHelpers::qDrawBorderPixmap(painter, m_targetRect.toRect(), margins, pm, QRect(0, 0, pm.width(), pm.height()), | - | ||||||||||||||||||||||||
432 | margins, tilerules, QSGSoftwareHelpers::QDrawBorderPixmap::DrawingHints(nullptr)); | - | ||||||||||||||||||||||||
433 | return; never executed: return; | 0 | ||||||||||||||||||||||||
434 | } | - | ||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||
436 | if (m_tileHorizontal
| 0 | ||||||||||||||||||||||||
437 | painter->save(); | - | ||||||||||||||||||||||||
438 | qreal sx = m_targetRect.width()/(m_subSourceRect.width()*pm.width()); | - | ||||||||||||||||||||||||
439 | qreal sy = m_targetRect.height()/(m_subSourceRect.height()*pm.height()); | - | ||||||||||||||||||||||||
440 | QMatrix transform(sx, 0, 0, sy, 0, 0); | - | ||||||||||||||||||||||||
441 | painter->setMatrix(transform, true); | - | ||||||||||||||||||||||||
442 | painter->drawTiledPixmap(QRectF(m_targetRect.x()/sx, m_targetRect.y()/sy, m_targetRect.width()/sx, m_targetRect.height()/sy), | - | ||||||||||||||||||||||||
443 | pm, | - | ||||||||||||||||||||||||
444 | QPointF(m_subSourceRect.left()*pm.width(), m_subSourceRect.top()*pm.height())); | - | ||||||||||||||||||||||||
445 | painter->restore(); | - | ||||||||||||||||||||||||
446 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
447 | QRectF sr(m_subSourceRect.left()*pm.width(), m_subSourceRect.top()*pm.height(), | - | ||||||||||||||||||||||||
448 | m_subSourceRect.width()*pm.width(), m_subSourceRect.height()*pm.height()); | - | ||||||||||||||||||||||||
449 | painter->drawPixmap(m_targetRect, pm, sr); | - | ||||||||||||||||||||||||
450 | } never executed: end of block | 0 | ||||||||||||||||||||||||
451 | } | - | ||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||
453 | QRectF QSGSoftwareInternalImageNode::rect() const | - | ||||||||||||||||||||||||
454 | { | - | ||||||||||||||||||||||||
455 | return never executed: m_targetRect;return m_targetRect; never executed: return m_targetRect; | 0 | ||||||||||||||||||||||||
456 | } | - | ||||||||||||||||||||||||
457 | - | |||||||||||||||||||||||||
458 | const QPixmap &QSGSoftwareInternalImageNode::pixmap() const | - | ||||||||||||||||||||||||
459 | { | - | ||||||||||||||||||||||||
460 | if (QSGSoftwarePixmapTexture *pt = qobject_cast<QSGSoftwarePixmapTexture*>(m_texture)
| 0 | ||||||||||||||||||||||||
461 | return never executed: pt->pixmap();return pt->pixmap(); never executed: return pt->pixmap(); | 0 | ||||||||||||||||||||||||
462 | if (QSGSoftwareLayer *layer = qobject_cast<QSGSoftwareLayer*>(m_texture)
| 0 | ||||||||||||||||||||||||
463 | return never executed: layer->pixmap();return layer->pixmap(); never executed: return layer->pixmap(); | 0 | ||||||||||||||||||||||||
464 | ((m_texture == nullptr) ? static_cast<void>(0) : qt_assert("m_texture == nullptr", __FILE__, 508)); | - | ||||||||||||||||||||||||
465 | static const QPixmap nullPixmap; | - | ||||||||||||||||||||||||
466 | return never executed: nullPixmap;return nullPixmap; never executed: return nullPixmap; | 0 | ||||||||||||||||||||||||
467 | } | - | ||||||||||||||||||||||||
468 | - | |||||||||||||||||||||||||
469 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |