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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 // Even for really wide viewports, at some point GPU raster should use | 42 // Even for really wide viewports, at some point GPU raster should use |
43 // less than 4 tiles to fill the viewport. This is set to 256 as a | 43 // less than 4 tiles to fill the viewport. This is set to 256 as a |
44 // sane minimum for now, but we might want to tune this for low-end. | 44 // sane minimum for now, but we might want to tune this for low-end. |
45 const int kMinHeightForGpuRasteredTile = 256; | 45 const int kMinHeightForGpuRasteredTile = 256; |
46 | 46 |
47 // When making odd-sized tiles, round them up to increase the chances | 47 // When making odd-sized tiles, round them up to increase the chances |
48 // of using the same tile size. | 48 // of using the same tile size. |
49 const int kTileRoundUp = 64; | 49 const int kTileRoundUp = 64; |
50 | 50 |
51 // For performance reasons and to support compressed tile textures, tile | |
52 // width and height should be an even multiple of 4 in size. | |
53 const int kTileMinimalAlignment = 4; | |
54 | |
55 } // namespace | 51 } // namespace |
56 | 52 |
57 namespace cc { | 53 namespace cc { |
58 | 54 |
59 PictureLayerImpl::PictureLayerImpl( | 55 PictureLayerImpl::PictureLayerImpl( |
60 LayerTreeImpl* tree_impl, | 56 LayerTreeImpl* tree_impl, |
61 int id, | 57 int id, |
62 bool is_mask, | 58 bool is_mask, |
63 scoped_refptr<SyncedScrollOffset> scroll_offset) | 59 scoped_refptr<SyncedScrollOffset> scroll_offset) |
64 : LayerImpl(tree_impl, id, scroll_offset), | 60 : LayerImpl(tree_impl, id, scroll_offset), |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 tile_width = std::min(tile_width, content_bounds.width()); | 760 tile_width = std::min(tile_width, content_bounds.width()); |
765 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileRoundUp); | 761 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileRoundUp); |
766 tile_width = std::min(tile_width, default_tile_width); | 762 tile_width = std::min(tile_width, default_tile_width); |
767 } | 763 } |
768 if (content_bounds.height() < default_tile_height) { | 764 if (content_bounds.height() < default_tile_height) { |
769 tile_height = std::min(tile_height, content_bounds.height()); | 765 tile_height = std::min(tile_height, content_bounds.height()); |
770 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileRoundUp); | 766 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileRoundUp); |
771 tile_height = std::min(tile_height, default_tile_height); | 767 tile_height = std::min(tile_height, default_tile_height); |
772 } | 768 } |
773 | 769 |
774 // Ensure that tile width and height are properly aligned. | |
775 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileMinimalAlignment); | |
776 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileMinimalAlignment); | |
777 | |
778 // Under no circumstance should we be larger than the max texture size. | 770 // Under no circumstance should we be larger than the max texture size. |
779 tile_width = std::min(tile_width, max_texture_size); | 771 tile_width = std::min(tile_width, max_texture_size); |
780 tile_height = std::min(tile_height, max_texture_size); | 772 tile_height = std::min(tile_height, max_texture_size); |
781 return gfx::Size(tile_width, tile_height); | 773 return gfx::Size(tile_width, tile_height); |
782 } | 774 } |
783 | 775 |
784 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, | 776 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, |
785 gfx::Size* resource_size) const { | 777 gfx::Size* resource_size) const { |
786 // The bounds and the pile size may differ if the pile wasn't updated (ie. | 778 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
787 // PictureLayer::Update didn't happen). In that case the pile will be empty. | 779 // PictureLayer::Update didn't happen). In that case the pile will be empty. |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 | 1240 |
1249 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1241 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1250 return !layer_tree_impl()->IsRecycleTree(); | 1242 return !layer_tree_impl()->IsRecycleTree(); |
1251 } | 1243 } |
1252 | 1244 |
1253 bool PictureLayerImpl::HasValidTilePriorities() const { | 1245 bool PictureLayerImpl::HasValidTilePriorities() const { |
1254 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1246 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1255 } | 1247 } |
1256 | 1248 |
1257 } // namespace cc | 1249 } // namespace cc |
OLD | NEW |