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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 } | 662 } |
663 } | 663 } |
664 last_tile = tile; | 664 last_tile = tile; |
665 queue.Pop(); | 665 queue.Pop(); |
666 } | 666 } |
667 size_t expected_occluded_count = | 667 size_t expected_occluded_count = |
668 pending_child_high_res_tiles.size() + pending_child_low_res_tiles.size(); | 668 pending_child_high_res_tiles.size() + pending_child_low_res_tiles.size(); |
669 EXPECT_EQ(expected_occluded_count, occluded_count); | 669 EXPECT_EQ(expected_occluded_count, occluded_count); |
670 } | 670 } |
671 | 671 |
| 672 TEST_F(TileManagerTilePriorityQueueTest, |
| 673 EvictionTilePriorityQueueWithTransparentLayer) { |
| 674 gfx::Size tile_size(102, 102); |
| 675 gfx::Size layer_bounds(1000, 1000); |
| 676 |
| 677 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 678 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 679 SetupPendingTree(pending_pile); |
| 680 pending_layer_->CreateDefaultTilingsAndTiles(); |
| 681 |
| 682 scoped_ptr<FakePictureLayerImpl> pending_child = |
| 683 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, |
| 684 pending_pile); |
| 685 pending_layer_->AddChild(pending_child.Pass()); |
| 686 |
| 687 // Create a fully transparent child layer so that its tile priorities are not |
| 688 // considered to be valid. |
| 689 FakePictureLayerImpl* pending_child_layer = |
| 690 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); |
| 691 pending_child_layer->SetDrawsContent(true); |
| 692 pending_child_layer->CreateDefaultTilingsAndTiles(); |
| 693 pending_child_layer->SetOpacity(0.0); |
| 694 pending_child_layer->layer_tree_impl()->UpdateDrawProperties(); |
| 695 pending_child_layer->DoPostCommitInitializationIfNeeded(); |
| 696 |
| 697 // Renew all of the tile priorities. |
| 698 gfx::Rect viewport(layer_bounds); |
| 699 pending_layer_->HighResTiling()->ComputeTilePriorityRects( |
| 700 PENDING_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 701 pending_layer_->LowResTiling()->ComputeTilePriorityRects( |
| 702 PENDING_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 703 pending_child_layer->HighResTiling()->ComputeTilePriorityRects( |
| 704 PENDING_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 705 pending_child_layer->LowResTiling()->ComputeTilePriorityRects( |
| 706 PENDING_TREE, viewport, 1.0f, 1.0, Occlusion()); |
| 707 |
| 708 // Populate all tiles directly from the tilings. |
| 709 std::set<Tile*> all_pending_tiles; |
| 710 std::vector<Tile*> pending_high_res_tiles = |
| 711 pending_layer_->HighResTiling()->AllTilesForTesting(); |
| 712 all_pending_tiles.insert(pending_high_res_tiles.begin(), |
| 713 pending_high_res_tiles.end()); |
| 714 EXPECT_EQ(16u, pending_high_res_tiles.size()); |
| 715 |
| 716 std::vector<Tile*> pending_low_res_tiles = |
| 717 pending_layer_->LowResTiling()->AllTilesForTesting(); |
| 718 all_pending_tiles.insert(pending_low_res_tiles.begin(), |
| 719 pending_low_res_tiles.end()); |
| 720 EXPECT_EQ(1u, pending_low_res_tiles.size()); |
| 721 |
| 722 std::set<Tile*> all_pending_child_tiles; |
| 723 std::vector<Tile*> pending_child_high_res_tiles = |
| 724 pending_child_layer->HighResTiling()->AllTilesForTesting(); |
| 725 all_pending_child_tiles.insert(pending_child_high_res_tiles.begin(), |
| 726 pending_child_high_res_tiles.end()); |
| 727 EXPECT_EQ(16u, pending_child_high_res_tiles.size()); |
| 728 |
| 729 std::vector<Tile*> pending_child_low_res_tiles = |
| 730 pending_child_layer->LowResTiling()->AllTilesForTesting(); |
| 731 all_pending_child_tiles.insert(pending_child_low_res_tiles.begin(), |
| 732 pending_child_low_res_tiles.end()); |
| 733 EXPECT_EQ(1u, pending_child_low_res_tiles.size()); |
| 734 |
| 735 std::set<Tile*> all_tiles = all_pending_tiles; |
| 736 all_tiles.insert(all_pending_child_tiles.begin(), |
| 737 all_pending_child_tiles.end()); |
| 738 |
| 739 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 740 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 741 |
| 742 EXPECT_TRUE(pending_layer_->HasValidTilePriorities()); |
| 743 EXPECT_FALSE(pending_child_layer->HasValidTilePriorities()); |
| 744 |
| 745 // Verify that eviction queue returns tiles also from layers without valid |
| 746 // tile priorities and that the tile priority bin of those tiles is (at most) |
| 747 // EVENTUALLY. |
| 748 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; |
| 749 std::set<Tile*> new_content_tiles; |
| 750 size_t tile_count = 0; |
| 751 EvictionTilePriorityQueue queue; |
| 752 host_impl_.BuildEvictionQueue(&queue, tree_priority); |
| 753 while (!queue.IsEmpty()) { |
| 754 Tile* tile = queue.Top(); |
| 755 const TilePriority& pending_priority = tile->priority(PENDING_TREE); |
| 756 EXPECT_NE(std::numeric_limits<float>::infinity(), |
| 757 pending_priority.distance_to_visible); |
| 758 if (all_pending_child_tiles.find(tile) != all_pending_child_tiles.end()) |
| 759 EXPECT_EQ(TilePriority::EVENTUALLY, pending_priority.priority_bin); |
| 760 else |
| 761 EXPECT_EQ(TilePriority::NOW, pending_priority.priority_bin); |
| 762 new_content_tiles.insert(tile); |
| 763 ++tile_count; |
| 764 queue.Pop(); |
| 765 } |
| 766 EXPECT_EQ(tile_count, new_content_tiles.size()); |
| 767 EXPECT_EQ(all_tiles, new_content_tiles); |
| 768 } |
| 769 |
672 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) { | 770 TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueEmptyLayers) { |
673 SetupDefaultTrees(gfx::Size(1000, 1000)); | 771 SetupDefaultTrees(gfx::Size(1000, 1000)); |
674 | 772 |
675 active_layer_->CreateDefaultTilingsAndTiles(); | 773 active_layer_->CreateDefaultTilingsAndTiles(); |
676 pending_layer_->CreateDefaultTilingsAndTiles(); | 774 pending_layer_->CreateDefaultTilingsAndTiles(); |
677 | 775 |
678 RasterTilePriorityQueue queue; | 776 RasterTilePriorityQueue queue; |
679 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); | 777 host_impl_.BuildRasterQueue(&queue, SAME_PRIORITY_FOR_BOTH_TREES); |
680 EXPECT_FALSE(queue.IsEmpty()); | 778 EXPECT_FALSE(queue.IsEmpty()); |
681 | 779 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 all_tiles.insert(queue.Top()); | 858 all_tiles.insert(queue.Top()); |
761 ++tile_count; | 859 ++tile_count; |
762 queue.Pop(); | 860 queue.Pop(); |
763 } | 861 } |
764 EXPECT_EQ(tile_count, all_tiles.size()); | 862 EXPECT_EQ(tile_count, all_tiles.size()); |
765 EXPECT_EQ(16u, tile_count); | 863 EXPECT_EQ(16u, tile_count); |
766 } | 864 } |
767 | 865 |
768 } // namespace | 866 } // namespace |
769 } // namespace cc | 867 } // namespace cc |
OLD | NEW |