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 | |
51 } // namespace | 55 } // namespace |
52 | 56 |
53 namespace cc { | 57 namespace cc { |
54 | 58 |
55 PictureLayerImpl::PictureLayerImpl( | 59 PictureLayerImpl::PictureLayerImpl( |
56 LayerTreeImpl* tree_impl, | 60 LayerTreeImpl* tree_impl, |
57 int id, | 61 int id, |
58 bool is_mask, | 62 bool is_mask, |
59 scoped_refptr<SyncedScrollOffset> scroll_offset) | 63 scoped_refptr<SyncedScrollOffset> scroll_offset) |
60 : LayerImpl(tree_impl, id, scroll_offset), | 64 : LayerImpl(tree_impl, id, scroll_offset), |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
760 tile_width = std::min(tile_width, content_bounds.width()); | 764 tile_width = std::min(tile_width, content_bounds.width()); |
761 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileRoundUp); | 765 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileRoundUp); |
762 tile_width = std::min(tile_width, default_tile_width); | 766 tile_width = std::min(tile_width, default_tile_width); |
763 } | 767 } |
764 if (content_bounds.height() < default_tile_height) { | 768 if (content_bounds.height() < default_tile_height) { |
765 tile_height = std::min(tile_height, content_bounds.height()); | 769 tile_height = std::min(tile_height, content_bounds.height()); |
766 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileRoundUp); | 770 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileRoundUp); |
767 tile_height = std::min(tile_height, default_tile_height); | 771 tile_height = std::min(tile_height, default_tile_height); |
768 } | 772 } |
769 | 773 |
774 // Ensure that tile width and height are properly aligned. | |
775 if (tile_width % kTileMinimalAlignment != 0 || | |
776 tile_height % kTileMinimalAlignment != 0) { | |
reveman
2015/12/02 18:27:18
nit: remove these checks and execute UncheckedRoun
christiank
2015/12/03 12:57:59
Done.
| |
777 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileMinimalAlignment); | |
778 tile_height = | |
779 MathUtil::UncheckedRoundUp(tile_height, kTileMinimalAlignment); | |
780 } | |
781 | |
770 // Under no circumstance should we be larger than the max texture size. | 782 // Under no circumstance should we be larger than the max texture size. |
771 tile_width = std::min(tile_width, max_texture_size); | 783 tile_width = std::min(tile_width, max_texture_size); |
772 tile_height = std::min(tile_height, max_texture_size); | 784 tile_height = std::min(tile_height, max_texture_size); |
773 return gfx::Size(tile_width, tile_height); | 785 return gfx::Size(tile_width, tile_height); |
774 } | 786 } |
775 | 787 |
776 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, | 788 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, |
777 gfx::Size* resource_size) const { | 789 gfx::Size* resource_size) const { |
778 // The bounds and the pile size may differ if the pile wasn't updated (ie. | 790 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
779 // PictureLayer::Update didn't happen). In that case the pile will be empty. | 791 // 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... | |
1240 | 1252 |
1241 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1253 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1242 return !layer_tree_impl()->IsRecycleTree(); | 1254 return !layer_tree_impl()->IsRecycleTree(); |
1243 } | 1255 } |
1244 | 1256 |
1245 bool PictureLayerImpl::HasValidTilePriorities() const { | 1257 bool PictureLayerImpl::HasValidTilePriorities() const { |
1246 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1258 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1247 } | 1259 } |
1248 | 1260 |
1249 } // namespace cc | 1261 } // namespace cc |
OLD | NEW |