OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010, 2011 Apple Inc. 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 | 72 |
73 int y; | 73 int y; |
74 size_t segmentIndex; | 74 size_t segmentIndex; |
75 }; | 75 }; |
76 | 76 |
77 class Shape { | 77 class Shape { |
78 public: | 78 public: |
79 Shape(); | 79 Shape(); |
80 Shape(const IntRect&); | 80 Shape(const IntRect&); |
| 81 Shape(size_t segmentsCapacity, size_t spansCapacity); |
81 | 82 |
82 IntRect bounds() const; | 83 IntRect bounds() const; |
83 bool isEmpty() const { return m_spans.isEmpty(); } | 84 bool isEmpty() const { return m_spans.isEmpty(); } |
84 bool isRect() const { return m_spans.size() <= 2 && m_segments.size() <=
2; } | 85 bool isRect() const { return m_spans.size() <= 2 && m_segments.size() <=
2; } |
85 | 86 |
86 typedef const Span* SpanIterator; | 87 typedef const Span* SpanIterator; |
87 SpanIterator spansBegin() const; | 88 SpanIterator spansBegin() const; |
88 SpanIterator spansEnd() const; | 89 SpanIterator spansEnd() const; |
| 90 size_t spansSize() const { return m_spans.size(); } |
89 | 91 |
90 typedef const int* SegmentIterator; | 92 typedef const int* SegmentIterator; |
91 SegmentIterator segmentsBegin(SpanIterator) const; | 93 SegmentIterator segmentsBegin(SpanIterator) const; |
92 SegmentIterator segmentsEnd(SpanIterator) const; | 94 SegmentIterator segmentsEnd(SpanIterator) const; |
| 95 size_t segmentsSize() const { return m_segments.size(); } |
93 | 96 |
94 static Shape unionShapes(const Shape& shape1, const Shape& shape2); | 97 static Shape unionShapes(const Shape& shape1, const Shape& shape2); |
95 static Shape intersectShapes(const Shape& shape1, const Shape& shape2); | 98 static Shape intersectShapes(const Shape& shape1, const Shape& shape2); |
96 static Shape subtractShapes(const Shape& shape1, const Shape& shape2); | 99 static Shape subtractShapes(const Shape& shape1, const Shape& shape2); |
97 | 100 |
98 void translate(const IntSize&); | 101 void translate(const IntSize&); |
99 void swap(Shape&); | 102 void swap(Shape&); |
100 | 103 |
101 struct CompareContainsOperation; | 104 struct CompareContainsOperation; |
102 struct CompareIntersectsOperation; | 105 struct CompareIntersectsOperation; |
103 | 106 |
104 template<typename CompareOperation> | 107 template<typename CompareOperation> |
105 static bool compareShapes(const Shape& shape1, const Shape& shape2); | 108 static bool compareShapes(const Shape& shape1, const Shape& shape2); |
| 109 void trimCapacities(); |
106 | 110 |
107 #ifndef NDEBUG | 111 #ifndef NDEBUG |
108 void dump() const; | 112 void dump() const; |
109 #endif | 113 #endif |
110 | 114 |
111 private: | 115 private: |
112 struct UnionOperation; | 116 struct UnionOperation; |
113 struct IntersectOperation; | 117 struct IntersectOperation; |
114 struct SubtractOperation; | 118 struct SubtractOperation; |
115 | 119 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 176 } |
173 | 177 |
174 inline bool operator==(const Region::Span& a, const Region::Span& b) | 178 inline bool operator==(const Region::Span& a, const Region::Span& b) |
175 { | 179 { |
176 return a.y == b.y && a.segmentIndex == b.segmentIndex; | 180 return a.y == b.y && a.segmentIndex == b.segmentIndex; |
177 } | 181 } |
178 | 182 |
179 } // namespace WebCore | 183 } // namespace WebCore |
180 | 184 |
181 #endif // Region_h | 185 #endif // Region_h |
OLD | NEW |