| 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/rect.h" | 9 #include "ui/gfx/rect.h" |
| 10 #include "ui/gfx/vector2d.h" | 10 #include "ui/gfx/vector2d.h" |
| 11 | 11 |
| 12 namespace cc { | 12 namespace cc { |
| 13 | 13 |
| 14 static int ComputeNumTiles(int max_texture_size, int total_size, int border_texe
ls) { | 14 static int ComputeNumTiles(int max_texture_size, |
| 15 int total_size, |
| 16 int border_texels) { |
| 15 if (max_texture_size - 2 * border_texels <= 0) | 17 if (max_texture_size - 2 * border_texels <= 0) |
| 16 return total_size > 0 && max_texture_size >= total_size ? 1 : 0; | 18 return total_size > 0 && max_texture_size >= total_size ? 1 : 0; |
| 17 | 19 |
| 18 int num_tiles = std::max(1, 1 + (total_size - 1 - 2 * border_texels) / (max_te
xture_size - 2 * border_texels)); | 20 int num_tiles = std::max(1, |
| 21 1 + (total_size - 1 - 2 * border_texels) / |
| 22 (max_texture_size - 2 * border_texels)); |
| 19 return total_size > 0 ? num_tiles : 0; | 23 return total_size > 0 ? num_tiles : 0; |
| 20 } | 24 } |
| 21 | 25 |
| 22 TilingData::TilingData() | 26 TilingData::TilingData() |
| 23 : border_texels_(0) { | 27 : border_texels_(0) { |
| 24 RecomputeNumTiles(); | 28 RecomputeNumTiles(); |
| 25 } | 29 } |
| 26 | 30 |
| 27 TilingData::TilingData( | 31 TilingData::TilingData( |
| 28 gfx::Size max_texture_size, | 32 gfx::Size max_texture_size, |
| 29 gfx::Size total_size, | 33 gfx::Size total_size, |
| 30 bool hasBorderTexels) | 34 bool has_border_texels) |
| 31 : max_texture_size_(max_texture_size), | 35 : max_texture_size_(max_texture_size), |
| 32 total_size_(total_size), | 36 total_size_(total_size), |
| 33 border_texels_(hasBorderTexels ? 1 : 0) { | 37 border_texels_(has_border_texels ? 1 : 0) { |
| 34 RecomputeNumTiles(); | 38 RecomputeNumTiles(); |
| 35 } | 39 } |
| 36 | 40 |
| 37 TilingData::TilingData( | 41 TilingData::TilingData( |
| 38 gfx::Size max_texture_size, | 42 gfx::Size max_texture_size, |
| 39 gfx::Size total_size, | 43 gfx::Size total_size, |
| 40 int border_texels) | 44 int border_texels) |
| 41 : max_texture_size_(max_texture_size), | 45 : max_texture_size_(max_texture_size), |
| 42 total_size_(total_size), | 46 total_size_(total_size), |
| 43 border_texels_(border_texels) { | 47 border_texels_(border_texels) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 } | 393 } |
| 390 | 394 |
| 391 if (index_y_ > consider_bottom_) | 395 if (index_y_ > consider_bottom_) |
| 392 done(); | 396 done(); |
| 393 } | 397 } |
| 394 | 398 |
| 395 return *this; | 399 return *this; |
| 396 } | 400 } |
| 397 | 401 |
| 398 } // namespace cc | 402 } // namespace cc |
| OLD | NEW |