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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 102 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
103 | 103 |
104 // Steal from the recycled tree. | 104 // Steal from the recycled tree. |
105 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); | 105 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); |
106 DCHECK_IMPLIES(old_pending_root, old_pending_root->id() == id_); | 106 DCHECK_IMPLIES(old_pending_root, old_pending_root->id() == id_); |
107 | 107 |
108 scoped_ptr<FakePictureLayerImpl> pending_layer; | 108 scoped_ptr<FakePictureLayerImpl> pending_layer; |
109 if (old_pending_root) { | 109 if (old_pending_root) { |
110 pending_layer.reset( | 110 pending_layer.reset( |
111 static_cast<FakePictureLayerImpl*>(old_pending_root.release())); | 111 static_cast<FakePictureLayerImpl*>(old_pending_root.release())); |
112 pending_layer->SetRasterSource(pile); | 112 pending_layer->SetRasterSourceOnPending(pile, Region(), false); |
113 } else { | 113 } else { |
114 pending_layer = | 114 pending_layer = FakePictureLayerImpl::CreateWithRasterSource( |
115 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, pile); | 115 pending_tree, id_, pile, false); |
116 pending_layer->SetDrawsContent(true); | 116 pending_layer->SetDrawsContent(true); |
117 } | 117 } |
118 // The bounds() just mirror the pile size. | 118 // The bounds() just mirror the pile size. |
119 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); | 119 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); |
120 pending_tree->SetRootLayer(pending_layer.Pass()); | 120 pending_tree->SetRootLayer(pending_layer.Pass()); |
121 | 121 |
122 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 122 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
123 host_impl_.pending_tree()->LayerById(id_)); | 123 host_impl_.pending_tree()->LayerById(id_)); |
124 pending_layer_->DoPostCommitInitializationIfNeeded(); | 124 pending_layer_->DoPostCommitInitializationIfNeeded(); |
125 } | 125 } |
126 | 126 |
127 void CreateHighLowResAndSetAllTilesVisible() { | |
128 // Active layer must get updated first so pending layer can share from it. | |
129 active_layer_->CreateDefaultTilingsAndTiles(); | |
130 active_layer_->SetAllTilesVisible(); | |
131 pending_layer_->CreateDefaultTilingsAndTiles(); | |
132 pending_layer_->SetAllTilesVisible(); | |
133 } | |
134 | |
135 TileManager* tile_manager() { return host_impl_.tile_manager(); } | 127 TileManager* tile_manager() { return host_impl_.tile_manager(); } |
136 | 128 |
137 protected: | 129 protected: |
138 GlobalStateThatImpactsTilePriority global_state_; | 130 GlobalStateThatImpactsTilePriority global_state_; |
139 | 131 |
140 TestSharedBitmapManager shared_bitmap_manager_; | 132 TestSharedBitmapManager shared_bitmap_manager_; |
141 TileMemoryLimitPolicy memory_limit_policy_; | 133 TileMemoryLimitPolicy memory_limit_policy_; |
142 int max_tiles_; | 134 int max_tiles_; |
143 bool ready_to_activate_; | 135 bool ready_to_activate_; |
144 int id_; | 136 int id_; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 SetupDefaultTrees(gfx::Size(1000, 1000)); | 329 SetupDefaultTrees(gfx::Size(1000, 1000)); |
338 | 330 |
339 active_layer_->CreateDefaultTilingsAndTiles(); | 331 active_layer_->CreateDefaultTilingsAndTiles(); |
340 pending_layer_->CreateDefaultTilingsAndTiles(); | 332 pending_layer_->CreateDefaultTilingsAndTiles(); |
341 | 333 |
342 // Create a pending child layer. | 334 // Create a pending child layer. |
343 gfx::Size tile_size(256, 256); | 335 gfx::Size tile_size(256, 256); |
344 scoped_refptr<FakePicturePileImpl> pending_pile = | 336 scoped_refptr<FakePicturePileImpl> pending_pile = |
345 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); | 337 FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 1000)); |
346 scoped_ptr<FakePictureLayerImpl> pending_child = | 338 scoped_ptr<FakePictureLayerImpl> pending_child = |
347 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), | 339 FakePictureLayerImpl::CreateWithRasterSource( |
348 id_ + 1, pending_pile); | 340 host_impl_.pending_tree(), id_ + 1, pending_pile, false); |
349 pending_layer_->AddChild(pending_child.Pass()); | 341 pending_layer_->AddChild(pending_child.Pass()); |
350 FakePictureLayerImpl* pending_child_raw = static_cast<FakePictureLayerImpl*>( | 342 FakePictureLayerImpl* pending_child_raw = static_cast<FakePictureLayerImpl*>( |
351 host_impl_.pending_tree()->LayerById(id_ + 1)); | 343 host_impl_.pending_tree()->LayerById(id_ + 1)); |
352 ASSERT_TRUE(pending_child_raw); | 344 ASSERT_TRUE(pending_child_raw); |
353 | 345 |
354 pending_child_raw->SetDrawsContent(true); | 346 pending_child_raw->SetDrawsContent(true); |
355 pending_child_raw->DoPostCommitInitializationIfNeeded(); | 347 pending_child_raw->DoPostCommitInitializationIfNeeded(); |
356 pending_child_raw->CreateDefaultTilingsAndTiles(); | 348 pending_child_raw->CreateDefaultTilingsAndTiles(); |
357 ASSERT_TRUE(pending_child_raw->HighResTiling()); | 349 ASSERT_TRUE(pending_child_raw->HighResTiling()); |
358 | 350 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 gfx::Size tile_size(102, 102); | 552 gfx::Size tile_size(102, 102); |
561 gfx::Size layer_bounds(1000, 1000); | 553 gfx::Size layer_bounds(1000, 1000); |
562 | 554 |
563 scoped_refptr<FakePicturePileImpl> pending_pile = | 555 scoped_refptr<FakePicturePileImpl> pending_pile = |
564 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 556 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
565 SetupPendingTree(pending_pile); | 557 SetupPendingTree(pending_pile); |
566 pending_layer_->CreateDefaultTilingsAndTiles(); | 558 pending_layer_->CreateDefaultTilingsAndTiles(); |
567 | 559 |
568 scoped_ptr<FakePictureLayerImpl> pending_child = | 560 scoped_ptr<FakePictureLayerImpl> pending_child = |
569 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, | 561 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, |
570 pending_pile); | 562 pending_pile, false); |
571 pending_layer_->AddChild(pending_child.Pass()); | 563 pending_layer_->AddChild(pending_child.Pass()); |
572 | 564 |
573 FakePictureLayerImpl* pending_child_layer = | 565 FakePictureLayerImpl* pending_child_layer = |
574 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); | 566 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); |
575 pending_child_layer->SetDrawsContent(true); | 567 pending_child_layer->SetDrawsContent(true); |
576 pending_child_layer->DoPostCommitInitializationIfNeeded(); | 568 pending_child_layer->DoPostCommitInitializationIfNeeded(); |
577 pending_child_layer->CreateDefaultTilingsAndTiles(); | 569 pending_child_layer->CreateDefaultTilingsAndTiles(); |
578 | 570 |
579 std::set<Tile*> all_tiles; | 571 std::set<Tile*> all_tiles; |
580 size_t tile_count = 0; | 572 size_t tile_count = 0; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 gfx::Size tile_size(102, 102); | 666 gfx::Size tile_size(102, 102); |
675 gfx::Size layer_bounds(1000, 1000); | 667 gfx::Size layer_bounds(1000, 1000); |
676 | 668 |
677 scoped_refptr<FakePicturePileImpl> pending_pile = | 669 scoped_refptr<FakePicturePileImpl> pending_pile = |
678 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 670 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
679 SetupPendingTree(pending_pile); | 671 SetupPendingTree(pending_pile); |
680 pending_layer_->CreateDefaultTilingsAndTiles(); | 672 pending_layer_->CreateDefaultTilingsAndTiles(); |
681 | 673 |
682 scoped_ptr<FakePictureLayerImpl> pending_child = | 674 scoped_ptr<FakePictureLayerImpl> pending_child = |
683 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, | 675 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, |
684 pending_pile); | 676 pending_pile, false); |
685 pending_layer_->AddChild(pending_child.Pass()); | 677 pending_layer_->AddChild(pending_child.Pass()); |
686 | 678 |
687 // Create a fully transparent child layer so that its tile priorities are not | 679 // Create a fully transparent child layer so that its tile priorities are not |
688 // considered to be valid. | 680 // considered to be valid. |
689 FakePictureLayerImpl* pending_child_layer = | 681 FakePictureLayerImpl* pending_child_layer = |
690 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); | 682 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); |
691 pending_child_layer->SetDrawsContent(true); | 683 pending_child_layer->SetDrawsContent(true); |
692 pending_child_layer->CreateDefaultTilingsAndTiles(); | 684 pending_child_layer->CreateDefaultTilingsAndTiles(); |
693 pending_child_layer->SetOpacity(0.0); | 685 pending_child_layer->SetOpacity(0.0); |
694 pending_child_layer->layer_tree_impl()->UpdateDrawProperties(); | 686 pending_child_layer->layer_tree_impl()->UpdateDrawProperties(); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 all_tiles.insert(queue.Top()); | 850 all_tiles.insert(queue.Top()); |
859 ++tile_count; | 851 ++tile_count; |
860 queue.Pop(); | 852 queue.Pop(); |
861 } | 853 } |
862 EXPECT_EQ(tile_count, all_tiles.size()); | 854 EXPECT_EQ(tile_count, all_tiles.size()); |
863 EXPECT_EQ(16u, tile_count); | 855 EXPECT_EQ(16u, tile_count); |
864 } | 856 } |
865 | 857 |
866 } // namespace | 858 } // namespace |
867 } // namespace cc | 859 } // namespace cc |
OLD | NEW |