| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "cc/debug/lap_timer.h" | 9 #include "cc/debug/lap_timer.h" |
| 10 #include "cc/test/fake_impl_task_runner_provider.h" | 10 #include "cc/test/fake_impl_task_runner_provider.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 host_impl_.InitializeRenderer(output_surface_.get()); | 56 host_impl_.InitializeRenderer(output_surface_.get()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void SetupPendingTree(const gfx::Size& layer_bounds) { | 59 void SetupPendingTree(const gfx::Size& layer_bounds) { |
| 60 scoped_refptr<FakeRasterSource> raster_source = | 60 scoped_refptr<FakeRasterSource> raster_source = |
| 61 FakeRasterSource::CreateFilled(layer_bounds); | 61 FakeRasterSource::CreateFilled(layer_bounds); |
| 62 host_impl_.CreatePendingTree(); | 62 host_impl_.CreatePendingTree(); |
| 63 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 63 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
| 64 pending_tree->ClearLayers(); | 64 pending_tree->ClearLayers(); |
| 65 | 65 |
| 66 scoped_ptr<FakePictureLayerImpl> pending_layer = | 66 std::unique_ptr<FakePictureLayerImpl> pending_layer = |
| 67 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, 7, | 67 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, 7, |
| 68 raster_source); | 68 raster_source); |
| 69 pending_layer->SetDrawsContent(true); | 69 pending_layer->SetDrawsContent(true); |
| 70 pending_layer->SetForceRenderSurface(true); | 70 pending_layer->SetForceRenderSurface(true); |
| 71 pending_tree->SetRootLayer(std::move(pending_layer)); | 71 pending_tree->SetRootLayer(std::move(pending_layer)); |
| 72 pending_tree->BuildPropertyTreesForTesting(); | 72 pending_tree->BuildPropertyTreesForTesting(); |
| 73 | 73 |
| 74 pending_layer_ = static_cast<FakePictureLayerImpl*>( | 74 pending_layer_ = static_cast<FakePictureLayerImpl*>( |
| 75 host_impl_.pending_tree()->LayerById(7)); | 75 host_impl_.pending_tree()->LayerById(7)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, | 78 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, |
| 79 int num_tiles, | 79 int num_tiles, |
| 80 const gfx::Size& viewport_size) { | 80 const gfx::Size& viewport_size) { |
| 81 host_impl_.SetViewportSize(viewport_size); | 81 host_impl_.SetViewportSize(viewport_size); |
| 82 bool update_lcd_text = false; | 82 bool update_lcd_text = false; |
| 83 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 83 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 84 | 84 |
| 85 timer_.Reset(); | 85 timer_.Reset(); |
| 86 do { | 86 do { |
| 87 int count = num_tiles; | 87 int count = num_tiles; |
| 88 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 88 std::unique_ptr<TilingSetRasterQueueAll> queue( |
| 89 pending_layer_->picture_layer_tiling_set(), false)); | 89 new TilingSetRasterQueueAll( |
| 90 pending_layer_->picture_layer_tiling_set(), false)); |
| 90 while (count--) { | 91 while (count--) { |
| 91 ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count; | 92 ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count; |
| 92 ASSERT_TRUE(queue->Top().tile()) << "count: " << count; | 93 ASSERT_TRUE(queue->Top().tile()) << "count: " << count; |
| 93 queue->Pop(); | 94 queue->Pop(); |
| 94 } | 95 } |
| 95 timer_.NextLap(); | 96 timer_.NextLap(); |
| 96 } while (!timer_.HasTimeLimitExpired()); | 97 } while (!timer_.HasTimeLimitExpired()); |
| 97 | 98 |
| 98 perf_test::PrintResult("tiling_set_raster_queue_construct_and_iterate", "", | 99 perf_test::PrintResult("tiling_set_raster_queue_construct_and_iterate", "", |
| 99 test_name, timer_.LapsPerSecond(), "runs/s", true); | 100 test_name, timer_.LapsPerSecond(), "runs/s", true); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void RunRasterQueueConstructTest(const std::string& test_name, | 103 void RunRasterQueueConstructTest(const std::string& test_name, |
| 103 const gfx::Rect& viewport) { | 104 const gfx::Rect& viewport) { |
| 104 host_impl_.SetViewportSize(viewport.size()); | 105 host_impl_.SetViewportSize(viewport.size()); |
| 105 host_impl_.pending_tree() | 106 host_impl_.pending_tree() |
| 106 ->property_trees() | 107 ->property_trees() |
| 107 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 108 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
| 108 pending_layer_->id(), | 109 pending_layer_->id(), |
| 109 gfx::ScrollOffset(viewport.x(), viewport.y())); | 110 gfx::ScrollOffset(viewport.x(), viewport.y())); |
| 110 bool update_lcd_text = false; | 111 bool update_lcd_text = false; |
| 111 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 112 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 112 | 113 |
| 113 timer_.Reset(); | 114 timer_.Reset(); |
| 114 do { | 115 do { |
| 115 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 116 std::unique_ptr<TilingSetRasterQueueAll> queue( |
| 116 pending_layer_->picture_layer_tiling_set(), false)); | 117 new TilingSetRasterQueueAll( |
| 118 pending_layer_->picture_layer_tiling_set(), false)); |
| 117 timer_.NextLap(); | 119 timer_.NextLap(); |
| 118 } while (!timer_.HasTimeLimitExpired()); | 120 } while (!timer_.HasTimeLimitExpired()); |
| 119 | 121 |
| 120 perf_test::PrintResult("tiling_set_raster_queue_construct", "", test_name, | 122 perf_test::PrintResult("tiling_set_raster_queue_construct", "", test_name, |
| 121 timer_.LapsPerSecond(), "runs/s", true); | 123 timer_.LapsPerSecond(), "runs/s", true); |
| 122 } | 124 } |
| 123 | 125 |
| 124 void RunEvictionQueueConstructAndIterateTest( | 126 void RunEvictionQueueConstructAndIterateTest( |
| 125 const std::string& test_name, | 127 const std::string& test_name, |
| 126 int num_tiles, | 128 int num_tiles, |
| 127 const gfx::Size& viewport_size) { | 129 const gfx::Size& viewport_size) { |
| 128 host_impl_.SetViewportSize(viewport_size); | 130 host_impl_.SetViewportSize(viewport_size); |
| 129 bool update_lcd_text = false; | 131 bool update_lcd_text = false; |
| 130 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 132 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 131 | 133 |
| 132 timer_.Reset(); | 134 timer_.Reset(); |
| 133 do { | 135 do { |
| 134 int count = num_tiles; | 136 int count = num_tiles; |
| 135 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( | 137 std::unique_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( |
| 136 pending_layer_->picture_layer_tiling_set())); | 138 pending_layer_->picture_layer_tiling_set())); |
| 137 while (count--) { | 139 while (count--) { |
| 138 ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count; | 140 ASSERT_TRUE(!queue->IsEmpty()) << "count: " << count; |
| 139 ASSERT_TRUE(queue->Top().tile()) << "count: " << count; | 141 ASSERT_TRUE(queue->Top().tile()) << "count: " << count; |
| 140 queue->Pop(); | 142 queue->Pop(); |
| 141 } | 143 } |
| 142 timer_.NextLap(); | 144 timer_.NextLap(); |
| 143 } while (!timer_.HasTimeLimitExpired()); | 145 } while (!timer_.HasTimeLimitExpired()); |
| 144 | 146 |
| 145 perf_test::PrintResult("tiling_set_eviction_queue_construct_and_iterate", | 147 perf_test::PrintResult("tiling_set_eviction_queue_construct_and_iterate", |
| 146 "", test_name, timer_.LapsPerSecond(), "runs/s", | 148 "", test_name, timer_.LapsPerSecond(), "runs/s", |
| 147 true); | 149 true); |
| 148 } | 150 } |
| 149 | 151 |
| 150 void RunEvictionQueueConstructTest(const std::string& test_name, | 152 void RunEvictionQueueConstructTest(const std::string& test_name, |
| 151 const gfx::Rect& viewport) { | 153 const gfx::Rect& viewport) { |
| 152 host_impl_.SetViewportSize(viewport.size()); | 154 host_impl_.SetViewportSize(viewport.size()); |
| 153 host_impl_.pending_tree() | 155 host_impl_.pending_tree() |
| 154 ->property_trees() | 156 ->property_trees() |
| 155 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 157 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
| 156 pending_layer_->id(), | 158 pending_layer_->id(), |
| 157 gfx::ScrollOffset(viewport.x(), viewport.y())); | 159 gfx::ScrollOffset(viewport.x(), viewport.y())); |
| 158 bool update_lcd_text = false; | 160 bool update_lcd_text = false; |
| 159 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); | 161 host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); |
| 160 | 162 |
| 161 timer_.Reset(); | 163 timer_.Reset(); |
| 162 do { | 164 do { |
| 163 scoped_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( | 165 std::unique_ptr<TilingSetEvictionQueue> queue(new TilingSetEvictionQueue( |
| 164 pending_layer_->picture_layer_tiling_set())); | 166 pending_layer_->picture_layer_tiling_set())); |
| 165 timer_.NextLap(); | 167 timer_.NextLap(); |
| 166 } while (!timer_.HasTimeLimitExpired()); | 168 } while (!timer_.HasTimeLimitExpired()); |
| 167 | 169 |
| 168 perf_test::PrintResult("tiling_set_eviction_queue_construct", "", test_name, | 170 perf_test::PrintResult("tiling_set_eviction_queue_construct", "", test_name, |
| 169 timer_.LapsPerSecond(), "runs/s", true); | 171 timer_.LapsPerSecond(), "runs/s", true); |
| 170 } | 172 } |
| 171 | 173 |
| 172 protected: | 174 protected: |
| 173 TestSharedBitmapManager shared_bitmap_manager_; | 175 TestSharedBitmapManager shared_bitmap_manager_; |
| 174 TestTaskGraphRunner task_graph_runner_; | 176 TestTaskGraphRunner task_graph_runner_; |
| 175 FakeImplTaskRunnerProvider task_runner_provider_; | 177 FakeImplTaskRunnerProvider task_runner_provider_; |
| 176 scoped_ptr<OutputSurface> output_surface_; | 178 std::unique_ptr<OutputSurface> output_surface_; |
| 177 FakeLayerTreeHostImpl host_impl_; | 179 FakeLayerTreeHostImpl host_impl_; |
| 178 FakePictureLayerImpl* pending_layer_; | 180 FakePictureLayerImpl* pending_layer_; |
| 179 LapTimer timer_; | 181 LapTimer timer_; |
| 180 | 182 |
| 181 private: | 183 private: |
| 182 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest); | 184 DISALLOW_COPY_AND_ASSIGN(PictureLayerImplPerfTest); |
| 183 }; | 185 }; |
| 184 | 186 |
| 185 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstructAndIterate) { | 187 TEST_F(PictureLayerImplPerfTest, TilingSetRasterQueueConstructAndIterate) { |
| 186 SetupPendingTree(gfx::Size(10000, 10000)); | 188 SetupPendingTree(gfx::Size(10000, 10000)); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); | 257 ASSERT_TRUE(host_impl_.tile_manager() != nullptr); |
| 256 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); | 258 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); |
| 257 | 259 |
| 258 RunEvictionQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); | 260 RunEvictionQueueConstructTest("0_0_100x100", gfx::Rect(0, 0, 100, 100)); |
| 259 RunEvictionQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100)); | 261 RunEvictionQueueConstructTest("5000_0_100x100", gfx::Rect(5000, 0, 100, 100)); |
| 260 RunEvictionQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100)); | 262 RunEvictionQueueConstructTest("9999_0_100x100", gfx::Rect(9999, 0, 100, 100)); |
| 261 } | 263 } |
| 262 | 264 |
| 263 } // namespace | 265 } // namespace |
| 264 } // namespace cc | 266 } // namespace cc |
| OLD | NEW |