| 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/tile.h" | 5 #include "cc/resources/tile.h" |
| 6 #include "cc/resources/tile_priority.h" | 6 #include "cc/resources/tile_priority.h" |
| 7 #include "cc/test/fake_impl_proxy.h" | 7 #include "cc/test/fake_impl_proxy.h" |
| 8 #include "cc/test/fake_layer_tree_host_impl.h" | 8 #include "cc/test/fake_layer_tree_host_impl.h" |
| 9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
| 10 #include "cc/test/fake_output_surface_client.h" | 10 #include "cc/test/fake_output_surface_client.h" |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 } | 673 } |
| 674 | 674 |
| 675 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 675 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 676 gfx::Size tile_size(100, 100); | 676 gfx::Size tile_size(100, 100); |
| 677 | 677 |
| 678 scoped_refptr<FakePicturePileImpl> pending_pile = | 678 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 679 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 679 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 680 scoped_refptr<FakePicturePileImpl> active_pile = | 680 scoped_refptr<FakePicturePileImpl> active_pile = |
| 681 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 681 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 682 | 682 |
| 683 SetupTrees(pending_pile, active_pile); | 683 SetupTrees(pending_pile, active_pile, layer_bounds, layer_bounds); |
| 684 } | 684 } |
| 685 | 685 |
| 686 void ActivateTree() { | 686 void ActivateTree() { |
| 687 host_impl_.ActivatePendingTree(); | 687 host_impl_.ActivatePendingTree(); |
| 688 CHECK(!host_impl_.pending_tree()); | 688 CHECK(!host_impl_.pending_tree()); |
| 689 pending_layer_ = NULL; | 689 pending_layer_ = NULL; |
| 690 active_layer_ = static_cast<FakePictureLayerImpl*>( | 690 active_layer_ = static_cast<FakePictureLayerImpl*>( |
| 691 host_impl_.active_tree()->LayerById(id_)); | 691 host_impl_.active_tree()->LayerById(id_)); |
| 692 } | 692 } |
| 693 | 693 |
| 694 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, | 694 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, |
| 695 const gfx::Size& tile_size) { | 695 const gfx::Size& tile_size) { |
| 696 SetupDefaultTrees(layer_bounds); | 696 SetupDefaultTrees(layer_bounds); |
| 697 pending_layer_->set_fixed_tile_size(tile_size); | 697 pending_layer_->set_fixed_tile_size(tile_size); |
| 698 active_layer_->set_fixed_tile_size(tile_size); | 698 active_layer_->set_fixed_tile_size(tile_size); |
| 699 } | 699 } |
| 700 | 700 |
| 701 void SetupTrees(scoped_refptr<PicturePileImpl> pending_pile, | 701 void SetupTrees(scoped_refptr<PicturePileImpl> pending_pile, |
| 702 scoped_refptr<PicturePileImpl> active_pile) { | 702 scoped_refptr<PicturePileImpl> active_pile, |
| 703 SetupPendingTree(active_pile); | 703 const gfx::Size& pending_layer_bounds, |
| 704 const gfx::Size& active_layer_bounds) { |
| 705 SetupPendingTree(active_pile, active_layer_bounds); |
| 704 ActivateTree(); | 706 ActivateTree(); |
| 705 SetupPendingTree(pending_pile); | 707 SetupPendingTree(pending_pile, pending_layer_bounds); |
| 706 } | 708 } |
| 707 | 709 |
| 708 void SetupPendingTree(scoped_refptr<PicturePileImpl> pile) { | 710 void SetupPendingTree(scoped_refptr<PicturePileImpl> pile, |
| 711 const gfx::Size& layer_bounds) { |
| 709 host_impl_.CreatePendingTree(); | 712 host_impl_.CreatePendingTree(); |
| 710 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 713 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 711 // Clear recycled tree. | 714 // Clear recycled tree. |
| 712 pending_tree->DetachLayerTree(); | 715 pending_tree->DetachLayerTree(); |
| 713 | 716 |
| 714 scoped_ptr<FakePictureLayerImpl> pending_layer = | 717 scoped_ptr<FakePictureLayerImpl> pending_layer = |
| 715 FakePictureLayerImpl::CreateWithPile(pending_tree, id_, pile); | 718 FakePictureLayerImpl::CreateWithPile( |
| 719 pending_tree, id_, pile, layer_bounds); |
| 716 pending_layer->SetDrawsContent(true); | 720 pending_layer->SetDrawsContent(true); |
| 717 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); | 721 pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>()); |
| 718 | 722 |
| 719 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 723 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
| 720 host_impl_.pending_tree()->LayerById(id_)); | 724 host_impl_.pending_tree()->LayerById(id_)); |
| 721 pending_layer_->DoPostCommitInitializationIfNeeded(); | 725 pending_layer_->DoPostCommitInitializationIfNeeded(); |
| 722 } | 726 } |
| 723 | 727 |
| 724 void CreateHighLowResAndSetAllTilesVisible() { | 728 void CreateHighLowResAndSetAllTilesVisible() { |
| 725 // Active layer must get updated first so pending layer can share from it. | 729 // Active layer must get updated first so pending layer can share from it. |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 | 970 |
| 967 EXPECT_EQ(tile_count, new_content_tiles.size()); | 971 EXPECT_EQ(tile_count, new_content_tiles.size()); |
| 968 EXPECT_EQ(all_tiles, new_content_tiles); | 972 EXPECT_EQ(all_tiles, new_content_tiles); |
| 969 // Since we don't guarantee increasing distance due to spiral iterator, we | 973 // Since we don't guarantee increasing distance due to spiral iterator, we |
| 970 // should check that we're _mostly_ right. | 974 // should check that we're _mostly_ right. |
| 971 EXPECT_GT(increasing_distance_tiles, 3 * tile_count / 4); | 975 EXPECT_GT(increasing_distance_tiles, 3 * tile_count / 4); |
| 972 } | 976 } |
| 973 | 977 |
| 974 } // namespace | 978 } // namespace |
| 975 } // namespace cc | 979 } // namespace cc |
| OLD | NEW |