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/eviction_tile_priority_queue.h" | 5 #include "cc/resources/eviction_tile_priority_queue.h" |
6 #include "cc/resources/raster_tile_priority_queue.h" | 6 #include "cc/resources/raster_tile_priority_queue.h" |
7 #include "cc/resources/tile.h" | 7 #include "cc/resources/tile.h" |
8 #include "cc/resources/tile_priority.h" | 8 #include "cc/resources/tile_priority.h" |
9 #include "cc/test/fake_impl_proxy.h" | 9 #include "cc/test/fake_impl_proxy.h" |
10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 state.num_resources_limit); | 513 state.num_resources_limit); |
514 host_impl_.tile_manager()->SetGlobalStateForTesting(state); | 514 host_impl_.tile_manager()->SetGlobalStateForTesting(state); |
515 } | 515 } |
516 | 516 |
517 virtual void SetUp() OVERRIDE { | 517 virtual void SetUp() OVERRIDE { |
518 InitializeRenderer(); | 518 InitializeRenderer(); |
519 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 519 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
520 } | 520 } |
521 | 521 |
522 virtual void InitializeRenderer() { | 522 virtual void InitializeRenderer() { |
523 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); | 523 host_impl_.InitializeRenderer( |
| 524 FakeOutputSurface::Create3d().PassAs<OutputSurface>()); |
524 } | 525 } |
525 | 526 |
526 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 527 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
527 gfx::Size tile_size(100, 100); | 528 gfx::Size tile_size(100, 100); |
528 | 529 |
529 scoped_refptr<FakePicturePileImpl> pending_pile = | 530 scoped_refptr<FakePicturePileImpl> pending_pile = |
530 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 531 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
531 scoped_refptr<FakePicturePileImpl> active_pile = | 532 scoped_refptr<FakePicturePileImpl> active_pile = |
532 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 533 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
533 | 534 |
(...skipping 24 matching lines...) Expand all Loading... |
558 | 559 |
559 void SetupPendingTree(scoped_refptr<PicturePileImpl> pile) { | 560 void SetupPendingTree(scoped_refptr<PicturePileImpl> pile) { |
560 host_impl_.CreatePendingTree(); | 561 host_impl_.CreatePendingTree(); |
561 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 562 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
562 // Clear recycled tree. | 563 // Clear recycled tree. |
563 pending_tree->DetachLayerTree(); | 564 pending_tree->DetachLayerTree(); |
564 | 565 |
565 scoped_ptr<FakePictureLayerImpl> pending_layer = | 566 scoped_ptr<FakePictureLayerImpl> pending_layer = |
566 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); | 567 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); |
567 pending_layer->SetDrawsContent(true); | 568 pending_layer->SetDrawsContent(true); |
568 pending_tree->SetRootLayer(pending_layer.Pass()); | 569 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); |
569 | 570 |
570 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 571 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
571 host_impl_.pending_tree()->LayerById(id_)); | 572 host_impl_.pending_tree()->LayerById(id_)); |
572 pending_layer_->DoPostCommitInitializationIfNeeded(); | 573 pending_layer_->DoPostCommitInitializationIfNeeded(); |
573 } | 574 } |
574 | 575 |
575 void CreateHighLowResAndSetAllTilesVisible() { | 576 void CreateHighLowResAndSetAllTilesVisible() { |
576 // Active layer must get updated first so pending layer can share from it. | 577 // Active layer must get updated first so pending layer can share from it. |
577 active_layer_->CreateDefaultTilingsAndTiles(); | 578 active_layer_->CreateDefaultTilingsAndTiles(); |
578 active_layer_->SetAllTilesVisible(); | 579 active_layer_->SetAllTilesVisible(); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 gfx::Size layer_bounds(1000, 1000); | 934 gfx::Size layer_bounds(1000, 1000); |
934 | 935 |
935 scoped_refptr<FakePicturePileImpl> pending_pile = | 936 scoped_refptr<FakePicturePileImpl> pending_pile = |
936 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 937 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
937 SetupPendingTree(pending_pile); | 938 SetupPendingTree(pending_pile); |
938 pending_layer_->CreateDefaultTilingsAndTiles(); | 939 pending_layer_->CreateDefaultTilingsAndTiles(); |
939 | 940 |
940 scoped_ptr<FakePictureLayerImpl> pending_child = | 941 scoped_ptr<FakePictureLayerImpl> pending_child = |
941 FakePictureLayerImpl::CreateWithPile( | 942 FakePictureLayerImpl::CreateWithPile( |
942 host_impl_.pending_tree(), 2, pending_pile); | 943 host_impl_.pending_tree(), 2, pending_pile); |
943 pending_layer_->AddChild(pending_child.Pass()); | 944 pending_layer_->AddChild(pending_child.PassAs<LayerImpl>()); |
944 | 945 |
945 FakePictureLayerImpl* pending_child_layer = | 946 FakePictureLayerImpl* pending_child_layer = |
946 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); | 947 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); |
947 pending_child_layer->SetDrawsContent(true); | 948 pending_child_layer->SetDrawsContent(true); |
948 pending_child_layer->DoPostCommitInitializationIfNeeded(); | 949 pending_child_layer->DoPostCommitInitializationIfNeeded(); |
949 pending_child_layer->CreateDefaultTilingsAndTiles(); | 950 pending_child_layer->CreateDefaultTilingsAndTiles(); |
950 | 951 |
951 std::set<Tile*> all_tiles; | 952 std::set<Tile*> all_tiles; |
952 size_t tile_count = 0; | 953 size_t tile_count = 0; |
953 RasterTilePriorityQueue raster_queue; | 954 RasterTilePriorityQueue raster_queue; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 EXPECT_EQ(tile_count, all_tiles.size()); | 1067 EXPECT_EQ(tile_count, all_tiles.size()); |
1067 EXPECT_EQ(17u, tile_count); | 1068 EXPECT_EQ(17u, tile_count); |
1068 | 1069 |
1069 queue.Reset(); | 1070 queue.Reset(); |
1070 for (int i = 1; i < 10; ++i) { | 1071 for (int i = 1; i < 10; ++i) { |
1071 scoped_ptr<FakePictureLayerImpl> pending_layer = | 1072 scoped_ptr<FakePictureLayerImpl> pending_layer = |
1072 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); | 1073 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); |
1073 pending_layer->SetDrawsContent(true); | 1074 pending_layer->SetDrawsContent(true); |
1074 pending_layer->DoPostCommitInitializationIfNeeded(); | 1075 pending_layer->DoPostCommitInitializationIfNeeded(); |
1075 pending_layer->set_has_valid_tile_priorities(true); | 1076 pending_layer->set_has_valid_tile_priorities(true); |
1076 pending_layer_->AddChild(pending_layer.Pass()); | 1077 pending_layer_->AddChild(pending_layer.PassAs<LayerImpl>()); |
1077 } | 1078 } |
1078 | 1079 |
1079 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); | 1080 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); |
1080 EXPECT_FALSE(queue.IsEmpty()); | 1081 EXPECT_FALSE(queue.IsEmpty()); |
1081 | 1082 |
1082 tile_count = 0; | 1083 tile_count = 0; |
1083 all_tiles.clear(); | 1084 all_tiles.clear(); |
1084 while (!queue.IsEmpty()) { | 1085 while (!queue.IsEmpty()) { |
1085 EXPECT_TRUE(queue.Top()); | 1086 EXPECT_TRUE(queue.Top()); |
1086 all_tiles.insert(queue.Top()); | 1087 all_tiles.insert(queue.Top()); |
(...skipping 28 matching lines...) Expand all Loading... |
1115 std::vector<Tile*> tiles(all_tiles.begin(), all_tiles.end()); | 1116 std::vector<Tile*> tiles(all_tiles.begin(), all_tiles.end()); |
1116 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 1117 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
1117 | 1118 |
1118 EvictionTilePriorityQueue queue; | 1119 EvictionTilePriorityQueue queue; |
1119 for (int i = 1; i < 10; ++i) { | 1120 for (int i = 1; i < 10; ++i) { |
1120 scoped_ptr<FakePictureLayerImpl> pending_layer = | 1121 scoped_ptr<FakePictureLayerImpl> pending_layer = |
1121 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); | 1122 FakePictureLayerImpl::Create(host_impl_.pending_tree(), id_ + i); |
1122 pending_layer->SetDrawsContent(true); | 1123 pending_layer->SetDrawsContent(true); |
1123 pending_layer->DoPostCommitInitializationIfNeeded(); | 1124 pending_layer->DoPostCommitInitializationIfNeeded(); |
1124 pending_layer->set_has_valid_tile_priorities(true); | 1125 pending_layer->set_has_valid_tile_priorities(true); |
1125 pending_layer_->AddChild(pending_layer.Pass()); | 1126 pending_layer_->AddChild(pending_layer.PassAs<LayerImpl>()); |
1126 } | 1127 } |
1127 | 1128 |
1128 host_impl_.BuildEvictionQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); | 1129 host_impl_.BuildEvictionQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); |
1129 EXPECT_FALSE(queue.IsEmpty()); | 1130 EXPECT_FALSE(queue.IsEmpty()); |
1130 | 1131 |
1131 tile_count = 0; | 1132 tile_count = 0; |
1132 all_tiles.clear(); | 1133 all_tiles.clear(); |
1133 while (!queue.IsEmpty()) { | 1134 while (!queue.IsEmpty()) { |
1134 EXPECT_TRUE(queue.Top()); | 1135 EXPECT_TRUE(queue.Top()); |
1135 all_tiles.insert(queue.Top()); | 1136 all_tiles.insert(queue.Top()); |
1136 ++tile_count; | 1137 ++tile_count; |
1137 queue.Pop(); | 1138 queue.Pop(); |
1138 } | 1139 } |
1139 EXPECT_EQ(tile_count, all_tiles.size()); | 1140 EXPECT_EQ(tile_count, all_tiles.size()); |
1140 EXPECT_EQ(17u, tile_count); | 1141 EXPECT_EQ(17u, tile_count); |
1141 } | 1142 } |
1142 | 1143 |
1143 } // namespace | 1144 } // namespace |
1144 } // namespace cc | 1145 } // namespace cc |
OLD | NEW |