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 17 matching lines...) Expand all Loading... |
28 */ | 28 */ |
29 | 29 |
30 #ifndef FloatPolygon_h | 30 #ifndef FloatPolygon_h |
31 #define FloatPolygon_h | 31 #define FloatPolygon_h |
32 | 32 |
33 #include "platform/PODIntervalTree.h" | 33 #include "platform/PODIntervalTree.h" |
34 #include "platform/geometry/FloatPoint.h" | 34 #include "platform/geometry/FloatPoint.h" |
35 #include "platform/geometry/FloatRect.h" | 35 #include "platform/geometry/FloatRect.h" |
36 #include "platform/graphics/GraphicsTypes.h" | 36 #include "platform/graphics/GraphicsTypes.h" |
37 #include "wtf/Allocator.h" | 37 #include "wtf/Allocator.h" |
| 38 #include "wtf/OwnPtr.h" |
| 39 #include "wtf/PassOwnPtr.h" |
38 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
39 #include <memory> | |
40 | 41 |
41 namespace blink { | 42 namespace blink { |
42 | 43 |
43 class FloatPolygonEdge; | 44 class FloatPolygonEdge; |
44 | 45 |
45 // This class is used by PODIntervalTree for debugging. | 46 // This class is used by PODIntervalTree for debugging. |
46 #ifndef NDEBUG | 47 #ifndef NDEBUG |
47 template <class> struct ValueToString; | 48 template <class> struct ValueToString; |
48 #endif | 49 #endif |
49 | 50 |
50 class PLATFORM_EXPORT FloatPolygon { | 51 class PLATFORM_EXPORT FloatPolygon { |
51 USING_FAST_MALLOC(FloatPolygon); | 52 USING_FAST_MALLOC(FloatPolygon); |
52 WTF_MAKE_NONCOPYABLE(FloatPolygon); | 53 WTF_MAKE_NONCOPYABLE(FloatPolygon); |
53 public: | 54 public: |
54 FloatPolygon(std::unique_ptr<Vector<FloatPoint>> vertices, WindRule fillRule
); | 55 FloatPolygon(PassOwnPtr<Vector<FloatPoint>> vertices, WindRule fillRule); |
55 | 56 |
56 const FloatPoint& vertexAt(unsigned index) const { return (*m_vertices)[inde
x]; } | 57 const FloatPoint& vertexAt(unsigned index) const { return (*m_vertices)[inde
x]; } |
57 unsigned numberOfVertices() const { return m_vertices->size(); } | 58 unsigned numberOfVertices() const { return m_vertices->size(); } |
58 | 59 |
59 WindRule fillRule() const { return m_fillRule; } | 60 WindRule fillRule() const { return m_fillRule; } |
60 | 61 |
61 const FloatPolygonEdge& edgeAt(unsigned index) const { return m_edges[index]
; } | 62 const FloatPolygonEdge& edgeAt(unsigned index) const { return m_edges[index]
; } |
62 unsigned numberOfEdges() const { return m_edges.size(); } | 63 unsigned numberOfEdges() const { return m_edges.size(); } |
63 | 64 |
64 FloatRect boundingBox() const { return m_boundingBox; } | 65 FloatRect boundingBox() const { return m_boundingBox; } |
65 bool overlappingEdges(float minY, float maxY, Vector<const FloatPolygonEdge*
>& result) const; | 66 bool overlappingEdges(float minY, float maxY, Vector<const FloatPolygonEdge*
>& result) const; |
66 bool contains(const FloatPoint&) const; | 67 bool contains(const FloatPoint&) const; |
67 bool isEmpty() const { return m_empty; } | 68 bool isEmpty() const { return m_empty; } |
68 | 69 |
69 private: | 70 private: |
70 typedef PODInterval<float, FloatPolygonEdge*> EdgeInterval; | 71 typedef PODInterval<float, FloatPolygonEdge*> EdgeInterval; |
71 typedef PODIntervalTree<float, FloatPolygonEdge*> EdgeIntervalTree; | 72 typedef PODIntervalTree<float, FloatPolygonEdge*> EdgeIntervalTree; |
72 | 73 |
73 bool containsNonZero(const FloatPoint&) const; | 74 bool containsNonZero(const FloatPoint&) const; |
74 bool containsEvenOdd(const FloatPoint&) const; | 75 bool containsEvenOdd(const FloatPoint&) const; |
75 | 76 |
76 std::unique_ptr<Vector<FloatPoint>> m_vertices; | 77 OwnPtr<Vector<FloatPoint>> m_vertices; |
77 WindRule m_fillRule; | 78 WindRule m_fillRule; |
78 FloatRect m_boundingBox; | 79 FloatRect m_boundingBox; |
79 bool m_empty; | 80 bool m_empty; |
80 Vector<FloatPolygonEdge> m_edges; | 81 Vector<FloatPolygonEdge> m_edges; |
81 EdgeIntervalTree m_edgeTree; // Each EdgeIntervalTree node stores minY, maxY
, and a ("UserData") pointer to a FloatPolygonEdge. | 82 EdgeIntervalTree m_edgeTree; // Each EdgeIntervalTree node stores minY, maxY
, and a ("UserData") pointer to a FloatPolygonEdge. |
82 | 83 |
83 }; | 84 }; |
84 | 85 |
85 class PLATFORM_EXPORT VertexPair { | 86 class PLATFORM_EXPORT VertexPair { |
86 public: | 87 public: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 149 |
149 template<> struct ValueToString<FloatPolygonEdge*> { | 150 template<> struct ValueToString<FloatPolygonEdge*> { |
150 STATIC_ONLY(ValueToString); | 151 STATIC_ONLY(ValueToString); |
151 static String toString(const FloatPolygonEdge* edge) { return String::format
("%p (%f,%f %f,%f)", edge, edge->vertex1().x(), edge->vertex1().y(), edge->verte
x2().x(), edge->vertex2().y()); } | 152 static String toString(const FloatPolygonEdge* edge) { return String::format
("%p (%f,%f %f,%f)", edge, edge->vertex1().x(), edge->vertex1().y(), edge->verte
x2().x(), edge->vertex2().y()); } |
152 }; | 153 }; |
153 #endif | 154 #endif |
154 | 155 |
155 } // namespace blink | 156 } // namespace blink |
156 | 157 |
157 #endif // FloatPolygon_h | 158 #endif // FloatPolygon_h |
OLD | NEW |