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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 int consider_left_; | 117 int consider_left_; |
118 int consider_top_; | 118 int consider_top_; |
119 int consider_right_; | 119 int consider_right_; |
120 int consider_bottom_; | 120 int consider_bottom_; |
121 int ignore_left_; | 121 int ignore_left_; |
122 int ignore_top_; | 122 int ignore_top_; |
123 int ignore_right_; | 123 int ignore_right_; |
124 int ignore_bottom_; | 124 int ignore_bottom_; |
125 }; | 125 }; |
126 | 126 |
| 127 // Iterate through all indices whose bounds + border intersect with |
| 128 // |consider| but which also do not intersect with |ignore|. The iterator |
| 129 // order is a counterclockwise spiral around the given center. |
| 130 class CC_EXPORT SpiralDifferenceIterator : public BaseIterator { |
| 131 public: |
| 132 SpiralDifferenceIterator(const TilingData* tiling_data, |
| 133 const gfx::Rect& consider_rect, |
| 134 const gfx::Rect& ignore_rect, |
| 135 const gfx::Rect& center_rect); |
| 136 SpiralDifferenceIterator& operator++(); |
| 137 |
| 138 private: |
| 139 bool in_consider_rect() const { |
| 140 return index_x_ >= consider_left_ && index_x_ <= consider_right_ && |
| 141 index_y_ >= consider_top_ && index_y_ <= consider_bottom_; |
| 142 } |
| 143 bool in_ignore_rect() const { |
| 144 return index_x_ >= ignore_left_ && index_x_ <= ignore_right_ && |
| 145 index_y_ >= ignore_top_ && index_y_ <= ignore_bottom_; |
| 146 } |
| 147 bool valid_column() const { |
| 148 return index_x_ >= consider_left_ && index_x_ <= consider_right_; |
| 149 } |
| 150 bool valid_row() const { |
| 151 return index_y_ >= consider_top_ && index_y_ <= consider_bottom_; |
| 152 } |
| 153 |
| 154 int current_step_count() const { |
| 155 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_ |
| 156 : horizontal_step_count_; |
| 157 } |
| 158 |
| 159 bool needs_direction_switch() const; |
| 160 void switch_direction(); |
| 161 |
| 162 int consider_left_; |
| 163 int consider_top_; |
| 164 int consider_right_; |
| 165 int consider_bottom_; |
| 166 int ignore_left_; |
| 167 int ignore_top_; |
| 168 int ignore_right_; |
| 169 int ignore_bottom_; |
| 170 |
| 171 enum Direction { UP, LEFT, DOWN, RIGHT }; |
| 172 |
| 173 Direction direction_; |
| 174 int delta_x_; |
| 175 int delta_y_; |
| 176 int current_step_; |
| 177 int horizontal_step_count_; |
| 178 int vertical_step_count_; |
| 179 }; |
| 180 |
127 private: | 181 private: |
| 182 std::pair<int, int> UnclampedFirstBorderTileIndexFromSrcCoord(int x, |
| 183 int y) const; |
| 184 std::pair<int, int> UnclampedLastBorderTileIndexFromSrcCoord(int x, |
| 185 int y) const; |
| 186 |
128 void AssertTile(int i, int j) const { | 187 void AssertTile(int i, int j) const { |
129 DCHECK_GE(i, 0); | 188 DCHECK_GE(i, 0); |
130 DCHECK_LT(i, num_tiles_x_); | 189 DCHECK_LT(i, num_tiles_x_); |
131 DCHECK_GE(j, 0); | 190 DCHECK_GE(j, 0); |
132 DCHECK_LT(j, num_tiles_y_); | 191 DCHECK_LT(j, num_tiles_y_); |
133 } | 192 } |
134 | 193 |
135 void RecomputeNumTiles(); | 194 void RecomputeNumTiles(); |
136 | 195 |
137 gfx::Size max_texture_size_; | 196 gfx::Size max_texture_size_; |
138 gfx::Size total_size_; | 197 gfx::Size total_size_; |
139 int border_texels_; | 198 int border_texels_; |
140 | 199 |
141 // These are computed values. | 200 // These are computed values. |
142 int num_tiles_x_; | 201 int num_tiles_x_; |
143 int num_tiles_y_; | 202 int num_tiles_y_; |
144 }; | 203 }; |
145 | 204 |
146 } // namespace cc | 205 } // namespace cc |
147 | 206 |
148 #endif // CC_BASE_TILING_DATA_H_ | 207 #endif // CC_BASE_TILING_DATA_H_ |
OLD | NEW |