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/resources/tile.h" | 5 #include "cc/resources/tile.h" |
6 #include "cc/resources/tile_priority.h" | 6 #include "cc/resources/tile_priority.h" |
7 #include "cc/test/fake_impl_proxy.h" | 7 #include "cc/test/fake_impl_proxy.h" |
8 #include "cc/test/fake_layer_tree_host_impl.h" | 8 #include "cc/test/fake_layer_tree_host_impl.h" |
9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
10 #include "cc/test/fake_output_surface_client.h" | 10 #include "cc/test/fake_output_surface_client.h" |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 tile->priority(PENDING_TREE).distance_to_visible); | 952 tile->priority(PENDING_TREE).distance_to_visible); |
953 } | 953 } |
954 | 954 |
955 last_tile = tile; | 955 last_tile = tile; |
956 new_content_tiles.insert(tile); | 956 new_content_tiles.insert(tile); |
957 } | 957 } |
958 | 958 |
959 EXPECT_EQ(tile_count, new_content_tiles.size()); | 959 EXPECT_EQ(tile_count, new_content_tiles.size()); |
960 EXPECT_EQ(all_tiles, new_content_tiles); | 960 EXPECT_EQ(all_tiles, new_content_tiles); |
961 } | 961 } |
| 962 |
| 963 TEST_F(TileManagerTileIteratorTest, EvictionTileIteratorWithOcclusion) { |
| 964 gfx::Size tile_size(102, 102); |
| 965 gfx::Size layer_bounds(1000, 1000); |
| 966 |
| 967 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 968 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 969 SetupPendingTree(pending_pile); |
| 970 pending_layer_->CreateDefaultTilingsAndTiles(); |
| 971 |
| 972 scoped_ptr<FakePictureLayerImpl> pending_child = |
| 973 FakePictureLayerImpl::CreateWithPile( |
| 974 host_impl_.pending_tree(), 2, pending_pile); |
| 975 pending_layer_->AddChild(pending_child.PassAs<LayerImpl>()); |
| 976 |
| 977 FakePictureLayerImpl* pending_child_layer = |
| 978 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); |
| 979 pending_child_layer->SetDrawsContent(true); |
| 980 pending_child_layer->DoPostCommitInitializationIfNeeded(); |
| 981 pending_child_layer->CreateDefaultTilingsAndTiles(); |
| 982 |
| 983 TileManager* tile_manager = TileManagerTileIteratorTest::tile_manager(); |
| 984 EXPECT_TRUE(tile_manager); |
| 985 |
| 986 std::vector<TileManager::PairedPictureLayer> paired_layers; |
| 987 tile_manager->GetPairedPictureLayers(&paired_layers); |
| 988 EXPECT_EQ(2u, paired_layers.size()); |
| 989 |
| 990 std::set<Tile*> all_tiles; |
| 991 size_t tile_count = 0; |
| 992 for (TileManager::RasterTileIterator raster_it(tile_manager, |
| 993 NEW_CONTENT_TAKES_PRIORITY); |
| 994 raster_it; |
| 995 ++raster_it) { |
| 996 ++tile_count; |
| 997 EXPECT_TRUE(*raster_it); |
| 998 all_tiles.insert(*raster_it); |
| 999 } |
| 1000 EXPECT_EQ(tile_count, all_tiles.size()); |
| 1001 EXPECT_EQ(34u, tile_count); |
| 1002 |
| 1003 pending_layer_->ResetAllTilesPriorities(); |
| 1004 |
| 1005 // Renew all of the tile priorities. |
| 1006 gfx::Rect viewport(layer_bounds); |
| 1007 pending_layer_->HighResTiling()->UpdateTilePriorities( |
| 1008 PENDING_TREE, |
| 1009 viewport, |
| 1010 1.0f, |
| 1011 1.0, |
| 1012 NULL, |
| 1013 pending_layer_->render_target(), |
| 1014 pending_layer_->draw_transform()); |
| 1015 pending_layer_->LowResTiling()->UpdateTilePriorities( |
| 1016 PENDING_TREE, |
| 1017 viewport, |
| 1018 1.0f, |
| 1019 1.0, |
| 1020 NULL, |
| 1021 pending_layer_->render_target(), |
| 1022 pending_layer_->draw_transform()); |
| 1023 pending_child_layer->HighResTiling()->UpdateTilePriorities( |
| 1024 PENDING_TREE, |
| 1025 viewport, |
| 1026 1.0f, |
| 1027 1.0, |
| 1028 NULL, |
| 1029 pending_child_layer->render_target(), |
| 1030 pending_child_layer->draw_transform()); |
| 1031 pending_child_layer->LowResTiling()->UpdateTilePriorities( |
| 1032 PENDING_TREE, |
| 1033 viewport, |
| 1034 1.0f, |
| 1035 1.0, |
| 1036 NULL, |
| 1037 pending_child_layer->render_target(), |
| 1038 pending_child_layer->draw_transform()); |
| 1039 |
| 1040 // Populate all tiles directly from the tilings. |
| 1041 all_tiles.clear(); |
| 1042 std::vector<Tile*> pending_high_res_tiles = |
| 1043 pending_layer_->HighResTiling()->AllTilesForTesting(); |
| 1044 for (size_t i = 0; i < pending_high_res_tiles.size(); ++i) |
| 1045 all_tiles.insert(pending_high_res_tiles[i]); |
| 1046 |
| 1047 std::vector<Tile*> pending_low_res_tiles = |
| 1048 pending_layer_->LowResTiling()->AllTilesForTesting(); |
| 1049 for (size_t i = 0; i < pending_low_res_tiles.size(); ++i) |
| 1050 all_tiles.insert(pending_low_res_tiles[i]); |
| 1051 |
| 1052 // Set all tiles on the pending_child_layer as occluded on the pending tree. |
| 1053 std::vector<Tile*> pending_child_high_res_tiles = |
| 1054 pending_child_layer->HighResTiling()->AllTilesForTesting(); |
| 1055 for (size_t i = 0; i < pending_child_high_res_tiles.size(); ++i) { |
| 1056 pending_child_high_res_tiles[i]->set_is_occluded(PENDING_TREE, true); |
| 1057 all_tiles.insert(pending_child_high_res_tiles[i]); |
| 1058 } |
| 1059 |
| 1060 std::vector<Tile*> pending_child_low_res_tiles = |
| 1061 pending_child_layer->LowResTiling()->AllTilesForTesting(); |
| 1062 for (size_t i = 0; i < pending_child_low_res_tiles.size(); ++i) { |
| 1063 pending_child_low_res_tiles[i]->set_is_occluded(PENDING_TREE, true); |
| 1064 all_tiles.insert(pending_child_low_res_tiles[i]); |
| 1065 } |
| 1066 |
| 1067 tile_manager->InitializeTilesWithResourcesForTesting( |
| 1068 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 1069 |
| 1070 // Verify occlusion is considered by EvictionTileIterator. |
| 1071 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; |
| 1072 size_t occluded_count = 0u; |
| 1073 Tile* last_tile = NULL; |
| 1074 for (TileManager::EvictionTileIterator it(tile_manager, tree_priority); it; |
| 1075 ++it) { |
| 1076 Tile* tile = *it; |
| 1077 if (!last_tile) |
| 1078 last_tile = tile; |
| 1079 |
| 1080 bool tile_is_occluded = tile->is_occluded_for_tree_priority(tree_priority); |
| 1081 |
| 1082 // The only way we will encounter an occluded tile after an unoccluded |
| 1083 // tile is if the priorty bin decreased, the tile is required for |
| 1084 // activation, or the scale changed. |
| 1085 if (tile_is_occluded) { |
| 1086 occluded_count++; |
| 1087 |
| 1088 bool last_tile_is_occluded = |
| 1089 last_tile->is_occluded_for_tree_priority(tree_priority); |
| 1090 if (!last_tile_is_occluded) { |
| 1091 TilePriority::PriorityBin tile_priority_bin = |
| 1092 tile->priority_for_tree_priority(tree_priority).priority_bin; |
| 1093 TilePriority::PriorityBin last_tile_priority_bin = |
| 1094 last_tile->priority_for_tree_priority(tree_priority).priority_bin; |
| 1095 |
| 1096 EXPECT_TRUE((tile_priority_bin < last_tile_priority_bin) || |
| 1097 tile->required_for_activation() || |
| 1098 (tile->contents_scale() != last_tile->contents_scale())); |
| 1099 } |
| 1100 } |
| 1101 last_tile = tile; |
| 1102 } |
| 1103 size_t expected_occluded_count = |
| 1104 pending_child_high_res_tiles.size() + pending_child_low_res_tiles.size(); |
| 1105 EXPECT_EQ(expected_occluded_count, occluded_count); |
| 1106 } |
962 } // namespace | 1107 } // namespace |
963 } // namespace cc | 1108 } // namespace cc |
OLD | NEW |