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