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(); | |
105 | 103 |
106 scoped_ptr<FakePictureLayerImpl> pending_layer = | 104 // Steal from the recycled tree. |
107 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); | 105 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); |
108 pending_layer->SetDrawsContent(true); | 106 DCHECK_IMPLIES(old_pending_root, old_pending_root->id() == id_); |
| 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()); |
109 pending_tree->SetRootLayer(pending_layer.Pass()); | 120 pending_tree->SetRootLayer(pending_layer.Pass()); |
110 | 121 |
111 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 122 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
112 host_impl_.pending_tree()->LayerById(id_)); | 123 host_impl_.pending_tree()->LayerById(id_)); |
113 pending_layer_->DoPostCommitInitializationIfNeeded(); | 124 pending_layer_->DoPostCommitInitializationIfNeeded(); |
114 } | 125 } |
115 | 126 |
116 void CreateHighLowResAndSetAllTilesVisible() { | 127 void CreateHighLowResAndSetAllTilesVisible() { |
117 // Active layer must get updated first so pending layer can share from it. | 128 // Active layer must get updated first so pending layer can share from it. |
118 active_layer_->CreateDefaultTilingsAndTiles(); | 129 active_layer_->CreateDefaultTilingsAndTiles(); |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 all_tiles.insert(queue.Top()); | 760 all_tiles.insert(queue.Top()); |
750 ++tile_count; | 761 ++tile_count; |
751 queue.Pop(); | 762 queue.Pop(); |
752 } | 763 } |
753 EXPECT_EQ(tile_count, all_tiles.size()); | 764 EXPECT_EQ(tile_count, all_tiles.size()); |
754 EXPECT_EQ(16u, tile_count); | 765 EXPECT_EQ(16u, tile_count); |
755 } | 766 } |
756 | 767 |
757 } // namespace | 768 } // namespace |
758 } // namespace cc | 769 } // namespace cc |
OLD | NEW |