Chromium Code Reviews| 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "base/thread_task_runner_handle.h" | 6 #include "base/thread_task_runner_handle.h" |
| 7 #include "cc/playback/display_list_raster_source.h" | 7 #include "cc/playback/display_list_raster_source.h" |
| 8 #include "cc/playback/display_list_recording_source.h" | 8 #include "cc/playback/display_list_recording_source.h" |
| 9 #include "cc/resources/resource_pool.h" | 9 #include "cc/resources/resource_pool.h" |
| 10 #include "cc/test/begin_frame_args_test.h" | 10 #include "cc/test/begin_frame_args_test.h" |
| 11 #include "cc/test/fake_display_list_raster_source.h" | |
| 11 #include "cc/test/fake_display_list_recording_source.h" | 12 #include "cc/test/fake_display_list_recording_source.h" |
| 12 #include "cc/test/fake_impl_proxy.h" | 13 #include "cc/test/fake_impl_proxy.h" |
| 13 #include "cc/test/fake_layer_tree_host_impl.h" | 14 #include "cc/test/fake_layer_tree_host_impl.h" |
| 14 #include "cc/test/fake_output_surface.h" | 15 #include "cc/test/fake_output_surface.h" |
| 15 #include "cc/test/fake_output_surface_client.h" | 16 #include "cc/test/fake_output_surface_client.h" |
| 16 #include "cc/test/fake_picture_layer_impl.h" | 17 #include "cc/test/fake_picture_layer_impl.h" |
| 17 #include "cc/test/fake_picture_layer_tiling_client.h" | 18 #include "cc/test/fake_picture_layer_tiling_client.h" |
| 18 #include "cc/test/fake_picture_pile_impl.h" | |
| 19 #include "cc/test/fake_tile_manager.h" | 19 #include "cc/test/fake_tile_manager.h" |
| 20 #include "cc/test/test_shared_bitmap_manager.h" | 20 #include "cc/test/test_shared_bitmap_manager.h" |
| 21 #include "cc/test/test_task_graph_runner.h" | 21 #include "cc/test/test_task_graph_runner.h" |
| 22 #include "cc/test/test_tile_priorities.h" | 22 #include "cc/test/test_tile_priorities.h" |
| 23 #include "cc/tiles/eviction_tile_priority_queue.h" | 23 #include "cc/tiles/eviction_tile_priority_queue.h" |
| 24 #include "cc/tiles/raster_tile_priority_queue.h" | 24 #include "cc/tiles/raster_tile_priority_queue.h" |
| 25 #include "cc/tiles/tile.h" | 25 #include "cc/tiles/tile.h" |
| 26 #include "cc/tiles/tile_priority.h" | 26 #include "cc/tiles/tile_priority.h" |
| 27 #include "cc/tiles/tiling_set_raster_queue_all.h" | 27 #include "cc/tiles/tiling_set_raster_queue_all.h" |
| 28 #include "cc/trees/layer_tree_impl.h" | 28 #include "cc/trees/layer_tree_impl.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 void SetUp() override { | 71 void SetUp() override { |
| 72 InitializeRenderer(); | 72 InitializeRenderer(); |
| 73 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 73 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
| 74 } | 74 } |
| 75 | 75 |
| 76 virtual void InitializeRenderer() { | 76 virtual void InitializeRenderer() { |
| 77 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); | 77 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 80 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 81 gfx::Size tile_size(100, 100); | 81 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
| 82 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | |
| 83 scoped_refptr<FakeDisplayListRasterSource> active_raster_source = | |
| 84 FakeDisplayListRasterSource::CreateFilled(layer_bounds); | |
| 82 | 85 |
| 83 scoped_refptr<FakePicturePileImpl> pending_pile = | 86 SetupTrees(pending_raster_source, active_raster_source); |
| 84 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 85 scoped_refptr<FakePicturePileImpl> active_pile = | |
| 86 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 87 | |
| 88 SetupTrees(pending_pile, active_pile); | |
| 89 } | 87 } |
| 90 | 88 |
| 91 // This matches picture_layer_impl_unittest's ActivateTree. | 89 // This matches picture_layer_impl_unittest's ActivateTree. |
| 92 void ActivateTree() { | 90 void ActivateTree() { |
| 93 host_impl_.ActivateSyncTree(); | 91 host_impl_.ActivateSyncTree(); |
| 94 CHECK(!host_impl_.pending_tree()); | 92 CHECK(!host_impl_.pending_tree()); |
| 95 pending_layer_ = NULL; | 93 pending_layer_ = NULL; |
| 96 active_layer_ = static_cast<FakePictureLayerImpl*>( | 94 active_layer_ = static_cast<FakePictureLayerImpl*>( |
| 97 host_impl_.active_tree()->LayerById(id_)); | 95 host_impl_.active_tree()->LayerById(id_)); |
| 98 bool update_lcd_text = false; | 96 bool update_lcd_text = false; |
| 99 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); | 97 host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); |
| 100 } | 98 } |
| 101 | 99 |
| 102 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, | 100 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, |
| 103 const gfx::Size& tile_size) { | 101 const gfx::Size& tile_size) { |
| 104 SetupDefaultTrees(layer_bounds); | 102 SetupDefaultTrees(layer_bounds); |
| 105 pending_layer_->set_fixed_tile_size(tile_size); | 103 pending_layer_->set_fixed_tile_size(tile_size); |
| 106 active_layer_->set_fixed_tile_size(tile_size); | 104 active_layer_->set_fixed_tile_size(tile_size); |
| 107 } | 105 } |
| 108 | 106 |
| 109 void SetupTrees(scoped_refptr<PicturePileImpl> pending_pile, | 107 void SetupTrees(scoped_refptr<RasterSource> pending_raster_source, |
| 110 scoped_refptr<PicturePileImpl> active_pile) { | 108 scoped_refptr<RasterSource> active_raster_source) { |
| 111 SetupPendingTree(active_pile); | 109 SetupPendingTree(active_raster_source); |
| 112 ActivateTree(); | 110 ActivateTree(); |
| 113 SetupPendingTree(pending_pile); | 111 SetupPendingTree(pending_raster_source); |
| 114 } | 112 } |
| 115 | 113 |
| 116 void SetupPendingTree(scoped_refptr<RasterSource> pile) { | 114 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { |
| 117 host_impl_.CreatePendingTree(); | 115 host_impl_.CreatePendingTree(); |
| 118 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 116 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 119 | 117 |
| 120 // Steal from the recycled tree. | 118 // Steal from the recycled tree. |
| 121 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); | 119 scoped_ptr<LayerImpl> old_pending_root = pending_tree->DetachLayerTree(); |
| 122 DCHECK_IMPLIES(old_pending_root, old_pending_root->id() == id_); | 120 DCHECK_IMPLIES(old_pending_root, old_pending_root->id() == id_); |
| 123 | 121 |
| 124 scoped_ptr<FakePictureLayerImpl> pending_layer; | 122 scoped_ptr<FakePictureLayerImpl> pending_layer; |
| 125 if (old_pending_root) { | 123 if (old_pending_root) { |
| 126 pending_layer.reset( | 124 pending_layer.reset( |
| 127 static_cast<FakePictureLayerImpl*>(old_pending_root.release())); | 125 static_cast<FakePictureLayerImpl*>(old_pending_root.release())); |
| 128 pending_layer->SetRasterSourceOnPending(pile, Region()); | 126 pending_layer->SetRasterSourceOnPending(raster_source, Region()); |
| 129 } else { | 127 } else { |
| 130 pending_layer = | 128 pending_layer = FakePictureLayerImpl::CreateWithRasterSource( |
| 131 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, pile); | 129 pending_tree, id_, raster_source); |
| 132 pending_layer->SetDrawsContent(true); | 130 pending_layer->SetDrawsContent(true); |
| 133 pending_layer->SetHasRenderSurface(true); | 131 pending_layer->SetHasRenderSurface(true); |
| 134 } | 132 } |
| 135 // The bounds() just mirror the pile size. | 133 // The bounds() just mirror the raster source size. |
| 136 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); | 134 pending_layer->SetBounds(pending_layer->raster_source()->GetSize()); |
| 137 pending_tree->SetRootLayer(pending_layer.Pass()); | 135 pending_tree->SetRootLayer(pending_layer.Pass()); |
| 138 | 136 |
| 139 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 137 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
| 140 host_impl_.pending_tree()->LayerById(id_)); | 138 host_impl_.pending_tree()->LayerById(id_)); |
| 141 | 139 |
| 142 // Add tilings/tiles for the layer. | 140 // Add tilings/tiles for the layer. |
| 143 bool update_lcd_text = false; | 141 bool update_lcd_text = false; |
| 144 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 142 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 145 } | 143 } |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 591 actual_required_for_activation_tiles); | 589 actual_required_for_activation_tiles); |
| 592 } | 590 } |
| 593 | 591 |
| 594 TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { | 592 TEST_F(TileManagerTilePriorityQueueTest, ActivationComesBeforeEventually) { |
| 595 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 593 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 596 | 594 |
| 597 gfx::Size layer_bounds(1000, 1000); | 595 gfx::Size layer_bounds(1000, 1000); |
| 598 SetupDefaultTrees(layer_bounds); | 596 SetupDefaultTrees(layer_bounds); |
| 599 | 597 |
| 600 // Create a pending child layer. | 598 // Create a pending child layer. |
| 601 gfx::Size tile_size(256, 256); | 599 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
| 602 scoped_refptr<FakePicturePileImpl> pending_pile = | 600 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
| 603 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | |
| 604 scoped_ptr<FakePictureLayerImpl> pending_child = | 601 scoped_ptr<FakePictureLayerImpl> pending_child = |
| 605 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), | 602 FakePictureLayerImpl::CreateWithRasterSource( |
| 606 id_ + 1, pending_pile); | 603 host_impl_.pending_tree(), id_ + 1, pending_raster_source); |
| 607 FakePictureLayerImpl* pending_child_raw = pending_child.get(); | 604 FakePictureLayerImpl* pending_child_raw = pending_child.get(); |
| 608 pending_child_raw->SetDrawsContent(true); | 605 pending_child_raw->SetDrawsContent(true); |
| 609 pending_layer_->AddChild(pending_child.Pass()); | 606 pending_layer_->AddChild(pending_child.Pass()); |
| 610 | 607 |
| 611 // Set a small viewport, so we have soon and eventually tiles. | 608 // Set a small viewport, so we have soon and eventually tiles. |
| 612 host_impl_.SetViewportSize(gfx::Size(200, 200)); | 609 host_impl_.SetViewportSize(gfx::Size(200, 200)); |
| 613 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 610 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 614 bool update_lcd_text = false; | 611 bool update_lcd_text = false; |
| 615 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 612 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 616 | 613 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 EXPECT_EQ(3, distance_increasing); | 804 EXPECT_EQ(3, distance_increasing); |
| 808 EXPECT_EQ(16, distance_decreasing); | 805 EXPECT_EQ(16, distance_decreasing); |
| 809 EXPECT_EQ(tile_count, new_content_tiles.size()); | 806 EXPECT_EQ(tile_count, new_content_tiles.size()); |
| 810 EXPECT_EQ(all_tiles, new_content_tiles); | 807 EXPECT_EQ(all_tiles, new_content_tiles); |
| 811 } | 808 } |
| 812 | 809 |
| 813 TEST_F(TileManagerTilePriorityQueueTest, | 810 TEST_F(TileManagerTilePriorityQueueTest, |
| 814 EvictionTilePriorityQueueWithOcclusion) { | 811 EvictionTilePriorityQueueWithOcclusion) { |
| 815 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 812 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 816 | 813 |
| 817 gfx::Size tile_size(102, 102); | |
| 818 gfx::Size layer_bounds(1000, 1000); | 814 gfx::Size layer_bounds(1000, 1000); |
| 819 | 815 |
| 820 host_impl_.SetViewportSize(layer_bounds); | 816 host_impl_.SetViewportSize(layer_bounds); |
| 821 | 817 |
| 822 scoped_refptr<FakePicturePileImpl> pending_pile = | 818 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
| 823 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 819 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
| 824 SetupPendingTree(pending_pile); | 820 SetupPendingTree(pending_raster_source); |
| 825 | 821 |
| 826 scoped_ptr<FakePictureLayerImpl> pending_child = | 822 scoped_ptr<FakePictureLayerImpl> pending_child = |
| 827 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, | 823 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, |
| 828 pending_pile); | 824 pending_raster_source); |
| 829 pending_layer_->AddChild(pending_child.Pass()); | 825 pending_layer_->AddChild(pending_child.Pass()); |
| 830 | 826 |
| 831 FakePictureLayerImpl* pending_child_layer = | 827 FakePictureLayerImpl* pending_child_layer = |
| 832 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); | 828 static_cast<FakePictureLayerImpl*>(pending_layer_->children()[0]); |
| 833 pending_child_layer->SetDrawsContent(true); | 829 pending_child_layer->SetDrawsContent(true); |
| 834 | 830 |
| 835 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 831 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 836 bool update_lcd_text = false; | 832 bool update_lcd_text = false; |
| 837 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 833 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 838 | 834 |
| 839 ActivateTree(); | 835 ActivateTree(); |
| 840 SetupPendingTree(pending_pile); | 836 SetupPendingTree(pending_raster_source); |
| 841 | 837 |
| 842 FakePictureLayerImpl* active_child_layer = | 838 FakePictureLayerImpl* active_child_layer = |
| 843 static_cast<FakePictureLayerImpl*>(active_layer_->children()[0]); | 839 static_cast<FakePictureLayerImpl*>(active_layer_->children()[0]); |
| 844 | 840 |
| 845 std::set<Tile*> all_tiles; | 841 std::set<Tile*> all_tiles; |
| 846 size_t tile_count = 0; | 842 size_t tile_count = 0; |
| 847 scoped_ptr<RasterTilePriorityQueue> raster_queue(host_impl_.BuildRasterQueue( | 843 scoped_ptr<RasterTilePriorityQueue> raster_queue(host_impl_.BuildRasterQueue( |
| 848 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 844 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 849 while (!raster_queue->IsEmpty()) { | 845 while (!raster_queue->IsEmpty()) { |
| 850 ++tile_count; | 846 ++tile_count; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 924 queue->Pop(); | 920 queue->Pop(); |
| 925 } | 921 } |
| 926 size_t expected_occluded_count = pending_child_high_res_tiles.size(); | 922 size_t expected_occluded_count = pending_child_high_res_tiles.size(); |
| 927 EXPECT_EQ(expected_occluded_count, occluded_count); | 923 EXPECT_EQ(expected_occluded_count, occluded_count); |
| 928 } | 924 } |
| 929 | 925 |
| 930 TEST_F(TileManagerTilePriorityQueueTest, | 926 TEST_F(TileManagerTilePriorityQueueTest, |
| 931 EvictionTilePriorityQueueWithTransparentLayer) { | 927 EvictionTilePriorityQueueWithTransparentLayer) { |
| 932 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 928 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 933 | 929 |
| 934 gfx::Size tile_size(102, 102); | |
|
danakj
2015/09/22 21:52:15
:D :D:D: D:D :D: :D :D :D :D :D :D :D :D:DDDDDDDDD
| |
| 935 gfx::Size layer_bounds(1000, 1000); | 930 gfx::Size layer_bounds(1000, 1000); |
| 936 | 931 |
| 937 scoped_refptr<FakePicturePileImpl> pending_pile = | 932 scoped_refptr<FakeDisplayListRasterSource> pending_raster_source = |
| 938 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 933 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
| 939 SetupPendingTree(pending_pile); | 934 SetupPendingTree(pending_raster_source); |
| 940 | 935 |
| 941 scoped_ptr<FakePictureLayerImpl> pending_child = | 936 scoped_ptr<FakePictureLayerImpl> pending_child = |
| 942 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, | 937 FakePictureLayerImpl::CreateWithRasterSource(host_impl_.pending_tree(), 2, |
| 943 pending_pile); | 938 pending_raster_source); |
| 944 FakePictureLayerImpl* pending_child_layer = pending_child.get(); | 939 FakePictureLayerImpl* pending_child_layer = pending_child.get(); |
| 945 pending_layer_->AddChild(pending_child.Pass()); | 940 pending_layer_->AddChild(pending_child.Pass()); |
| 946 | 941 |
| 947 // Create a fully transparent child layer so that its tile priorities are not | 942 // Create a fully transparent child layer so that its tile priorities are not |
| 948 // considered to be valid. | 943 // considered to be valid. |
| 949 pending_child_layer->SetDrawsContent(true); | 944 pending_child_layer->SetDrawsContent(true); |
| 950 | 945 |
| 951 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 946 host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| 952 bool update_lcd_text = false; | 947 bool update_lcd_text = false; |
| 953 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 948 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1119 soon_rect.Inset(-inset, -inset); | 1114 soon_rect.Inset(-inset, -inset); |
| 1120 | 1115 |
| 1121 client.SetTileSize(gfx::Size(30, 30)); | 1116 client.SetTileSize(gfx::Size(30, 30)); |
| 1122 LayerTreeSettings settings; | 1117 LayerTreeSettings settings; |
| 1123 | 1118 |
| 1124 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( | 1119 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( |
| 1125 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, | 1120 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, |
| 1126 settings.skewport_target_time_in_seconds, | 1121 settings.skewport_target_time_in_seconds, |
| 1127 settings.skewport_extrapolation_limit_in_content_pixels); | 1122 settings.skewport_extrapolation_limit_in_content_pixels); |
| 1128 | 1123 |
| 1129 scoped_refptr<FakePicturePileImpl> pile = | 1124 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
| 1130 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 1125 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
| 1131 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, pile); | 1126 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source); |
| 1132 tiling->set_resolution(HIGH_RESOLUTION); | 1127 tiling->set_resolution(HIGH_RESOLUTION); |
| 1133 | 1128 |
| 1134 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); | 1129 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); |
| 1135 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); | 1130 std::vector<Tile*> all_tiles = tiling->AllTilesForTesting(); |
| 1136 // Sanity check. | 1131 // Sanity check. |
| 1137 EXPECT_EQ(3364u, all_tiles.size()); | 1132 EXPECT_EQ(3364u, all_tiles.size()); |
| 1138 | 1133 |
| 1139 // The explanation of each iteration is as follows: | 1134 // The explanation of each iteration is as follows: |
| 1140 // 1. First iteration tests that we can get all of the tiles correctly. | 1135 // 1. First iteration tests that we can get all of the tiles correctly. |
| 1141 // 2. Second iteration ensures that we can get all of the tiles again (first | 1136 // 2. Second iteration ensures that we can get all of the tiles again (first |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1228 gfx::Size layer_bounds(1000, 1000); | 1223 gfx::Size layer_bounds(1000, 1000); |
| 1229 | 1224 |
| 1230 client.SetTileSize(gfx::Size(30, 30)); | 1225 client.SetTileSize(gfx::Size(30, 30)); |
| 1231 LayerTreeSettings settings; | 1226 LayerTreeSettings settings; |
| 1232 | 1227 |
| 1233 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( | 1228 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( |
| 1234 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, | 1229 ACTIVE_TREE, &client, settings.tiling_interest_area_padding, |
| 1235 settings.skewport_target_time_in_seconds, | 1230 settings.skewport_target_time_in_seconds, |
| 1236 settings.skewport_extrapolation_limit_in_content_pixels); | 1231 settings.skewport_extrapolation_limit_in_content_pixels); |
| 1237 | 1232 |
| 1238 scoped_refptr<FakePicturePileImpl> pile = | 1233 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
| 1239 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 1234 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
| 1240 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, pile); | 1235 PictureLayerTiling* tiling = tiling_set->AddTiling(1.0f, raster_source); |
| 1241 tiling->set_resolution(HIGH_RESOLUTION); | 1236 tiling->set_resolution(HIGH_RESOLUTION); |
| 1242 | 1237 |
| 1243 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); | 1238 tiling_set->UpdateTilePriorities(viewport, 1.0f, 1.0, Occlusion(), true); |
| 1244 tiling_set->UpdateTilePriorities(moved_viewport, 1.0f, 2.0, Occlusion(), | 1239 tiling_set->UpdateTilePriorities(moved_viewport, 1.0f, 2.0, Occlusion(), |
| 1245 true); | 1240 true); |
| 1246 | 1241 |
| 1247 float inset = | 1242 float inset = |
| 1248 PictureLayerTiling::CalculateSoonBorderDistance(moved_viewport, 1.0f); | 1243 PictureLayerTiling::CalculateSoonBorderDistance(moved_viewport, 1.0f); |
| 1249 gfx::Rect soon_rect = moved_viewport; | 1244 gfx::Rect soon_rect = moved_viewport; |
| 1250 soon_rect.Inset(-inset, -inset); | 1245 soon_rect.Inset(-inset, -inset); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1286 } | 1281 } |
| 1287 | 1282 |
| 1288 EXPECT_GT(eventually_bin_order_correct_count, | 1283 EXPECT_GT(eventually_bin_order_correct_count, |
| 1289 eventually_bin_order_incorrect_count); | 1284 eventually_bin_order_incorrect_count); |
| 1290 | 1285 |
| 1291 EXPECT_TRUE(have_tiles[TilePriority::NOW]); | 1286 EXPECT_TRUE(have_tiles[TilePriority::NOW]); |
| 1292 EXPECT_TRUE(have_tiles[TilePriority::SOON]); | 1287 EXPECT_TRUE(have_tiles[TilePriority::SOON]); |
| 1293 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); | 1288 EXPECT_TRUE(have_tiles[TilePriority::EVENTUALLY]); |
| 1294 } | 1289 } |
| 1295 | 1290 |
| 1296 TEST_F(TileManagerTilePriorityQueueTest, SetIsLikelyToRequireADraw) { | 1291 // TODO(vmpstr): Move these to LTHI tests, since they can't create real |
|
danakj
2015/09/22 21:52:15
Hm, the bug says we don't get up a real resource p
vmpstr
2015/09/22 22:57:50
The bug is just a guess at what's going on here. I
danakj
2015/09/22 23:04:06
OK follow up is fine, but I just don't expect that
| |
| 1292 // resources and so they don't work with non-solid raster sources. | |
| 1293 // crbug.com/534911 | |
| 1294 TEST_F(TileManagerTilePriorityQueueTest, DISABLED_SetIsLikelyToRequireADraw) { | |
| 1297 const gfx::Size layer_bounds(1000, 1000); | 1295 const gfx::Size layer_bounds(1000, 1000); |
| 1298 host_impl_.SetViewportSize(layer_bounds); | 1296 host_impl_.SetViewportSize(layer_bounds); |
| 1299 SetupDefaultTrees(layer_bounds); | 1297 SetupDefaultTrees(layer_bounds); |
| 1300 | 1298 |
| 1301 // Verify that the queue has a required for draw tile at Top. | 1299 // Verify that the queue has a required for draw tile at Top. |
| 1302 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( | 1300 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 1303 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 1301 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 1304 EXPECT_FALSE(queue->IsEmpty()); | 1302 EXPECT_FALSE(queue->IsEmpty()); |
| 1305 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); | 1303 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); |
| 1306 | 1304 |
| 1307 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); | 1305 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1308 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); | 1306 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); |
| 1309 EXPECT_TRUE(host_impl_.is_likely_to_require_a_draw()); | 1307 EXPECT_TRUE(host_impl_.is_likely_to_require_a_draw()); |
| 1310 } | 1308 } |
| 1311 | 1309 |
| 1310 // TODO(vmpstr): Move these to LTHI tests, since they can't create real | |
| 1311 // resources and so they don't work with non-solid raster sources. | |
| 1312 // crbug.com/534911 | |
| 1312 TEST_F(TileManagerTilePriorityQueueTest, | 1313 TEST_F(TileManagerTilePriorityQueueTest, |
| 1313 SetIsLikelyToRequireADrawOnZeroMemoryBudget) { | 1314 DISABLED_SetIsLikelyToRequireADrawOnZeroMemoryBudget) { |
| 1314 const gfx::Size layer_bounds(1000, 1000); | 1315 const gfx::Size layer_bounds(1000, 1000); |
| 1315 host_impl_.SetViewportSize(layer_bounds); | 1316 host_impl_.SetViewportSize(layer_bounds); |
| 1316 SetupDefaultTrees(layer_bounds); | 1317 SetupDefaultTrees(layer_bounds); |
| 1317 | 1318 |
| 1318 // Verify that the queue has a required for draw tile at Top. | 1319 // Verify that the queue has a required for draw tile at Top. |
| 1319 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( | 1320 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 1320 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 1321 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 1321 EXPECT_FALSE(queue->IsEmpty()); | 1322 EXPECT_FALSE(queue->IsEmpty()); |
| 1322 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); | 1323 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); |
| 1323 | 1324 |
| 1324 ManagedMemoryPolicy policy = host_impl_.ActualManagedMemoryPolicy(); | 1325 ManagedMemoryPolicy policy = host_impl_.ActualManagedMemoryPolicy(); |
| 1325 policy.bytes_limit_when_visible = 0; | 1326 policy.bytes_limit_when_visible = 0; |
| 1326 host_impl_.SetMemoryPolicy(policy); | 1327 host_impl_.SetMemoryPolicy(policy); |
| 1327 | 1328 |
| 1328 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); | 1329 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1329 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); | 1330 host_impl_.tile_manager()->PrepareTiles(host_impl_.global_tile_state()); |
| 1330 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); | 1331 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1331 } | 1332 } |
| 1332 | 1333 |
| 1334 // TODO(vmpstr): Move these to LTHI tests, since they can't create real | |
| 1335 // resources and so they don't work with non-solid raster sources. | |
| 1336 // crbug.com/534911 | |
| 1333 TEST_F(TileManagerTilePriorityQueueTest, | 1337 TEST_F(TileManagerTilePriorityQueueTest, |
| 1334 SetIsLikelyToRequireADrawOnLimitedMemoryBudget) { | 1338 DISABLED_SetIsLikelyToRequireADrawOnLimitedMemoryBudget) { |
| 1335 const gfx::Size layer_bounds(1000, 1000); | 1339 const gfx::Size layer_bounds(1000, 1000); |
| 1336 host_impl_.SetViewportSize(layer_bounds); | 1340 host_impl_.SetViewportSize(layer_bounds); |
| 1337 SetupDefaultTrees(layer_bounds); | 1341 SetupDefaultTrees(layer_bounds); |
| 1338 | 1342 |
| 1339 // Verify that the queue has a required for draw tile at Top. | 1343 // Verify that the queue has a required for draw tile at Top. |
| 1340 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( | 1344 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( |
| 1341 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); | 1345 SAME_PRIORITY_FOR_BOTH_TREES, RasterTilePriorityQueue::Type::ALL)); |
| 1342 EXPECT_FALSE(queue->IsEmpty()); | 1346 EXPECT_FALSE(queue->IsEmpty()); |
| 1343 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); | 1347 EXPECT_TRUE(queue->Top().tile()->required_for_draw()); |
| 1344 EXPECT_EQ(gfx::Size(256, 256), queue->Top().tile()->desired_texture_size()); | 1348 EXPECT_EQ(gfx::Size(256, 256), queue->Top().tile()->desired_texture_size()); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1360 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); | 1364 EXPECT_FALSE(host_impl_.is_likely_to_require_a_draw()); |
| 1361 | 1365 |
| 1362 host_impl_.resource_pool()->ReleaseResource(resource, 0); | 1366 host_impl_.resource_pool()->ReleaseResource(resource, 0); |
| 1363 } | 1367 } |
| 1364 | 1368 |
| 1365 TEST_F(TileManagerTilePriorityQueueTest, RasterQueueAllUsesCorrectTileBounds) { | 1369 TEST_F(TileManagerTilePriorityQueueTest, RasterQueueAllUsesCorrectTileBounds) { |
| 1366 // Verify that we use the real tile bounds when advancing phases during the | 1370 // Verify that we use the real tile bounds when advancing phases during the |
| 1367 // tile iteration. | 1371 // tile iteration. |
| 1368 gfx::Size layer_bounds(1, 1); | 1372 gfx::Size layer_bounds(1, 1); |
| 1369 | 1373 |
| 1370 scoped_refptr<FakePicturePileImpl> pile = | 1374 scoped_refptr<FakeDisplayListRasterSource> raster_source = |
| 1371 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(layer_bounds); | 1375 FakeDisplayListRasterSource::CreateFilled(layer_bounds); |
| 1372 | 1376 |
| 1373 FakePictureLayerTilingClient pending_client; | 1377 FakePictureLayerTilingClient pending_client; |
| 1374 pending_client.SetTileSize(gfx::Size(64, 64)); | 1378 pending_client.SetTileSize(gfx::Size(64, 64)); |
| 1375 | 1379 |
| 1376 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( | 1380 scoped_ptr<PictureLayerTilingSet> tiling_set = PictureLayerTilingSet::Create( |
| 1377 WhichTree::ACTIVE_TREE, &pending_client, 1.0f, 1.0f, 1000); | 1381 WhichTree::ACTIVE_TREE, &pending_client, 1.0f, 1.0f, 1000); |
| 1378 pending_client.set_twin_tiling_set(tiling_set.get()); | 1382 pending_client.set_twin_tiling_set(tiling_set.get()); |
| 1379 | 1383 |
| 1380 auto* tiling = tiling_set->AddTiling(1.0f, pile); | 1384 auto* tiling = tiling_set->AddTiling(1.0f, raster_source); |
| 1381 | 1385 |
| 1382 tiling->set_resolution(HIGH_RESOLUTION); | 1386 tiling->set_resolution(HIGH_RESOLUTION); |
| 1383 tiling->CreateAllTilesForTesting(); | 1387 tiling->CreateAllTilesForTesting(); |
| 1384 | 1388 |
| 1385 // The tile is (0, 0, 1, 1), create an intersecting and non-intersecting | 1389 // The tile is (0, 0, 1, 1), create an intersecting and non-intersecting |
| 1386 // rectangle to test the advance phase with. The tile size is (64, 64), so | 1390 // rectangle to test the advance phase with. The tile size is (64, 64), so |
| 1387 // both rectangles intersect the tile content size, but only one should | 1391 // both rectangles intersect the tile content size, but only one should |
| 1388 // intersect the actual size. | 1392 // intersect the actual size. |
| 1389 gfx::Rect non_intersecting_rect(2, 2, 10, 10); | 1393 gfx::Rect non_intersecting_rect(2, 2, 10, 10); |
| 1390 gfx::Rect intersecting_rect(0, 0, 10, 10); | 1394 gfx::Rect intersecting_rect(0, 0, 10, 10); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1554 // background is not visible. | 1558 // background is not visible. |
| 1555 ASSERT_EQ(SK_ColorBLUE, bitmap->getColor(x, y)); | 1559 ASSERT_EQ(SK_ColorBLUE, bitmap->getColor(x, y)); |
| 1556 } | 1560 } |
| 1557 } | 1561 } |
| 1558 } | 1562 } |
| 1559 } | 1563 } |
| 1560 } | 1564 } |
| 1561 | 1565 |
| 1562 } // namespace | 1566 } // namespace |
| 1563 } // namespace cc | 1567 } // namespace cc |
| OLD | NEW |