OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 typedef PODIntervalTree<float, FloatPolygonEdge*> EdgeIntervalTree; | 79 typedef PODIntervalTree<float, FloatPolygonEdge*> EdgeIntervalTree; |
80 | 80 |
81 bool containsNonZero(const FloatPoint&) const; | 81 bool containsNonZero(const FloatPoint&) const; |
82 bool containsEvenOdd(const FloatPoint&) const; | 82 bool containsEvenOdd(const FloatPoint&) const; |
83 | 83 |
84 std::unique_ptr<Vector<FloatPoint>> m_vertices; | 84 std::unique_ptr<Vector<FloatPoint>> m_vertices; |
85 WindRule m_fillRule; | 85 WindRule m_fillRule; |
86 FloatRect m_boundingBox; | 86 FloatRect m_boundingBox; |
87 bool m_empty; | 87 bool m_empty; |
88 Vector<FloatPolygonEdge> m_edges; | 88 Vector<FloatPolygonEdge> m_edges; |
89 EdgeIntervalTree | 89 EdgeIntervalTree m_edgeTree; // Each EdgeIntervalTree node stores minY, maxY, |
90 m_edgeTree; // Each EdgeIntervalTree node stores minY, maxY, and a ("User
Data") pointer to a FloatPolygonEdge. | 90 // and a ("UserData") pointer to a |
| 91 // FloatPolygonEdge. |
91 }; | 92 }; |
92 | 93 |
93 class PLATFORM_EXPORT VertexPair { | 94 class PLATFORM_EXPORT VertexPair { |
94 public: | 95 public: |
95 virtual ~VertexPair() {} | 96 virtual ~VertexPair() {} |
96 | 97 |
97 virtual const FloatPoint& vertex1() const = 0; | 98 virtual const FloatPoint& vertex1() const = 0; |
98 virtual const FloatPoint& vertex2() const = 0; | 99 virtual const FloatPoint& vertex2() const = 0; |
99 | 100 |
100 float minX() const { return std::min(vertex1().x(), vertex2().x()); } | 101 float minX() const { return std::min(vertex1().x(), vertex2().x()); } |
(...skipping 29 matching lines...) Expand all Loading... |
130 ASSERT(m_polygon && m_polygon->numberOfEdges() > 1); | 131 ASSERT(m_polygon && m_polygon->numberOfEdges() > 1); |
131 return m_polygon->edgeAt((m_edgeIndex + 1) % m_polygon->numberOfEdges()); | 132 return m_polygon->edgeAt((m_edgeIndex + 1) % m_polygon->numberOfEdges()); |
132 } | 133 } |
133 | 134 |
134 const FloatPolygon* polygon() const { return m_polygon; } | 135 const FloatPolygon* polygon() const { return m_polygon; } |
135 unsigned vertexIndex1() const { return m_vertexIndex1; } | 136 unsigned vertexIndex1() const { return m_vertexIndex1; } |
136 unsigned vertexIndex2() const { return m_vertexIndex2; } | 137 unsigned vertexIndex2() const { return m_vertexIndex2; } |
137 unsigned edgeIndex() const { return m_edgeIndex; } | 138 unsigned edgeIndex() const { return m_edgeIndex; } |
138 | 139 |
139 private: | 140 private: |
140 // Edge vertex index1 is less than index2, except the last edge, where index2
is 0. When a polygon edge | 141 // Edge vertex index1 is less than index2, except the last edge, where index2 |
141 // is defined by 3 or more colinear vertices, index2 can be the the index of t
he last colinear vertex. | 142 // is 0. When a polygon edge is defined by 3 or more colinear vertices, index2 |
| 143 // can be the the index of the last colinear vertex. |
142 unsigned m_vertexIndex1; | 144 unsigned m_vertexIndex1; |
143 unsigned m_vertexIndex2; | 145 unsigned m_vertexIndex2; |
144 unsigned m_edgeIndex; | 146 unsigned m_edgeIndex; |
145 const FloatPolygon* m_polygon; | 147 const FloatPolygon* m_polygon; |
146 }; | 148 }; |
147 | 149 |
148 // These structures are used by PODIntervalTree for debugging. | 150 // These structures are used by PODIntervalTree for debugging. |
149 #ifndef NDEBUG | 151 #ifndef NDEBUG |
150 template <> | 152 template <> |
151 struct ValueToString<float> { | 153 struct ValueToString<float> { |
152 STATIC_ONLY(ValueToString); | 154 STATIC_ONLY(ValueToString); |
153 static String toString(const float value) { return String::number(value); } | 155 static String toString(const float value) { return String::number(value); } |
154 }; | 156 }; |
155 | 157 |
156 template <> | 158 template <> |
157 struct ValueToString<FloatPolygonEdge*> { | 159 struct ValueToString<FloatPolygonEdge*> { |
158 STATIC_ONLY(ValueToString); | 160 STATIC_ONLY(ValueToString); |
159 static String toString(const FloatPolygonEdge* edge) { | 161 static String toString(const FloatPolygonEdge* edge) { |
160 return String::format("%p (%f,%f %f,%f)", edge, edge->vertex1().x(), | 162 return String::format("%p (%f,%f %f,%f)", edge, edge->vertex1().x(), |
161 edge->vertex1().y(), edge->vertex2().x(), | 163 edge->vertex1().y(), edge->vertex2().x(), |
162 edge->vertex2().y()); | 164 edge->vertex2().y()); |
163 } | 165 } |
164 }; | 166 }; |
165 #endif | 167 #endif |
166 | 168 |
167 } // namespace blink | 169 } // namespace blink |
168 | 170 |
169 #endif // FloatPolygon_h | 171 #endif // FloatPolygon_h |
OLD | NEW |