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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 102 } |
103 | 103 |
104 bool Region::intersects(const Region& region) const | 104 bool Region::intersects(const Region& region) const |
105 { | 105 { |
106 if (!m_bounds.intersects(region.m_bounds)) | 106 if (!m_bounds.intersects(region.m_bounds)) |
107 return false; | 107 return false; |
108 | 108 |
109 return Shape::compareShapes<Shape::CompareIntersectsOperation>(m_shape, regi
on.m_shape); | 109 return Shape::compareShapes<Shape::CompareIntersectsOperation>(m_shape, regi
on.m_shape); |
110 } | 110 } |
111 | 111 |
112 unsigned Region::totalArea() const | |
113 { | |
114 Vector<IntRect> rects = this->rects(); | |
115 size_t size = rects.size(); | |
116 unsigned totalArea = 0; | |
117 | |
118 for (size_t i = 0; i < size; ++i) { | |
119 IntRect rect = rects[i]; | |
120 totalArea += (rect.width() * rect.height()); | |
121 } | |
122 | |
123 return totalArea; | |
124 } | |
125 | |
126 template<typename CompareOperation> | 112 template<typename CompareOperation> |
127 bool Region::Shape::compareShapes(const Shape& aShape, const Shape& bShape) | 113 bool Region::Shape::compareShapes(const Shape& aShape, const Shape& bShape) |
128 { | 114 { |
129 bool result = CompareOperation::defaultResult; | 115 bool result = CompareOperation::defaultResult; |
130 | 116 |
131 Shape::SpanIterator aSpan = aShape.spansBegin(); | 117 Shape::SpanIterator aSpan = aShape.spansBegin(); |
132 Shape::SpanIterator aSpanEnd = aShape.spansEnd(); | 118 Shape::SpanIterator aSpanEnd = aShape.spansEnd(); |
133 Shape::SpanIterator bSpan = bShape.spansBegin(); | 119 Shape::SpanIterator bSpan = bShape.spansBegin(); |
134 Shape::SpanIterator bSpanEnd = bShape.spansEnd(); | 120 Shape::SpanIterator bSpanEnd = bShape.spansEnd(); |
135 | 121 |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 m_bounds = m_shape.bounds(); | 608 m_bounds = m_shape.bounds(); |
623 } | 609 } |
624 | 610 |
625 void Region::translate(const IntSize& offset) | 611 void Region::translate(const IntSize& offset) |
626 { | 612 { |
627 m_bounds.move(offset); | 613 m_bounds.move(offset); |
628 m_shape.translate(offset); | 614 m_shape.translate(offset); |
629 } | 615 } |
630 | 616 |
631 } // namespace blink | 617 } // namespace blink |
OLD | NEW |