| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/base/reverse_spiral_iterator.h" | 5 #include "cc/base/reverse_spiral_iterator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 namespace cc { | 9 namespace cc { |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 around_index_rect_.num_indices_x() + 2 * max_distance; | 70 around_index_rect_.num_indices_x() + 2 * max_distance; |
| 71 | 71 |
| 72 // Start with one to the right of the padded around rect. | 72 // Start with one to the right of the padded around rect. |
| 73 index_x_ = around_index_rect_.right() + max_distance + 1; | 73 index_x_ = around_index_rect_.right() + max_distance + 1; |
| 74 index_y_ = around_index_rect_.bottom() + max_distance; | 74 index_y_ = around_index_rect_.bottom() + max_distance; |
| 75 | 75 |
| 76 // The current index is outside a valid tile, so advance immediately. | 76 // The current index is outside a valid tile, so advance immediately. |
| 77 ++(*this); | 77 ++(*this); |
| 78 } | 78 } |
| 79 | 79 |
| 80 ReverseSpiralIterator::ReverseSpiralIterator( |
| 81 const ReverseSpiralIterator& other) = default; |
| 82 |
| 83 ReverseSpiralIterator::ReverseSpiralIterator(ReverseSpiralIterator&& other) = |
| 84 default; |
| 85 |
| 86 ReverseSpiralIterator::~ReverseSpiralIterator() = default; |
| 87 |
| 88 ReverseSpiralIterator& ReverseSpiralIterator::operator=( |
| 89 const ReverseSpiralIterator& other) = default; |
| 90 |
| 91 ReverseSpiralIterator& ReverseSpiralIterator::operator=( |
| 92 ReverseSpiralIterator&& other) = default; |
| 93 |
| 80 ReverseSpiralIterator::operator bool() const { | 94 ReverseSpiralIterator::operator bool() const { |
| 81 return index_x_ != -1 && index_y_ != -1; | 95 return index_x_ != -1 && index_y_ != -1; |
| 82 } | 96 } |
| 83 | 97 |
| 84 ReverseSpiralIterator& ReverseSpiralIterator::operator++() { | 98 ReverseSpiralIterator& ReverseSpiralIterator::operator++() { |
| 85 while (!around_index_rect_.Contains(index_x_, index_y_)) { | 99 while (!around_index_rect_.Contains(index_x_, index_y_)) { |
| 86 if (needs_direction_switch()) | 100 if (needs_direction_switch()) |
| 87 switch_direction(); | 101 switch_direction(); |
| 88 | 102 |
| 89 index_x_ += delta_x_; | 103 index_x_ += delta_x_; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 206 |
| 193 // We should always end up in an around rect at some point. | 207 // We should always end up in an around rect at some point. |
| 194 // Since the direction is now vertical, we have to ensure that we will | 208 // Since the direction is now vertical, we have to ensure that we will |
| 195 // advance. | 209 // advance. |
| 196 DCHECK_GE(horizontal_step_count_, 1); | 210 DCHECK_GE(horizontal_step_count_, 1); |
| 197 DCHECK_GE(vertical_step_count_, 1); | 211 DCHECK_GE(vertical_step_count_, 1); |
| 198 } | 212 } |
| 199 } | 213 } |
| 200 | 214 |
| 201 } // namespace cc | 215 } // namespace cc |
| OLD | NEW |