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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 void SetupTrees(scoped_refptr<PicturePileImpl> pending_pile, | 93 void SetupTrees(scoped_refptr<PicturePileImpl> pending_pile, |
94 scoped_refptr<PicturePileImpl> active_pile) { | 94 scoped_refptr<PicturePileImpl> active_pile) { |
95 SetupPendingTree(active_pile); | 95 SetupPendingTree(active_pile); |
96 ActivateTree(); | 96 ActivateTree(); |
97 SetupPendingTree(pending_pile); | 97 SetupPendingTree(pending_pile); |
98 } | 98 } |
99 | 99 |
100 void SetupPendingTree(scoped_refptr<PicturePileImpl> pile) { | 100 void SetupPendingTree(scoped_refptr<PicturePileImpl> pile) { |
101 host_impl_.CreatePendingTree(); | 101 host_impl_.CreatePendingTree(); |
102 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 102 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 103 // Clear recycled tree. |
| 104 pending_tree->DetachLayerTree(); |
103 | 105 |
104 // Steal from the recycled tree. | 106 scoped_ptr<FakePictureLayerImpl> pending_layer = |
105 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); | 107 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); |
106 DCHECK_IMPLIES(old_pending_root, old_pending_root->id() == id_); | 108 pending_layer->SetDrawsContent(true); |
107 | |
108 scoped_ptr<FakePictureLayerImpl> pending_layer; | |
109 if (old_pending_root) { | |
110 pending_layer.reset( | |
111 static_cast<FakePictureLayerImpl*>(old_pending_root.release())); | |
112 pending_layer->SetPile(pile); | |
113 } else { | |
114 pending_layer = | |
115 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); | |
116 pending_layer->SetDrawsContent(true); | |
117 } | |
118 // The bounds() just mirror the pile size. | |
119 pending_layer->SetBounds(pending_layer->pile()->tiling_size()); | |
120 pending_tree->SetRootLayer(pending_layer.Pass()); | 109 pending_tree->SetRootLayer(pending_layer.Pass()); |
121 | 110 |
122 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 111 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
123 host_impl_.pending_tree()->LayerById(id_)); | 112 host_impl_.pending_tree()->LayerById(id_)); |
124 pending_layer_->DoPostCommitInitializationIfNeeded(); | 113 pending_layer_->DoPostCommitInitializationIfNeeded(); |
125 } | 114 } |
126 | 115 |
127 void CreateHighLowResAndSetAllTilesVisible() { | 116 void CreateHighLowResAndSetAllTilesVisible() { |
128 // Active layer must get updated first so pending layer can share from it. | 117 // Active layer must get updated first so pending layer can share from it. |
129 active_layer_->CreateDefaultTilingsAndTiles(); | 118 active_layer_->CreateDefaultTilingsAndTiles(); |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 all_tiles.insert(queue.Top()); | 749 all_tiles.insert(queue.Top()); |
761 ++tile_count; | 750 ++tile_count; |
762 queue.Pop(); | 751 queue.Pop(); |
763 } | 752 } |
764 EXPECT_EQ(tile_count, all_tiles.size()); | 753 EXPECT_EQ(tile_count, all_tiles.size()); |
765 EXPECT_EQ(16u, tile_count); | 754 EXPECT_EQ(16u, tile_count); |
766 } | 755 } |
767 | 756 |
768 } // namespace | 757 } // namespace |
769 } // namespace cc | 758 } // namespace cc |
OLD | NEW |