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_SPIRAL_ITERATOR_H_ | 5 #ifndef CC_BASE_SPIRAL_ITERATOR_H_ |
6 #define CC_BASE_SPIRAL_ITERATOR_H_ | 6 #define CC_BASE_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 based on directions around the center | 14 // The spiral iterator which iterates based on directions around the center |
15 // rect in the given region. If the center rect is at index (2, 2), spiral | 15 // rect in the given region. If the center rect is at index (2, 2), spiral |
16 // iterator gives following sequence on iterating. | 16 // 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 │ 16│ 15│ 14│ 13│ 12│ | 20 // 0 │ 16│ 15│ 14│ 13│ 12│ |
21 // ├───┼───┼───┼───┼───┤ | 21 // ├───┼───┼───┼───┼───┤ |
22 // 1 │ 17│ 4│ 3│ 2│ 11│ | 22 // 1 │ 17│ 4│ 3│ 2│ 11│ |
23 // ├───┼───┼───┼───┼───┤ | 23 // ├───┼───┼───┼───┼───┤ |
24 // 2 │ 18│ 5│ *│ 1│ 10│ | 24 // 2 │ 18│ 5│ *│ 1│ 10│ |
25 // ├───┼───┼───┼───┼───┤ | 25 // ├───┼───┼───┼───┼───┤ |
26 // 3 │ 19│ 6│ 7│ 8│ 9│ | 26 // 3 │ 19│ 6│ 7│ 8│ 9│ |
27 // ├───┼───┼───┼───┼───┤ | 27 // ├───┼───┼───┼───┼───┤ |
28 // 4 │ 20│ 21│ 22│ 23│ 24│ | 28 // 4 │ 20│ 21│ 22│ 23│ 24│ |
29 // └───┴───┴───┴───┴───┘ | 29 // └───┴───┴───┴───┴───┘ |
30 class CC_EXPORT SpiralIterator { | 30 class CC_BASE_EXPORT SpiralIterator { |
31 public: | 31 public: |
32 SpiralIterator(); | 32 SpiralIterator(); |
33 SpiralIterator(const IndexRect& around_index_rect, | 33 SpiralIterator(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 ~SpiralIterator() = default; | 37 ~SpiralIterator() = default; |
38 | 38 |
39 operator bool() const; | 39 operator bool() const; |
40 SpiralIterator& operator++(); | 40 SpiralIterator& operator++(); |
(...skipping 21 matching lines...) Expand all Loading... |
62 int delta_x_; | 62 int delta_x_; |
63 int delta_y_; | 63 int delta_y_; |
64 int current_step_; | 64 int current_step_; |
65 int horizontal_step_count_; | 65 int horizontal_step_count_; |
66 int vertical_step_count_; | 66 int vertical_step_count_; |
67 }; | 67 }; |
68 | 68 |
69 } // namespace cc | 69 } // namespace cc |
70 | 70 |
71 #endif // CC_BASE_SPIRAL_ITERATOR_H_ | 71 #endif // CC_BASE_SPIRAL_ITERATOR_H_ |
OLD | NEW |