OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "cc/layers/append_quads_data.h" | 9 #include "cc/layers/append_quads_data.h" |
10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 | 818 |
819 SetupPendingTree(pending_pile); | 819 SetupPendingTree(pending_pile); |
820 | 820 |
821 ASSERT_TRUE(pending_layer_->CanHaveTilings()); | 821 ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
822 pending_layer_->AddTiling(1.0f); | 822 pending_layer_->AddTiling(1.0f); |
823 pending_layer_->AddTiling(2.0f); | 823 pending_layer_->AddTiling(2.0f); |
824 | 824 |
825 // It should be safe to call this (and MarkVisibleResourcesAsRequired) | 825 // It should be safe to call this (and MarkVisibleResourcesAsRequired) |
826 // on a layer with no recordings. | 826 // on a layer with no recordings. |
827 host_impl_.pending_tree()->UpdateDrawProperties(); | 827 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 828 pending_layer_->MarkVisibleResourcesAsRequired(); |
| 829 } |
| 830 |
| 831 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) { |
| 832 gfx::Size tile_size(100, 100); |
| 833 gfx::Size layer_bounds(200, 100); |
| 834 |
| 835 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 836 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 837 SetupPendingTree(pending_pile); |
| 838 |
| 839 pending_layer_->set_fixed_tile_size(tile_size); |
| 840 ASSERT_TRUE(pending_layer_->CanHaveTilings()); |
| 841 PictureLayerTiling* tiling = pending_layer_->AddTiling(1.f); |
| 842 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 843 EXPECT_EQ(tiling->resolution(), HIGH_RESOLUTION); |
| 844 |
| 845 // Fake set priorities. |
| 846 int tile_count = 0; |
| 847 for (PictureLayerTiling::CoverageIterator iter( |
| 848 tiling, |
| 849 pending_layer_->contents_scale_x(), |
| 850 gfx::Rect(pending_layer_->visible_content_rect())); |
| 851 iter; |
| 852 ++iter) { |
| 853 if (!*iter) |
| 854 continue; |
| 855 Tile* tile = *iter; |
| 856 TilePriority priority; |
| 857 priority.resolution = HIGH_RESOLUTION; |
| 858 if (++tile_count % 2) { |
| 859 priority.time_to_visible_in_seconds = 0.f; |
| 860 priority.distance_to_visible_in_pixels = 0.f; |
| 861 } else { |
| 862 priority.time_to_visible_in_seconds = 1.f; |
| 863 priority.distance_to_visible_in_pixels = 1.f; |
| 864 } |
| 865 tile->SetPriority(PENDING_TREE, priority); |
| 866 } |
| 867 |
| 868 pending_layer_->MarkVisibleResourcesAsRequired(); |
| 869 |
| 870 int num_visible = 0; |
| 871 int num_offscreen = 0; |
| 872 |
| 873 for (PictureLayerTiling::CoverageIterator iter( |
| 874 tiling, |
| 875 pending_layer_->contents_scale_x(), |
| 876 gfx::Rect(pending_layer_->visible_content_rect())); |
| 877 iter; |
| 878 ++iter) { |
| 879 if (!*iter) |
| 880 continue; |
| 881 const Tile* tile = *iter; |
| 882 if (tile->priority(PENDING_TREE).distance_to_visible_in_pixels == 0.f) { |
| 883 EXPECT_TRUE(tile->required_for_activation()); |
| 884 num_visible++; |
| 885 } else { |
| 886 EXPECT_FALSE(tile->required_for_activation()); |
| 887 num_offscreen++; |
| 888 } |
| 889 } |
| 890 |
| 891 EXPECT_GT(num_visible, 0); |
| 892 EXPECT_GT(num_offscreen, 0); |
828 } | 893 } |
829 | 894 |
830 } // namespace | 895 } // namespace |
831 } // namespace cc | 896 } // namespace cc |
OLD | NEW |