| 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 #include "cc/base/tiling_data.h" | 5 #include "cc/base/tiling_data.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ui/gfx/geometry/rect.h" | 9 #include "ui/gfx/geometry/rect.h" |
| 10 #include "ui/gfx/geometry/rect_f.h" |
| 10 #include "ui/gfx/geometry/vector2d.h" | 11 #include "ui/gfx/geometry/vector2d.h" |
| 11 | 12 |
| 12 namespace cc { | 13 namespace cc { |
| 13 | 14 |
| 14 static int ComputeNumTiles(int max_texture_size, | 15 static int ComputeNumTiles(int max_texture_size, |
| 15 int total_size, | 16 int total_size, |
| 16 int border_texels) { | 17 int border_texels) { |
| 17 if (max_texture_size - 2 * border_texels <= 0) | 18 if (max_texture_size - 2 * border_texels <= 0) |
| 18 return total_size > 0 && max_texture_size >= total_size ? 1 : 0; | 19 return total_size > 0 && max_texture_size >= total_size ? 1 : 0; |
| 19 | 20 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 return max_texture_size_.height() - border_texels_; | 273 return max_texture_size_.height() - border_texels_; |
| 273 if (y_index < num_tiles_y_ - 1) | 274 if (y_index < num_tiles_y_ - 1) |
| 274 return max_texture_size_.height() - 2 * border_texels_; | 275 return max_texture_size_.height() - 2 * border_texels_; |
| 275 if (y_index == num_tiles_y_ - 1) | 276 if (y_index == num_tiles_y_ - 1) |
| 276 return tiling_size_.height() - TilePositionY(y_index); | 277 return tiling_size_.height() - TilePositionY(y_index); |
| 277 | 278 |
| 278 NOTREACHED(); | 279 NOTREACHED(); |
| 279 return 0; | 280 return 0; |
| 280 } | 281 } |
| 281 | 282 |
| 283 gfx::RectF TilingData::TexelExtent(int i, int j) const { |
| 284 gfx::RectF result(TileBoundsWithBorder(i, j)); |
| 285 result.Inset(0.5f, 0.5f); |
| 286 return result; |
| 287 } |
| 288 |
| 282 gfx::Vector2d TilingData::TextureOffset(int x_index, int y_index) const { | 289 gfx::Vector2d TilingData::TextureOffset(int x_index, int y_index) const { |
| 283 int left = (!x_index || num_tiles_x_ == 1) ? 0 : border_texels_; | 290 int left = (!x_index || num_tiles_x_ == 1) ? 0 : border_texels_; |
| 284 int top = (!y_index || num_tiles_y_ == 1) ? 0 : border_texels_; | 291 int top = (!y_index || num_tiles_y_ == 1) ? 0 : border_texels_; |
| 285 | 292 |
| 286 return gfx::Vector2d(left, top); | 293 return gfx::Vector2d(left, top); |
| 287 } | 294 } |
| 288 | 295 |
| 289 void TilingData::RecomputeNumTiles() { | 296 void TilingData::RecomputeNumTiles() { |
| 290 num_tiles_x_ = ComputeNumTiles( | 297 num_tiles_x_ = ComputeNumTiles( |
| 291 max_texture_size_.width(), tiling_size_.width(), border_texels_); | 298 max_texture_size_.width(), tiling_size_.width(), border_texels_); |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 | 865 |
| 859 // We should always end up in an around rect at some point. | 866 // We should always end up in an around rect at some point. |
| 860 // Since the direction is now vertical, we have to ensure that we will | 867 // Since the direction is now vertical, we have to ensure that we will |
| 861 // advance. | 868 // advance. |
| 862 DCHECK_GE(horizontal_step_count_, 1); | 869 DCHECK_GE(horizontal_step_count_, 1); |
| 863 DCHECK_GE(vertical_step_count_, 1); | 870 DCHECK_GE(vertical_step_count_, 1); |
| 864 } | 871 } |
| 865 } | 872 } |
| 866 | 873 |
| 867 } // namespace cc | 874 } // namespace cc |
| OLD | NEW |