| 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/logging.h" | 10 #include "base/logging.h" |
| 11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
| 12 #include "cc/base/pyramid_sequence.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 13 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 class Vector2d; | 17 class Vector2d; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace cc { | 20 namespace cc { |
| 20 | 21 |
| 21 class CC_EXPORT TilingData { | 22 class CC_EXPORT TilingData { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 43 int num_tiles_y() const { return num_tiles_y_; } | 44 int num_tiles_y() const { return num_tiles_y_; } |
| 44 // Return the tile index whose non-border texels include src_position. | 45 // Return the tile index whose non-border texels include src_position. |
| 45 int TileXIndexFromSrcCoord(int src_position) const; | 46 int TileXIndexFromSrcCoord(int src_position) const; |
| 46 int TileYIndexFromSrcCoord(int src_position) const; | 47 int TileYIndexFromSrcCoord(int src_position) const; |
| 47 // Return the lowest tile index whose border texels include src_position. | 48 // Return the lowest tile index whose border texels include src_position. |
| 48 int FirstBorderTileXIndexFromSrcCoord(int src_position) const; | 49 int FirstBorderTileXIndexFromSrcCoord(int src_position) const; |
| 49 int FirstBorderTileYIndexFromSrcCoord(int src_position) const; | 50 int FirstBorderTileYIndexFromSrcCoord(int src_position) const; |
| 50 // Return the highest tile index whose border texels include src_position. | 51 // Return the highest tile index whose border texels include src_position. |
| 51 int LastBorderTileXIndexFromSrcCoord(int src_position) const; | 52 int LastBorderTileXIndexFromSrcCoord(int src_position) const; |
| 52 int LastBorderTileYIndexFromSrcCoord(int src_position) const; | 53 int LastBorderTileYIndexFromSrcCoord(int src_position) const; |
| 54 // Return the virtual tile index, assuming tiling size to be infinite in all |
| 55 // quadrants. |
| 56 int TileVirtualXIndexFromSrcCoord(int src_position) const; |
| 57 int TileVirtualYIndexFromSrcCoord(int src_position) const; |
| 58 // Return the virtual around tile indices around the given rect. |
| 59 void TileVirtualAroundIndices(const gfx::Rect& center_rect, |
| 60 int* around_left, |
| 61 int* around_right, |
| 62 int* around_top, |
| 63 int* around_bottom) const; |
| 53 | 64 |
| 54 gfx::Rect ExpandRectIgnoringBordersToTileBounds(const gfx::Rect& rect) const; | 65 gfx::Rect ExpandRectIgnoringBordersToTileBounds(const gfx::Rect& rect) const; |
| 55 gfx::Rect ExpandRectToTileBounds(const gfx::Rect& rect) const; | 66 gfx::Rect ExpandRectToTileBounds(const gfx::Rect& rect) const; |
| 56 | 67 |
| 57 gfx::Rect TileBounds(int i, int j) const; | 68 gfx::Rect TileBounds(int i, int j) const; |
| 58 gfx::Rect TileBoundsWithBorder(int i, int j) const; | 69 gfx::Rect TileBoundsWithBorder(int i, int j) const; |
| 59 int TilePositionX(int x_index) const; | 70 int TilePositionX(int x_index) const; |
| 60 int TilePositionY(int y_index) const; | 71 int TilePositionY(int y_index) const; |
| 61 int TileSizeX(int x_index) const; | 72 int TileSizeX(int x_index) const; |
| 62 int TileSizeY(int y_index) const; | 73 int TileSizeY(int y_index) const; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // Iterate through all indices whose bounds + border intersect with | 152 // Iterate through all indices whose bounds + border intersect with |
| 142 // |consider| but which also do not intersect with |ignore|. The iterator | 153 // |consider| but which also do not intersect with |ignore|. The iterator |
| 143 // order is a counterclockwise spiral around the given center. | 154 // order is a counterclockwise spiral around the given center. |
| 144 class CC_EXPORT SpiralDifferenceIterator : public BaseDifferenceIterator { | 155 class CC_EXPORT SpiralDifferenceIterator : public BaseDifferenceIterator { |
| 145 public: | 156 public: |
| 146 SpiralDifferenceIterator(); | 157 SpiralDifferenceIterator(); |
| 147 SpiralDifferenceIterator(const TilingData* tiling_data, | 158 SpiralDifferenceIterator(const TilingData* tiling_data, |
| 148 const gfx::Rect& consider_rect, | 159 const gfx::Rect& consider_rect, |
| 149 const gfx::Rect& ignore_rect, | 160 const gfx::Rect& ignore_rect, |
| 150 const gfx::Rect& center_rect); | 161 const gfx::Rect& center_rect); |
| 162 SpiralDifferenceIterator(const SpiralDifferenceIterator& other); |
| 163 SpiralDifferenceIterator(SpiralDifferenceIterator&& other); |
| 164 ~SpiralDifferenceIterator(); |
| 165 |
| 166 SpiralDifferenceIterator& operator=(const SpiralDifferenceIterator& other); |
| 167 SpiralDifferenceIterator& operator=(SpiralDifferenceIterator&& other); |
| 168 |
| 151 SpiralDifferenceIterator& operator++(); | 169 SpiralDifferenceIterator& operator++(); |
| 152 | 170 |
| 153 private: | 171 private: |
| 154 bool valid_column() const { | 172 TopDownPyramidSequence pyramid_sequence_; |
| 155 return index_x_ >= consider_left_ && index_x_ <= consider_right_; | |
| 156 } | |
| 157 bool valid_row() const { | |
| 158 return index_y_ >= consider_top_ && index_y_ <= consider_bottom_; | |
| 159 } | |
| 160 | |
| 161 int current_step_count() const { | |
| 162 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_ | |
| 163 : horizontal_step_count_; | |
| 164 } | |
| 165 | |
| 166 bool needs_direction_switch() const; | |
| 167 void switch_direction(); | |
| 168 | |
| 169 enum Direction { UP, LEFT, DOWN, RIGHT }; | |
| 170 | |
| 171 Direction direction_; | |
| 172 int delta_x_; | |
| 173 int delta_y_; | |
| 174 int current_step_; | |
| 175 int horizontal_step_count_; | |
| 176 int vertical_step_count_; | |
| 177 }; | 173 }; |
| 178 | 174 |
| 179 class CC_EXPORT ReverseSpiralDifferenceIterator | 175 class CC_EXPORT ReverseSpiralDifferenceIterator |
| 180 : public BaseDifferenceIterator { | 176 : public BaseDifferenceIterator { |
| 181 public: | 177 public: |
| 182 ReverseSpiralDifferenceIterator(); | 178 ReverseSpiralDifferenceIterator(); |
| 183 ReverseSpiralDifferenceIterator(const TilingData* tiling_data, | 179 ReverseSpiralDifferenceIterator(const TilingData* tiling_data, |
| 184 const gfx::Rect& consider_rect, | 180 const gfx::Rect& consider_rect, |
| 185 const gfx::Rect& ignore_rect, | 181 const gfx::Rect& ignore_rect, |
| 186 const gfx::Rect& center_rect); | 182 const gfx::Rect& center_rect); |
| 183 ReverseSpiralDifferenceIterator( |
| 184 const ReverseSpiralDifferenceIterator& other); |
| 185 ReverseSpiralDifferenceIterator(ReverseSpiralDifferenceIterator&& other); |
| 186 ~ReverseSpiralDifferenceIterator(); |
| 187 |
| 188 ReverseSpiralDifferenceIterator& operator=( |
| 189 const ReverseSpiralDifferenceIterator& other); |
| 190 ReverseSpiralDifferenceIterator& operator=( |
| 191 ReverseSpiralDifferenceIterator&& other); |
| 192 |
| 187 ReverseSpiralDifferenceIterator& operator++(); | 193 ReverseSpiralDifferenceIterator& operator++(); |
| 188 | 194 |
| 189 private: | 195 private: |
| 190 bool in_around_rect() const { | 196 BottomUpPyramidSequence pyramid_sequence_; |
| 191 return index_x_ >= around_left_ && index_x_ <= around_right_ && | |
| 192 index_y_ >= around_top_ && index_y_ <= around_bottom_; | |
| 193 } | |
| 194 bool valid_column() const { | |
| 195 return index_x_ >= consider_left_ && index_x_ <= consider_right_; | |
| 196 } | |
| 197 bool valid_row() const { | |
| 198 return index_y_ >= consider_top_ && index_y_ <= consider_bottom_; | |
| 199 } | |
| 200 | |
| 201 int current_step_count() const { | |
| 202 return (direction_ == UP || direction_ == DOWN) ? vertical_step_count_ | |
| 203 : horizontal_step_count_; | |
| 204 } | |
| 205 | |
| 206 bool needs_direction_switch() const; | |
| 207 void switch_direction(); | |
| 208 | |
| 209 int around_left_; | |
| 210 int around_top_; | |
| 211 int around_right_; | |
| 212 int around_bottom_; | |
| 213 | |
| 214 enum Direction { LEFT, UP, RIGHT, DOWN }; | |
| 215 | |
| 216 Direction direction_; | |
| 217 int delta_x_; | |
| 218 int delta_y_; | |
| 219 int current_step_; | |
| 220 int horizontal_step_count_; | |
| 221 int vertical_step_count_; | |
| 222 }; | 197 }; |
| 223 | 198 |
| 224 private: | 199 private: |
| 225 void AssertTile(int i, int j) const { | 200 void AssertTile(int i, int j) const { |
| 226 DCHECK_GE(i, 0); | 201 DCHECK_GE(i, 0); |
| 227 DCHECK_LT(i, num_tiles_x_); | 202 DCHECK_LT(i, num_tiles_x_); |
| 228 DCHECK_GE(j, 0); | 203 DCHECK_GE(j, 0); |
| 229 DCHECK_LT(j, num_tiles_y_); | 204 DCHECK_LT(j, num_tiles_y_); |
| 230 } | 205 } |
| 231 | 206 |
| 232 void RecomputeNumTiles(); | 207 void RecomputeNumTiles(); |
| 233 | 208 |
| 234 gfx::Size max_texture_size_; | 209 gfx::Size max_texture_size_; |
| 235 gfx::Size tiling_size_; | 210 gfx::Size tiling_size_; |
| 236 int border_texels_; | 211 int border_texels_; |
| 237 | 212 |
| 238 // These are computed values. | 213 // These are computed values. |
| 239 int num_tiles_x_; | 214 int num_tiles_x_; |
| 240 int num_tiles_y_; | 215 int num_tiles_y_; |
| 241 }; | 216 }; |
| 242 | 217 |
| 243 } // namespace cc | 218 } // namespace cc |
| 244 | 219 |
| 245 #endif // CC_BASE_TILING_DATA_H_ | 220 #endif // CC_BASE_TILING_DATA_H_ |
| OLD | NEW |