OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 int viewport_height = gpu_raster_max_texture_size_.height(); | 695 int viewport_height = gpu_raster_max_texture_size_.height(); |
696 default_tile_width = viewport_width; | 696 default_tile_width = viewport_width; |
697 | 697 |
698 // Also, increase the height proportionally as the width decreases, and | 698 // Also, increase the height proportionally as the width decreases, and |
699 // pad by our border texels to make the tiles exactly match the viewport. | 699 // pad by our border texels to make the tiles exactly match the viewport. |
700 int divisor = 4; | 700 int divisor = 4; |
701 if (content_bounds.width() <= viewport_width / 2) | 701 if (content_bounds.width() <= viewport_width / 2) |
702 divisor = 2; | 702 divisor = 2; |
703 if (content_bounds.width() <= viewport_width / 4) | 703 if (content_bounds.width() <= viewport_width / 4) |
704 divisor = 1; | 704 divisor = 1; |
705 default_tile_height = MathUtil::RoundUp(viewport_height, divisor) / divisor; | 705 default_tile_height = |
| 706 MathUtil::UncheckedRoundUp(viewport_height, divisor) / divisor; |
706 | 707 |
707 // Grow default sizes to account for overlapping border texels. | 708 // Grow default sizes to account for overlapping border texels. |
708 default_tile_width += 2 * PictureLayerTiling::kBorderTexels; | 709 default_tile_width += 2 * PictureLayerTiling::kBorderTexels; |
709 default_tile_height += 2 * PictureLayerTiling::kBorderTexels; | 710 default_tile_height += 2 * PictureLayerTiling::kBorderTexels; |
710 | 711 |
711 default_tile_height = | 712 default_tile_height = |
712 std::max(default_tile_height, kMinHeightForGpuRasteredTile); | 713 std::max(default_tile_height, kMinHeightForGpuRasteredTile); |
713 } else { | 714 } else { |
714 // For CPU rasterization we use tile-size settings. | 715 // For CPU rasterization we use tile-size settings. |
715 const LayerTreeSettings& settings = layer_tree_impl()->settings(); | 716 const LayerTreeSettings& settings = layer_tree_impl()->settings(); |
(...skipping 15 matching lines...) Expand all Loading... |
731 default_tile_width = max_untiled_content_width; | 732 default_tile_width = max_untiled_content_width; |
732 } | 733 } |
733 } | 734 } |
734 | 735 |
735 int tile_width = default_tile_width; | 736 int tile_width = default_tile_width; |
736 int tile_height = default_tile_height; | 737 int tile_height = default_tile_height; |
737 | 738 |
738 // Clamp the tile width/height to the content width/height to save space. | 739 // Clamp the tile width/height to the content width/height to save space. |
739 if (content_bounds.width() < default_tile_width) { | 740 if (content_bounds.width() < default_tile_width) { |
740 tile_width = std::min(tile_width, content_bounds.width()); | 741 tile_width = std::min(tile_width, content_bounds.width()); |
741 tile_width = MathUtil::RoundUp(tile_width, kTileRoundUp); | 742 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileRoundUp); |
742 tile_width = std::min(tile_width, default_tile_width); | 743 tile_width = std::min(tile_width, default_tile_width); |
743 } | 744 } |
744 if (content_bounds.height() < default_tile_height) { | 745 if (content_bounds.height() < default_tile_height) { |
745 tile_height = std::min(tile_height, content_bounds.height()); | 746 tile_height = std::min(tile_height, content_bounds.height()); |
746 tile_height = MathUtil::RoundUp(tile_height, kTileRoundUp); | 747 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileRoundUp); |
747 tile_height = std::min(tile_height, default_tile_height); | 748 tile_height = std::min(tile_height, default_tile_height); |
748 } | 749 } |
749 | 750 |
750 // Under no circumstance should we be larger than the max texture size. | 751 // Under no circumstance should we be larger than the max texture size. |
751 tile_width = std::min(tile_width, max_texture_size); | 752 tile_width = std::min(tile_width, max_texture_size); |
752 tile_height = std::min(tile_height, max_texture_size); | 753 tile_height = std::min(tile_height, max_texture_size); |
753 return gfx::Size(tile_width, tile_height); | 754 return gfx::Size(tile_width, tile_height); |
754 } | 755 } |
755 | 756 |
756 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, | 757 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 | 1227 |
1227 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1228 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1228 return !layer_tree_impl()->IsRecycleTree(); | 1229 return !layer_tree_impl()->IsRecycleTree(); |
1229 } | 1230 } |
1230 | 1231 |
1231 bool PictureLayerImpl::HasValidTilePriorities() const { | 1232 bool PictureLayerImpl::HasValidTilePriorities() const { |
1232 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1233 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1233 } | 1234 } |
1234 | 1235 |
1235 } // namespace cc | 1236 } // namespace cc |
OLD | NEW |