Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickmaskextruder.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | QQuickMaskExtruder::QQuickMaskExtruder(QObject *parent) : | - | ||||||||||||
3 | QQuickParticleExtruder(parent) | - | ||||||||||||
4 | , m_lastWidth(-1) | - | ||||||||||||
5 | , m_lastHeight(-1) | - | ||||||||||||
6 | { | - | ||||||||||||
7 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
8 | - | |||||||||||||
9 | void QQuickMaskExtruder::setSource(QUrl arg) | - | ||||||||||||
10 | { | - | ||||||||||||
11 | if (m_source != arg
| 0-14 | ||||||||||||
12 | m_source = arg; | - | ||||||||||||
13 | - | |||||||||||||
14 | m_lastHeight = -1; | - | ||||||||||||
15 | m_lastWidth = -1; | - | ||||||||||||
16 | sourceChanged(arg); | - | ||||||||||||
17 | startMaskLoading(); | - | ||||||||||||
18 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
19 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
20 | - | |||||||||||||
21 | void QQuickMaskExtruder::startMaskLoading() | - | ||||||||||||
22 | { | - | ||||||||||||
23 | m_pix.clear(this); | - | ||||||||||||
24 | if (m_source.isEmpty()
| 0-14 | ||||||||||||
25 | return; never executed: return; | 0 | ||||||||||||
26 | m_pix.load(qmlEngine(this), m_source); | - | ||||||||||||
27 | if (m_pix.isLoading()
| 0-14 | ||||||||||||
28 | m_pix.connectFinished(this, qFlagLocation("1""finishMaskLoading()" "\0" __FILE__ ":" "90")); never executed: m_pix.connectFinished(this, qFlagLocation("1""finishMaskLoading()" "\0" __FILE__ ":" "90")); | 0 | ||||||||||||
29 | else | - | ||||||||||||
30 | finishMaskLoading(); executed 14 times by 2 tests: finishMaskLoading(); Executed by:
| 14 | ||||||||||||
31 | } | - | ||||||||||||
32 | - | |||||||||||||
33 | void QQuickMaskExtruder::finishMaskLoading() | - | ||||||||||||
34 | { | - | ||||||||||||
35 | if (m_pix.isError()
| 0-14 | ||||||||||||
36 | qmlWarning(this) << m_pix.error(); never executed: qmlWarning(this) << m_pix.error(); | 0 | ||||||||||||
37 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
38 | - | |||||||||||||
39 | QPointF QQuickMaskExtruder::extrude(const QRectF &r) | - | ||||||||||||
40 | { | - | ||||||||||||
41 | ensureInitialized(r); | - | ||||||||||||
42 | if (!m_mask.count()
| 0-1216 | ||||||||||||
43 | return never executed: r.topLeft();return r.topLeft(); never executed: return r.topLeft(); | 0 | ||||||||||||
44 | const QPointF p = m_mask[QRandomGenerator::global()->bounded(m_mask.count())]; | - | ||||||||||||
45 | - | |||||||||||||
46 | return executed 1216 times by 1 test: p + r.topLeft();return p + r.topLeft(); Executed by:
executed 1216 times by 1 test: return p + r.topLeft(); Executed by:
| 1216 | ||||||||||||
47 | } | - | ||||||||||||
48 | - | |||||||||||||
49 | bool QQuickMaskExtruder::contains(const QRectF &bounds, const QPointF &point) | - | ||||||||||||
50 | { | - | ||||||||||||
51 | ensureInitialized(bounds); | - | ||||||||||||
52 | if (m_img.isNull()
| 0 | ||||||||||||
53 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
54 | - | |||||||||||||
55 | QPointF pt = point - bounds.topLeft(); | - | ||||||||||||
56 | QPoint p(pt.x() * m_img.width() / bounds.width(), | - | ||||||||||||
57 | pt.y() * m_img.height() / bounds.height()); | - | ||||||||||||
58 | return never executed: m_img.rect().contains(p) && (m_img.pixel(p) & 0xff000000);return m_img.rect().contains(p) && (m_img.pixel(p) & 0xff000000); never executed: return m_img.rect().contains(p) && (m_img.pixel(p) & 0xff000000); | 0 | ||||||||||||
59 | } | - | ||||||||||||
60 | - | |||||||||||||
61 | void QQuickMaskExtruder::ensureInitialized(const QRectF &rf) | - | ||||||||||||
62 | { | - | ||||||||||||
63 | - | |||||||||||||
64 | - | |||||||||||||
65 | QRect r = rf.toRect(); | - | ||||||||||||
66 | if (m_lastWidth == r.width()
| 0-1214 | ||||||||||||
67 | return; executed 1214 times by 1 test: return; Executed by:
| 1214 | ||||||||||||
68 | if (!m_pix.isReady()
| 0-2 | ||||||||||||
69 | return; never executed: return; | 0 | ||||||||||||
70 | m_lastWidth = r.width(); | - | ||||||||||||
71 | m_lastHeight = r.height(); | - | ||||||||||||
72 | - | |||||||||||||
73 | m_mask.clear(); | - | ||||||||||||
74 | - | |||||||||||||
75 | m_img = m_pix.image(); | - | ||||||||||||
76 | - | |||||||||||||
77 | - | |||||||||||||
78 | if (m_img.format() != QImage::Format_ARGB32
| 0-2 | ||||||||||||
79 | m_img = m_img.convertToFormat(QImage::Format_ARGB32_Premultiplied); never executed: m_img = m_img.convertToFormat(QImage::Format_ARGB32_Premultiplied); | 0 | ||||||||||||
80 | - | |||||||||||||
81 | - | |||||||||||||
82 | int sx = (m_img.width() << 16) / r.width(); | - | ||||||||||||
83 | int sy = (m_img.height() << 16) / r.height(); | - | ||||||||||||
84 | int w = r.width(); | - | ||||||||||||
85 | int h = r.height(); | - | ||||||||||||
86 | for (int y=0; y<h
| 2-640 | ||||||||||||
87 | const uint *sl = (const uint *) m_img.constScanLine((y * sy) >> 16); | - | ||||||||||||
88 | for (int x=0; x<w
| 640-204800 | ||||||||||||
89 | if (sl[(x * sx) >> 16] & 0xff000000
| 20402-184398 | ||||||||||||
90 | m_mask << QPointF(x, y); executed 20402 times by 1 test: m_mask << QPointF(x, y); Executed by:
| 20402 | ||||||||||||
91 | } executed 204800 times by 1 test: end of block Executed by:
| 204800 | ||||||||||||
92 | } executed 640 times by 1 test: end of block Executed by:
| 640 | ||||||||||||
93 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
94 | - | |||||||||||||
95 | - | |||||||||||||
Switch to Source code | Preprocessed file |