| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 span != end && span + 1 != end; ++span) { | 47 span != end && span + 1 != end; ++span) { |
| 48 int y = span->y; | 48 int y = span->y; |
| 49 int height = (span + 1)->y - y; | 49 int height = (span + 1)->y - y; |
| 50 | 50 |
| 51 for (Shape::SegmentIterator segment = m_shape.segmentsBegin(span), | 51 for (Shape::SegmentIterator segment = m_shape.segmentsBegin(span), |
| 52 end = m_shape.segmentsEnd(span); | 52 end = m_shape.segmentsEnd(span); |
| 53 segment != end && segment + 1 != end; segment += 2) { | 53 segment != end && segment + 1 != end; segment += 2) { |
| 54 int x = *segment; | 54 int x = *segment; |
| 55 int width = *(segment + 1) - x; | 55 int width = *(segment + 1) - x; |
| 56 | 56 |
| 57 rects.append(IntRect(x, y, width, height)); | 57 rects.push_back(IntRect(x, y, width, height)); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 return rects; | 61 return rects; |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool Region::contains(const Region& region) const { | 64 bool Region::contains(const Region& region) const { |
| 65 if (!m_bounds.contains(region.m_bounds)) | 65 if (!m_bounds.contains(region.m_bounds)) |
| 66 return false; | 66 return false; |
| 67 | 67 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 appendSegment(rect.maxX()); | 232 appendSegment(rect.maxX()); |
| 233 appendSpan(rect.maxY()); | 233 appendSpan(rect.maxY()); |
| 234 } | 234 } |
| 235 | 235 |
| 236 Region::Shape::Shape(size_t segmentsCapacity, size_t spansCapacity) { | 236 Region::Shape::Shape(size_t segmentsCapacity, size_t spansCapacity) { |
| 237 m_segments.reserveCapacity(segmentsCapacity); | 237 m_segments.reserveCapacity(segmentsCapacity); |
| 238 m_spans.reserveCapacity(spansCapacity); | 238 m_spans.reserveCapacity(spansCapacity); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void Region::Shape::appendSpan(int y) { | 241 void Region::Shape::appendSpan(int y) { |
| 242 m_spans.append(Span(y, m_segments.size())); | 242 m_spans.push_back(Span(y, m_segments.size())); |
| 243 } | 243 } |
| 244 | 244 |
| 245 bool Region::Shape::canCoalesce(SegmentIterator begin, SegmentIterator end) { | 245 bool Region::Shape::canCoalesce(SegmentIterator begin, SegmentIterator end) { |
| 246 if (m_spans.isEmpty()) | 246 if (m_spans.isEmpty()) |
| 247 return false; | 247 return false; |
| 248 | 248 |
| 249 SegmentIterator lastSpanBegin = | 249 SegmentIterator lastSpanBegin = |
| 250 m_segments.data() + m_spans.back().segmentIndex; | 250 m_segments.data() + m_spans.back().segmentIndex; |
| 251 SegmentIterator lastSpanEnd = m_segments.data() + m_segments.size(); | 251 SegmentIterator lastSpanEnd = m_segments.data() + m_segments.size(); |
| 252 | 252 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 273 } | 273 } |
| 274 | 274 |
| 275 void Region::Shape::appendSpans(const Shape& shape, | 275 void Region::Shape::appendSpans(const Shape& shape, |
| 276 SpanIterator begin, | 276 SpanIterator begin, |
| 277 SpanIterator end) { | 277 SpanIterator end) { |
| 278 for (SpanIterator it = begin; it != end; ++it) | 278 for (SpanIterator it = begin; it != end; ++it) |
| 279 appendSpan(it->y, shape.segmentsBegin(it), shape.segmentsEnd(it)); | 279 appendSpan(it->y, shape.segmentsBegin(it), shape.segmentsEnd(it)); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void Region::Shape::appendSegment(int x) { | 282 void Region::Shape::appendSegment(int x) { |
| 283 m_segments.append(x); | 283 m_segments.push_back(x); |
| 284 } | 284 } |
| 285 | 285 |
| 286 Region::Shape::SpanIterator Region::Shape::spansBegin() const { | 286 Region::Shape::SpanIterator Region::Shape::spansBegin() const { |
| 287 return m_spans.data(); | 287 return m_spans.data(); |
| 288 } | 288 } |
| 289 | 289 |
| 290 Region::Shape::SpanIterator Region::Shape::spansEnd() const { | 290 Region::Shape::SpanIterator Region::Shape::spansEnd() const { |
| 291 return m_spans.data() + m_spans.size(); | 291 return m_spans.data() + m_spans.size(); |
| 292 } | 292 } |
| 293 | 293 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 flag = flag ^ 1; | 462 flag = flag ^ 1; |
| 463 ++s1; | 463 ++s1; |
| 464 } | 464 } |
| 465 if (test >= 0) { | 465 if (test >= 0) { |
| 466 x = *s2; | 466 x = *s2; |
| 467 flag = flag ^ 2; | 467 flag = flag ^ 2; |
| 468 ++s2; | 468 ++s2; |
| 469 } | 469 } |
| 470 | 470 |
| 471 if (flag == Operation::opCode || oldFlag == Operation::opCode) | 471 if (flag == Operation::opCode || oldFlag == Operation::opCode) |
| 472 segments.append(x); | 472 segments.push_back(x); |
| 473 | 473 |
| 474 oldFlag = flag; | 474 oldFlag = flag; |
| 475 } | 475 } |
| 476 | 476 |
| 477 // Add any remaining segments. | 477 // Add any remaining segments. |
| 478 if (Operation::shouldAddRemainingSegmentsFromSpan1 && s1 != segments1End) | 478 if (Operation::shouldAddRemainingSegmentsFromSpan1 && s1 != segments1End) |
| 479 segments.appendRange(s1, segments1End); | 479 segments.appendRange(s1, segments1End); |
| 480 else if (Operation::shouldAddRemainingSegmentsFromSpan2 && | 480 else if (Operation::shouldAddRemainingSegmentsFromSpan2 && |
| 481 s2 != segments2End) | 481 s2 != segments2End) |
| 482 segments.appendRange(s2, segments2End); | 482 segments.appendRange(s2, segments2End); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 m_shape.swap(subtractedShape); | 618 m_shape.swap(subtractedShape); |
| 619 m_bounds = m_shape.bounds(); | 619 m_bounds = m_shape.bounds(); |
| 620 } | 620 } |
| 621 | 621 |
| 622 void Region::translate(const IntSize& offset) { | 622 void Region::translate(const IntSize& offset) { |
| 623 m_bounds.move(offset); | 623 m_bounds.move(offset); |
| 624 m_shape.translate(offset); | 624 m_shape.translate(offset); |
| 625 } | 625 } |
| 626 | 626 |
| 627 } // namespace blink | 627 } // namespace blink |
| OLD | NEW |