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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 completed_tasks_.clear(); | 64 completed_tasks_.clear(); |
65 } | 65 } |
66 ResourceFormat GetResourceFormat(bool must_support_alpha) const override { | 66 ResourceFormat GetResourceFormat(bool must_support_alpha) const override { |
67 return RGBA_8888; | 67 return RGBA_8888; |
68 } | 68 } |
69 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override { | 69 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override { |
70 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); | 70 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); |
71 } | 71 } |
72 | 72 |
73 // Overridden from TileTaskClient: | 73 // Overridden from TileTaskClient: |
74 scoped_ptr<RasterBuffer> AcquireBufferForRaster( | 74 std::unique_ptr<RasterBuffer> AcquireBufferForRaster( |
75 const Resource* resource, | 75 const Resource* resource, |
76 uint64_t new_content_id, | 76 uint64_t new_content_id, |
77 uint64_t previous_content_id) override { | 77 uint64_t previous_content_id) override { |
78 return nullptr; | 78 return nullptr; |
79 } | 79 } |
80 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override {} | 80 void ReleaseBufferForRaster(std::unique_ptr<RasterBuffer> buffer) override {} |
81 | 81 |
82 private: | 82 private: |
83 TileTask::Vector completed_tasks_; | 83 TileTask::Vector completed_tasks_; |
84 }; | 84 }; |
85 base::LazyInstance<FakeTileTaskRunnerImpl> g_fake_tile_task_runner = | 85 base::LazyInstance<FakeTileTaskRunnerImpl> g_fake_tile_task_runner = |
86 LAZY_INSTANCE_INITIALIZER; | 86 LAZY_INSTANCE_INITIALIZER; |
87 | 87 |
88 class TileManagerPerfTest : public testing::Test { | 88 class TileManagerPerfTest : public testing::Test { |
89 public: | 89 public: |
90 TileManagerPerfTest() | 90 TileManagerPerfTest() |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 ActivateTree(); | 159 ActivateTree(); |
160 SetupPendingTree(pending_raster_source); | 160 SetupPendingTree(pending_raster_source); |
161 } | 161 } |
162 | 162 |
163 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { | 163 void SetupPendingTree(scoped_refptr<RasterSource> raster_source) { |
164 host_impl_.CreatePendingTree(); | 164 host_impl_.CreatePendingTree(); |
165 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); | 165 LayerTreeImpl* pending_tree = host_impl_.pending_tree(); |
166 // Clear recycled tree. | 166 // Clear recycled tree. |
167 pending_tree->ClearLayers(); | 167 pending_tree->ClearLayers(); |
168 | 168 |
169 scoped_ptr<FakePictureLayerImpl> pending_layer = | 169 std::unique_ptr<FakePictureLayerImpl> pending_layer = |
170 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, | 170 FakePictureLayerImpl::CreateWithRasterSource(pending_tree, id_, |
171 raster_source); | 171 raster_source); |
172 pending_layer->SetDrawsContent(true); | 172 pending_layer->SetDrawsContent(true); |
173 pending_layer->SetForceRenderSurface(true); | 173 pending_layer->SetForceRenderSurface(true); |
174 pending_tree->SetRootLayer(std::move(pending_layer)); | 174 pending_tree->SetRootLayer(std::move(pending_layer)); |
175 pending_tree->BuildPropertyTreesForTesting(); | 175 pending_tree->BuildPropertyTreesForTesting(); |
176 | 176 |
177 pending_root_layer_ = static_cast<FakePictureLayerImpl*>( | 177 pending_root_layer_ = static_cast<FakePictureLayerImpl*>( |
178 host_impl_.pending_tree()->LayerById(id_)); | 178 host_impl_.pending_tree()->LayerById(id_)); |
179 } | 179 } |
180 | 180 |
181 void RunRasterQueueConstructTest(const std::string& test_name, | 181 void RunRasterQueueConstructTest(const std::string& test_name, |
182 int layer_count) { | 182 int layer_count) { |
183 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 183 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
184 SMOOTHNESS_TAKES_PRIORITY, | 184 SMOOTHNESS_TAKES_PRIORITY, |
185 NEW_CONTENT_TAKES_PRIORITY}; | 185 NEW_CONTENT_TAKES_PRIORITY}; |
186 int priority_count = 0; | 186 int priority_count = 0; |
187 | 187 |
188 std::vector<FakePictureLayerImpl*> layers = CreateLayers(layer_count, 10); | 188 std::vector<FakePictureLayerImpl*> layers = CreateLayers(layer_count, 10); |
189 for (const auto& layer : layers) | 189 for (const auto& layer : layers) |
190 layer->UpdateTiles(); | 190 layer->UpdateTiles(); |
191 | 191 |
192 timer_.Reset(); | 192 timer_.Reset(); |
193 do { | 193 do { |
194 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( | 194 std::unique_ptr<RasterTilePriorityQueue> queue( |
195 priorities[priority_count], RasterTilePriorityQueue::Type::ALL)); | 195 host_impl_.BuildRasterQueue(priorities[priority_count], |
| 196 RasterTilePriorityQueue::Type::ALL)); |
196 priority_count = (priority_count + 1) % arraysize(priorities); | 197 priority_count = (priority_count + 1) % arraysize(priorities); |
197 timer_.NextLap(); | 198 timer_.NextLap(); |
198 } while (!timer_.HasTimeLimitExpired()); | 199 } while (!timer_.HasTimeLimitExpired()); |
199 | 200 |
200 perf_test::PrintResult("tile_manager_raster_tile_queue_construct", | 201 perf_test::PrintResult("tile_manager_raster_tile_queue_construct", |
201 "", | 202 "", |
202 test_name, | 203 test_name, |
203 timer_.LapsPerSecond(), | 204 timer_.LapsPerSecond(), |
204 "runs/s", | 205 "runs/s", |
205 true); | 206 true); |
206 } | 207 } |
207 | 208 |
208 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, | 209 void RunRasterQueueConstructAndIterateTest(const std::string& test_name, |
209 int layer_count, | 210 int layer_count, |
210 int tile_count) { | 211 int tile_count) { |
211 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, | 212 TreePriority priorities[] = {SAME_PRIORITY_FOR_BOTH_TREES, |
212 SMOOTHNESS_TAKES_PRIORITY, | 213 SMOOTHNESS_TAKES_PRIORITY, |
213 NEW_CONTENT_TAKES_PRIORITY}; | 214 NEW_CONTENT_TAKES_PRIORITY}; |
214 | 215 |
215 std::vector<FakePictureLayerImpl*> layers = CreateLayers(layer_count, 100); | 216 std::vector<FakePictureLayerImpl*> layers = CreateLayers(layer_count, 100); |
216 for (const auto& layer : layers) | 217 for (const auto& layer : layers) |
217 layer->UpdateTiles(); | 218 layer->UpdateTiles(); |
218 | 219 |
219 int priority_count = 0; | 220 int priority_count = 0; |
220 timer_.Reset(); | 221 timer_.Reset(); |
221 do { | 222 do { |
222 int count = tile_count; | 223 int count = tile_count; |
223 scoped_ptr<RasterTilePriorityQueue> queue(host_impl_.BuildRasterQueue( | 224 std::unique_ptr<RasterTilePriorityQueue> queue( |
224 priorities[priority_count], RasterTilePriorityQueue::Type::ALL)); | 225 host_impl_.BuildRasterQueue(priorities[priority_count], |
| 226 RasterTilePriorityQueue::Type::ALL)); |
225 while (count--) { | 227 while (count--) { |
226 ASSERT_FALSE(queue->IsEmpty()); | 228 ASSERT_FALSE(queue->IsEmpty()); |
227 ASSERT_TRUE(queue->Top().tile()); | 229 ASSERT_TRUE(queue->Top().tile()); |
228 queue->Pop(); | 230 queue->Pop(); |
229 } | 231 } |
230 priority_count = (priority_count + 1) % arraysize(priorities); | 232 priority_count = (priority_count + 1) % arraysize(priorities); |
231 timer_.NextLap(); | 233 timer_.NextLap(); |
232 } while (!timer_.HasTimeLimitExpired()); | 234 } while (!timer_.HasTimeLimitExpired()); |
233 | 235 |
234 perf_test::PrintResult( | 236 perf_test::PrintResult( |
(...skipping 16 matching lines...) Expand all Loading... |
251 for (const auto& layer : layers) { | 253 for (const auto& layer : layers) { |
252 layer->UpdateTiles(); | 254 layer->UpdateTiles(); |
253 for (size_t i = 0; i < layer->num_tilings(); ++i) { | 255 for (size_t i = 0; i < layer->num_tilings(); ++i) { |
254 tile_manager()->InitializeTilesWithResourcesForTesting( | 256 tile_manager()->InitializeTilesWithResourcesForTesting( |
255 layer->tilings()->tiling_at(i)->AllTilesForTesting()); | 257 layer->tilings()->tiling_at(i)->AllTilesForTesting()); |
256 } | 258 } |
257 } | 259 } |
258 | 260 |
259 timer_.Reset(); | 261 timer_.Reset(); |
260 do { | 262 do { |
261 scoped_ptr<EvictionTilePriorityQueue> queue( | 263 std::unique_ptr<EvictionTilePriorityQueue> queue( |
262 host_impl_.BuildEvictionQueue(priorities[priority_count])); | 264 host_impl_.BuildEvictionQueue(priorities[priority_count])); |
263 priority_count = (priority_count + 1) % arraysize(priorities); | 265 priority_count = (priority_count + 1) % arraysize(priorities); |
264 timer_.NextLap(); | 266 timer_.NextLap(); |
265 } while (!timer_.HasTimeLimitExpired()); | 267 } while (!timer_.HasTimeLimitExpired()); |
266 | 268 |
267 perf_test::PrintResult("tile_manager_eviction_tile_queue_construct", | 269 perf_test::PrintResult("tile_manager_eviction_tile_queue_construct", |
268 "", | 270 "", |
269 test_name, | 271 test_name, |
270 timer_.LapsPerSecond(), | 272 timer_.LapsPerSecond(), |
271 "runs/s", | 273 "runs/s", |
(...skipping 14 matching lines...) Expand all Loading... |
286 layer->UpdateTiles(); | 288 layer->UpdateTiles(); |
287 for (size_t i = 0; i < layer->num_tilings(); ++i) { | 289 for (size_t i = 0; i < layer->num_tilings(); ++i) { |
288 tile_manager()->InitializeTilesWithResourcesForTesting( | 290 tile_manager()->InitializeTilesWithResourcesForTesting( |
289 layer->tilings()->tiling_at(i)->AllTilesForTesting()); | 291 layer->tilings()->tiling_at(i)->AllTilesForTesting()); |
290 } | 292 } |
291 } | 293 } |
292 | 294 |
293 timer_.Reset(); | 295 timer_.Reset(); |
294 do { | 296 do { |
295 int count = tile_count; | 297 int count = tile_count; |
296 scoped_ptr<EvictionTilePriorityQueue> queue( | 298 std::unique_ptr<EvictionTilePriorityQueue> queue( |
297 host_impl_.BuildEvictionQueue(priorities[priority_count])); | 299 host_impl_.BuildEvictionQueue(priorities[priority_count])); |
298 while (count--) { | 300 while (count--) { |
299 ASSERT_FALSE(queue->IsEmpty()); | 301 ASSERT_FALSE(queue->IsEmpty()); |
300 ASSERT_TRUE(queue->Top().tile()); | 302 ASSERT_TRUE(queue->Top().tile()); |
301 queue->Pop(); | 303 queue->Pop(); |
302 } | 304 } |
303 priority_count = (priority_count + 1) % arraysize(priorities); | 305 priority_count = (priority_count + 1) % arraysize(priorities); |
304 timer_.NextLap(); | 306 timer_.NextLap(); |
305 } while (!timer_.HasTimeLimitExpired()); | 307 } while (!timer_.HasTimeLimitExpired()); |
306 | 308 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 std::vector<FakePictureLayerImpl*> layers; | 345 std::vector<FakePictureLayerImpl*> layers; |
344 | 346 |
345 // Pending layer counts as one layer. | 347 // Pending layer counts as one layer. |
346 layers.push_back(pending_root_layer_); | 348 layers.push_back(pending_root_layer_); |
347 int next_id = id_ + 1; | 349 int next_id = id_ + 1; |
348 | 350 |
349 // Create the rest of the layers as children of the root layer. | 351 // Create the rest of the layers as children of the root layer. |
350 scoped_refptr<FakeRasterSource> raster_source = | 352 scoped_refptr<FakeRasterSource> raster_source = |
351 FakeRasterSource::CreateFilled(layer_bounds); | 353 FakeRasterSource::CreateFilled(layer_bounds); |
352 while (static_cast<int>(layers.size()) < layer_count) { | 354 while (static_cast<int>(layers.size()) < layer_count) { |
353 scoped_ptr<FakePictureLayerImpl> layer = | 355 std::unique_ptr<FakePictureLayerImpl> layer = |
354 FakePictureLayerImpl::CreateWithRasterSource( | 356 FakePictureLayerImpl::CreateWithRasterSource( |
355 host_impl_.pending_tree(), next_id, raster_source); | 357 host_impl_.pending_tree(), next_id, raster_source); |
356 layer->SetBounds(layer_bounds); | 358 layer->SetBounds(layer_bounds); |
357 layer->SetDrawsContent(true); | 359 layer->SetDrawsContent(true); |
358 layers.push_back(layer.get()); | 360 layers.push_back(layer.get()); |
359 pending_root_layer_->AddChild(std::move(layer)); | 361 pending_root_layer_->AddChild(std::move(layer)); |
360 ++next_id; | 362 ++next_id; |
361 } | 363 } |
362 | 364 |
363 // Property trees need to be rebuilt because layers were added above. | 365 // Property trees need to be rebuilt because layers were added above. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 412 |
411 protected: | 413 protected: |
412 GlobalStateThatImpactsTilePriority global_state_; | 414 GlobalStateThatImpactsTilePriority global_state_; |
413 | 415 |
414 TestSharedBitmapManager shared_bitmap_manager_; | 416 TestSharedBitmapManager shared_bitmap_manager_; |
415 TestTaskGraphRunner task_graph_runner_; | 417 TestTaskGraphRunner task_graph_runner_; |
416 TileMemoryLimitPolicy memory_limit_policy_; | 418 TileMemoryLimitPolicy memory_limit_policy_; |
417 int max_tiles_; | 419 int max_tiles_; |
418 int id_; | 420 int id_; |
419 FakeImplTaskRunnerProvider task_runner_provider_; | 421 FakeImplTaskRunnerProvider task_runner_provider_; |
420 scoped_ptr<OutputSurface> output_surface_; | 422 std::unique_ptr<OutputSurface> output_surface_; |
421 FakeLayerTreeHostImpl host_impl_; | 423 FakeLayerTreeHostImpl host_impl_; |
422 FakePictureLayerImpl* pending_root_layer_; | 424 FakePictureLayerImpl* pending_root_layer_; |
423 FakePictureLayerImpl* active_root_layer_; | 425 FakePictureLayerImpl* active_root_layer_; |
424 LapTimer timer_; | 426 LapTimer timer_; |
425 LayerTreeSettings settings_; | 427 LayerTreeSettings settings_; |
426 }; | 428 }; |
427 | 429 |
428 TEST_F(TileManagerPerfTest, PrepareTiles) { | 430 TEST_F(TileManagerPerfTest, PrepareTiles) { |
429 RunPrepareTilesTest("2_100", 2, 100); | 431 RunPrepareTilesTest("2_100", 2, 100); |
430 RunPrepareTilesTest("2_500", 2, 500); | 432 RunPrepareTilesTest("2_500", 2, 500); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 RunEvictionQueueConstructAndIterateTest("10_64", 10, 64); | 476 RunEvictionQueueConstructAndIterateTest("10_64", 10, 64); |
475 RunEvictionQueueConstructAndIterateTest("10_128", 10, 128); | 477 RunEvictionQueueConstructAndIterateTest("10_128", 10, 128); |
476 RunEvictionQueueConstructAndIterateTest("50_16", 50, 16); | 478 RunEvictionQueueConstructAndIterateTest("50_16", 50, 16); |
477 RunEvictionQueueConstructAndIterateTest("50_32", 50, 32); | 479 RunEvictionQueueConstructAndIterateTest("50_32", 50, 32); |
478 RunEvictionQueueConstructAndIterateTest("50_64", 50, 64); | 480 RunEvictionQueueConstructAndIterateTest("50_64", 50, 64); |
479 RunEvictionQueueConstructAndIterateTest("50_128", 50, 128); | 481 RunEvictionQueueConstructAndIterateTest("50_128", 50, 128); |
480 } | 482 } |
481 | 483 |
482 } // namespace | 484 } // namespace |
483 } // namespace cc | 485 } // namespace cc |
OLD | NEW |