| 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 EXPECT_EQ(3, distance_increasing); | 700 EXPECT_EQ(3, distance_increasing); |
| 700 EXPECT_EQ(16, distance_decreasing); | 701 EXPECT_EQ(17, distance_decreasing); |
| 701 EXPECT_EQ(tile_count, smoothness_tiles.size()); | 702 EXPECT_EQ(tile_count, smoothness_tiles.size()); |
| 702 EXPECT_EQ(all_tiles, smoothness_tiles); | 703 EXPECT_EQ(all_tiles, smoothness_tiles); |
| 703 | 704 |
| 704 std::set<Tile*> new_content_tiles; | 705 std::set<Tile*> new_content_tiles; |
| 705 last_tile = NULL; | 706 last_tile = NULL; |
| 706 // Here we expect to get increasing PENDING_TREE priority_bin. | 707 // Again, we expect to get increasing combined priority_bin. |
| 707 queue = host_impl_.BuildEvictionQueue(NEW_CONTENT_TAKES_PRIORITY); | 708 queue = host_impl_.BuildEvictionQueue(NEW_CONTENT_TAKES_PRIORITY); |
| 708 distance_decreasing = 0; | 709 distance_decreasing = 0; |
| 709 distance_increasing = 0; | 710 distance_increasing = 0; |
| 710 while (!queue->IsEmpty()) { | 711 while (!queue->IsEmpty()) { |
| 711 Tile* tile = queue->Top(); | 712 Tile* tile = queue->Top(); |
| 712 EXPECT_TRUE(tile); | 713 EXPECT_TRUE(tile); |
| 713 | 714 |
| 714 if (!last_tile) | 715 if (!last_tile) |
| 715 last_tile = tile; | 716 last_tile = tile; |
| 716 | 717 |
| 717 EXPECT_GE(last_tile->priority(PENDING_TREE).priority_bin, | 718 const TilePriority& last_priority = last_tile->combined_priority(); |
| 718 tile->priority(PENDING_TREE).priority_bin); | 719 const TilePriority& priority = tile->combined_priority(); |
| 719 if (last_tile->priority(PENDING_TREE).priority_bin == | 720 |
| 720 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) { |
| 721 EXPECT_LE(last_tile->required_for_activation(), | 723 EXPECT_LE(last_tile->required_for_activation(), |
| 722 tile->required_for_activation()); | 724 tile->required_for_activation()); |
| 723 if (last_tile->required_for_activation() == | 725 if (last_tile->required_for_activation() == |
| 724 tile->required_for_activation()) { | 726 tile->required_for_activation()) { |
| 725 if (last_tile->priority(PENDING_TREE).distance_to_visible >= | 727 if (last_priority.distance_to_visible >= priority.distance_to_visible) |
| 726 tile->priority(PENDING_TREE).distance_to_visible) | |
| 727 ++distance_decreasing; | 728 ++distance_decreasing; |
| 728 else | 729 else |
| 729 ++distance_increasing; | 730 ++distance_increasing; |
| 730 } | 731 } |
| 731 } | 732 } |
| 732 | 733 |
| 733 last_tile = tile; | 734 last_tile = tile; |
| 734 new_content_tiles.insert(tile); | 735 new_content_tiles.insert(tile); |
| 735 queue->Pop(); | 736 queue->Pop(); |
| 736 } | 737 } |
| 737 | 738 |
| 739 // Ensure that the distance is decreasing many more times than increasing. |
| 738 EXPECT_EQ(3, distance_increasing); | 740 EXPECT_EQ(3, distance_increasing); |
| 739 EXPECT_EQ(16, distance_decreasing); | 741 EXPECT_EQ(17, distance_decreasing); |
| 740 EXPECT_EQ(tile_count, new_content_tiles.size()); | 742 EXPECT_EQ(tile_count, new_content_tiles.size()); |
| 741 EXPECT_EQ(all_tiles, new_content_tiles); | 743 EXPECT_EQ(all_tiles, new_content_tiles); |
| 742 } | 744 } |
| 743 | 745 |
| 744 TEST_F(TileManagerTilePriorityQueueTest, | 746 TEST_F(TileManagerTilePriorityQueueTest, |
| 745 EvictionTilePriorityQueueWithOcclusion) { | 747 EvictionTilePriorityQueueWithOcclusion) { |
| 746 base::TimeTicks time_ticks; | 748 base::TimeTicks time_ticks; |
| 747 time_ticks += base::TimeDelta::FromMilliseconds(1); | 749 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 748 host_impl_.SetCurrentBeginFrameArgs( | 750 host_impl_.SetCurrentBeginFrameArgs( |
| 749 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 751 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 764 | 766 |
| 765 FakePictureLayerImpl* pending_child_layer = | 767 FakePictureLayerImpl* pending_child_layer = |
| 766 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); | 768 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); |
| 767 pending_child_layer->SetDrawsContent(true); | 769 pending_child_layer->SetDrawsContent(true); |
| 768 | 770 |
| 769 time_ticks += base::TimeDelta::FromMilliseconds(1); | 771 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 770 host_impl_.SetCurrentBeginFrameArgs( | 772 host_impl_.SetCurrentBeginFrameArgs( |
| 771 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 773 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 772 host_impl_.pending_tree()->UpdateDrawProperties(); | 774 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 773 | 775 |
| 776 ActivateTree(); |
| 777 SetupPendingTree(pending_pile); |
| 778 |
| 779 FakePictureLayerImpl* active_child_layer = |
| 780 static_cast<FakePictureLayerImpl*>(active_layer_->children()[0]); |
| 781 |
| 774 std::set<Tile*> all_tiles; | 782 std::set<Tile*> all_tiles; |
| 775 size_t tile_count = 0; | 783 size_t tile_count = 0; |
| 776 scoped_ptr<RasterTilePriorityQueue> raster_queue(host_impl_.BuildRasterQueue( | 784 scoped_ptr<RasterTilePriorityQueue> raster_queue(host_impl_.BuildRasterQueue( |
| 777 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 785 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 778 while (!raster_queue->IsEmpty()) { | 786 while (!raster_queue->IsEmpty()) { |
| 779 ++tile_count; | 787 ++tile_count; |
| 780 EXPECT_TRUE(raster_queue->Top()); | 788 EXPECT_TRUE(raster_queue->Top()); |
| 781 all_tiles.insert(raster_queue->Top()); | 789 all_tiles.insert(raster_queue->Top()); |
| 782 raster_queue->Pop(); | 790 raster_queue->Pop(); |
| 783 } | 791 } |
| 784 EXPECT_EQ(tile_count, all_tiles.size()); | 792 EXPECT_EQ(tile_count, all_tiles.size()); |
| 785 EXPECT_EQ(32u, tile_count); | 793 EXPECT_EQ(32u, tile_count); |
| 786 | 794 |
| 787 pending_layer_->ResetAllTilesPriorities(); | 795 pending_layer_->ResetAllTilesPriorities(); |
| 788 | 796 |
| 789 // Renew all of the tile priorities. | 797 // Renew all of the tile priorities. |
| 790 gfx::Rect viewport(layer_bounds); | 798 gfx::Rect viewport(layer_bounds); |
| 791 pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, | 799 pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
| 792 Occlusion()); | 800 Occlusion()); |
| 793 pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, | 801 pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0, |
| 794 Occlusion()); | 802 Occlusion()); |
| 795 pending_child_layer->HighResTiling()->ComputeTilePriorityRects( | 803 pending_child_layer->HighResTiling()->ComputeTilePriorityRects( |
| 796 viewport, 1.0f, 1.0, Occlusion()); | 804 viewport, 1.0f, 1.0, Occlusion()); |
| 797 pending_child_layer->LowResTiling()->ComputeTilePriorityRects( | 805 pending_child_layer->LowResTiling()->ComputeTilePriorityRects( |
| 798 viewport, 1.0f, 1.0, Occlusion()); | 806 viewport, 1.0f, 1.0, Occlusion()); |
| 799 | 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 |
| 800 // Populate all tiles directly from the tilings. | 817 // Populate all tiles directly from the tilings. |
| 801 all_tiles.clear(); | 818 all_tiles.clear(); |
| 802 std::vector<Tile*> pending_high_res_tiles = | 819 std::vector<Tile*> pending_high_res_tiles = |
| 803 pending_layer_->HighResTiling()->AllTilesForTesting(); | 820 pending_layer_->HighResTiling()->AllTilesForTesting(); |
| 804 all_tiles.insert(pending_high_res_tiles.begin(), | 821 all_tiles.insert(pending_high_res_tiles.begin(), |
| 805 pending_high_res_tiles.end()); | 822 pending_high_res_tiles.end()); |
| 806 | 823 |
| 807 std::vector<Tile*> pending_low_res_tiles = | 824 std::vector<Tile*> pending_low_res_tiles = |
| 808 pending_layer_->LowResTiling()->AllTilesForTesting(); | 825 pending_layer_->LowResTiling()->AllTilesForTesting(); |
| 809 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()); |
| 810 | 827 |
| 811 // 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. |
| 812 std::vector<Tile*> pending_child_high_res_tiles = | 829 std::vector<Tile*> pending_child_high_res_tiles = |
| 813 pending_child_layer->HighResTiling()->AllTilesForTesting(); | 830 pending_child_layer->HighResTiling()->AllTilesForTesting(); |
| 814 pending_child_layer->HighResTiling()->SetAllTilesOccludedForTesting(); | 831 pending_child_layer->HighResTiling()->SetAllTilesOccludedForTesting(); |
| 832 active_child_layer->HighResTiling()->SetAllTilesOccludedForTesting(); |
| 815 all_tiles.insert(pending_child_high_res_tiles.begin(), | 833 all_tiles.insert(pending_child_high_res_tiles.begin(), |
| 816 pending_child_high_res_tiles.end()); | 834 pending_child_high_res_tiles.end()); |
| 817 | 835 |
| 818 std::vector<Tile*> pending_child_low_res_tiles = | 836 std::vector<Tile*> pending_child_low_res_tiles = |
| 819 pending_child_layer->LowResTiling()->AllTilesForTesting(); | 837 pending_child_layer->LowResTiling()->AllTilesForTesting(); |
| 820 pending_child_layer->LowResTiling()->SetAllTilesOccludedForTesting(); | 838 pending_child_layer->LowResTiling()->SetAllTilesOccludedForTesting(); |
| 839 active_child_layer->LowResTiling()->SetAllTilesOccludedForTesting(); |
| 821 all_tiles.insert(pending_child_low_res_tiles.begin(), | 840 all_tiles.insert(pending_child_low_res_tiles.begin(), |
| 822 pending_child_low_res_tiles.end()); | 841 pending_child_low_res_tiles.end()); |
| 823 | 842 |
| 824 tile_manager()->InitializeTilesWithResourcesForTesting( | 843 tile_manager()->InitializeTilesWithResourcesForTesting( |
| 825 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); | 844 std::vector<Tile*>(all_tiles.begin(), all_tiles.end())); |
| 826 | 845 |
| 827 // Verify occlusion is considered by EvictionTilePriorityQueue. | 846 // Verify occlusion is considered by EvictionTilePriorityQueue. |
| 828 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; | 847 TreePriority tree_priority = NEW_CONTENT_TAKES_PRIORITY; |
| 829 size_t occluded_count = 0u; | 848 size_t occluded_count = 0u; |
| 830 Tile* last_tile = NULL; | 849 Tile* last_tile = NULL; |
| 831 scoped_ptr<EvictionTilePriorityQueue> queue( | 850 scoped_ptr<EvictionTilePriorityQueue> queue( |
| 832 host_impl_.BuildEvictionQueue(tree_priority)); | 851 host_impl_.BuildEvictionQueue(tree_priority)); |
| 833 while (!queue->IsEmpty()) { | 852 while (!queue->IsEmpty()) { |
| 834 Tile* tile = queue->Top(); | 853 Tile* tile = queue->Top(); |
| 835 if (!last_tile) | 854 if (!last_tile) |
| 836 last_tile = tile; | 855 last_tile = tile; |
| 837 | 856 |
| 838 bool tile_is_occluded = tile->is_occluded_for_tree_priority(tree_priority); | 857 bool tile_is_occluded = tile->is_occluded_combined(); |
| 839 | 858 |
| 840 // 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 |
| 841 // 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 |
| 842 // activation, or the scale changed. | 861 // activation, or the scale changed. |
| 843 if (tile_is_occluded) { | 862 if (tile_is_occluded) { |
| 844 occluded_count++; | 863 occluded_count++; |
| 845 | 864 |
| 846 bool last_tile_is_occluded = | 865 bool last_tile_is_occluded = last_tile->is_occluded_combined(); |
| 847 last_tile->is_occluded_for_tree_priority(tree_priority); | |
| 848 if (!last_tile_is_occluded) { | 866 if (!last_tile_is_occluded) { |
| 849 TilePriority::PriorityBin tile_priority_bin = | 867 TilePriority::PriorityBin tile_priority_bin = |
| 850 tile->priority_for_tree_priority(tree_priority).priority_bin; | 868 tile->priority_for_tree_priority(tree_priority).priority_bin; |
| 851 TilePriority::PriorityBin last_tile_priority_bin = | 869 TilePriority::PriorityBin last_tile_priority_bin = |
| 852 last_tile->priority_for_tree_priority(tree_priority).priority_bin; | 870 last_tile->priority_for_tree_priority(tree_priority).priority_bin; |
| 853 | 871 |
| 854 EXPECT_TRUE((tile_priority_bin < last_tile_priority_bin) || | 872 EXPECT_TRUE((tile_priority_bin < last_tile_priority_bin) || |
| 855 tile->required_for_activation() || | 873 tile->required_for_activation() || |
| 856 (tile->contents_scale() != last_tile->contents_scale())); | 874 (tile->contents_scale() != last_tile->contents_scale())); |
| 857 } | 875 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 queue->Pop(); | 1080 queue->Pop(); |
| 1063 } | 1081 } |
| 1064 EXPECT_EQ(tile_count, all_tiles.size()); | 1082 EXPECT_EQ(tile_count, all_tiles.size()); |
| 1065 EXPECT_EQ(16u, tile_count); | 1083 EXPECT_EQ(16u, tile_count); |
| 1066 } | 1084 } |
| 1067 | 1085 |
| 1068 TEST_F(TileManagerTilePriorityQueueTest, | 1086 TEST_F(TileManagerTilePriorityQueueTest, |
| 1069 RasterTilePriorityQueueStaticViewport) { | 1087 RasterTilePriorityQueueStaticViewport) { |
| 1070 FakePictureLayerTilingClient client; | 1088 FakePictureLayerTilingClient client; |
| 1071 | 1089 |
| 1072 gfx::Rect viewport(50, 50, 100, 100); | 1090 gfx::Rect viewport(50, 50, 500, 500); |
| 1073 gfx::Size layer_bounds(800, 800); | 1091 gfx::Size layer_bounds(1600, 1600); |
| 1074 | 1092 |
| 1093 float inset = PictureLayerTiling::CalculateSoonBorderDistance(viewport, 1.0f); |
| 1075 gfx::Rect soon_rect = viewport; | 1094 gfx::Rect soon_rect = viewport; |
| 1076 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1095 soon_rect.Inset(-inset, -inset); |
| 1077 | 1096 |
| 1078 client.SetTileSize(gfx::Size(30, 30)); | 1097 client.SetTileSize(gfx::Size(30, 30)); |
| 1079 client.set_tree(ACTIVE_TREE); | 1098 client.set_tree(ACTIVE_TREE); |
| 1080 LayerTreeSettings settings; | 1099 LayerTreeSettings settings; |
| 1081 settings.max_tiles_for_interest_area = 10000; | 1100 settings.max_tiles_for_interest_area = 10000; |
| 1082 | 1101 |
| 1083 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( | 1102 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( |
| 1084 &client, settings.max_tiles_for_interest_area, | 1103 &client, settings.max_tiles_for_interest_area, |
| 1085 settings.skewport_target_time_in_seconds, | 1104 settings.skewport_target_time_in_seconds, |
| 1086 settings.skewport_extrapolation_limit_in_content_pixels); | 1105 settings.skewport_extrapolation_limit_in_content_pixels); |
| 1087 | 1106 |
| 1088 scoped_refptr<FakePicturePileImpl> pile = | 1107 scoped_refptr<FakePicturePileImpl> pile = |
| 1089 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 1108 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 1090 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, pile); | 1109 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, pile); |
| 1091 tiling->set_resolution(HIGH_RESOLUTION); | 1110 tiling->set_resolution(HIGH_RESOLUTION); |
| 1092 | 1111 |
| 1093 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); | 1112 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); |
| 1094 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1113 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| 1095 // Sanity check. | 1114 // Sanity check. |
| 1096 EXPECT_EQ(841u, all_tiles.size()); | 1115 EXPECT_EQ(3364u, all_tiles.size()); |
| 1097 | 1116 |
| 1098 // The explanation of each iteration is as follows: | 1117 // The explanation of each iteration is as follows: |
| 1099 // 1. First iteration tests that we can get all of the tiles correctly. | 1118 // 1. First iteration tests that we can get all of the tiles correctly. |
| 1100 // 2. Second iteration ensures that we can get all of the tiles again (first | 1119 // 2. Second iteration ensures that we can get all of the tiles again (first |
| 1101 // iteration didn't change any tiles), as well set all tiles to be ready to | 1120 // iteration didn't change any tiles), as well set all tiles to be ready to |
| 1102 // draw. | 1121 // draw. |
| 1103 // 3. Third iteration ensures that no tiles are returned, since they were all | 1122 // 3. Third iteration ensures that no tiles are returned, since they were all |
| 1104 // marked as ready to draw. | 1123 // marked as ready to draw. |
| 1105 for (int i = 0; i < 3; ++i) { | 1124 for (int i = 0; i < 3; ++i) { |
| 1106 scoped_ptr<TilingSetRasterQueueAll> queue( | 1125 scoped_ptr<TilingSetRasterQueueAll> queue( |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 | 1217 |
| 1199 scoped_refptr<FakePicturePileImpl> pile = | 1218 scoped_refptr<FakePicturePileImpl> pile = |
| 1200 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 1219 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); |
| 1201 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, pile); | 1220 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, pile); |
| 1202 tiling->set_resolution(HIGH_RESOLUTION); | 1221 tiling->set_resolution(HIGH_RESOLUTION); |
| 1203 | 1222 |
| 1204 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); | 1223 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); |
| 1205 tiling_set->UpdateTilePriorities(moved_viewport, 1.0f, 2.0, Occlusion(), | 1224 tiling_set->UpdateTilePriorities(moved_viewport, 1.0f, 2.0, Occlusion(), |
| 1206 true); | 1225 true); |
| 1207 | 1226 |
| 1227 float inset = |
| 1228 PictureLayerTiling::CalculateSoonBorderDistance(moved_viewport, 1.0f); |
| 1208 gfx::Rect soon_rect = moved_viewport; | 1229 gfx::Rect soon_rect = moved_viewport; |
| 1209 soon_rect.Inset(-312.f, -312.f, -312.f, -312.f); | 1230 soon_rect.Inset(-inset, -inset); |
| 1210 | 1231 |
| 1211 // There are 3 bins in TilePriority. | 1232 // There are 3 bins in TilePriority. |
| 1212 bool have_tiles[3] = {}; | 1233 bool have_tiles[3] = {}; |
| 1213 Tile* last_tile = NULL; | 1234 Tile* last_tile = NULL; |
| 1214 int eventually_bin_order_correct_count = 0; | 1235 int eventually_bin_order_correct_count = 0; |
| 1215 int eventually_bin_order_incorrect_count = 0; | 1236 int eventually_bin_order_incorrect_count = 0; |
| 1216 scoped_ptr<TilingSetRasterQueueAll> queue( | 1237 scoped_ptr<TilingSetRasterQueueAll> queue( |
| 1217 new TilingSetRasterQueueAll(tiling_set.get(), false)); | 1238 new TilingSetRasterQueueAll(tiling_set.get(), false)); |
| 1218 for (; !queue->IsEmpty(); queue->Pop()) { | 1239 for (; !queue->IsEmpty(); queue->Pop()) { |
| 1219 if (!last_tile) | 1240 if (!last_tile) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1247 EXPECT_GT(eventually_bin_order_correct_count, | 1268 EXPECT_GT(eventually_bin_order_correct_count, |
| 1248 eventually_bin_order_incorrect_count); | 1269 eventually_bin_order_incorrect_count); |
| 1249 | 1270 |
| 1250 EXPECT_TRUE(have_tiles[TilePriority::NOW]); | 1271 EXPECT_TRUE(have_tiles[TilePriority::NOW]); |
| 1251 EXPECT_TRUE(have_tiles[TilePriority::SOON]); | 1272 EXPECT_TRUE(have_tiles[TilePriority::SOON]); |
| 1252 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); | 1273 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); |
| 1253 } | 1274 } |
| 1254 | 1275 |
| 1255 } // namespace | 1276 } // namespace |
| 1256 } // namespace cc | 1277 } // namespace cc |
| OLD | NEW |