| 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/resources/tiling_set_raster_queue_all.h" | 9 #include "cc/resources/tiling_set_raster_queue_all.h" |
| 10 #include "cc/test/begin_frame_args_test.h" | 10 #include "cc/test/begin_frame_args_test.h" |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 active_layer_->LowResTiling()->AllTilesForTesting(); | 655 active_layer_->LowResTiling()->AllTilesForTesting(); |
| 656 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) | 656 for (size_t i = 0; i < active_low_res_tiles.size(); ++i) |
| 657 all_tiles.insert(active_low_res_tiles[i]); | 657 all_tiles.insert(active_low_res_tiles[i]); |
| 658 | 658 |
| 659 tile_manager()->InitializeTilesWithResourcesForTesting( | 659 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 660 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 660 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 661 | 661 |
| 662 Tile* last_tile = NULL; | 662 Tile* last_tile = NULL; |
| 663 smoothness_tiles.clear(); | 663 smoothness_tiles.clear(); |
| 664 tile_count = 0; | 664 tile_count = 0; |
| 665 // Here we expect to get increasing ACTIVE_TREE priority_bin. | 665 // Here we expect to get increasing combined priority_bin. |
| 666 queue = host_impl_.BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY); | 666 queue = host_impl_.BuildEvictionQueue(SMOOTHNESS_TAKES_PRIORITY); |
| 667 int distance_increasing = 0; | 667 int distance_increasing = 0; |
| 668 int distance_decreasing = 0; | 668 int distance_decreasing = 0; |
| 669 while (!queue->IsEmpty()) { | 669 while (!queue->IsEmpty()) { |
| 670 Tile* tile = queue->Top(); | 670 Tile* tile = queue->Top(); |
| 671 EXPECT_TRUE(tile); | 671 EXPECT_TRUE(tile); |
| 672 EXPECT_TRUE(tile->HasResource()); | 672 EXPECT_TRUE(tile->HasResource()); |
| 673 | 673 |
| 674 if (!last_tile) | 674 if (!last_tile) |
| 675 last_tile = tile; | 675 last_tile = tile; |
| 676 | 676 |
| 677 EXPECT_GE(last_tile->priority(ACTIVE_TREE).priority_bin, | 677 const TilePriority& last_priority = last_tile->combined_priority(); |
| 678 tile->priority(ACTIVE_TREE).priority_bin); | 678 const TilePriority& priority = tile->combined_priority(); |
| 679 if (last_tile->priority(ACTIVE_TREE).priority_bin == | 679 |
| 680 tile->priority(ACTIVE_TREE).priority_bin) { | 680 EXPECT_GE(last_priority.priority_bin, priority.priority_bin); |
| 681 if (last_priority.priority_bin == priority.priority_bin) { |
| 681 EXPECT_LE(last_tile->required_for_activation(), | 682 EXPECT_LE(last_tile->required_for_activation(), |
| 682 tile->required_for_activation()); | 683 tile->required_for_activation()); |
| 683 if (last_tile->required_for_activation() == | 684 if (last_tile->required_for_activation() == |
| 684 tile->required_for_activation()) { | 685 tile->required_for_activation()) { |
| 685 if (last_tile->priority(ACTIVE_TREE).distance_to_visible >= | 686 if (last_priority.distance_to_visible >= priority.distance_to_visible) |
| 686 tile->priority(ACTIVE_TREE).distance_to_visible) | |
| 687 ++distance_decreasing; | 687 ++distance_decreasing; |
| 688 else | 688 else |
| 689 ++distance_increasing; | 689 ++distance_increasing; |
| 690 } | 690 } |
| 691 } | 691 } |
| 692 | 692 |
| 693 last_tile = tile; | 693 last_tile = tile; |
| 694 ++tile_count; | 694 ++tile_count; |
| 695 smoothness_tiles.insert(tile); | 695 smoothness_tiles.insert(tile); |
| 696 queue->Pop(); | 696 queue->Pop(); |
| 697 } | 697 } |
| 698 | 698 |
| 699 // Ensure that the distance is decreasing many more times than increasing. | 699 // Ensure that the distance is decreasing many more times than increasing. |
| 700 EXPECT_EQ(3, distance_increasing); | 700 EXPECT_EQ(3, distance_increasing); |
| 701 EXPECT_EQ(17, distance_decreasing); | 701 EXPECT_EQ(17, distance_decreasing); |
| 702 EXPECT_EQ(tile_count, smoothness_tiles.size()); | 702 EXPECT_EQ(tile_count, smoothness_tiles.size()); |
| 703 EXPECT_EQ(all_tiles, smoothness_tiles); | 703 EXPECT_EQ(all_tiles, smoothness_tiles); |
| 704 | 704 |
| 705 std::set<Tile*> new_content_tiles; | 705 std::set<Tile*> new_content_tiles; |
| 706 last_tile = NULL; | 706 last_tile = NULL; |
| 707 // Here we expect to get increasing PENDING_TREE priority_bin. | 707 // Again, we expect to get increasing combined priority_bin. |
| 708 queue = host_impl_.BuildEvictionQueue(NEW_CONTENT_TAKES_PRIORITY); | 708 queue = host_impl_.BuildEvictionQueue(NEW_CONTENT_TAKES_PRIORITY); |
| 709 distance_decreasing = 0; | 709 distance_decreasing = 0; |
| 710 distance_increasing = 0; | 710 distance_increasing = 0; |
| 711 while (!queue->IsEmpty()) { | 711 while (!queue->IsEmpty()) { |
| 712 Tile* tile = queue->Top(); | 712 Tile* tile = queue->Top(); |
| 713 EXPECT_TRUE(tile); | 713 EXPECT_TRUE(tile); |
| 714 | 714 |
| 715 if (!last_tile) | 715 if (!last_tile) |
| 716 last_tile = tile; | 716 last_tile = tile; |
| 717 | 717 |
| 718 EXPECT_GE(last_tile->priority(PENDING_TREE).priority_bin, | 718 const TilePriority& last_priority = last_tile->combined_priority(); |
| 719 tile->priority(PENDING_TREE).priority_bin); | 719 const TilePriority& priority = tile->combined_priority(); |
| 720 if (last_tile->priority(PENDING_TREE).priority_bin == | 720 |
| 721 tile->priority(PENDING_TREE).priority_bin) { | 721 EXPECT_GE(last_priority.priority_bin, priority.priority_bin); |
| 722 if (last_priority.priority_bin == priority.priority_bin) { |
| 722 EXPECT_LE(last_tile->required_for_activation(), | 723 EXPECT_LE(last_tile->required_for_activation(), |
| 723 tile->required_for_activation()); | 724 tile->required_for_activation()); |
| 724 if (last_tile->required_for_activation() == | 725 if (last_tile->required_for_activation() == |
| 725 tile->required_for_activation()) { | 726 tile->required_for_activation()) { |
| 726 if (last_tile->priority(PENDING_TREE).distance_to_visible >= | 727 if (last_priority.distance_to_visible >= priority.distance_to_visible) |
| 727 tile->priority(PENDING_TREE).distance_to_visible) | |
| 728 ++distance_decreasing; | 728 ++distance_decreasing; |
| 729 else | 729 else |
| 730 ++distance_increasing; | 730 ++distance_increasing; |
| 731 } | 731 } |
| 732 } | 732 } |
| 733 | 733 |
| 734 last_tile = tile; | 734 last_tile = tile; |
| 735 new_content_tiles.insert(tile); | 735 new_content_tiles.insert(tile); |
| 736 queue->Pop(); | 736 queue->Pop(); |
| 737 } | 737 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 766 | 766 |
| 767 FakePictureLayerImpl* pending_child_layer = | 767 FakePictureLayerImpl* pending_child_layer = |
| 768 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); | 768 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); |
| 769 pending_child_layer->SetDrawsContent(true); | 769 pending_child_layer->SetDrawsContent(true); |
| 770 | 770 |
| 771 time_ticks += base::TimeDelta::FromMilliseconds(1); | 771 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 772 host_impl_.SetCurrentBeginFrameArgs( | 772 host_impl_.SetCurrentBeginFrameArgs( |
| 773 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 773 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 774 host_impl_.pending_tree()->UpdateDrawProperties(); | 774 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 775 | 775 |
| 776 ActivateTree(); |
| 777 SetupPendingTree(pending_pile); |
| 778 |
| 779 FakePictureLayerImpl* active_child_layer = |
| 780 static_cast<FakePictureLayerImpl*>(active_layer_->children()[0]); |
| 781 |
| 776 std::set<Tile*> all_tiles; | 782 std::set<Tile*> all_tiles; |
| 777 size_t tile_count = 0; | 783 size_t tile_count = 0; |
| 778 scoped_ptr<RasterTilePriorityQueue> raster_queue(host_impl_.BuildRasterQueue( | 784 scoped_ptr<RasterTilePriorityQueue> raster_queue(host_impl_.BuildRasterQueue( |
| 779 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 785 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 780 while (!raster_queue->IsEmpty()) { | 786 while (!raster_queue->IsEmpty()) { |
| 781 ++tile_count; | 787 ++tile_count; |
| 782 EXPECT_TRUE(raster_queue->Top()); | 788 EXPECT_TRUE(raster_queue->Top()); |
| 783 all_tiles.insert(raster_queue->Top()); | 789 all_tiles.insert(raster_queue->Top()); |
| 784 raster_queue->Pop(); | 790 raster_queue->Pop(); |
| 785 } | 791 } |
| 786 EXPECT_EQ(tile_count, all_tiles.size()); | 792 EXPECT_EQ(tile_count, all_tiles.size()); |
| 787 EXPECT_EQ(32u, tile_count); | 793 EXPECT_EQ(32u, tile_count); |
| 788 | 794 |
| 789 pending_layer_->ResetAllTilesPriorities(); | 795 pending_layer_->ResetAllTilesPriorities(); |
| 790 | 796 |
| 791 // Renew all of the tile priorities. | 797 // Renew all of the tile priorities. |
| 792 gfx::Rect viewport(layer_bounds); | 798 gfx::Rect viewport(layer_bounds); |
| 793 pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, | 799 pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
| 794 Occlusion()); | 800 Occlusion()); |
| 795 pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, | 801 pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
| 796 Occlusion()); | 802 Occlusion()); |
| 797 pending_child_layer->HighResTiling()->ComputeTilePriorityRects( | 803 pending_child_layer->HighResTiling()->ComputeTilePriorityRects( |
| 798 viewport, 1.0f, 1.0, Occlusion()); | 804 viewport, 1.0f, 1.0, Occlusion()); |
| 799 pending_child_layer->LowResTiling()->ComputeTilePriorityRects( | 805 pending_child_layer->LowResTiling()->ComputeTilePriorityRects( |
| 800 viewport, 1.0f, 1.0, Occlusion()); | 806 viewport, 1.0f, 1.0, Occlusion()); |
| 801 | 807 |
| 808 active_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
| 809 Occlusion()); |
| 810 active_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
| 811 Occlusion()); |
| 812 active_child_layer->HighResTiling()->ComputeTilePriorityRects( |
| 813 viewport, 1.0f, 1.0, Occlusion()); |
| 814 active_child_layer->LowResTiling()->ComputeTilePriorityRects( |
| 815 viewport, 1.0f, 1.0, Occlusion()); |
| 816 |
| 802 // Populate all tiles directly from the tilings. | 817 // Populate all tiles directly from the tilings. |
| 803 all_tiles.clear(); | 818 all_tiles.clear(); |
| 804 std::vector<Tile*> pending_high_res_tiles = | 819 std::vector<Tile*> pending_high_res_tiles = |
| 805 pending_layer_->HighResTiling()->AllTilesForTesting(); | 820 pending_layer_->HighResTiling()->AllTilesForTesting(); |
| 806 all_tiles.insert(pending_high_res_tiles.begin(), | 821 all_tiles.insert(pending_high_res_tiles.begin(), |
| 807 pending_high_res_tiles.end()); | 822 pending_high_res_tiles.end()); |
| 808 | 823 |
| 809 std::vector<Tile*> pending_low_res_tiles = | 824 std::vector<Tile*> pending_low_res_tiles = |
| 810 pending_layer_->LowResTiling()->AllTilesForTesting(); | 825 pending_layer_->LowResTiling()->AllTilesForTesting(); |
| 811 all_tiles.insert(pending_low_res_tiles.begin(), pending_low_res_tiles.end()); | 826 all_tiles.insert(pending_low_res_tiles.begin(), pending_low_res_tiles.end()); |
| 812 | 827 |
| 813 // Set all tiles on the pending_child_layer as occluded on the pending tree. | 828 // Set all tiles on the pending_child_layer as occluded on the pending tree. |
| 814 std::vector<Tile*> pending_child_high_res_tiles = | 829 std::vector<Tile*> pending_child_high_res_tiles = |
| 815 pending_child_layer->HighResTiling()->AllTilesForTesting(); | 830 pending_child_layer->HighResTiling()->AllTilesForTesting(); |
| 816 pending_child_layer->HighResTiling()->SetAllTilesOccludedForTesting(); | 831 pending_child_layer->HighResTiling()->SetAllTilesOccludedForTesting(); |
| 832 active_child_layer->HighResTiling()->SetAllTilesOccludedForTesting(); |
| 817 all_tiles.insert(pending_child_high_res_tiles.begin(), | 833 all_tiles.insert(pending_child_high_res_tiles.begin(), |
| 818 pending_child_high_res_tiles.end()); | 834 pending_child_high_res_tiles.end()); |
| 819 | 835 |
| 820 std::vector<Tile*> pending_child_low_res_tiles = | 836 std::vector<Tile*> pending_child_low_res_tiles = |
| 821 pending_child_layer->LowResTiling()->AllTilesForTesting(); | 837 pending_child_layer->LowResTiling()->AllTilesForTesting(); |
| 822 pending_child_layer->LowResTiling()->SetAllTilesOccludedForTesting(); | 838 pending_child_layer->LowResTiling()->SetAllTilesOccludedForTesting(); |
| 839 active_child_layer->LowResTiling()->SetAllTilesOccludedForTesting(); |
| 823 all_tiles.insert(pending_child_low_res_tiles.begin(), | 840 all_tiles.insert(pending_child_low_res_tiles.begin(), |
| 824 pending_child_low_res_tiles.end()); | 841 pending_child_low_res_tiles.end()); |
| 825 | 842 |
| 826 tile_manager()->InitializeTilesWithResourcesForTesting( | 843 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 827 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 844 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 828 | 845 |
| 829 // Verify occlusion is considered by EvictionTilePriorityQueue. | 846 // Verify occlusion is considered by EvictionTilePriorityQueue. |
| 830 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; | 847 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; |
| 831 size_t occluded_count = 0u; | 848 size_t occluded_count = 0u; |
| 832 Tile* last_tile = NULL; | 849 Tile* last_tile = NULL; |
| 833 scoped_ptr<EvictionTilePriorityQueue> queue( | 850 scoped_ptr<EvictionTilePriorityQueue> queue( |
| 834 host_impl_.BuildEvictionQueue(tree_priority)); | 851 host_impl_.BuildEvictionQueue(tree_priority)); |
| 835 while (!queue->IsEmpty()) { | 852 while (!queue->IsEmpty()) { |
| 836 Tile* tile = queue->Top(); | 853 Tile* tile = queue->Top(); |
| 837 if (!last_tile) | 854 if (!last_tile) |
| 838 last_tile = tile; | 855 last_tile = tile; |
| 839 | 856 |
| 840 bool tile_is_occluded = tile->is_occluded_for_tree_priority(tree_priority); | 857 bool tile_is_occluded = tile->is_occluded_combined(); |
| 841 | 858 |
| 842 // The only way we will encounter an occluded tile after an unoccluded | 859 // The only way we will encounter an occluded tile after an unoccluded |
| 843 // tile is if the priorty bin decreased, the tile is required for | 860 // tile is if the priorty bin decreased, the tile is required for |
| 844 // activation, or the scale changed. | 861 // activation, or the scale changed. |
| 845 if (tile_is_occluded) { | 862 if (tile_is_occluded) { |
| 846 occluded_count++; | 863 occluded_count++; |
| 847 | 864 |
| 848 bool last_tile_is_occluded = | 865 bool last_tile_is_occluded = |
| 849 last_tile->is_occluded_for_tree_priority(tree_priority); | 866 last_tile->is_occluded_for_tree_priority(tree_priority); |
| 850 if (!last_tile_is_occluded) { | 867 if (!last_tile_is_occluded) { |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 EXPECT_GT(eventually_bin_order_correct_count, | 1269 EXPECT_GT(eventually_bin_order_correct_count, |
| 1253 eventually_bin_order_incorrect_count); | 1270 eventually_bin_order_incorrect_count); |
| 1254 | 1271 |
| 1255 EXPECT_TRUE(have_tiles[TilePriority::NOW]); | 1272 EXPECT_TRUE(have_tiles[TilePriority::NOW]); |
| 1256 EXPECT_TRUE(have_tiles[TilePriority::SOON]); | 1273 EXPECT_TRUE(have_tiles[TilePriority::SOON]); |
| 1257 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); | 1274 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); |
| 1258 } | 1275 } |
| 1259 | 1276 |
| 1260 } // namespace | 1277 } // namespace |
| 1261 } // namespace cc | 1278 } // namespace cc |
| OLD | NEW |