| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
| 13 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
| 14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
| 15 | 15 |
| 16 namespace gfx { | 16 namespace gfx { |
| 17 class Vector2d; | 17 class Vector2d; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 | 21 |
| 22 class CC_EXPORT TilingData { | 22 class CC_EXPORT TilingData { |
| 23 public: | 23 public: |
| 24 TilingData(); | 24 TilingData(); |
| 25 TilingData(const gfx::Size& max_texture_size, | 25 TilingData(const gfx::Size& max_texture_size, |
| 26 const gfx::Rect& tiling_rect, | 26 const gfx::Size& tiling_size, |
| 27 bool has_border_texels); | 27 bool has_border_texels); |
| 28 TilingData(const gfx::Size& max_texture_size, | 28 TilingData(const gfx::Size& max_texture_size, |
| 29 const gfx::Rect& tiling_rect, | 29 const gfx::Size& tiling_size, |
| 30 int border_texels); | 30 int border_texels); |
| 31 | 31 |
| 32 gfx::Rect tiling_rect() const { return tiling_rect_; } | 32 gfx::Size tiling_size() const { return tiling_size_; } |
| 33 void SetTilingRect(const gfx::Rect& tiling_rect); | 33 void SetTilingSize(const gfx::Size& tiling_size); |
| 34 | 34 |
| 35 gfx::Size max_texture_size() const { return max_texture_size_; } | 35 gfx::Size max_texture_size() const { return max_texture_size_; } |
| 36 void SetMaxTextureSize(const gfx::Size& max_texture_size); | 36 void SetMaxTextureSize(const gfx::Size& max_texture_size); |
| 37 | 37 |
| 38 int border_texels() const { return border_texels_; } | 38 int border_texels() const { return border_texels_; } |
| 39 void SetHasBorderTexels(bool has_border_texels); | 39 void SetHasBorderTexels(bool has_border_texels); |
| 40 void SetBorderTexels(int border_texels); | 40 void SetBorderTexels(int border_texels); |
| 41 | 41 |
| 42 bool has_empty_bounds() const { return !num_tiles_x_ || !num_tiles_y_; } | 42 bool has_empty_bounds() const { return !num_tiles_x_ || !num_tiles_y_; } |
| 43 int num_tiles_x() const { return num_tiles_x_; } | 43 int num_tiles_x() const { return num_tiles_x_; } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 const TilingData* tiling_data_; | 86 const TilingData* tiling_data_; |
| 87 int index_x_; | 87 int index_x_; |
| 88 int index_y_; | 88 int index_y_; |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 // Iterate through tiles whose bounds + optional border intersect with |rect|. | 91 // Iterate through tiles whose bounds + optional border intersect with |rect|. |
| 92 class CC_EXPORT Iterator : public BaseIterator { | 92 class CC_EXPORT Iterator : public BaseIterator { |
| 93 public: | 93 public: |
| 94 Iterator(); | 94 Iterator(); |
| 95 Iterator(const TilingData* tiling_data, | 95 Iterator(const TilingData* tiling_data, |
| 96 const gfx::Rect& tiling_rect, | 96 const gfx::Rect& consider_rect, |
| 97 bool include_borders); | 97 bool include_borders); |
| 98 Iterator& operator++(); | 98 Iterator& operator++(); |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 int left_; | 101 int left_; |
| 102 int right_; | 102 int right_; |
| 103 int bottom_; | 103 int bottom_; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 // Iterate through all indices whose bounds + border intersect with | 106 // Iterate through all indices whose bounds + border intersect with |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void AssertTile(int i, int j) const { | 188 void AssertTile(int i, int j) const { |
| 189 DCHECK_GE(i, 0); | 189 DCHECK_GE(i, 0); |
| 190 DCHECK_LT(i, num_tiles_x_); | 190 DCHECK_LT(i, num_tiles_x_); |
| 191 DCHECK_GE(j, 0); | 191 DCHECK_GE(j, 0); |
| 192 DCHECK_LT(j, num_tiles_y_); | 192 DCHECK_LT(j, num_tiles_y_); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void RecomputeNumTiles(); | 195 void RecomputeNumTiles(); |
| 196 | 196 |
| 197 gfx::Size max_texture_size_; | 197 gfx::Size max_texture_size_; |
| 198 gfx::Rect tiling_rect_; | 198 gfx::Size tiling_size_; |
| 199 int border_texels_; | 199 int border_texels_; |
| 200 | 200 |
| 201 // These are computed values. | 201 // These are computed values. |
| 202 int num_tiles_x_; | 202 int num_tiles_x_; |
| 203 int num_tiles_y_; | 203 int num_tiles_y_; |
| 204 }; | 204 }; |
| 205 | 205 |
| 206 } // namespace cc | 206 } // namespace cc |
| 207 | 207 |
| 208 #endif // CC_BASE_TILING_DATA_H_ | 208 #endif // CC_BASE_TILING_DATA_H_ |
| OLD | NEW |