Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: cc/resources/tile_manager_unittest.cc

Issue 377793003: Consider occluded tiles during eviction with occluded as Tile property. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add TileManager unit test Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« cc/resources/tile_manager.cc ('K') | « cc/resources/tile_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 tile->priority(PENDING_TREE).distance_to_visible); 948 tile->priority(PENDING_TREE).distance_to_visible);
949 } 949 }
950 950
951 last_tile = tile; 951 last_tile = tile;
952 new_content_tiles.insert(tile); 952 new_content_tiles.insert(tile);
953 } 953 }
954 954
955 EXPECT_EQ(tile_count, new_content_tiles.size()); 955 EXPECT_EQ(tile_count, new_content_tiles.size());
956 EXPECT_EQ(all_tiles, new_content_tiles); 956 EXPECT_EQ(all_tiles, new_content_tiles);
957 } 957 }
958
959 TEST_F(TileManagerTileIteratorTest, EvictionTileIteratorWithOcclusion) {
960 gfx::Size tile_size(102, 102);
961 gfx::Size layer_bounds(1000, 1000);
962
963 scoped_refptr<FakePicturePileImpl> pending_pile =
964 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
965 SetupPendingTree(pending_pile);
966 pending_layer_->CreateDefaultTilingsAndTiles();
967
968 scoped_ptr<FakePictureLayerImpl> pending_child =
969 FakePictureLayerImpl::CreateWithPile(
970 host_impl_.pending_tree(), 2, pending_pile);
971 pending_layer_->AddChild(pending_child.PassAs<LayerImpl>());
972
973 FakePictureLayerImpl* pending_child_layer =
974 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]);
975 pending_child_layer->SetDrawsContent(true);
976 pending_child_layer->DoPostCommitInitializationIfNeeded();
977 pending_child_layer->CreateDefaultTilingsAndTiles();
978
979 TileManager* tile_manager = TileManagerTileIteratorTest::tile_manager();
980 EXPECT_TRUE(tile_manager);
981
982 std::vector<TileManager::PairedPictureLayer> paired_layers;
983 tile_manager->GetPairedPictureLayers(&paired_layers);
984 EXPECT_EQ(2u, paired_layers.size());
985
986 std::set<Tile*> all_tiles;
987 size_t tile_count = 0;
988 for (TileManager::RasterTileIterator raster_it(tile_manager,
989 NEW_CONTENT_TAKES_PRIORITY);
990 raster_it;
991 ++raster_it) {
992 ++tile_count;
993 EXPECT_TRUE(*raster_it);
994 all_tiles.insert(*raster_it);
995 }
996 EXPECT_EQ(tile_count, all_tiles.size());
997 EXPECT_EQ(34u, tile_count);
998
999 pending_layer_->ResetAllTilesPriorities();
1000
1001 // Renew all of the tile priorities.
1002 gfx::Rect viewport(layer_bounds);
1003 pending_layer_->HighResTiling()->UpdateTilePriorities(
1004 PENDING_TREE,
1005 viewport,
1006 1.0f,
1007 1.0,
1008 NULL,
1009 pending_layer_->render_target(),
1010 pending_layer_->draw_transform());
1011 pending_layer_->LowResTiling()->UpdateTilePriorities(
1012 PENDING_TREE,
1013 viewport,
1014 1.0f,
1015 1.0,
1016 NULL,
1017 pending_layer_->render_target(),
1018 pending_layer_->draw_transform());
1019 pending_child_layer->HighResTiling()->UpdateTilePriorities(
1020 PENDING_TREE,
1021 viewport,
1022 1.0f,
1023 1.0,
1024 NULL,
1025 pending_child_layer->render_target(),
1026 pending_child_layer->draw_transform());
1027 pending_child_layer->LowResTiling()->UpdateTilePriorities(
1028 PENDING_TREE,
1029 viewport,
1030 1.0f,
1031 1.0,
1032 NULL,
1033 pending_child_layer->render_target(),
1034 pending_child_layer->draw_transform());
1035
1036 // Populate all tiles directly from the tilings.
1037 all_tiles.clear();
1038 std::vector<Tile*> pending_high_res_tiles =
1039 pending_layer_->HighResTiling()->AllTilesForTesting();
1040 for (size_t i = 0; i < pending_high_res_tiles.size(); ++i)
1041 all_tiles.insert(pending_high_res_tiles[i]);
1042
1043 std::vector<Tile*> pending_low_res_tiles =
1044 pending_layer_->LowResTiling()->AllTilesForTesting();
1045 for (size_t i = 0; i < pending_low_res_tiles.size(); ++i)
1046 all_tiles.insert(pending_low_res_tiles[i]);
1047
1048 // Set all tiles on the pending_child_layer as occluded on the pending tree.
1049 std::vector<Tile*> pending_child_high_res_tiles =
1050 pending_child_layer->HighResTiling()->AllTilesForTesting();
1051 for (size_t i = 0; i < pending_child_high_res_tiles.size(); ++i) {
1052 pending_child_high_res_tiles[i]->set_is_occluded(PENDING_TREE, true);
1053 all_tiles.insert(pending_child_high_res_tiles[i]);
1054 }
1055
1056 std::vector<Tile*> pending_child_low_res_tiles =
1057 pending_child_layer->LowResTiling()->AllTilesForTesting();
1058 for (size_t i = 0; i < pending_child_low_res_tiles.size(); ++i) {
1059 pending_child_low_res_tiles[i]->set_is_occluded(PENDING_TREE, true);
1060 all_tiles.insert(pending_child_low_res_tiles[i]);
1061 }
1062
1063 tile_manager->InitializeTilesWithResourcesForTesting(
1064 std::vector<Tile*>(all_tiles.begin(), all_tiles.end()));
1065
1066 // Verify occlusion is considered by EvictionTileIterator.
1067 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY;
vmpstr 2014/07/14 18:42:20 From my understanding, this mode would normally fo
jbedley 2014/07/14 19:31:33 By using NEW_CONTENT_TAKES_PRIORITY, only the pend
vmpstr 2014/07/14 19:33:13 Awesome, thanks.
danakj 2014/07/15 21:26:51 What happens for unshared tiles in the SAME_PRIORI
jbedley 2014/07/16 16:09:31 That is correct. Unshared tiles will be considered
danakj 2014/07/16 22:30:47 Hm, I think there's 2 problems with this SAME_PRIO
1068 size_t occluded_count = 0u;
1069 Tile* last_tile = NULL;
1070 for (TileManager::EvictionTileIterator it(tile_manager, tree_priority); it;
1071 ++it) {
1072 Tile* tile = *it;
1073 if (!last_tile)
1074 last_tile = tile;
1075
1076 bool tile_is_occluded = tile->is_occluded_for_tree_priority(tree_priority);
1077
1078 // The only way we will encounter an occluded tile after an unoccluded
1079 // tile is if the priorty bin decreased, the tile is required for
1080 // activation, or the scale changed.
1081 if (tile_is_occluded) {
1082 occluded_count++;
1083
1084 bool last_tile_is_occluded =
1085 last_tile->is_occluded_for_tree_priority(tree_priority);
1086 if (!last_tile_is_occluded) {
1087 TilePriority::PriorityBin tile_priority_bin =
1088 tile->priority_for_tree_priority(tree_priority).priority_bin;
1089 TilePriority::PriorityBin last_tile_priority_bin =
1090 last_tile->priority_for_tree_priority(tree_priority).priority_bin;
1091
1092 EXPECT_TRUE((tile_priority_bin < last_tile_priority_bin) ||
1093 tile->required_for_activation() ||
1094 (tile->contents_scale() != last_tile->contents_scale()));
1095 }
1096 }
1097 last_tile = tile;
1098 }
1099 size_t expected_occluded_count =
1100 pending_child_high_res_tiles.size() + pending_child_low_res_tiles.size();
1101 EXPECT_EQ(expected_occluded_count, occluded_count);
1102 }
958 } // namespace 1103 } // namespace
959 } // namespace cc 1104 } // namespace cc
OLDNEW
« cc/resources/tile_manager.cc ('K') | « cc/resources/tile_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698