Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quickshapes/qquickshapenvprrenderer.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | void QQuickShapeNvprRenderer::beginSync(int totalCount) | - | ||||||||||||
5 | { | - | ||||||||||||
6 | if (m_sp.count() != totalCount
| 0 | ||||||||||||
7 | m_sp.resize(totalCount); | - | ||||||||||||
8 | m_accDirty |= DirtyList; | - | ||||||||||||
9 | } never executed: end of block | 0 | ||||||||||||
10 | } never executed: end of block | 0 | ||||||||||||
11 | - | |||||||||||||
12 | void QQuickShapeNvprRenderer::setPath(int index, const QQuickPath *path) | - | ||||||||||||
13 | { | - | ||||||||||||
14 | ShapePathGuiData &d(m_sp[index]); | - | ||||||||||||
15 | convertPath(path, &d); | - | ||||||||||||
16 | d.dirty |= DirtyPath; | - | ||||||||||||
17 | m_accDirty |= DirtyPath; | - | ||||||||||||
18 | } never executed: end of block | 0 | ||||||||||||
19 | - | |||||||||||||
20 | void QQuickShapeNvprRenderer::setStrokeColor(int index, const QColor &color) | - | ||||||||||||
21 | { | - | ||||||||||||
22 | ShapePathGuiData &d(m_sp[index]); | - | ||||||||||||
23 | d.strokeColor = color; | - | ||||||||||||
24 | d.dirty |= DirtyStyle; | - | ||||||||||||
25 | m_accDirty |= DirtyStyle; | - | ||||||||||||
26 | } never executed: end of block | 0 | ||||||||||||
27 | - | |||||||||||||
28 | void QQuickShapeNvprRenderer::setStrokeWidth(int index, qreal w) | - | ||||||||||||
29 | { | - | ||||||||||||
30 | ShapePathGuiData &d(m_sp[index]); | - | ||||||||||||
31 | d.strokeWidth = w; | - | ||||||||||||
32 | d.dirty |= DirtyStyle; | - | ||||||||||||
33 | m_accDirty |= DirtyStyle; | - | ||||||||||||
34 | } never executed: end of block | 0 | ||||||||||||
35 | - | |||||||||||||
36 | void QQuickShapeNvprRenderer::setFillColor(int index, const QColor &color) | - | ||||||||||||
37 | { | - | ||||||||||||
38 | ShapePathGuiData &d(m_sp[index]); | - | ||||||||||||
39 | d.fillColor = color; | - | ||||||||||||
40 | d.dirty |= DirtyStyle; | - | ||||||||||||
41 | m_accDirty |= DirtyStyle; | - | ||||||||||||
42 | } never executed: end of block | 0 | ||||||||||||
43 | - | |||||||||||||
44 | void QQuickShapeNvprRenderer::setFillRule(int index, QQuickShapePath::FillRule fillRule) | - | ||||||||||||
45 | { | - | ||||||||||||
46 | ShapePathGuiData &d(m_sp[index]); | - | ||||||||||||
47 | d.fillRule = fillRule; | - | ||||||||||||
48 | d.dirty |= DirtyFillRule; | - | ||||||||||||
49 | m_accDirty |= DirtyFillRule; | - | ||||||||||||
50 | } never executed: end of block | 0 | ||||||||||||
51 | - | |||||||||||||
52 | void QQuickShapeNvprRenderer::setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) | - | ||||||||||||
53 | { | - | ||||||||||||
54 | ShapePathGuiData &d(m_sp[index]); | - | ||||||||||||
55 | d.joinStyle = joinStyle; | - | ||||||||||||
56 | d.miterLimit = miterLimit; | - | ||||||||||||
57 | d.dirty |= DirtyStyle; | - | ||||||||||||
58 | m_accDirty |= DirtyStyle; | - | ||||||||||||
59 | } never executed: end of block | 0 | ||||||||||||
60 | - | |||||||||||||
61 | void QQuickShapeNvprRenderer::setCapStyle(int index, QQuickShapePath::CapStyle capStyle) | - | ||||||||||||
62 | { | - | ||||||||||||
63 | ShapePathGuiData &d(m_sp[index]); | - | ||||||||||||
64 | d.capStyle = capStyle; | - | ||||||||||||
65 | d.dirty |= DirtyStyle; | - | ||||||||||||
66 | m_accDirty |= DirtyStyle; | - | ||||||||||||
67 | } never executed: end of block | 0 | ||||||||||||
68 | - | |||||||||||||
69 | void QQuickShapeNvprRenderer::setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle, | - | ||||||||||||
70 | qreal dashOffset, const QVector<qreal> &dashPattern) | - | ||||||||||||
71 | { | - | ||||||||||||
72 | ShapePathGuiData &d(m_sp[index]); | - | ||||||||||||
73 | d.dashActive = strokeStyle == QQuickShapePath::DashLine; | - | ||||||||||||
74 | d.dashOffset = dashOffset; | - | ||||||||||||
75 | d.dashPattern = dashPattern; | - | ||||||||||||
76 | d.dirty |= DirtyDash; | - | ||||||||||||
77 | m_accDirty |= DirtyDash; | - | ||||||||||||
78 | } never executed: end of block | 0 | ||||||||||||
79 | - | |||||||||||||
80 | void QQuickShapeNvprRenderer::setFillGradient(int index, QQuickShapeGradient *gradient) | - | ||||||||||||
81 | { | - | ||||||||||||
82 | ShapePathGuiData &d(m_sp[index]); | - | ||||||||||||
83 | if (gradient
| 0 | ||||||||||||
84 | d.fillGradient.stops = gradient->gradientStops(); | - | ||||||||||||
85 | d.fillGradient.spread = gradient->spread(); | - | ||||||||||||
86 | if (QQuickShapeLinearGradient *g = qobject_cast<QQuickShapeLinearGradient *>(gradient)
| 0 | ||||||||||||
87 | d.fillGradientActive = LinearGradient; | - | ||||||||||||
88 | d.fillGradient.a = QPointF(g->x1(), g->y1()); | - | ||||||||||||
89 | d.fillGradient.b = QPointF(g->x2(), g->y2()); | - | ||||||||||||
90 | } never executed: else if (QQuickShapeRadialGradient *g = qobject_cast<QQuickShapeRadialGradient *>(gradient)end of block
| 0 | ||||||||||||
91 | d.fillGradientActive = RadialGradient; | - | ||||||||||||
92 | d.fillGradient.a = QPointF(g->centerX(), g->centerY()); | - | ||||||||||||
93 | d.fillGradient.b = QPointF(g->focalX(), g->focalY()); | - | ||||||||||||
94 | d.fillGradient.v0 = g->centerRadius(); | - | ||||||||||||
95 | d.fillGradient.v1 = g->focalRadius(); | - | ||||||||||||
96 | } never executed: else if (QQuickShapeConicalGradient *g = qobject_cast<QQuickShapeConicalGradient *>(gradient)end of block
| 0 | ||||||||||||
97 | d.fillGradientActive = ConicalGradient; | - | ||||||||||||
98 | d.fillGradient.a = QPointF(g->centerX(), g->centerY()); | - | ||||||||||||
99 | d.fillGradient.v0 = g->angle(); | - | ||||||||||||
100 | } never executed: else {end of block | 0 | ||||||||||||
101 | do { ((false) ? static_cast<void>(0) : qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached", __FILE__, 148)); __builtin_unreachable(); } while (false); | - | ||||||||||||
102 | } never executed: end of block | 0 | ||||||||||||
103 | } else { | - | ||||||||||||
104 | d.fillGradientActive = NoGradient; | - | ||||||||||||
105 | } never executed: end of block | 0 | ||||||||||||
106 | d.dirty |= DirtyFillGradient; | - | ||||||||||||
107 | m_accDirty |= DirtyFillGradient; | - | ||||||||||||
108 | } never executed: end of block | 0 | ||||||||||||
109 | - | |||||||||||||
110 | void QQuickShapeNvprRenderer::endSync(bool) | - | ||||||||||||
111 | { | - | ||||||||||||
112 | } | - | ||||||||||||
113 | - | |||||||||||||
114 | void QQuickShapeNvprRenderer::setNode(QQuickShapeNvprRenderNode *node) | - | ||||||||||||
115 | { | - | ||||||||||||
116 | if (m_node != node
| 0 | ||||||||||||
117 | m_node = node; | - | ||||||||||||
118 | m_accDirty |= DirtyList; | - | ||||||||||||
119 | } never executed: end of block | 0 | ||||||||||||
120 | } never executed: end of block | 0 | ||||||||||||
121 | - | |||||||||||||
122 | QDebug operator<<(QDebug debug, const QQuickShapeNvprRenderer::NvprPath &path) | - | ||||||||||||
123 | { | - | ||||||||||||
124 | QDebugStateSaver saver(debug); | - | ||||||||||||
125 | debug.space().noquote(); | - | ||||||||||||
126 | if (!path.str.isEmpty()
| 0 | ||||||||||||
127 | debug << "Path with SVG string" << path.str; | - | ||||||||||||
128 | return never executed: debug;return debug; never executed: return debug; | 0 | ||||||||||||
129 | } | - | ||||||||||||
130 | debug << "Path with" << path.cmd.count() << "commands"; | - | ||||||||||||
131 | int ci = 0; | - | ||||||||||||
132 | for (GLubyte cmd : path.cmd) { | - | ||||||||||||
133 | static struct { GLubyte cmd; const char *s; int coordCount; } nameTab[] = { | - | ||||||||||||
134 | { 0x02, "moveTo", 2 }, | - | ||||||||||||
135 | { 0x04, "lineTo", 2 }, | - | ||||||||||||
136 | { 0x0A, "quadTo", 4 }, | - | ||||||||||||
137 | { 0x0C, "cubicTo", 6 }, | - | ||||||||||||
138 | { 0x18, "arcTo-large-CW", 5 }, | - | ||||||||||||
139 | { 0x16, "arcTo-large-CCW", 5 }, | - | ||||||||||||
140 | { 0x14, "arcTo-small-CW", 5 }, | - | ||||||||||||
141 | { 0x12, "arcTo-small-CCW", 5 }, | - | ||||||||||||
142 | { 0x00, "closePath", 0 } }; | - | ||||||||||||
143 | for (size_t i = 0; i < sizeof(nameTab) / sizeof(nameTab[0])
| 0 | ||||||||||||
144 | if (nameTab[i].cmd == cmd
| 0 | ||||||||||||
145 | QByteArray cs; | - | ||||||||||||
146 | for (int j = 0; j < nameTab[i].coordCount
| 0 | ||||||||||||
147 | cs.append(QByteArray::number(path.coord[ci++])); | - | ||||||||||||
148 | cs.append(' '); | - | ||||||||||||
149 | } never executed: end of block | 0 | ||||||||||||
150 | debug << "\n " << nameTab[i].s << " " << cs; | - | ||||||||||||
151 | break; never executed: break; | 0 | ||||||||||||
152 | } | - | ||||||||||||
153 | } never executed: end of block | 0 | ||||||||||||
154 | } never executed: end of block | 0 | ||||||||||||
155 | return never executed: debug;return debug; never executed: return debug; | 0 | ||||||||||||
156 | } | - | ||||||||||||
157 | - | |||||||||||||
158 | static inline void appendCoords(QVector<GLfloat> *v, QQuickCurve *c, QPointF *pos) | - | ||||||||||||
159 | { | - | ||||||||||||
160 | QPointF p(c->hasRelativeX() ? pos->x() + c->relativeX() : c->x(), | - | ||||||||||||
161 | c->hasRelativeY() ? pos->y() + c->relativeY() : c->y()); | - | ||||||||||||
162 | v->append(p.x()); | - | ||||||||||||
163 | v->append(p.y()); | - | ||||||||||||
164 | *pos = p; | - | ||||||||||||
165 | } never executed: end of block | 0 | ||||||||||||
166 | - | |||||||||||||
167 | static inline void appendControlCoords(QVector<GLfloat> *v, QQuickPathQuad *c, const QPointF &pos) | - | ||||||||||||
168 | { | - | ||||||||||||
169 | QPointF p(c->hasRelativeControlX() ? pos.x() + c->relativeControlX() : c->controlX(), | - | ||||||||||||
170 | c->hasRelativeControlY() ? pos.y() + c->relativeControlY() : c->controlY()); | - | ||||||||||||
171 | v->append(p.x()); | - | ||||||||||||
172 | v->append(p.y()); | - | ||||||||||||
173 | } never executed: end of block | 0 | ||||||||||||
174 | - | |||||||||||||
175 | static inline void appendControl1Coords(QVector<GLfloat> *v, QQuickPathCubic *c, const QPointF &pos) | - | ||||||||||||
176 | { | - | ||||||||||||
177 | QPointF p(c->hasRelativeControl1X() ? pos.x() + c->relativeControl1X() : c->control1X(), | - | ||||||||||||
178 | c->hasRelativeControl1Y() ? pos.y() + c->relativeControl1Y() : c->control1Y()); | - | ||||||||||||
179 | v->append(p.x()); | - | ||||||||||||
180 | v->append(p.y()); | - | ||||||||||||
181 | } never executed: end of block | 0 | ||||||||||||
182 | - | |||||||||||||
183 | static inline void appendControl2Coords(QVector<GLfloat> *v, QQuickPathCubic *c, const QPointF &pos) | - | ||||||||||||
184 | { | - | ||||||||||||
185 | QPointF p(c->hasRelativeControl2X() ? pos.x() + c->relativeControl2X() : c->control2X(), | - | ||||||||||||
186 | c->hasRelativeControl2Y() ? pos.y() + c->relativeControl2Y() : c->control2Y()); | - | ||||||||||||
187 | v->append(p.x()); | - | ||||||||||||
188 | v->append(p.y()); | - | ||||||||||||
189 | } never executed: end of block | 0 | ||||||||||||
190 | - | |||||||||||||
191 | void QQuickShapeNvprRenderer::convertPath(const QQuickPath *path, ShapePathGuiData *d) | - | ||||||||||||
192 | { | - | ||||||||||||
193 | d->path = NvprPath(); | - | ||||||||||||
194 | if (!path
| 0 | ||||||||||||
195 | return; never executed: return; | 0 | ||||||||||||
196 | - | |||||||||||||
197 | const QList<QQuickPathElement *> &pp(QQuickPathPrivate::get(path)->_pathElements); | - | ||||||||||||
198 | if (pp.isEmpty()
| 0 | ||||||||||||
199 | return; never executed: return; | 0 | ||||||||||||
200 | - | |||||||||||||
201 | QPointF startPos(path->startX(), path->startY()); | - | ||||||||||||
202 | QPointF pos(startPos); | - | ||||||||||||
203 | if (!qFuzzyIsNull(pos.x())
| 0 | ||||||||||||
204 | d->path.cmd.append(0x02); | - | ||||||||||||
205 | d->path.coord.append(pos.x()); | - | ||||||||||||
206 | d->path.coord.append(pos.y()); | - | ||||||||||||
207 | } never executed: end of block | 0 | ||||||||||||
208 | - | |||||||||||||
209 | for (QQuickPathElement *e : pp) { | - | ||||||||||||
210 | if (QQuickPathMove *o = qobject_cast<QQuickPathMove *>(e)
| 0 | ||||||||||||
211 | d->path.cmd.append(0x02); | - | ||||||||||||
212 | appendCoords(&d->path.coord, o, &pos); | - | ||||||||||||
213 | startPos = pos; | - | ||||||||||||
214 | } never executed: else if (QQuickPathLine *o = qobject_cast<QQuickPathLine *>(e)end of block
| 0 | ||||||||||||
215 | d->path.cmd.append(0x04); | - | ||||||||||||
216 | appendCoords(&d->path.coord, o, &pos); | - | ||||||||||||
217 | } never executed: else if (QQuickPathQuad *o = qobject_cast<QQuickPathQuad *>(e)end of block
| 0 | ||||||||||||
218 | d->path.cmd.append(0x0A); | - | ||||||||||||
219 | appendControlCoords(&d->path.coord, o, pos); | - | ||||||||||||
220 | appendCoords(&d->path.coord, o, &pos); | - | ||||||||||||
221 | } never executed: else if (QQuickPathCubic *o = qobject_cast<QQuickPathCubic *>(e)end of block
| 0 | ||||||||||||
222 | d->path.cmd.append(0x0C); | - | ||||||||||||
223 | appendControl1Coords(&d->path.coord, o, pos); | - | ||||||||||||
224 | appendControl2Coords(&d->path.coord, o, pos); | - | ||||||||||||
225 | appendCoords(&d->path.coord, o, &pos); | - | ||||||||||||
226 | } never executed: else if (QQuickPathArc *o = qobject_cast<QQuickPathArc *>(e)end of block
| 0 | ||||||||||||
227 | const bool sweepFlag = o->direction() == QQuickPathArc::Clockwise; | - | ||||||||||||
228 | GLenum cmd; | - | ||||||||||||
229 | if (o->useLargeArc()
| 0 | ||||||||||||
230 | cmd = sweepFlag
never executed: cmd = sweepFlag ? 0x16 : 0x18; | 0 | ||||||||||||
231 | else | - | ||||||||||||
232 | cmd = sweepFlag
never executed: cmd = sweepFlag ? 0x12 : 0x14; | 0 | ||||||||||||
233 | d->path.cmd.append(cmd); | - | ||||||||||||
234 | d->path.coord.append(o->radiusX()); | - | ||||||||||||
235 | d->path.coord.append(o->radiusY()); | - | ||||||||||||
236 | d->path.coord.append(o->xAxisRotation()); | - | ||||||||||||
237 | appendCoords(&d->path.coord, o, &pos); | - | ||||||||||||
238 | } never executed: else if (QQuickPathSvg *o = qobject_cast<QQuickPathSvg *>(e)end of block
| 0 | ||||||||||||
239 | - | |||||||||||||
240 | - | |||||||||||||
241 | if (d->path.str.isEmpty()
| 0 | ||||||||||||
242 | d->path.str = QString(([]() noexcept -> QString { enum { Size = sizeof(u"" "M %1 %2 ")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "M %1 %2 " }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }())).arg(pos.x()).arg(pos.y()).toUtf8();return qstring_literal_temp; never executed: d->path.str = QString(([]() noexcept -> QString { enum { Size = sizeof(u"" "M %1 %2 ")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "M %1 %2 " }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())).arg(pos.x()).arg(pos.y()).toUtf8(); | 0 | ||||||||||||
243 | d->path.str.append(o->path().toUtf8()); | - | ||||||||||||
244 | } never executed: else if (QQuickPathAngleArc *o = qobject_cast<QQuickPathAngleArc *>(e)end of block
| 0 | ||||||||||||
245 | QRectF rect(o->centerX() - o->radiusX(), o->centerY() - o->radiusY(), o->radiusX() * 2, o->radiusY() * 2); | - | ||||||||||||
246 | QPointF startPoint; | - | ||||||||||||
247 | QPointF endPoint; | - | ||||||||||||
248 | qt_find_ellipse_coords(rect, o->startAngle(), -o->sweepAngle(), &startPoint, &endPoint); | - | ||||||||||||
249 | - | |||||||||||||
250 | - | |||||||||||||
251 | if (o->moveToStart()
| 0 | ||||||||||||
252 | d->path.cmd.append(0x02); never executed: d->path.cmd.append(0x02); | 0 | ||||||||||||
253 | else | - | ||||||||||||
254 | d->path.cmd.append(0x04); never executed: d->path.cmd.append(0x04); | 0 | ||||||||||||
255 | d->path.coord.append(startPoint.x()); | - | ||||||||||||
256 | d->path.coord.append(startPoint.y()); | - | ||||||||||||
257 | - | |||||||||||||
258 | const bool sweepFlag = o->sweepAngle() > 0; | - | ||||||||||||
259 | d->path.cmd.append(qAbs(o->sweepAngle()) > 180.0 | - | ||||||||||||
260 | ? (sweepFlag ? 0x16 : 0x18) | - | ||||||||||||
261 | : (sweepFlag ? 0x12 : 0x14)); | - | ||||||||||||
262 | d->path.coord.append(o->radiusX()); | - | ||||||||||||
263 | d->path.coord.append(o->radiusY()); | - | ||||||||||||
264 | d->path.coord.append(0); | - | ||||||||||||
265 | d->path.coord.append(endPoint.x()); | - | ||||||||||||
266 | d->path.coord.append(endPoint.y()); | - | ||||||||||||
267 | pos = endPoint; | - | ||||||||||||
268 | } never executed: else {end of block | 0 | ||||||||||||
269 | QMessageLogger(__FILE__, 316, __PRETTY_FUNCTION__).warning() << "Shape/NVPR: unsupported Path element" << e; | - | ||||||||||||
270 | } never executed: end of block | 0 | ||||||||||||
271 | } | - | ||||||||||||
272 | - | |||||||||||||
273 | - | |||||||||||||
274 | - | |||||||||||||
275 | - | |||||||||||||
276 | - | |||||||||||||
277 | - | |||||||||||||
278 | if (pos == startPos
| 0 | ||||||||||||
279 | d->path.cmd.append(0x00); never executed: d->path.cmd.append(0x00); | 0 | ||||||||||||
280 | } never executed: end of block | 0 | ||||||||||||
281 | - | |||||||||||||
282 | static inline QVector4D qsg_premultiply(const QColor &c, float globalOpacity) | - | ||||||||||||
283 | { | - | ||||||||||||
284 | const float o = c.alphaF() * globalOpacity; | - | ||||||||||||
285 | return never executed: QVector4D(c.redF() * o, c.greenF() * o, c.blueF() * o, o);return QVector4D(c.redF() * o, c.greenF() * o, c.blueF() * o, o); never executed: return QVector4D(c.redF() * o, c.greenF() * o, c.blueF() * o, o); | 0 | ||||||||||||
286 | } | - | ||||||||||||
287 | - | |||||||||||||
288 | void QQuickShapeNvprRenderer::updateNode() | - | ||||||||||||
289 | { | - | ||||||||||||
290 | - | |||||||||||||
291 | - | |||||||||||||
292 | - | |||||||||||||
293 | if (!m_accDirty
| 0 | ||||||||||||
294 | return; never executed: return; | 0 | ||||||||||||
295 | - | |||||||||||||
296 | const int count = m_sp.count(); | - | ||||||||||||
297 | const bool listChanged = m_accDirty & DirtyList; | - | ||||||||||||
298 | if (listChanged
| 0 | ||||||||||||
299 | m_node->m_sp.resize(count); never executed: m_node->m_sp.resize(count); | 0 | ||||||||||||
300 | - | |||||||||||||
301 | for (int i = 0; i < count
| 0 | ||||||||||||
302 | ShapePathGuiData &src(m_sp[i]); | - | ||||||||||||
303 | QQuickShapeNvprRenderNode::ShapePathRenderData &dst(m_node->m_sp[i]); | - | ||||||||||||
304 | - | |||||||||||||
305 | int dirty = src.dirty; | - | ||||||||||||
306 | src.dirty = 0; | - | ||||||||||||
307 | if (listChanged
| 0 | ||||||||||||
308 | dirty |= DirtyPath | DirtyStyle | DirtyFillRule | DirtyDash | DirtyFillGradient; never executed: dirty |= DirtyPath | DirtyStyle | DirtyFillRule | DirtyDash | DirtyFillGradient; | 0 | ||||||||||||
309 | - | |||||||||||||
310 | - | |||||||||||||
311 | - | |||||||||||||
312 | dst.dirty |= dirty; | - | ||||||||||||
313 | - | |||||||||||||
314 | if (dirty & DirtyPath
| 0 | ||||||||||||
315 | dst.source = src.path; never executed: dst.source = src.path; | 0 | ||||||||||||
316 | - | |||||||||||||
317 | if (dirty & DirtyStyle
| 0 | ||||||||||||
318 | dst.strokeWidth = src.strokeWidth; | - | ||||||||||||
319 | dst.strokeColor = qsg_premultiply(src.strokeColor, 1.0f); | - | ||||||||||||
320 | dst.fillColor = qsg_premultiply(src.fillColor, 1.0f); | - | ||||||||||||
321 | switch (src.joinStyle) { | - | ||||||||||||
322 | case never executed: QQuickShapePath::MiterJoin:case QQuickShapePath::MiterJoin: never executed: case QQuickShapePath::MiterJoin: | 0 | ||||||||||||
323 | dst.joinStyle = 0x90A8; | - | ||||||||||||
324 | break; never executed: break; | 0 | ||||||||||||
325 | case never executed: QQuickShapePath::BevelJoin:case QQuickShapePath::BevelJoin: never executed: case QQuickShapePath::BevelJoin: | 0 | ||||||||||||
326 | dst.joinStyle = 0x90A6; | - | ||||||||||||
327 | break; never executed: break; | 0 | ||||||||||||
328 | case never executed: QQuickShapePath::RoundJoin:case QQuickShapePath::RoundJoin: never executed: case QQuickShapePath::RoundJoin: | 0 | ||||||||||||
329 | dst.joinStyle = 0x90A4; | - | ||||||||||||
330 | break; never executed: break; | 0 | ||||||||||||
331 | default never executed: :default: never executed: default: | 0 | ||||||||||||
332 | do { ((false) ? static_cast<void>(0) : qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached", __FILE__, 379)); __builtin_unreachable(); } while (false); | - | ||||||||||||
333 | } never executed: end of block | 0 | ||||||||||||
334 | dst.miterLimit = src.miterLimit; | - | ||||||||||||
335 | switch (src.capStyle) { | - | ||||||||||||
336 | case never executed: QQuickShapePath::FlatCap:case QQuickShapePath::FlatCap: never executed: case QQuickShapePath::FlatCap: | 0 | ||||||||||||
337 | dst.capStyle = | - | ||||||||||||
338 | 0x1D00 | - | ||||||||||||
339 | ; | - | ||||||||||||
340 | break; never executed: break; | 0 | ||||||||||||
341 | case never executed: QQuickShapePath::SquareCap:case QQuickShapePath::SquareCap: never executed: case QQuickShapePath::SquareCap: | 0 | ||||||||||||
342 | dst.capStyle = 0x90A3; | - | ||||||||||||
343 | break; never executed: break; | 0 | ||||||||||||
344 | case never executed: QQuickShapePath::RoundCap:case QQuickShapePath::RoundCap: never executed: case QQuickShapePath::RoundCap: | 0 | ||||||||||||
345 | dst.capStyle = 0x90A4; | - | ||||||||||||
346 | break; never executed: break; | 0 | ||||||||||||
347 | default never executed: :default: never executed: default: | 0 | ||||||||||||
348 | do { ((false) ? static_cast<void>(0) : qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached", __FILE__, 393)); __builtin_unreachable(); } while (false); | - | ||||||||||||
349 | } never executed: end of block | 0 | ||||||||||||
350 | } | - | ||||||||||||
351 | - | |||||||||||||
352 | if (dirty & DirtyFillRule
| 0 | ||||||||||||
353 | switch (src.fillRule) { | - | ||||||||||||
354 | case never executed: QQuickShapePath::OddEvenFill:case QQuickShapePath::OddEvenFill: never executed: case QQuickShapePath::OddEvenFill: | 0 | ||||||||||||
355 | dst.fillRule = | - | ||||||||||||
356 | 0x150A | - | ||||||||||||
357 | ; | - | ||||||||||||
358 | break; never executed: break; | 0 | ||||||||||||
359 | case never executed: QQuickShapePath::WindingFill:case QQuickShapePath::WindingFill: never executed: case QQuickShapePath::WindingFill: | 0 | ||||||||||||
360 | dst.fillRule = 0x9088; | - | ||||||||||||
361 | break; never executed: break; | 0 | ||||||||||||
362 | default never executed: :default: never executed: default: | 0 | ||||||||||||
363 | do { ((false) ? static_cast<void>(0) : qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached", __FILE__, 406)); __builtin_unreachable(); } while (false); | - | ||||||||||||
364 | } never executed: end of block | 0 | ||||||||||||
365 | } | - | ||||||||||||
366 | - | |||||||||||||
367 | if (dirty & DirtyDash
| 0 | ||||||||||||
368 | - | |||||||||||||
369 | - | |||||||||||||
370 | dst.dashOffset = src.dashOffset * src.strokeWidth; | - | ||||||||||||
371 | if (src.dashActive
| 0 | ||||||||||||
372 | if (src.dashPattern.isEmpty()
| 0 | ||||||||||||
373 | - | |||||||||||||
374 | dst.dashPattern.resize(2); | - | ||||||||||||
375 | dst.dashPattern[0] = 4 * src.strokeWidth; | - | ||||||||||||
376 | dst.dashPattern[1] = 2 * src.strokeWidth; | - | ||||||||||||
377 | } never executed: else {end of block | 0 | ||||||||||||
378 | dst.dashPattern.resize(src.dashPattern.count()); | - | ||||||||||||
379 | for (int i = 0; i < src.dashPattern.count()
| 0 | ||||||||||||
380 | dst.dashPattern[i] = GLfloat(src.dashPattern[i]) * src.strokeWidth; never executed: dst.dashPattern[i] = GLfloat(src.dashPattern[i]) * src.strokeWidth; | 0 | ||||||||||||
381 | - | |||||||||||||
382 | - | |||||||||||||
383 | if (src.dashPattern.count() % 2 != 0
| 0 | ||||||||||||
384 | QMessageLogger(__FILE__, 427, __PRETTY_FUNCTION__).warning("QQuickShapeNvprRenderNode: dash pattern not of even length"); | - | ||||||||||||
385 | dst.dashPattern << src.strokeWidth; | - | ||||||||||||
386 | } never executed: end of block | 0 | ||||||||||||
387 | } never executed: end of block | 0 | ||||||||||||
388 | } else { | - | ||||||||||||
389 | dst.dashPattern.clear(); | - | ||||||||||||
390 | } never executed: end of block | 0 | ||||||||||||
391 | } | - | ||||||||||||
392 | - | |||||||||||||
393 | if (dirty & DirtyFillGradient
| 0 | ||||||||||||
394 | dst.fillGradientActive = src.fillGradientActive; | - | ||||||||||||
395 | if (src.fillGradientActive
| 0 | ||||||||||||
396 | dst.fillGradient = src.fillGradient; never executed: dst.fillGradient = src.fillGradient; | 0 | ||||||||||||
397 | } never executed: end of block | 0 | ||||||||||||
398 | } never executed: end of block | 0 | ||||||||||||
399 | - | |||||||||||||
400 | m_node->markDirty(QSGNode::DirtyMaterial); | - | ||||||||||||
401 | m_accDirty = 0; | - | ||||||||||||
402 | } never executed: end of block | 0 | ||||||||||||
403 | - | |||||||||||||
404 | bool QQuickShapeNvprRenderNode::nvprInited = false; | - | ||||||||||||
405 | QQuickNvprFunctions QQuickShapeNvprRenderNode::nvpr; | - | ||||||||||||
406 | QQuickNvprMaterialManager QQuickShapeNvprRenderNode::mtlmgr; | - | ||||||||||||
407 | - | |||||||||||||
408 | QQuickShapeNvprRenderNode::~QQuickShapeNvprRenderNode() | - | ||||||||||||
409 | { | - | ||||||||||||
410 | releaseResources(); | - | ||||||||||||
411 | } never executed: end of block | 0 | ||||||||||||
412 | - | |||||||||||||
413 | void QQuickShapeNvprRenderNode::releaseResources() | - | ||||||||||||
414 | { | - | ||||||||||||
415 | for (ShapePathRenderData &d : m_sp) { | - | ||||||||||||
416 | if (d.path
| 0 | ||||||||||||
417 | nvpr.deletePaths(d.path, 1); | - | ||||||||||||
418 | d.path = 0; | - | ||||||||||||
419 | } never executed: end of block | 0 | ||||||||||||
420 | if (d.fallbackFbo
| 0 | ||||||||||||
421 | delete d.fallbackFbo; | - | ||||||||||||
422 | d.fallbackFbo = nullptr; | - | ||||||||||||
423 | } never executed: end of block | 0 | ||||||||||||
424 | } never executed: end of block | 0 | ||||||||||||
425 | - | |||||||||||||
426 | m_fallbackBlitter.destroy(); | - | ||||||||||||
427 | } never executed: end of block | 0 | ||||||||||||
428 | - | |||||||||||||
429 | void QQuickNvprMaterialManager::create(QQuickNvprFunctions *nvpr) | - | ||||||||||||
430 | { | - | ||||||||||||
431 | m_nvpr = nvpr; | - | ||||||||||||
432 | } never executed: end of block | 0 | ||||||||||||
433 | - | |||||||||||||
434 | void QQuickNvprMaterialManager::releaseResources() | - | ||||||||||||
435 | { | - | ||||||||||||
436 | QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions(); | - | ||||||||||||
437 | for (MaterialDesc &mtl : m_materials) { | - | ||||||||||||
438 | if (mtl.ppl
| 0 | ||||||||||||
439 | f->glDeleteProgramPipelines(1, &mtl.ppl); | - | ||||||||||||
440 | mtl = MaterialDesc(); | - | ||||||||||||
441 | } never executed: end of block | 0 | ||||||||||||
442 | } never executed: end of block | 0 | ||||||||||||
443 | } never executed: end of block | 0 | ||||||||||||
444 | - | |||||||||||||
445 | QQuickNvprMaterialManager::MaterialDesc *QQuickNvprMaterialManager::activateMaterial(Material m) | - | ||||||||||||
446 | { | - | ||||||||||||
447 | QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions(); | - | ||||||||||||
448 | MaterialDesc &mtl(m_materials[m]); | - | ||||||||||||
449 | - | |||||||||||||
450 | if (!mtl.ppl
| 0 | ||||||||||||
451 | if (m == MatSolid
| 0 | ||||||||||||
452 | static const char *fragSrc = | - | ||||||||||||
453 | "#version 310 es\n" | - | ||||||||||||
454 | "precision highp float;\n" | - | ||||||||||||
455 | "out vec4 fragColor;\n" | - | ||||||||||||
456 | "uniform vec4 color;\n" | - | ||||||||||||
457 | "uniform float opacity;\n" | - | ||||||||||||
458 | "void main() {\n" | - | ||||||||||||
459 | " fragColor = color * opacity;\n" | - | ||||||||||||
460 | "}\n"; | - | ||||||||||||
461 | if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)
| 0 | ||||||||||||
462 | QMessageLogger(__FILE__, 505, __PRETTY_FUNCTION__).warning("NVPR: Failed to create shader pipeline for solid fill"); | - | ||||||||||||
463 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
464 | } | - | ||||||||||||
465 | ((mtl.ppl && mtl.prg) ? static_cast<void>(0) : qt_assert("mtl.ppl && mtl.prg", __FILE__, 508)); | - | ||||||||||||
466 | mtl.uniLoc[0] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "color"); | - | ||||||||||||
467 | ((mtl.uniLoc[0] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[0] >= 0", __FILE__, 510)); | - | ||||||||||||
468 | mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "opacity"); | - | ||||||||||||
469 | ((mtl.uniLoc[1] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[1] >= 0", __FILE__, 512)); | - | ||||||||||||
470 | } never executed: else if (m == MatLinearGradientend of block
| 0 | ||||||||||||
471 | static const char *fragSrc = | - | ||||||||||||
472 | "#version 310 es\n" | - | ||||||||||||
473 | "precision highp float;\n" | - | ||||||||||||
474 | "layout(location = 0) in vec2 uv;" | - | ||||||||||||
475 | "uniform float opacity;\n" | - | ||||||||||||
476 | "uniform sampler2D gradTab;\n" | - | ||||||||||||
477 | "uniform vec2 gradStart;\n" | - | ||||||||||||
478 | "uniform vec2 gradEnd;\n" | - | ||||||||||||
479 | "out vec4 fragColor;\n" | - | ||||||||||||
480 | "void main() {\n" | - | ||||||||||||
481 | " vec2 gradVec = gradEnd - gradStart;\n" | - | ||||||||||||
482 | " float gradTabIndex = dot(gradVec, uv - gradStart) / (gradVec.x * gradVec.x + gradVec.y * gradVec.y);\n" | - | ||||||||||||
483 | " fragColor = texture(gradTab, vec2(gradTabIndex, 0.5)) * opacity;\n" | - | ||||||||||||
484 | "}\n"; | - | ||||||||||||
485 | if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)
| 0 | ||||||||||||
486 | QMessageLogger(__FILE__, 529, __PRETTY_FUNCTION__).warning("NVPR: Failed to create shader pipeline for linear gradient"); | - | ||||||||||||
487 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
488 | } | - | ||||||||||||
489 | ((mtl.ppl && mtl.prg) ? static_cast<void>(0) : qt_assert("mtl.ppl && mtl.prg", __FILE__, 532)); | - | ||||||||||||
490 | mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "opacity"); | - | ||||||||||||
491 | ((mtl.uniLoc[1] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[1] >= 0", __FILE__, 534)); | - | ||||||||||||
492 | mtl.uniLoc[2] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "gradStart"); | - | ||||||||||||
493 | ((mtl.uniLoc[2] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[2] >= 0", __FILE__, 536)); | - | ||||||||||||
494 | mtl.uniLoc[3] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "gradEnd"); | - | ||||||||||||
495 | ((mtl.uniLoc[3] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[3] >= 0", __FILE__, 538)); | - | ||||||||||||
496 | } never executed: else if (m == MatRadialGradientend of block
| 0 | ||||||||||||
497 | static const char *fragSrc = | - | ||||||||||||
498 | "#version 310 es\n" | - | ||||||||||||
499 | "precision highp float;\n" | - | ||||||||||||
500 | "uniform sampler2D gradTab;\n" | - | ||||||||||||
501 | "uniform float opacity;\n" | - | ||||||||||||
502 | "uniform vec2 focalToCenter;\n" | - | ||||||||||||
503 | "uniform float centerRadius;\n" | - | ||||||||||||
504 | "uniform float focalRadius;\n" | - | ||||||||||||
505 | "uniform vec2 translationPoint;\n" | - | ||||||||||||
506 | "layout(location = 0) in vec2 uv;\n" | - | ||||||||||||
507 | "out vec4 fragColor;\n" | - | ||||||||||||
508 | "void main() {\n" | - | ||||||||||||
509 | " vec2 coord = uv - translationPoint;\n" | - | ||||||||||||
510 | " float rd = centerRadius - focalRadius;\n" | - | ||||||||||||
511 | " float b = 2.0 * (rd * focalRadius + dot(coord, focalToCenter));\n" | - | ||||||||||||
512 | " float fmp2_m_radius2 = -focalToCenter.x * focalToCenter.x - focalToCenter.y * focalToCenter.y + rd * rd;\n" | - | ||||||||||||
513 | " float inverse_2_fmp2_m_radius2 = 1.0 / (2.0 * fmp2_m_radius2);\n" | - | ||||||||||||
514 | " float det = b * b - 4.0 * fmp2_m_radius2 * ((focalRadius * focalRadius) - dot(coord, coord));\n" | - | ||||||||||||
515 | " vec4 result = vec4(0.0);\n" | - | ||||||||||||
516 | " if (det >= 0.0) {\n" | - | ||||||||||||
517 | " float detSqrt = sqrt(det);\n" | - | ||||||||||||
518 | " float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2);\n" | - | ||||||||||||
519 | " if (focalRadius + w * (centerRadius - focalRadius) >= 0.0)\n" | - | ||||||||||||
520 | " result = texture(gradTab, vec2(w, 0.5)) * opacity;\n" | - | ||||||||||||
521 | " }\n" | - | ||||||||||||
522 | " fragColor = result;\n" | - | ||||||||||||
523 | "}\n"; | - | ||||||||||||
524 | if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)
| 0 | ||||||||||||
525 | QMessageLogger(__FILE__, 568, __PRETTY_FUNCTION__).warning("NVPR: Failed to create shader pipeline for radial gradient"); | - | ||||||||||||
526 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
527 | } | - | ||||||||||||
528 | ((mtl.ppl && mtl.prg) ? static_cast<void>(0) : qt_assert("mtl.ppl && mtl.prg", __FILE__, 571)); | - | ||||||||||||
529 | mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "opacity"); | - | ||||||||||||
530 | ((mtl.uniLoc[1] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[1] >= 0", __FILE__, 573)); | - | ||||||||||||
531 | mtl.uniLoc[2] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "focalToCenter"); | - | ||||||||||||
532 | ((mtl.uniLoc[2] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[2] >= 0", __FILE__, 575)); | - | ||||||||||||
533 | mtl.uniLoc[3] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "centerRadius"); | - | ||||||||||||
534 | ((mtl.uniLoc[3] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[3] >= 0", __FILE__, 577)); | - | ||||||||||||
535 | mtl.uniLoc[4] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "focalRadius"); | - | ||||||||||||
536 | ((mtl.uniLoc[4] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[4] >= 0", __FILE__, 579)); | - | ||||||||||||
537 | mtl.uniLoc[5] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "translationPoint"); | - | ||||||||||||
538 | ((mtl.uniLoc[5] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[5] >= 0", __FILE__, 581)); | - | ||||||||||||
539 | } never executed: else if (m == MatConicalGradientend of block
| 0 | ||||||||||||
540 | static const char *fragSrc = | - | ||||||||||||
541 | "#version 310 es\n" | - | ||||||||||||
542 | "precision highp float;\n" | - | ||||||||||||
543 | "#define INVERSE_2PI 0.1591549430918953358\n" | - | ||||||||||||
544 | "uniform sampler2D gradTab;\n" | - | ||||||||||||
545 | "uniform float opacity;\n" | - | ||||||||||||
546 | "uniform float angle;\n" | - | ||||||||||||
547 | "uniform vec2 translationPoint;\n" | - | ||||||||||||
548 | "layout(location = 0) in vec2 uv;\n" | - | ||||||||||||
549 | "out vec4 fragColor;\n" | - | ||||||||||||
550 | "void main() {\n" | - | ||||||||||||
551 | " vec2 coord = uv - translationPoint;\n" | - | ||||||||||||
552 | " float t;\n" | - | ||||||||||||
553 | " if (abs(coord.y) == abs(coord.x))\n" | - | ||||||||||||
554 | " t = (atan(-coord.y + 0.002, coord.x) + angle) * INVERSE_2PI;\n" | - | ||||||||||||
555 | " else\n" | - | ||||||||||||
556 | " t = (atan(-coord.y, coord.x) + angle) * INVERSE_2PI;\n" | - | ||||||||||||
557 | " fragColor = texture(gradTab, vec2(t - floor(t), 0.5)) * opacity;\n" | - | ||||||||||||
558 | "}\n"; | - | ||||||||||||
559 | if (!m_nvpr->createFragmentOnlyPipeline(fragSrc, &mtl.ppl, &mtl.prg)
| 0 | ||||||||||||
560 | QMessageLogger(__FILE__, 603, __PRETTY_FUNCTION__).warning("NVPR: Failed to create shader pipeline for conical gradient"); | - | ||||||||||||
561 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
562 | } | - | ||||||||||||
563 | ((mtl.ppl && mtl.prg) ? static_cast<void>(0) : qt_assert("mtl.ppl && mtl.prg", __FILE__, 606)); | - | ||||||||||||
564 | mtl.uniLoc[1] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "opacity"); | - | ||||||||||||
565 | ((mtl.uniLoc[1] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[1] >= 0", __FILE__, 608)); | - | ||||||||||||
566 | mtl.uniLoc[2] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "angle"); | - | ||||||||||||
567 | ((mtl.uniLoc[2] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[2] >= 0", __FILE__, 610)); | - | ||||||||||||
568 | mtl.uniLoc[3] = f->glGetProgramResourceLocation(mtl.prg, 0x92E1, "translationPoint"); | - | ||||||||||||
569 | ((mtl.uniLoc[3] >= 0) ? static_cast<void>(0) : qt_assert("mtl.uniLoc[3] >= 0", __FILE__, 612)); | - | ||||||||||||
570 | } never executed: else {end of block | 0 | ||||||||||||
571 | do { ((false) ? static_cast<void>(0) : qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached", __FILE__, 614)); __builtin_unreachable(); } while (false); | - | ||||||||||||
572 | } never executed: end of block | 0 | ||||||||||||
573 | } | - | ||||||||||||
574 | - | |||||||||||||
575 | f->glBindProgramPipeline(mtl.ppl); | - | ||||||||||||
576 | - | |||||||||||||
577 | return never executed: &mtl;return &mtl; never executed: return &mtl; | 0 | ||||||||||||
578 | } | - | ||||||||||||
579 | - | |||||||||||||
580 | void QQuickShapeNvprRenderNode::updatePath(ShapePathRenderData *d) | - | ||||||||||||
581 | { | - | ||||||||||||
582 | if (d->dirty & QQuickShapeNvprRenderer::DirtyPath
| 0 | ||||||||||||
583 | if (!d->path
| 0 | ||||||||||||
584 | d->path = nvpr.genPaths(1); | - | ||||||||||||
585 | ((d->path != 0) ? static_cast<void>(0) : qt_assert("d->path != 0", __FILE__, 628)); | - | ||||||||||||
586 | } never executed: end of block | 0 | ||||||||||||
587 | if (d->source.str.isEmpty()
| 0 | ||||||||||||
588 | nvpr.pathCommands(d->path, d->source.cmd.count(), d->source.cmd.constData(), | - | ||||||||||||
589 | d->source.coord.count(), | - | ||||||||||||
590 | 0x1406 | - | ||||||||||||
591 | , d->source.coord.constData()); | - | ||||||||||||
592 | } never executed: else {end of block | 0 | ||||||||||||
593 | nvpr.pathString(d->path, 0x9070, d->source.str.count(), d->source.str.constData()); | - | ||||||||||||
594 | } never executed: end of block | 0 | ||||||||||||
595 | } | - | ||||||||||||
596 | - | |||||||||||||
597 | if (d->dirty & QQuickShapeNvprRenderer::DirtyStyle
| 0 | ||||||||||||
598 | nvpr.pathParameterf(d->path, 0x9075, d->strokeWidth); | - | ||||||||||||
599 | nvpr.pathParameteri(d->path, 0x9079, d->joinStyle); | - | ||||||||||||
600 | nvpr.pathParameteri(d->path, 0x907A, d->miterLimit); | - | ||||||||||||
601 | nvpr.pathParameteri(d->path, 0x9076, d->capStyle); | - | ||||||||||||
602 | nvpr.pathParameteri(d->path, 0x907B, d->capStyle); | - | ||||||||||||
603 | } never executed: end of block | 0 | ||||||||||||
604 | - | |||||||||||||
605 | if (d->dirty & QQuickShapeNvprRenderer::DirtyDash
| 0 | ||||||||||||
606 | nvpr.pathParameterf(d->path, 0x907E, d->dashOffset); | - | ||||||||||||
607 | - | |||||||||||||
608 | nvpr.pathDashArray(d->path, d->dashPattern.count(), d->dashPattern.constData()); | - | ||||||||||||
609 | } never executed: end of block | 0 | ||||||||||||
610 | - | |||||||||||||
611 | if (d->dirty
| 0 | ||||||||||||
612 | d->fallbackValid = false; never executed: d->fallbackValid = false; | 0 | ||||||||||||
613 | } never executed: end of block | 0 | ||||||||||||
614 | - | |||||||||||||
615 | void QQuickShapeNvprRenderNode::renderStroke(ShapePathRenderData *d, int strokeStencilValue, int writeMask) | - | ||||||||||||
616 | { | - | ||||||||||||
617 | QQuickNvprMaterialManager::MaterialDesc *mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatSolid); | - | ||||||||||||
618 | f->glProgramUniform4f(mtl->prg, mtl->uniLoc[0], | - | ||||||||||||
619 | d->strokeColor.x(), d->strokeColor.y(), d->strokeColor.z(), d->strokeColor.w()); | - | ||||||||||||
620 | f->glProgramUniform1f(mtl->prg, mtl->uniLoc[1], inheritedOpacity()); | - | ||||||||||||
621 | - | |||||||||||||
622 | nvpr.stencilThenCoverStrokePath(d->path, strokeStencilValue, writeMask, 0x908B); | - | ||||||||||||
623 | } never executed: end of block | 0 | ||||||||||||
624 | - | |||||||||||||
625 | void QQuickShapeNvprRenderNode::renderFill(ShapePathRenderData *d) | - | ||||||||||||
626 | { | - | ||||||||||||
627 | QQuickNvprMaterialManager::MaterialDesc *mtl = nullptr; | - | ||||||||||||
628 | if (d->fillGradientActive
| 0 | ||||||||||||
629 | QQuickShapeGradient::SpreadMode spread = d->fillGradient.spread; | - | ||||||||||||
630 | if (d->fillGradientActive == QQuickAbstractPathRenderer::LinearGradient
| 0 | ||||||||||||
631 | mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatLinearGradient); | - | ||||||||||||
632 | - | |||||||||||||
633 | - | |||||||||||||
634 | - | |||||||||||||
635 | GLfloat coeff[6] = { 1, 0, 0, | - | ||||||||||||
636 | 0, 1, 0 }; | - | ||||||||||||
637 | nvpr.programPathFragmentInputGen(mtl->prg, 0, 0x2401, 2, coeff); | - | ||||||||||||
638 | f->glProgramUniform2f(mtl->prg, mtl->uniLoc[2], d->fillGradient.a.x(), d->fillGradient.a.y()); | - | ||||||||||||
639 | f->glProgramUniform2f(mtl->prg, mtl->uniLoc[3], d->fillGradient.b.x(), d->fillGradient.b.y()); | - | ||||||||||||
640 | } never executed: else if (d->fillGradientActive == QQuickAbstractPathRenderer::RadialGradientend of block
| 0 | ||||||||||||
641 | mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatRadialGradient); | - | ||||||||||||
642 | - | |||||||||||||
643 | GLfloat coeff[6] = { 1, 0, 0, | - | ||||||||||||
644 | 0, 1, 0 }; | - | ||||||||||||
645 | nvpr.programPathFragmentInputGen(mtl->prg, 0, 0x2401, 2, coeff); | - | ||||||||||||
646 | - | |||||||||||||
647 | const QPointF centerPoint = d->fillGradient.a; | - | ||||||||||||
648 | const QPointF focalPoint = d->fillGradient.b; | - | ||||||||||||
649 | const QPointF focalToCenter = centerPoint - focalPoint; | - | ||||||||||||
650 | const GLfloat centerRadius = d->fillGradient.v0; | - | ||||||||||||
651 | const GLfloat focalRadius = d->fillGradient.v1; | - | ||||||||||||
652 | - | |||||||||||||
653 | f->glProgramUniform2f(mtl->prg, mtl->uniLoc[2], focalToCenter.x(), focalToCenter.y()); | - | ||||||||||||
654 | f->glProgramUniform1f(mtl->prg, mtl->uniLoc[3], centerRadius); | - | ||||||||||||
655 | f->glProgramUniform1f(mtl->prg, mtl->uniLoc[4], focalRadius); | - | ||||||||||||
656 | f->glProgramUniform2f(mtl->prg, mtl->uniLoc[5], focalPoint.x(), focalPoint.y()); | - | ||||||||||||
657 | } never executed: else if (d->fillGradientActive == QQuickAbstractPathRenderer::ConicalGradientend of block
| 0 | ||||||||||||
658 | mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatConicalGradient); | - | ||||||||||||
659 | - | |||||||||||||
660 | GLfloat coeff[6] = { 1, 0, 0, | - | ||||||||||||
661 | 0, 1, 0 }; | - | ||||||||||||
662 | nvpr.programPathFragmentInputGen(mtl->prg, 0, 0x2401, 2, coeff); | - | ||||||||||||
663 | - | |||||||||||||
664 | const QPointF centerPoint = d->fillGradient.a; | - | ||||||||||||
665 | const GLfloat angle = -qDegreesToRadians(d->fillGradient.v0); | - | ||||||||||||
666 | - | |||||||||||||
667 | f->glProgramUniform1f(mtl->prg, mtl->uniLoc[2], angle); | - | ||||||||||||
668 | f->glProgramUniform2f(mtl->prg, mtl->uniLoc[3], centerPoint.x(), centerPoint.y()); | - | ||||||||||||
669 | - | |||||||||||||
670 | spread = QQuickShapeGradient::RepeatSpread; | - | ||||||||||||
671 | } never executed: else {end of block | 0 | ||||||||||||
672 | do { ((false) ? static_cast<void>(0) : qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached", __FILE__, 713)); __builtin_unreachable(); } while (false); | - | ||||||||||||
673 | } never executed: end of block | 0 | ||||||||||||
674 | const QQuickShapeGradientCache::Key cacheKey(d->fillGradient.stops, spread); | - | ||||||||||||
675 | QSGTexture *tx = QQuickShapeGradientCache::currentCache()->get(cacheKey); | - | ||||||||||||
676 | tx->bind(); | - | ||||||||||||
677 | } never executed: else {end of block | 0 | ||||||||||||
678 | mtl = mtlmgr.activateMaterial(QQuickNvprMaterialManager::MatSolid); | - | ||||||||||||
679 | f->glProgramUniform4f(mtl->prg, mtl->uniLoc[0], | - | ||||||||||||
680 | d->fillColor.x(), d->fillColor.y(), d->fillColor.z(), d->fillColor.w()); | - | ||||||||||||
681 | } never executed: end of block | 0 | ||||||||||||
682 | f->glProgramUniform1f(mtl->prg, mtl->uniLoc[1], inheritedOpacity()); | - | ||||||||||||
683 | - | |||||||||||||
684 | const int writeMask = 0xFF; | - | ||||||||||||
685 | nvpr.stencilThenCoverFillPath(d->path, d->fillRule, writeMask, 0x908D); | - | ||||||||||||
686 | } never executed: end of block | 0 | ||||||||||||
687 | - | |||||||||||||
688 | void QQuickShapeNvprRenderNode::renderOffscreenFill(ShapePathRenderData *d) | - | ||||||||||||
689 | { | - | ||||||||||||
690 | if (d->fallbackValid
| 0 | ||||||||||||
691 | return; never executed: return; | 0 | ||||||||||||
692 | - | |||||||||||||
693 | GLfloat bb[4]; | - | ||||||||||||
694 | nvpr.getPathParameterfv(d->path, 0x90A2, bb); | - | ||||||||||||
695 | QSize sz = QSizeF(bb[2] - bb[0] + 1, bb[3] - bb[1] + 1).toSize(); | - | ||||||||||||
696 | d->fallbackSize = QSize(qMax(32, sz.width()), qMax(32, sz.height())); | - | ||||||||||||
697 | d->fallbackTopLeft = QPointF(bb[0], bb[1]); | - | ||||||||||||
698 | - | |||||||||||||
699 | if (d->fallbackFbo
| 0 | ||||||||||||
700 | delete d->fallbackFbo; | - | ||||||||||||
701 | d->fallbackFbo = nullptr; | - | ||||||||||||
702 | } never executed: end of block | 0 | ||||||||||||
703 | if (!d->fallbackFbo
| 0 | ||||||||||||
704 | d->fallbackFbo = new QOpenGLFramebufferObject(d->fallbackSize, QOpenGLFramebufferObject::CombinedDepthStencil); never executed: d->fallbackFbo = new QOpenGLFramebufferObject(d->fallbackSize, QOpenGLFramebufferObject::CombinedDepthStencil); | 0 | ||||||||||||
705 | if (!d->fallbackFbo->bind()
| 0 | ||||||||||||
706 | return; never executed: return; | 0 | ||||||||||||
707 | - | |||||||||||||
708 | GLint prevViewport[4]; | - | ||||||||||||
709 | f->glGetIntegerv( | - | ||||||||||||
710 | 0x0BA2 | - | ||||||||||||
711 | , prevViewport); | - | ||||||||||||
712 | - | |||||||||||||
713 | f->glViewport(0, 0, d->fallbackSize.width(), d->fallbackSize.height()); | - | ||||||||||||
714 | f->glDisable( | - | ||||||||||||
715 | 0x0B71 | - | ||||||||||||
716 | ); | - | ||||||||||||
717 | f->glClearColor(0, 0, 0, 0); | - | ||||||||||||
718 | f->glClearStencil(0); | - | ||||||||||||
719 | f->glClear( | - | ||||||||||||
720 | 0x00004000 | - | ||||||||||||
721 | | | - | ||||||||||||
722 | 0x00000400 | - | ||||||||||||
723 | ); | - | ||||||||||||
724 | f->glStencilFunc( | - | ||||||||||||
725 | 0x0205 | - | ||||||||||||
726 | , 0, 0xFF); | - | ||||||||||||
727 | f->glStencilOp( | - | ||||||||||||
728 | 0x1E00 | - | ||||||||||||
729 | , | - | ||||||||||||
730 | 0x1E00 | - | ||||||||||||
731 | , | - | ||||||||||||
732 | 0x1E00 | - | ||||||||||||
733 | ); | - | ||||||||||||
734 | - | |||||||||||||
735 | QMatrix4x4 mv; | - | ||||||||||||
736 | mv.translate(-d->fallbackTopLeft.x(), -d->fallbackTopLeft.y()); | - | ||||||||||||
737 | nvpr.matrixLoadf(0x1700, mv.constData()); | - | ||||||||||||
738 | QMatrix4x4 proj; | - | ||||||||||||
739 | proj.ortho(0, d->fallbackSize.width(), d->fallbackSize.height(), 0, 1, -1); | - | ||||||||||||
740 | nvpr.matrixLoadf(0x1701, proj.constData()); | - | ||||||||||||
741 | - | |||||||||||||
742 | renderFill(d); | - | ||||||||||||
743 | - | |||||||||||||
744 | d->fallbackFbo->release(); | - | ||||||||||||
745 | f->glEnable( | - | ||||||||||||
746 | 0x0B71 | - | ||||||||||||
747 | ); | - | ||||||||||||
748 | f->glViewport(prevViewport[0], prevViewport[1], prevViewport[2], prevViewport[3]); | - | ||||||||||||
749 | - | |||||||||||||
750 | d->fallbackValid = true; | - | ||||||||||||
751 | } never executed: end of block | 0 | ||||||||||||
752 | - | |||||||||||||
753 | void QQuickShapeNvprRenderNode::setupStencilForCover(bool stencilClip, int sv) | - | ||||||||||||
754 | { | - | ||||||||||||
755 | if (!stencilClip
| 0 | ||||||||||||
756 | - | |||||||||||||
757 | - | |||||||||||||
758 | f->glStencilFunc( | - | ||||||||||||
759 | 0x0205 | - | ||||||||||||
760 | , 0, 0xFF); | - | ||||||||||||
761 | f->glStencilOp( | - | ||||||||||||
762 | 0x1E00 | - | ||||||||||||
763 | , | - | ||||||||||||
764 | 0x1E00 | - | ||||||||||||
765 | , | - | ||||||||||||
766 | 0 | - | ||||||||||||
767 | ); | - | ||||||||||||
768 | } never executed: else {end of block | 0 | ||||||||||||
769 | f->glStencilFunc( | - | ||||||||||||
770 | 0x0201 | - | ||||||||||||
771 | , sv, 0xFF); | - | ||||||||||||
772 | f->glStencilOp( | - | ||||||||||||
773 | 0x1E00 | - | ||||||||||||
774 | , | - | ||||||||||||
775 | 0x1E00 | - | ||||||||||||
776 | , | - | ||||||||||||
777 | 0x1E01 | - | ||||||||||||
778 | ); | - | ||||||||||||
779 | } never executed: end of block | 0 | ||||||||||||
780 | } | - | ||||||||||||
781 | - | |||||||||||||
782 | void QQuickShapeNvprRenderNode::render(const RenderState *state) | - | ||||||||||||
783 | { | - | ||||||||||||
784 | f = QOpenGLContext::currentContext()->extraFunctions(); | - | ||||||||||||
785 | - | |||||||||||||
786 | if (!nvprInited
| 0 | ||||||||||||
787 | if (!nvpr.create()
| 0 | ||||||||||||
788 | QMessageLogger(__FILE__, 795, __PRETTY_FUNCTION__).warning("NVPR init failed"); | - | ||||||||||||
789 | return; never executed: return; | 0 | ||||||||||||
790 | } | - | ||||||||||||
791 | mtlmgr.create(&nvpr); | - | ||||||||||||
792 | nvprInited = true; | - | ||||||||||||
793 | } never executed: end of block | 0 | ||||||||||||
794 | - | |||||||||||||
795 | f->glUseProgram(0); | - | ||||||||||||
796 | f->glStencilMask(~0); | - | ||||||||||||
797 | f->glEnable( | - | ||||||||||||
798 | 0x0B90 | - | ||||||||||||
799 | ); | - | ||||||||||||
800 | - | |||||||||||||
801 | const bool stencilClip = state->stencilEnabled(); | - | ||||||||||||
802 | - | |||||||||||||
803 | const int sv = state->stencilValue(); | - | ||||||||||||
804 | const bool hasScissor = state->scissorEnabled(); | - | ||||||||||||
805 | - | |||||||||||||
806 | if (hasScissor
| 0 | ||||||||||||
807 | - | |||||||||||||
808 | f->glEnable( | - | ||||||||||||
809 | 0x0C11 | - | ||||||||||||
810 | ); | - | ||||||||||||
811 | } never executed: end of block | 0 | ||||||||||||
812 | - | |||||||||||||
813 | - | |||||||||||||
814 | f->glEnable( | - | ||||||||||||
815 | 0x0B71 | - | ||||||||||||
816 | ); | - | ||||||||||||
817 | f->glDepthFunc( | - | ||||||||||||
818 | 0x0201 | - | ||||||||||||
819 | ); | - | ||||||||||||
820 | nvpr.pathCoverDepthFunc( | - | ||||||||||||
821 | 0x0201 | - | ||||||||||||
822 | ); | - | ||||||||||||
823 | nvpr.pathStencilDepthOffset(-0.05f, -1); | - | ||||||||||||
824 | - | |||||||||||||
825 | bool reloadMatrices = true; | - | ||||||||||||
826 | - | |||||||||||||
827 | for (ShapePathRenderData &d : m_sp) { | - | ||||||||||||
828 | updatePath(&d); | - | ||||||||||||
829 | - | |||||||||||||
830 | const bool hasFill = d.hasFill(); | - | ||||||||||||
831 | const bool hasStroke = d.hasStroke(); | - | ||||||||||||
832 | - | |||||||||||||
833 | if (hasFill
| 0 | ||||||||||||
834 | - | |||||||||||||
835 | - | |||||||||||||
836 | - | |||||||||||||
837 | if (hasScissor
| 0 | ||||||||||||
838 | f->glDisable( never executed: f->glDisable( 0x0C11 ); | 0 | ||||||||||||
839 | 0x0C11 never executed: f->glDisable( 0x0C11 ); | 0 | ||||||||||||
840 | ); never executed: f->glDisable( 0x0C11 ); | 0 | ||||||||||||
841 | renderOffscreenFill(&d); | - | ||||||||||||
842 | reloadMatrices = true; | - | ||||||||||||
843 | if (hasScissor
| 0 | ||||||||||||
844 | f->glEnable( never executed: f->glEnable( 0x0C11 ); | 0 | ||||||||||||
845 | 0x0C11 never executed: f->glEnable( 0x0C11 ); | 0 | ||||||||||||
846 | ); never executed: f->glEnable( 0x0C11 ); | 0 | ||||||||||||
847 | } never executed: end of block | 0 | ||||||||||||
848 | - | |||||||||||||
849 | if (reloadMatrices
| 0 | ||||||||||||
850 | reloadMatrices = false; | - | ||||||||||||
851 | nvpr.matrixLoadf(0x1700, matrix()->constData()); | - | ||||||||||||
852 | nvpr.matrixLoadf(0x1701, state->projectionMatrix()->constData()); | - | ||||||||||||
853 | } never executed: end of block | 0 | ||||||||||||
854 | - | |||||||||||||
855 | - | |||||||||||||
856 | if (hasFill
| 0 | ||||||||||||
857 | if (!stencilClip
| 0 | ||||||||||||
858 | setupStencilForCover(false, 0); | - | ||||||||||||
859 | renderFill(&d); | - | ||||||||||||
860 | } never executed: else {end of block | 0 | ||||||||||||
861 | if (!m_fallbackBlitter.isCreated()
| 0 | ||||||||||||
862 | m_fallbackBlitter.create(); never executed: m_fallbackBlitter.create(); | 0 | ||||||||||||
863 | f->glStencilFunc( | - | ||||||||||||
864 | 0x0202 | - | ||||||||||||
865 | , sv, 0xFF); | - | ||||||||||||
866 | f->glStencilOp( | - | ||||||||||||
867 | 0x1E00 | - | ||||||||||||
868 | , | - | ||||||||||||
869 | 0x1E00 | - | ||||||||||||
870 | , | - | ||||||||||||
871 | 0x1E00 | - | ||||||||||||
872 | ); | - | ||||||||||||
873 | QMatrix4x4 mv = *matrix(); | - | ||||||||||||
874 | mv.translate(d.fallbackTopLeft.x(), d.fallbackTopLeft.y()); | - | ||||||||||||
875 | m_fallbackBlitter.texturedQuad(d.fallbackFbo->texture(), d.fallbackFbo->size(), | - | ||||||||||||
876 | *state->projectionMatrix(), mv, | - | ||||||||||||
877 | inheritedOpacity()); | - | ||||||||||||
878 | } never executed: end of block | 0 | ||||||||||||
879 | } | - | ||||||||||||
880 | - | |||||||||||||
881 | - | |||||||||||||
882 | if (hasStroke
| 0 | ||||||||||||
883 | const int strokeStencilValue = 0x80; | - | ||||||||||||
884 | const int writeMask = 0x80; | - | ||||||||||||
885 | - | |||||||||||||
886 | setupStencilForCover(stencilClip, sv); | - | ||||||||||||
887 | if (stencilClip
| 0 | ||||||||||||
888 | - | |||||||||||||
889 | nvpr.pathStencilFunc( | - | ||||||||||||
890 | 0x0202 | - | ||||||||||||
891 | , sv, 0xFF); | - | ||||||||||||
892 | - | |||||||||||||
893 | - | |||||||||||||
894 | if (sv >= strokeStencilValue
| 0 | ||||||||||||
895 | QMessageLogger(__FILE__, 878, __PRETTY_FUNCTION__).warning("Shape/NVPR: stencil clip ref value %d too large; expect rendering errors", sv); never executed: QMessageLogger(__FILE__, 878, __PRETTY_FUNCTION__).warning("Shape/NVPR: stencil clip ref value %d too large; expect rendering errors", sv); | 0 | ||||||||||||
896 | } never executed: end of block | 0 | ||||||||||||
897 | - | |||||||||||||
898 | renderStroke(&d, strokeStencilValue, writeMask); | - | ||||||||||||
899 | } never executed: end of block | 0 | ||||||||||||
900 | - | |||||||||||||
901 | if (stencilClip
| 0 | ||||||||||||
902 | nvpr.pathStencilFunc( never executed: nvpr.pathStencilFunc( 0x0207 , 0, ~0); | 0 | ||||||||||||
903 | 0x0207 never executed: nvpr.pathStencilFunc( 0x0207 , 0, ~0); | 0 | ||||||||||||
904 | , 0, ~0); never executed: nvpr.pathStencilFunc( 0x0207 , 0, ~0); | 0 | ||||||||||||
905 | - | |||||||||||||
906 | d.dirty = 0; | - | ||||||||||||
907 | } never executed: end of block | 0 | ||||||||||||
908 | - | |||||||||||||
909 | f->glBindProgramPipeline(0); | - | ||||||||||||
910 | } never executed: end of block | 0 | ||||||||||||
911 | - | |||||||||||||
912 | QSGRenderNode::StateFlags QQuickShapeNvprRenderNode::changedStates() const | - | ||||||||||||
913 | { | - | ||||||||||||
914 | return never executed: BlendState | StencilState | DepthState | ScissorState;return BlendState | StencilState | DepthState | ScissorState; never executed: return BlendState | StencilState | DepthState | ScissorState; | 0 | ||||||||||||
915 | } | - | ||||||||||||
916 | - | |||||||||||||
917 | QSGRenderNode::RenderingFlags QQuickShapeNvprRenderNode::flags() const | - | ||||||||||||
918 | { | - | ||||||||||||
919 | return never executed: DepthAwareRendering;return DepthAwareRendering; never executed: return DepthAwareRendering; | 0 | ||||||||||||
920 | } | - | ||||||||||||
921 | - | |||||||||||||
922 | bool QQuickShapeNvprRenderNode::isSupported() | - | ||||||||||||
923 | { | - | ||||||||||||
924 | static const bool nvprDisabled = qEnvironmentVariableIntValue("QT_NO_NVPR") != 0; | - | ||||||||||||
925 | return executed 166 times by 1 test: !nvprDisabled && QQuickNvprFunctions::isSupported();return !nvprDisabled && QQuickNvprFunctions::isSupported(); Executed by:
executed 166 times by 1 test: return !nvprDisabled && QQuickNvprFunctions::isSupported(); Executed by:
| 166 | ||||||||||||
926 | } | - | ||||||||||||
927 | - | |||||||||||||
928 | bool QQuickNvprBlitter::create() | - | ||||||||||||
929 | { | - | ||||||||||||
930 | if (isCreated()
| 0 | ||||||||||||
931 | destroy(); never executed: destroy(); | 0 | ||||||||||||
932 | - | |||||||||||||
933 | m_program = new QOpenGLShaderProgram; | - | ||||||||||||
934 | if (QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile
| 0 | ||||||||||||
935 | m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Vertex, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/shapes/shaders/blit_core.vert")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/shapes/shaders/blit_core.vert" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||
936 | m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Fragment, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/shapes/shaders/blit_core.frag")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/shapes/shaders/blit_core.frag" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||
937 | } never executed: else {end of block | 0 | ||||||||||||
938 | m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Vertex, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/shapes/shaders/blit.vert")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/shapes/shaders/blit.vert" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||
939 | m_program->addCacheableShaderFromSourceFile(QOpenGLShader::Fragment, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/shapes/shaders/blit.frag")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/shapes/shaders/blit.frag" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||
940 | } never executed: end of block | 0 | ||||||||||||
941 | m_program->bindAttributeLocation("qt_Vertex", 0); | - | ||||||||||||
942 | m_program->bindAttributeLocation("qt_MultiTexCoord0", 1); | - | ||||||||||||
943 | if (!m_program->link()
| 0 | ||||||||||||
944 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
945 | - | |||||||||||||
946 | m_matrixLoc = m_program->uniformLocation("qt_Matrix"); | - | ||||||||||||
947 | m_opacityLoc = m_program->uniformLocation("qt_Opacity"); | - | ||||||||||||
948 | - | |||||||||||||
949 | m_buffer = new QOpenGLBuffer; | - | ||||||||||||
950 | if (!m_buffer->create()
| 0 | ||||||||||||
951 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
952 | m_buffer->bind(); | - | ||||||||||||
953 | m_buffer->allocate(4 * sizeof(GLfloat) * 6); | - | ||||||||||||
954 | m_buffer->release(); | - | ||||||||||||
955 | - | |||||||||||||
956 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
957 | } | - | ||||||||||||
958 | - | |||||||||||||
959 | void QQuickNvprBlitter::destroy() | - | ||||||||||||
960 | { | - | ||||||||||||
961 | if (m_program
| 0 | ||||||||||||
962 | delete m_program; | - | ||||||||||||
963 | m_program = nullptr; | - | ||||||||||||
964 | } never executed: end of block | 0 | ||||||||||||
965 | if (m_buffer
| 0 | ||||||||||||
966 | delete m_buffer; | - | ||||||||||||
967 | m_buffer = nullptr; | - | ||||||||||||
968 | } never executed: end of block | 0 | ||||||||||||
969 | } never executed: end of block | 0 | ||||||||||||
970 | - | |||||||||||||
971 | void QQuickNvprBlitter::texturedQuad(GLuint textureId, const QSize &size, | - | ||||||||||||
972 | const QMatrix4x4 &proj, const QMatrix4x4 &modelview, | - | ||||||||||||
973 | float opacity) | - | ||||||||||||
974 | { | - | ||||||||||||
975 | QOpenGLExtraFunctions *f = QOpenGLContext::currentContext()->extraFunctions(); | - | ||||||||||||
976 | - | |||||||||||||
977 | m_program->bind(); | - | ||||||||||||
978 | - | |||||||||||||
979 | QMatrix4x4 m = proj * modelview; | - | ||||||||||||
980 | m_program->setUniformValue(m_matrixLoc, m); | - | ||||||||||||
981 | m_program->setUniformValue(m_opacityLoc, opacity); | - | ||||||||||||
982 | - | |||||||||||||
983 | m_buffer->bind(); | - | ||||||||||||
984 | - | |||||||||||||
985 | if (size != m_prevSize
| 0 | ||||||||||||
986 | m_prevSize = size; | - | ||||||||||||
987 | - | |||||||||||||
988 | QPointF p0(size.width() - 1, size.height() - 1); | - | ||||||||||||
989 | QPointF p1(0, 0); | - | ||||||||||||
990 | QPointF p2(0, size.height() - 1); | - | ||||||||||||
991 | QPointF p3(size.width() - 1, 0); | - | ||||||||||||
992 | - | |||||||||||||
993 | GLfloat vertices[6 * 4] = { | - | ||||||||||||
994 | GLfloat(p0.x()), GLfloat(p0.y()), 1, 0, | - | ||||||||||||
995 | GLfloat(p1.x()), GLfloat(p1.y()), 0, 1, | - | ||||||||||||
996 | GLfloat(p2.x()), GLfloat(p2.y()), 0, 0, | - | ||||||||||||
997 | - | |||||||||||||
998 | GLfloat(p0.x()), GLfloat(p0.y()), 1, 0, | - | ||||||||||||
999 | GLfloat(p3.x()), GLfloat(p3.y()), 1, 1, | - | ||||||||||||
1000 | GLfloat(p1.x()), GLfloat(p1.y()), 0, 1, | - | ||||||||||||
1001 | }; | - | ||||||||||||
1002 | - | |||||||||||||
1003 | m_buffer->write(0, vertices, sizeof(vertices)); | - | ||||||||||||
1004 | } never executed: end of block | 0 | ||||||||||||
1005 | - | |||||||||||||
1006 | m_program->enableAttributeArray(0); | - | ||||||||||||
1007 | m_program->enableAttributeArray(1); | - | ||||||||||||
1008 | f->glVertexAttribPointer(0, 2, | - | ||||||||||||
1009 | 0x1406 | - | ||||||||||||
1010 | , | - | ||||||||||||
1011 | 0 | - | ||||||||||||
1012 | , 4 * sizeof(GLfloat), nullptr); | - | ||||||||||||
1013 | f->glVertexAttribPointer(1, 2, | - | ||||||||||||
1014 | 0x1406 | - | ||||||||||||
1015 | , | - | ||||||||||||
1016 | 0 | - | ||||||||||||
1017 | , 4 * sizeof(GLfloat), (const void *) (2 * sizeof(GLfloat))); | - | ||||||||||||
1018 | - | |||||||||||||
1019 | f->glBindTexture( | - | ||||||||||||
1020 | 0x0DE1 | - | ||||||||||||
1021 | , textureId); | - | ||||||||||||
1022 | - | |||||||||||||
1023 | f->glDrawArrays( | - | ||||||||||||
1024 | 0x0004 | - | ||||||||||||
1025 | , 0, 6); | - | ||||||||||||
1026 | - | |||||||||||||
1027 | f->glBindTexture( | - | ||||||||||||
1028 | 0x0DE1 | - | ||||||||||||
1029 | , 0); | - | ||||||||||||
1030 | m_buffer->release(); | - | ||||||||||||
1031 | m_program->release(); | - | ||||||||||||
1032 | } never executed: end of block | 0 | ||||||||||||
1033 | - | |||||||||||||
1034 | - | |||||||||||||
Switch to Source code | Preprocessed file |