opengl/qopengl2pexvertexarray.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui 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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qopengl2pexvertexarray_p.h" -
43 -
44#include <private/qbezier_p.h> -
45 -
46QT_BEGIN_NAMESPACE -
47 -
48void QOpenGL2PEXVertexArray::clear() -
49{ -
50 vertexArray.reset();
never executed (the execution status of this line is deduced): vertexArray.reset();
-
51 vertexArrayStops.reset();
never executed (the execution status of this line is deduced): vertexArrayStops.reset();
-
52 boundingRectDirty = true;
never executed (the execution status of this line is deduced): boundingRectDirty = true;
-
53}
never executed: }
0
54 -
55 -
56QOpenGLRect QOpenGL2PEXVertexArray::boundingRect() const -
57{ -
58 if (boundingRectDirty)
never evaluated: boundingRectDirty
0
59 return QOpenGLRect(0.0, 0.0, 0.0, 0.0);
never executed: return QOpenGLRect(0.0, 0.0, 0.0, 0.0);
0
60 else -
61 return QOpenGLRect(minX, minY, maxX, maxY);
never executed: return QOpenGLRect(minX, minY, maxX, maxY);
0
62} -
63 -
64void QOpenGL2PEXVertexArray::addClosingLine(int index) -
65{ -
66 QPointF point(vertexArray.at(index));
never executed (the execution status of this line is deduced): QPointF point(vertexArray.at(index));
-
67 if (point != QPointF(vertexArray.last()))
never evaluated: point != QPointF(vertexArray.last())
0
68 vertexArray.add(point);
never executed: vertexArray.add(point);
0
69}
never executed: }
0
70 -
71void QOpenGL2PEXVertexArray::addCentroid(const QVectorPath &path, int subPathIndex) -
72{ -
73 const QPointF *const points = reinterpret_cast<const QPointF *>(path.points());
never executed (the execution status of this line is deduced): const QPointF *const points = reinterpret_cast<const QPointF *>(path.points());
-
74 const QPainterPath::ElementType *const elements = path.elements();
never executed (the execution status of this line is deduced): const QPainterPath::ElementType *const elements = path.elements();
-
75 -
76 QPointF sum = points[subPathIndex];
never executed (the execution status of this line is deduced): QPointF sum = points[subPathIndex];
-
77 int count = 1;
never executed (the execution status of this line is deduced): int count = 1;
-
78 -
79 for (int i = subPathIndex + 1; i < path.elementCount() && (!elements || elements[i] != QPainterPath::MoveToElement); ++i) {
never evaluated: i < path.elementCount()
never evaluated: !elements
never evaluated: elements[i] != QPainterPath::MoveToElement
0
80 sum += points[i];
never executed (the execution status of this line is deduced): sum += points[i];
-
81 ++count;
never executed (the execution status of this line is deduced): ++count;
-
82 }
never executed: }
0
83 -
84 const QPointF centroid = sum / qreal(count);
never executed (the execution status of this line is deduced): const QPointF centroid = sum / qreal(count);
-
85 vertexArray.add(centroid);
never executed (the execution status of this line is deduced): vertexArray.add(centroid);
-
86}
never executed: }
0
87 -
88void QOpenGL2PEXVertexArray::addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline) -
89{ -
90 const QPointF* const points = reinterpret_cast<const QPointF*>(path.points());
never executed (the execution status of this line is deduced): const QPointF* const points = reinterpret_cast<const QPointF*>(path.points());
-
91 const QPainterPath::ElementType* const elements = path.elements();
never executed (the execution status of this line is deduced): const QPainterPath::ElementType* const elements = path.elements();
-
92 -
93 if (boundingRectDirty) {
never evaluated: boundingRectDirty
0
94 minX = maxX = points[0].x();
never executed (the execution status of this line is deduced): minX = maxX = points[0].x();
-
95 minY = maxY = points[0].y();
never executed (the execution status of this line is deduced): minY = maxY = points[0].y();
-
96 boundingRectDirty = false;
never executed (the execution status of this line is deduced): boundingRectDirty = false;
-
97 }
never executed: }
0
98 -
99 if (!outline && !path.isConvex())
never evaluated: !outline
never evaluated: !path.isConvex()
0
100 addCentroid(path, 0);
never executed: addCentroid(path, 0);
0
101 -
102 int lastMoveTo = vertexArray.size();
never executed (the execution status of this line is deduced): int lastMoveTo = vertexArray.size();
-
103 vertexArray.add(points[0]); // The first element is always a moveTo
never executed (the execution status of this line is deduced): vertexArray.add(points[0]);
-
104 -
105 do { -
106 if (!elements) {
never evaluated: !elements
0
107// qDebug("QVectorPath has no elements"); -
108 // If the path has a null elements pointer, the elements implicitly -
109 // start with a moveTo (already added) and continue with lineTos: -
110 for (int i=1; i<path.elementCount(); ++i)
never evaluated: i<path.elementCount()
0
111 lineToArray(points[i].x(), points[i].y());
never executed: lineToArray(points[i].x(), points[i].y());
0
112 -
113 break;
never executed: break;
0
114 } -
115// qDebug("QVectorPath has element types"); -
116 -
117 for (int i=1; i<path.elementCount(); ++i) {
never evaluated: i<path.elementCount()
0
118 switch (elements[i]) { -
119 case QPainterPath::MoveToElement: -
120 if (!outline)
never evaluated: !outline
0
121 addClosingLine(lastMoveTo);
never executed: addClosingLine(lastMoveTo);
0
122// qDebug("element[%d] is a MoveToElement", i); -
123 vertexArrayStops.add(vertexArray.size());
never executed (the execution status of this line is deduced): vertexArrayStops.add(vertexArray.size());
-
124 if (!outline) {
never evaluated: !outline
0
125 if (!path.isConvex()) addCentroid(path, i);
never executed: addCentroid(path, i);
never evaluated: !path.isConvex()
0
126 lastMoveTo = vertexArray.size();
never executed (the execution status of this line is deduced): lastMoveTo = vertexArray.size();
-
127 }
never executed: }
0
128 lineToArray(points[i].x(), points[i].y()); // Add the moveTo as a new vertex
never executed (the execution status of this line is deduced): lineToArray(points[i].x(), points[i].y());
-
129 break;
never executed: break;
0
130 case QPainterPath::LineToElement: -
131// qDebug("element[%d] is a LineToElement", i); -
132 lineToArray(points[i].x(), points[i].y());
never executed (the execution status of this line is deduced): lineToArray(points[i].x(), points[i].y());
-
133 break;
never executed: break;
0
134 case QPainterPath::CurveToElement: { -
135 QBezier b = QBezier::fromPoints(*(((const QPointF *) points) + i - 1),
never executed (the execution status of this line is deduced): QBezier b = QBezier::fromPoints(*(((const QPointF *) points) + i - 1),
-
136 points[i],
never executed (the execution status of this line is deduced): points[i],
-
137 points[i+1],
never executed (the execution status of this line is deduced): points[i+1],
-
138 points[i+2]);
never executed (the execution status of this line is deduced): points[i+2]);
-
139 QRectF bounds = b.bounds();
never executed (the execution status of this line is deduced): QRectF bounds = b.bounds();
-
140 // threshold based on same algorithm as in qtriangulatingstroker.cpp -
141 int threshold = qMin<float>(64, qMax(bounds.width(), bounds.height()) * 3.14f / (curveInverseScale * 6));
never executed (the execution status of this line is deduced): int threshold = qMin<float>(64, qMax(bounds.width(), bounds.height()) * 3.14f / (curveInverseScale * 6));
-
142 if (threshold < 3) threshold = 3;
never executed: threshold = 3;
never evaluated: threshold < 3
0
143 qreal one_over_threshold_minus_1 = qreal(1) / (threshold - 1);
never executed (the execution status of this line is deduced): qreal one_over_threshold_minus_1 = qreal(1) / (threshold - 1);
-
144 for (int t=0; t<threshold; ++t) {
never evaluated: t<threshold
0
145 QPointF pt = b.pointAt(t * one_over_threshold_minus_1);
never executed (the execution status of this line is deduced): QPointF pt = b.pointAt(t * one_over_threshold_minus_1);
-
146 lineToArray(pt.x(), pt.y());
never executed (the execution status of this line is deduced): lineToArray(pt.x(), pt.y());
-
147 }
never executed: }
0
148 i += 2;
never executed (the execution status of this line is deduced): i += 2;
-
149 break; }
never executed: break;
0
150 default: -
151 break;
never executed: break;
0
152 } -
153 }
never executed: }
0
154 } while (0);
never executed: }
never evaluated: 0
0
155 -
156 if (!outline)
never evaluated: !outline
0
157 addClosingLine(lastMoveTo);
never executed: addClosingLine(lastMoveTo);
0
158 vertexArrayStops.add(vertexArray.size());
never executed (the execution status of this line is deduced): vertexArrayStops.add(vertexArray.size());
-
159}
never executed: }
0
160 -
161void QOpenGL2PEXVertexArray::lineToArray(const GLfloat x, const GLfloat y) -
162{ -
163 vertexArray.add(QOpenGLPoint(x, y));
never executed (the execution status of this line is deduced): vertexArray.add(QOpenGLPoint(x, y));
-
164 -
165 if (x > maxX)
never evaluated: x > maxX
0
166 maxX = x;
never executed: maxX = x;
0
167 else if (x < minX)
never evaluated: x < minX
0
168 minX = x;
never executed: minX = x;
0
169 if (y > maxY)
never evaluated: y > maxY
0
170 maxY = y;
never executed: maxY = y;
0
171 else if (y < minY)
never evaluated: y < minY
0
172 minY = y;
never executed: minY = y;
0
173} -
174 -
175QT_END_NAMESPACE -
176 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial