| 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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 all_tiles.insert(queue.Top()); | 691 all_tiles.insert(queue.Top()); |
| 681 ++tile_count; | 692 ++tile_count; |
| 682 queue.Pop(); | 693 queue.Pop(); |
| 683 } | 694 } |
| 684 EXPECT_EQ(tile_count, all_tiles.size()); | 695 EXPECT_EQ(tile_count, all_tiles.size()); |
| 685 EXPECT_EQ(17u, tile_count); | 696 EXPECT_EQ(17u, tile_count); |
| 686 } | 697 } |
| 687 | 698 |
| 688 } // namespace | 699 } // namespace |
| 689 } // namespace cc | 700 } // namespace cc |
| OLD | NEW |