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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // Even for really wide viewports, at some point GPU raster should use | 46 // Even for really wide viewports, at some point GPU raster should use |
47 // less than 4 tiles to fill the viewport. This is set to 256 as a | 47 // less than 4 tiles to fill the viewport. This is set to 256 as a |
48 // sane minimum for now, but we might want to tune this for low-end. | 48 // sane minimum for now, but we might want to tune this for low-end. |
49 const int kMinHeightForGpuRasteredTile = 256; | 49 const int kMinHeightForGpuRasteredTile = 256; |
50 | 50 |
51 // When making odd-sized tiles, round them up to increase the chances | 51 // When making odd-sized tiles, round them up to increase the chances |
52 // of using the same tile size. | 52 // of using the same tile size. |
53 const int kTileRoundUp = 64; | 53 const int kTileRoundUp = 64; |
54 | 54 |
| 55 // For performance reasons and to support compressed tile textures, tile |
| 56 // width and height should be an even multiple of 4 in size. |
| 57 const int kTileMinimalAlignment = 4; |
| 58 |
55 } // namespace | 59 } // namespace |
56 | 60 |
57 namespace cc { | 61 namespace cc { |
58 | 62 |
59 PictureLayerImpl::PictureLayerImpl( | 63 PictureLayerImpl::PictureLayerImpl( |
60 LayerTreeImpl* tree_impl, | 64 LayerTreeImpl* tree_impl, |
61 int id, | 65 int id, |
62 bool is_mask, | 66 bool is_mask, |
63 scoped_refptr<SyncedScrollOffset> scroll_offset) | 67 scoped_refptr<SyncedScrollOffset> scroll_offset) |
64 : LayerImpl(tree_impl, id, scroll_offset), | 68 : LayerImpl(tree_impl, id, scroll_offset), |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 tile_width = std::min(tile_width, content_bounds.width()); | 778 tile_width = std::min(tile_width, content_bounds.width()); |
775 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileRoundUp); | 779 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileRoundUp); |
776 tile_width = std::min(tile_width, default_tile_width); | 780 tile_width = std::min(tile_width, default_tile_width); |
777 } | 781 } |
778 if (content_bounds.height() < default_tile_height) { | 782 if (content_bounds.height() < default_tile_height) { |
779 tile_height = std::min(tile_height, content_bounds.height()); | 783 tile_height = std::min(tile_height, content_bounds.height()); |
780 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileRoundUp); | 784 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileRoundUp); |
781 tile_height = std::min(tile_height, default_tile_height); | 785 tile_height = std::min(tile_height, default_tile_height); |
782 } | 786 } |
783 | 787 |
| 788 // Ensure that tile width and height are properly aligned. |
| 789 tile_width = MathUtil::UncheckedRoundUp(tile_width, kTileMinimalAlignment); |
| 790 tile_height = MathUtil::UncheckedRoundUp(tile_height, kTileMinimalAlignment); |
| 791 |
784 // Under no circumstance should we be larger than the max texture size. | 792 // Under no circumstance should we be larger than the max texture size. |
785 tile_width = std::min(tile_width, max_texture_size); | 793 tile_width = std::min(tile_width, max_texture_size); |
786 tile_height = std::min(tile_height, max_texture_size); | 794 tile_height = std::min(tile_height, max_texture_size); |
787 return gfx::Size(tile_width, tile_height); | 795 return gfx::Size(tile_width, tile_height); |
788 } | 796 } |
789 | 797 |
790 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, | 798 void PictureLayerImpl::GetContentsResourceId(ResourceId* resource_id, |
791 gfx::Size* resource_size) const { | 799 gfx::Size* resource_size) const { |
792 // The bounds and the pile size may differ if the pile wasn't updated (ie. | 800 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
793 // PictureLayer::Update didn't happen). In that case the pile will be empty. | 801 // PictureLayer::Update didn't happen). In that case the pile will be empty. |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 | 1264 |
1257 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1265 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1258 return !layer_tree_impl()->IsRecycleTree(); | 1266 return !layer_tree_impl()->IsRecycleTree(); |
1259 } | 1267 } |
1260 | 1268 |
1261 bool PictureLayerImpl::HasValidTilePriorities() const { | 1269 bool PictureLayerImpl::HasValidTilePriorities() const { |
1262 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1270 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1263 } | 1271 } |
1264 | 1272 |
1265 } // namespace cc | 1273 } // namespace cc |
OLD | NEW |