OpenCoverage

qgl2pexvertexarray.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtOpenGL module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qgl2pexvertexarray_p.h"-
41-
42#include <private/qbezier_p.h>-
43-
44QT_BEGIN_NAMESPACE-
45-
46void QGL2PEXVertexArray::clear()-
47{-
48 vertexArray.reset();-
49 vertexArrayStops.reset();-
50 boundingRectDirty = true;-
51}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
52-
53-
54QGLRect QGL2PEXVertexArray::boundingRect() const-
55{-
56 if (boundingRectDirty)
boundingRectDirtyDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-6
57 return QGLRect(0.0, 0.0, 0.0, 0.0);
never executed: return QGLRect(0.0, 0.0, 0.0, 0.0);
0
58 else-
59 return QGLRect(minX, minY, maxX, maxY);
executed 6 times by 1 test: return QGLRect(minX, minY, maxX, maxY);
Executed by:
  • tst_qmdiarea - unknown status
6
60}-
61-
62void QGL2PEXVertexArray::addClosingLine(int index)-
63{-
64 QPointF point(vertexArray.at(index));-
65 if (point != QPointF(vertexArray.last()))
point != QPoin...xArray.last())Description
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-42
66 vertexArray.add(point);
never executed: vertexArray.add(point);
0
67}
executed 42 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
42
68-
69void QGL2PEXVertexArray::addCentroid(const QVectorPath &path, int subPathIndex)-
70{-
71 const QPointF *const points = reinterpret_cast<const QPointF *>(path.points());-
72 const QPainterPath::ElementType *const elements = path.elements();-
73-
74 QPointF sum = points[subPathIndex];-
75 int count = 1;-
76-
77 for (int i = subPathIndex + 1; i < path.elementCount() && (!elements || elements[i] != QPainterPath::MoveToElement); ++i) {
i < path.elementCount()Description
TRUEevaluated 207 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
!elementsDescription
TRUEnever evaluated
FALSEevaluated 207 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
elements[i] !=...:MoveToElementDescription
TRUEevaluated 168 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 39 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-207
78 sum += points[i];-
79 ++count;-
80 }
executed 168 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
168
81-
82 const QPointF centroid = sum / qreal(count);-
83 vertexArray.add(centroid);-
84}
executed 42 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
42
85-
86void QGL2PEXVertexArray::addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline)-
87{-
88 const QPointF* const points = reinterpret_cast<const QPointF*>(path.points());-
89 const QPainterPath::ElementType* const elements = path.elements();-
90-
91 if (boundingRectDirty) {
boundingRectDirtyDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
92 minX = maxX = points[0].x();-
93 minY = maxY = points[0].y();-
94 boundingRectDirty = false;-
95 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
96-
97 if (!outline && !path.isConvex())
!outlineDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
!path.isConvex()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
98 addCentroid(path, 0);
executed 3 times by 1 test: addCentroid(path, 0);
Executed by:
  • tst_qmdiarea - unknown status
3
99-
100 int lastMoveTo = vertexArray.size();-
101 vertexArray.add(points[0]); // The first element is always a moveTo-
102-
103 do {-
104 if (!elements) {
!elementsDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
105// qDebug("QVectorPath has no elements");-
106 // If the path has a null elements pointer, the elements implicitly-
107 // start with a moveTo (already added) and continue with lineTos:-
108 for (int i=1; i<path.elementCount(); ++i)
i<path.elementCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
109 lineToArray(points[i].x(), points[i].y());
never executed: lineToArray(points[i].x(), points[i].y());
0
110-
111 break;
never executed: break;
0
112 }-
113// qDebug("QVectorPath has element types");-
114-
115 for (int i=1; i<path.elementCount(); ++i) {
i<path.elementCount()Description
TRUEevaluated 207 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
3-207
116 switch (elements[i]) {-
117 case QPainterPath::MoveToElement:
executed 39 times by 1 test: case QPainterPath::MoveToElement:
Executed by:
  • tst_qmdiarea - unknown status
39
118 if (!outline)
!outlineDescription
TRUEevaluated 39 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-39
119 addClosingLine(lastMoveTo);
executed 39 times by 1 test: addClosingLine(lastMoveTo);
Executed by:
  • tst_qmdiarea - unknown status
39
120// qDebug("element[%d] is a MoveToElement", i);-
121 vertexArrayStops.add(vertexArray.size());-
122 if (!outline) {
!outlineDescription
TRUEevaluated 39 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-39
123 if (!path.isConvex()) addCentroid(path, i);
executed 39 times by 1 test: addCentroid(path, i);
Executed by:
  • tst_qmdiarea - unknown status
!path.isConvex()Description
TRUEevaluated 39 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-39
124 lastMoveTo = vertexArray.size();-
125 }
executed 39 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
39
126 lineToArray(points[i].x(), points[i].y()); // Add the moveTo as a new vertex-
127 break;
executed 39 times by 1 test: break;
Executed by:
  • tst_qmdiarea - unknown status
39
128 case QPainterPath::LineToElement:
executed 168 times by 1 test: case QPainterPath::LineToElement:
Executed by:
  • tst_qmdiarea - unknown status
168
129// qDebug("element[%d] is a LineToElement", i);-
130 lineToArray(points[i].x(), points[i].y());-
131 break;
executed 168 times by 1 test: break;
Executed by:
  • tst_qmdiarea - unknown status
168
132 case QPainterPath::CurveToElement: {
never executed: case QPainterPath::CurveToElement:
0
133 QBezier b = QBezier::fromPoints(*(((const QPointF *) points) + i - 1),-
134 points[i],-
135 points[i+1],-
136 points[i+2]);-
137 QRectF bounds = b.bounds();-
138 // threshold based on same algorithm as in qtriangulatingstroker.cpp-
139 int threshold = qMin<float>(64, qMax(bounds.width(), bounds.height()) * 3.14f / (curveInverseScale * 6));-
140 if (threshold < 3) threshold = 3;
never executed: threshold = 3;
threshold < 3Description
TRUEnever evaluated
FALSEnever evaluated
0
141 qreal one_over_threshold_minus_1 = qreal(1) / (threshold - 1);-
142 for (int t=0; t<threshold; ++t) {
t<thresholdDescription
TRUEnever evaluated
FALSEnever evaluated
0
143 QPointF pt = b.pointAt(t * one_over_threshold_minus_1);-
144 lineToArray(pt.x(), pt.y());-
145 }
never executed: end of block
0
146 i += 2;-
147 break; }
never executed: break;
0
148 default:
never executed: default:
0
149 break;
never executed: break;
0
150 }-
151 }-
152 } while (0);-
153-
154 if (!outline)
!outlineDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
155 addClosingLine(lastMoveTo);
executed 3 times by 1 test: addClosingLine(lastMoveTo);
Executed by:
  • tst_qmdiarea - unknown status
3
156 vertexArrayStops.add(vertexArray.size());-
157}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
158-
159void QGL2PEXVertexArray::lineToArray(const GLfloat x, const GLfloat y)-
160{-
161 vertexArray.add(QGLPoint(x, y));-
162-
163 if (x > maxX)
x > maxXDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 192 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
15-192
164 maxX = x;
executed 15 times by 1 test: maxX = x;
Executed by:
  • tst_qmdiarea - unknown status
15
165 else if (x < minX)
x < minXDescription
TRUEnever evaluated
FALSEevaluated 192 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-192
166 minX = x;
never executed: minX = x;
0
167 if (y > maxY)
y > maxYDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 189 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
18-189
168 maxY = y;
executed 18 times by 1 test: maxY = y;
Executed by:
  • tst_qmdiarea - unknown status
18
169 else if (y < minY)
y < minYDescription
TRUEnever evaluated
FALSEevaluated 189 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-189
170 minY = y;
never executed: minY = y;
0
171}
executed 207 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
207
172-
173QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9