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 #ifndef CC_BASE_REVERSE_SPIRAL_ITERATOR_H_ | 5 #ifndef CC_BASE_REVERSE_SPIRAL_ITERATOR_H_ |
6 #define CC_BASE_REVERSE_SPIRAL_ITERATOR_H_ | 6 #define CC_BASE_REVERSE_SPIRAL_ITERATOR_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "cc/base/cc_export.h" | 9 #include "cc/base/base_export.h" |
10 #include "cc/base/index_rect.h" | 10 #include "cc/base/index_rect.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 | 13 |
14 // The spiral iterator which iterates in reverse direction based on directions | 14 // The spiral iterator which iterates in reverse direction based on directions |
15 // around the center rect in the given region. If the center rect is at index | 15 // around the center rect in the given region. If the center rect is at index |
16 // (2, 2), reverse spiral iterator gives following sequence on iterating. | 16 // (2, 2), reverse spiral iterator gives following sequence on iterating. |
17 // | 17 // |
18 // x 0 1 2 3 4 | 18 // x 0 1 2 3 4 |
19 // y ┌───┬───┬───┬───┬───┐ | 19 // y ┌───┬───┬───┬───┬───┐ |
20 // 0 │ 9│ 10│ 11│ 12│ 13│ | 20 // 0 │ 9│ 10│ 11│ 12│ 13│ |
21 // ├───┼───┼───┼───┼───┤ | 21 // ├───┼───┼───┼───┼───┤ |
22 // 1 │ 8│ 21│ 22│ 23│ 14│ | 22 // 1 │ 8│ 21│ 22│ 23│ 14│ |
23 // ├───┼───┼───┼───┼───┤ | 23 // ├───┼───┼───┼───┼───┤ |
24 // 2 │ 7│ 20│ *│ 24│ 15│ | 24 // 2 │ 7│ 20│ *│ 24│ 15│ |
25 // ├───┼───┼───┼───┼───┤ | 25 // ├───┼───┼───┼───┼───┤ |
26 // 3 │ 6│ 19│ 18│ 17│ 16│ | 26 // 3 │ 6│ 19│ 18│ 17│ 16│ |
27 // ├───┼───┼───┼───┼───┤ | 27 // ├───┼───┼───┼───┼───┤ |
28 // 4 │ 5│ 4│ 3│ 2│ 1│ | 28 // 4 │ 5│ 4│ 3│ 2│ 1│ |
29 // └───┴───┴───┴───┴───┘ | 29 // └───┴───┴───┴───┴───┘ |
30 class CC_EXPORT ReverseSpiralIterator { | 30 class CC_BASE_EXPORT ReverseSpiralIterator { |
31 public: | 31 public: |
32 ReverseSpiralIterator(); | 32 ReverseSpiralIterator(); |
33 ReverseSpiralIterator(const IndexRect& around_index_rect, | 33 ReverseSpiralIterator(const IndexRect& around_index_rect, |
34 const IndexRect& consider_index_rect, | 34 const IndexRect& consider_index_rect, |
35 const IndexRect& ignore_index_rect); | 35 const IndexRect& ignore_index_rect); |
36 | 36 |
37 ~ReverseSpiralIterator() = default; | 37 ~ReverseSpiralIterator() = default; |
38 | 38 |
| 39 ReverseSpiralIterator& operator=(ReverseSpiralIterator&& other) = default; |
| 40 |
39 operator bool() const; | 41 operator bool() const; |
40 ReverseSpiralIterator& operator++(); | 42 ReverseSpiralIterator& operator++(); |
41 int index_x() const { return index_x_; } | 43 int index_x() const { return index_x_; } |
42 int index_y() const { return index_y_; } | 44 int index_y() const { return index_y_; } |
43 | 45 |
44 private: | 46 private: |
45 int current_step_count() const { | 47 int current_step_count() const { |
46 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_ | 48 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_ |
47 : horizontal_step_count_; | 49 : horizontal_step_count_; |
48 } | 50 } |
(...skipping 13 matching lines...) Expand all Loading... |
62 int delta_x_; | 64 int delta_x_; |
63 int delta_y_; | 65 int delta_y_; |
64 int current_step_; | 66 int current_step_; |
65 int horizontal_step_count_; | 67 int horizontal_step_count_; |
66 int vertical_step_count_; | 68 int vertical_step_count_; |
67 }; | 69 }; |
68 | 70 |
69 } // namespace cc | 71 } // namespace cc |
70 | 72 |
71 #endif // CC_BASE_REVERSE_SPIRAL_ITERATOR_H_ | 73 #endif // CC_BASE_REVERSE_SPIRAL_ITERATOR_H_ |
OLD | NEW |