OpenCoverage

qquickturbulence.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickturbulence.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2QQuickTurbulenceAffector::QQuickTurbulenceAffector(QQuickItem *parent) :-
3 QQuickParticleAffector(parent),-
4 m_strength(10), m_lastT(0), m_gridSize(0), m_field(nullptr), m_vectorField(nullptr), m_inited(false)-
5{-
6}
executed 8 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickturbulence
8
7-
8void QQuickTurbulenceAffector::geometryChanged(const QRectF &, const QRectF &)-
9{-
10 initializeGrid();-
11}
executed 16 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickturbulence
16
12-
13QQuickTurbulenceAffector::~QQuickTurbulenceAffector()-
14{-
15 if (m_field
m_fieldDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_examples
) {
2-6
16 for (int i=0; i<m_gridSize
i<m_gridSizeDescription
TRUEevaluated 640 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; i++)
2-640
17 free(m_field[i]);
executed 640 times by 1 test: free(m_field[i]);
Executed by:
  • tst_qquickturbulence
640
18 free(m_field);-
19 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickturbulence
2
20 if (m_vectorField
m_vectorFieldDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_examples
) {
2-6
21 for (int i=0; i<m_gridSize
i<m_gridSizeDescription
TRUEevaluated 640 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; i++)
2-640
22 free(m_vectorField[i]);
executed 640 times by 1 test: free(m_vectorField[i]);
Executed by:
  • tst_qquickturbulence
640
23 free(m_vectorField);-
24 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickturbulence
2
25}
executed 8 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickturbulence
8
26-
27void QQuickTurbulenceAffector::initializeGrid()-
28{-
29 if (!m_inited
!m_initedDescription
TRUEevaluated 16 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickturbulence
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
2-16
30 return;
executed 16 times by 2 tests: return;
Executed by:
  • tst_examples
  • tst_qquickturbulence
16
31-
32 int arg = qMax(width(), height());-
33 if (m_gridSize != arg
m_gridSize != argDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEnever evaluated
) {
0-2
34 if (m_field
m_fieldDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
){
0-2
35 for (int i=0; i<m_gridSize
i<m_gridSizeDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
36 free(m_field[i]);
never executed: free(m_field[i]);
0
37 free(m_field);-
38 }
never executed: end of block
0
39 if (m_vectorField
m_vectorFieldDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
) {
0-2
40 for (int i=0; i<m_gridSize
i<m_gridSizeDescription
TRUEnever evaluated
FALSEnever evaluated
; i++)
0
41 free(m_vectorField[i]);
never executed: free(m_vectorField[i]);
0
42 free(m_vectorField);-
43 }
never executed: end of block
0
44 m_gridSize = arg;-
45 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickturbulence
2
46-
47 m_field = (qreal**)malloc(m_gridSize * sizeof(qreal*));-
48 for (int i=0; i<m_gridSize
i<m_gridSizeDescription
TRUEevaluated 640 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; i++)
2-640
49 m_field[i] = (qreal*)malloc(m_gridSize * sizeof(qreal));
executed 640 times by 1 test: m_field[i] = (qreal*)malloc(m_gridSize * sizeof(qreal));
Executed by:
  • tst_qquickturbulence
640
50 m_vectorField = (QPointF**)malloc(m_gridSize * sizeof(QPointF*));-
51 for (int i=0; i<m_gridSize
i<m_gridSizeDescription
TRUEevaluated 640 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; i++)
2-640
52 m_vectorField[i] = (QPointF*)malloc(m_gridSize * sizeof(QPointF));
executed 640 times by 1 test: m_vectorField[i] = (QPointF*)malloc(m_gridSize * sizeof(QPointF));
Executed by:
  • tst_qquickturbulence
640
53-
54 QImage image;-
55 if (!m_noiseSource.isEmpty()
!m_noiseSource.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
0-2
56 image = QImage(QQmlFile::urlToLocalFileOrQrc(m_noiseSource)).scaled(QSize(m_gridSize, m_gridSize));
never executed: image = QImage(QQmlFile::urlToLocalFileOrQrc(m_noiseSource)).scaled(QSize(m_gridSize, m_gridSize));
0
57 if (image.isNull()
image.isNull()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEnever evaluated
)
0-2
58 image = QImage(([]() noexcept -> QString { enum { Size = sizeof(u"" ":particleresources/noise.png")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":particleresources/noise.png" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 2 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qquickturbulence
qstring_literal_temp;
executed 2 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qquickturbulence
}())).scaled(QSize(m_gridSize, m_gridSize));
executed 2 times by 1 test: image = QImage(([]() noexcept -> QString { enum { Size = sizeof(u"" ":particleresources/noise.png")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":particleresources/noise.png" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())).scaled(QSize(m_gridSize, m_gridSize));
Executed by:
  • tst_qquickturbulence
2
59-
60 for (int i=0; i<m_gridSize
i<m_gridSizeDescription
TRUEevaluated 640 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; i++)
2-640
61 for (int j=0; j<m_gridSize
j<m_gridSizeDescription
TRUEevaluated 204800 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 640 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; j++)
640-204800
62 m_field[i][j] = qGray(image.pixel(QPoint(i,j)));
executed 204800 times by 1 test: m_field[i][j] = qGray(image.pixel(QPoint(i,j)));
Executed by:
  • tst_qquickturbulence
204800
63 for (int i=0; i<m_gridSize
i<m_gridSizeDescription
TRUEevaluated 640 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; i++){
2-640
64 for (int j=0; j<m_gridSize
j<m_gridSizeDescription
TRUEevaluated 204800 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 640 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; j++){
640-204800
65 m_vectorField[i][j].setX(boundsRespectingField(i-1,j) - boundsRespectingField(i,j));-
66 m_vectorField[i][j].setY(boundsRespectingField(i,j) - boundsRespectingField(i,j-1));-
67 }
executed 204800 times by 1 test: end of block
Executed by:
  • tst_qquickturbulence
204800
68 }
executed 640 times by 1 test: end of block
Executed by:
  • tst_qquickturbulence
640
69}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickturbulence
2
70-
71qreal QQuickTurbulenceAffector::boundsRespectingField(int x, int y)-
72{-
73 if (x < 0
x < 0Description
TRUEevaluated 640 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 818560 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
640-818560
74 x = 0;
executed 640 times by 1 test: x = 0;
Executed by:
  • tst_qquickturbulence
640
75 if (x >= m_gridSize
x >= m_gridSizeDescription
TRUEnever evaluated
FALSEevaluated 819200 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
0-819200
76 x = m_gridSize - 1;
never executed: x = m_gridSize - 1;
0
77 if (y < 0
y < 0Description
TRUEevaluated 640 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 818560 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
640-818560
78 y = 0;
executed 640 times by 1 test: y = 0;
Executed by:
  • tst_qquickturbulence
640
79 if (y >= m_gridSize
y >= m_gridSizeDescription
TRUEnever evaluated
FALSEevaluated 819200 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
0-819200
80 y = m_gridSize - 1;
never executed: y = m_gridSize - 1;
0
81 return
executed 819200 times by 1 test: return m_field[x][y];
Executed by:
  • tst_qquickturbulence
m_field[x][y];
executed 819200 times by 1 test: return m_field[x][y];
Executed by:
  • tst_qquickturbulence
819200
82}-
83-
84void QQuickTurbulenceAffector::ensureInit()-
85{-
86 if (m_inited
m_initedDescription
TRUEevaluated 78 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
2-78
87 return;
executed 78 times by 1 test: return;
Executed by:
  • tst_qquickturbulence
78
88 m_inited = true;-
89 initializeGrid();-
90}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickturbulence
2
91-
92void QQuickTurbulenceAffector::affectSystem(qreal dt)-
93{-
94 if (!m_system
!m_systemDescription
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickturbulence
|| !m_enabled
!m_enabledDescription
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
0-80
95 return;
never executed: return;
0
96 ensureInit();-
97 if (!m_gridSize
!m_gridSizeDescription
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
0-80
98 return;
never executed: return;
0
99-
100 updateOffsets();-
101-
102 QRect boundsRect(0,0,m_gridSize,m_gridSize);-
103 for (auto _container_ = QtPrivate::qMakeForeachContainer(m_system->groupData); _container_.control
_container_.controlDescription
TRUEevaluated 160 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEnever evaluated
&& _container_.i != _container_.e
_container_.i != _container_.eDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; ++_container_.i, _container_.control ^= 1) for (QQuickParticleGroupData *gd = *_container_.i; _container_.control
_container_.controlDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; _container_.control = 0){
0-160
104 if (!activeGroup(gd->index)
!activeGroup(gd->index)Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
0-80
105 continue;
never executed: continue;
0
106 for (auto _container_ = QtPrivate::qMakeForeachContainer(gd->data); _container_.control
_container_.controlDescription
TRUEevaluated 40080 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEnever evaluated
&& _container_.i != _container_.e
_container_.i != _container_.eDescription
TRUEevaluated 40000 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; ++_container_.i, _container_.control ^= 1) for (QQuickParticleData *d = *_container_.i; _container_.control
_container_.controlDescription
TRUEevaluated 40000 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 40000 times by 1 test
Evaluated by:
  • tst_qquickturbulence
; _container_.control = 0){
0-40080
107 if (!shouldAffect(d)
!shouldAffect(d)Description
TRUEevaluated 16156 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEevaluated 23844 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
16156-23844
108 continue;
executed 16156 times by 1 test: continue;
Executed by:
  • tst_qquickturbulence
16156
109 QPoint pos = (QPointF(d->curX(m_system), d->curY(m_system)) - m_offset).toPoint();-
110 if (!boundsRect.contains(pos,true)
!boundsRect.contains(pos,true)Description
TRUEnever evaluated
FALSEevaluated 23844 times by 1 test
Evaluated by:
  • tst_qquickturbulence
)
0-23844
111 continue;
never executed: continue;
0
112 qreal fx = 0.0;-
113 qreal fy = 0.0;-
114 fx += m_vectorField[pos.x()][pos.y()].x() * m_strength;-
115 fy += m_vectorField[pos.x()][pos.y()].y() * m_strength;-
116 if (fx || fy){-
117 d->setInstantaneousVX(d->curVX(m_system)+ fx * dt, m_system);-
118 d->setInstantaneousVY(d->curVY(m_system)+ fy * dt, m_system);-
119 postAffect(d);-
120 }
executed 20708 times by 1 test: end of block
Executed by:
  • tst_qquickturbulence
20708
121 }
executed 23844 times by 1 test: end of block
Executed by:
  • tst_qquickturbulence
23844
122 }
executed 80 times by 1 test: end of block
Executed by:
  • tst_qquickturbulence
80
123}
executed 80 times by 1 test: end of block
Executed by:
  • tst_qquickturbulence
80
124-
125-
126-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0