qopengl2pexvertexarray.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopengl2pexvertexarray.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 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 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 "qopengl2pexvertexarray_p.h"-
41-
42#include <private/qbezier_p.h>-
43-
44QT_BEGIN_NAMESPACE-
45-
46void QOpenGL2PEXVertexArray::clear()-
47{-
48 vertexArray.reset();-
49 vertexArrayStops.reset();-
50 boundingRectDirty = true;-
51}
never executed: end of block
0
52-
53-
54QOpenGLRect QOpenGL2PEXVertexArray::boundingRect() const-
55{-
56 if (boundingRectDirty)
boundingRectDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0
57 return QOpenGLRect(0.0, 0.0, 0.0, 0.0);
never executed: return QOpenGLRect(0.0, 0.0, 0.0, 0.0);
0
58 else-
59 return QOpenGLRect(minX, minY, maxX, maxY);
never executed: return QOpenGLRect(minX, minY, maxX, maxY);
0
60}-
61-
62void QOpenGL2PEXVertexArray::addClosingLine(int index)-
63{-
64 QPointF point(vertexArray.at(index));-
65 if (point != QPointF(vertexArray.last()))
point != QPoin...xArray.last())Description
TRUEnever evaluated
FALSEnever evaluated
0
66 vertexArray.add(point);
never executed: vertexArray.add(point);
0
67}
never executed: end of block
0
68-
69void QOpenGL2PEXVertexArray::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
TRUEnever evaluated
FALSEnever evaluated
!elementsDescription
TRUEnever evaluated
FALSEnever evaluated
elements[i] !=...:MoveToElementDescription
TRUEnever evaluated
FALSEnever evaluated
0
78 sum += points[i];-
79 ++count;-
80 }
never executed: end of block
0
81-
82 const QPointF centroid = sum / qreal(count);-
83 vertexArray.add(centroid);-
84}
never executed: end of block
0
85-
86void QOpenGL2PEXVertexArray::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
TRUEnever evaluated
FALSEnever evaluated
0
92 minX = maxX = points[0].x();-
93 minY = maxY = points[0].y();-
94 boundingRectDirty = false;-
95 }
never executed: end of block
0
96-
97 if (!outline && !path.isConvex())
!outlineDescription
TRUEnever evaluated
FALSEnever evaluated
!path.isConvex()Description
TRUEnever evaluated
FALSEnever evaluated
0
98 addCentroid(path, 0);
never executed: addCentroid(path, 0);
0
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
FALSEnever evaluated
0
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
TRUEnever evaluated
FALSEnever evaluated
0
116 switch (elements[i]) {-
117 case QPainterPath::MoveToElement:
never executed: case QPainterPath::MoveToElement:
0
118 if (!outline)
!outlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
119 addClosingLine(lastMoveTo);
never executed: addClosingLine(lastMoveTo);
0
120// qDebug("element[%d] is a MoveToElement", i);-
121 vertexArrayStops.add(vertexArray.size());-
122 if (!outline) {
!outlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
123 if (!path.isConvex()) addCentroid(path, i);
never executed: addCentroid(path, i);
!path.isConvex()Description
TRUEnever evaluated
FALSEnever evaluated
0
124 lastMoveTo = vertexArray.size();-
125 }
never executed: end of block
0
126 lineToArray(points[i].x(), points[i].y()); // Add the moveTo as a new vertex-
127 break;
never executed: break;
0
128 case QPainterPath::LineToElement:
never executed: case QPainterPath::LineToElement:
0
129// qDebug("element[%d] is a LineToElement", i);-
130 lineToArray(points[i].x(), points[i].y());-
131 break;
never executed: break;
0
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
TRUEnever evaluated
FALSEnever evaluated
0
155 addClosingLine(lastMoveTo);
never executed: addClosingLine(lastMoveTo);
0
156 vertexArrayStops.add(vertexArray.size());-
157}
never executed: end of block
0
158-
159void QOpenGL2PEXVertexArray::lineToArray(const GLfloat x, const GLfloat y)-
160{-
161 vertexArray.add(QOpenGLPoint(x, y));-
162-
163 if (x > maxX)
x > maxXDescription
TRUEnever evaluated
FALSEnever evaluated
0
164 maxX = x;
never executed: maxX = x;
0
165 else if (x < minX)
x < minXDescription
TRUEnever evaluated
FALSEnever evaluated
0
166 minX = x;
never executed: minX = x;
0
167 if (y > maxY)
y > maxYDescription
TRUEnever evaluated
FALSEnever evaluated
0
168 maxY = y;
never executed: maxY = y;
0
169 else if (y < minY)
y < minYDescription
TRUEnever evaluated
FALSEnever evaluated
0
170 minY = y;
never executed: minY = y;
0
171}
never executed: end of block
0
172-
173QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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