| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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_TILING_DATA_H_ | 5 #ifndef CC_BASE_TILING_DATA_H_ |
| 6 #define CC_BASE_TILING_DATA_H_ | 6 #define CC_BASE_TILING_DATA_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 const gfx::Rect& consider_rect, | 94 const gfx::Rect& consider_rect, |
| 95 bool include_borders); | 95 bool include_borders); |
| 96 Iterator& operator++(); | 96 Iterator& operator++(); |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 int left_; | 99 int left_; |
| 100 int right_; | 100 int right_; |
| 101 int bottom_; | 101 int bottom_; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 // Iterate through all indices whose bounds (not including borders) intersect | 104 class CC_EXPORT BaseDifferenceIterator : public BaseIterator { |
| 105 // with |consider| but which also do not intersect with |ignore|. | 105 protected: |
| 106 class CC_EXPORT DifferenceIterator : public BaseIterator { | 106 BaseDifferenceIterator(); |
| 107 public: | 107 BaseDifferenceIterator(const TilingData* tiling_data, |
| 108 DifferenceIterator(const TilingData* tiling_data, | 108 const gfx::Rect& consider_rect, |
| 109 const gfx::Rect& consider_rect, | 109 const gfx::Rect& ignore_rect); |
| 110 const gfx::Rect& ignore_rect); | |
| 111 DifferenceIterator& operator++(); | |
| 112 | 110 |
| 113 private: | 111 bool HasConsiderRect() const; |
| 112 bool in_consider_rect() const { |
| 113 return index_x_ >= consider_left_ && index_x_ <= consider_right_ && |
| 114 index_y_ >= consider_top_ && index_y_ <= consider_bottom_; |
| 115 } |
| 114 bool in_ignore_rect() const { | 116 bool in_ignore_rect() const { |
| 115 return index_x_ >= ignore_left_ && index_x_ <= ignore_right_ && | 117 return index_x_ >= ignore_left_ && index_x_ <= ignore_right_ && |
| 116 index_y_ >= ignore_top_ && index_y_ <= ignore_bottom_; | 118 index_y_ >= ignore_top_ && index_y_ <= ignore_bottom_; |
| 117 } | 119 } |
| 118 | 120 |
| 119 int consider_left_; | 121 int consider_left_; |
| 120 int consider_top_; | 122 int consider_top_; |
| 121 int consider_right_; | 123 int consider_right_; |
| 122 int consider_bottom_; | 124 int consider_bottom_; |
| 123 int ignore_left_; | 125 int ignore_left_; |
| 124 int ignore_top_; | 126 int ignore_top_; |
| 125 int ignore_right_; | 127 int ignore_right_; |
| 126 int ignore_bottom_; | 128 int ignore_bottom_; |
| 127 }; | 129 }; |
| 128 | 130 |
| 131 // Iterate through all indices whose bounds (not including borders) intersect |
| 132 // with |consider| but which also do not intersect with |ignore|. |
| 133 class CC_EXPORT DifferenceIterator : public BaseDifferenceIterator { |
| 134 public: |
| 135 DifferenceIterator(const TilingData* tiling_data, |
| 136 const gfx::Rect& consider_rect, |
| 137 const gfx::Rect& ignore_rect); |
| 138 DifferenceIterator& operator++(); |
| 139 }; |
| 140 |
| 129 // Iterate through all indices whose bounds + border intersect with | 141 // Iterate through all indices whose bounds + border intersect with |
| 130 // |consider| but which also do not intersect with |ignore|. The iterator | 142 // |consider| but which also do not intersect with |ignore|. The iterator |
| 131 // order is a counterclockwise spiral around the given center. | 143 // order is a counterclockwise spiral around the given center. |
| 132 class CC_EXPORT SpiralDifferenceIterator : public BaseIterator { | 144 class CC_EXPORT SpiralDifferenceIterator : public BaseDifferenceIterator { |
| 133 public: | 145 public: |
| 134 SpiralDifferenceIterator(); | 146 SpiralDifferenceIterator(); |
| 135 SpiralDifferenceIterator(const TilingData* tiling_data, | 147 SpiralDifferenceIterator(const TilingData* tiling_data, |
| 136 const gfx::Rect& consider_rect, | 148 const gfx::Rect& consider_rect, |
| 137 const gfx::Rect& ignore_rect, | 149 const gfx::Rect& ignore_rect, |
| 138 const gfx::Rect& center_rect); | 150 const gfx::Rect& center_rect); |
| 139 SpiralDifferenceIterator& operator++(); | 151 SpiralDifferenceIterator& operator++(); |
| 140 | 152 |
| 141 private: | 153 private: |
| 142 bool in_consider_rect() const { | |
| 143 return index_x_ >= consider_left_ && index_x_ <= consider_right_ && | |
| 144 index_y_ >= consider_top_ && index_y_ <= consider_bottom_; | |
| 145 } | |
| 146 bool in_ignore_rect() const { | |
| 147 return index_x_ >= ignore_left_ && index_x_ <= ignore_right_ && | |
| 148 index_y_ >= ignore_top_ && index_y_ <= ignore_bottom_; | |
| 149 } | |
| 150 bool valid_column() const { | 154 bool valid_column() const { |
| 151 return index_x_ >= consider_left_ && index_x_ <= consider_right_; | 155 return index_x_ >= consider_left_ && index_x_ <= consider_right_; |
| 152 } | 156 } |
| 153 bool valid_row() const { | 157 bool valid_row() const { |
| 154 return index_y_ >= consider_top_ && index_y_ <= consider_bottom_; | 158 return index_y_ >= consider_top_ && index_y_ <= consider_bottom_; |
| 155 } | 159 } |
| 156 | 160 |
| 157 int current_step_count() const { | 161 int current_step_count() const { |
| 158 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_ | 162 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_ |
| 159 : horizontal_step_count_; | 163 : horizontal_step_count_; |
| 160 } | 164 } |
| 161 | 165 |
| 162 bool needs_direction_switch() const; | 166 bool needs_direction_switch() const; |
| 163 void switch_direction(); | 167 void switch_direction(); |
| 164 | 168 |
| 165 int consider_left_; | |
| 166 int consider_top_; | |
| 167 int consider_right_; | |
| 168 int consider_bottom_; | |
| 169 int ignore_left_; | |
| 170 int ignore_top_; | |
| 171 int ignore_right_; | |
| 172 int ignore_bottom_; | |
| 173 | |
| 174 enum Direction { UP, LEFT, DOWN, RIGHT }; | 169 enum Direction { UP, LEFT, DOWN, RIGHT }; |
| 175 | 170 |
| 176 Direction direction_; | 171 Direction direction_; |
| 177 int delta_x_; | 172 int delta_x_; |
| 178 int delta_y_; | 173 int delta_y_; |
| 179 int current_step_; | 174 int current_step_; |
| 180 int horizontal_step_count_; | 175 int horizontal_step_count_; |
| 181 int vertical_step_count_; | 176 int vertical_step_count_; |
| 182 }; | 177 }; |
| 183 | 178 |
| 184 class CC_EXPORT ReverseSpiralDifferenceIterator : public BaseIterator { | 179 class CC_EXPORT ReverseSpiralDifferenceIterator |
| 180 : public BaseDifferenceIterator { |
| 185 public: | 181 public: |
| 186 ReverseSpiralDifferenceIterator(); | 182 ReverseSpiralDifferenceIterator(); |
| 187 ReverseSpiralDifferenceIterator(const TilingData* tiling_data, | 183 ReverseSpiralDifferenceIterator(const TilingData* tiling_data, |
| 188 const gfx::Rect& consider_rect, | 184 const gfx::Rect& consider_rect, |
| 189 const gfx::Rect& ignore_rect, | 185 const gfx::Rect& ignore_rect, |
| 190 const gfx::Rect& center_rect); | 186 const gfx::Rect& center_rect); |
| 191 ReverseSpiralDifferenceIterator& operator++(); | 187 ReverseSpiralDifferenceIterator& operator++(); |
| 192 | 188 |
| 193 private: | 189 private: |
| 194 bool in_consider_rect() const { | |
| 195 return index_x_ >= consider_left_ && index_x_ <= consider_right_ && | |
| 196 index_y_ >= consider_top_ && index_y_ <= consider_bottom_; | |
| 197 } | |
| 198 bool in_around_rect() const { | 190 bool in_around_rect() const { |
| 199 return index_x_ >= around_left_ && index_x_ <= around_right_ && | 191 return index_x_ >= around_left_ && index_x_ <= around_right_ && |
| 200 index_y_ >= around_top_ && index_y_ <= around_bottom_; | 192 index_y_ >= around_top_ && index_y_ <= around_bottom_; |
| 201 } | 193 } |
| 202 bool in_ignore_rect() const { | |
| 203 return index_x_ >= ignore_left_ && index_x_ <= ignore_right_ && | |
| 204 index_y_ >= ignore_top_ && index_y_ <= ignore_bottom_; | |
| 205 } | |
| 206 bool valid_column() const { | 194 bool valid_column() const { |
| 207 return index_x_ >= consider_left_ && index_x_ <= consider_right_; | 195 return index_x_ >= consider_left_ && index_x_ <= consider_right_; |
| 208 } | 196 } |
| 209 bool valid_row() const { | 197 bool valid_row() const { |
| 210 return index_y_ >= consider_top_ && index_y_ <= consider_bottom_; | 198 return index_y_ >= consider_top_ && index_y_ <= consider_bottom_; |
| 211 } | 199 } |
| 212 | 200 |
| 213 int current_step_count() const { | 201 int current_step_count() const { |
| 214 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_ | 202 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_ |
| 215 : horizontal_step_count_; | 203 : horizontal_step_count_; |
| 216 } | 204 } |
| 217 | 205 |
| 218 bool needs_direction_switch() const; | 206 bool needs_direction_switch() const; |
| 219 void switch_direction(); | 207 void switch_direction(); |
| 220 | 208 |
| 221 int consider_left_; | |
| 222 int consider_top_; | |
| 223 int consider_right_; | |
| 224 int consider_bottom_; | |
| 225 int around_left_; | 209 int around_left_; |
| 226 int around_top_; | 210 int around_top_; |
| 227 int around_right_; | 211 int around_right_; |
| 228 int around_bottom_; | 212 int around_bottom_; |
| 229 int ignore_left_; | |
| 230 int ignore_top_; | |
| 231 int ignore_right_; | |
| 232 int ignore_bottom_; | |
| 233 | 213 |
| 234 enum Direction { LEFT, UP, RIGHT, DOWN }; | 214 enum Direction { LEFT, UP, RIGHT, DOWN }; |
| 235 | 215 |
| 236 Direction direction_; | 216 Direction direction_; |
| 237 int delta_x_; | 217 int delta_x_; |
| 238 int delta_y_; | 218 int delta_y_; |
| 239 int current_step_; | 219 int current_step_; |
| 240 int horizontal_step_count_; | 220 int horizontal_step_count_; |
| 241 int vertical_step_count_; | 221 int vertical_step_count_; |
| 242 }; | 222 }; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 256 int border_texels_; | 236 int border_texels_; |
| 257 | 237 |
| 258 // These are computed values. | 238 // These are computed values. |
| 259 int num_tiles_x_; | 239 int num_tiles_x_; |
| 260 int num_tiles_y_; | 240 int num_tiles_y_; |
| 261 }; | 241 }; |
| 262 | 242 |
| 263 } // namespace cc | 243 } // namespace cc |
| 264 | 244 |
| 265 #endif // CC_BASE_TILING_DATA_H_ | 245 #endif // CC_BASE_TILING_DATA_H_ |
| OLD | NEW |