| 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/time/time.h" | 5 #include "base/time/time.h" |
| 6 #include "cc/debug/lap_timer.h" | 6 #include "cc/debug/lap_timer.h" |
| 7 #include "cc/resources/raster_buffer.h" | 7 #include "cc/resources/raster_buffer.h" |
| 8 #include "cc/resources/tile.h" | 8 #include "cc/resources/tile.h" |
| 9 #include "cc/resources/tile_priority.h" | 9 #include "cc/resources/tile_priority.h" |
| 10 #include "cc/test/begin_frame_args_test.h" | 10 #include "cc/test/begin_frame_args_test.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "ui/gfx/frame_time.h" | 27 #include "ui/gfx/frame_time.h" |
| 28 | 28 |
| 29 namespace cc { | 29 namespace cc { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 static const int kTimeLimitMillis = 2000; | 33 static const int kTimeLimitMillis = 2000; |
| 34 static const int kWarmupRuns = 5; | 34 static const int kWarmupRuns = 5; |
| 35 static const int kTimeCheckInterval = 10; | 35 static const int kTimeCheckInterval = 10; |
| 36 | 36 |
| 37 class FakeRasterizerImpl : public Rasterizer, public RasterizerTaskClient { | 37 class FakeTileTaskRunnerImpl : public TileTaskRunner, public TileTaskClient { |
| 38 public: | 38 public: |
| 39 // Overridden from Rasterizer: | 39 // Overridden from TileTaskRunner: |
| 40 void SetClient(RasterizerClient* client) override {} | 40 void SetClient(TileTaskRunnerClient* client) override {} |
| 41 void Shutdown() override {} | 41 void Shutdown() override {} |
| 42 void ScheduleTasks(RasterTaskQueue* queue) override { | 42 void ScheduleTasks(TileTaskQueue* queue) override { |
| 43 for (RasterTaskQueue::Item::Vector::const_iterator it = | 43 for (TileTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); |
| 44 queue->items.begin(); | 44 it != queue->items.end(); ++it) { |
| 45 it != queue->items.end(); | |
| 46 ++it) { | |
| 47 RasterTask* task = it->task; | 45 RasterTask* task = it->task; |
| 48 | 46 |
| 49 task->WillSchedule(); | 47 task->WillSchedule(); |
| 50 task->ScheduleOnOriginThread(this); | 48 task->ScheduleOnOriginThread(this); |
| 51 task->DidSchedule(); | 49 task->DidSchedule(); |
| 52 | 50 |
| 53 completed_tasks_.push_back(task); | 51 completed_tasks_.push_back(task); |
| 54 } | 52 } |
| 55 } | 53 } |
| 56 void CheckForCompletedTasks() override { | 54 void CheckForCompletedTasks() override { |
| 57 for (RasterTask::Vector::iterator it = completed_tasks_.begin(); | 55 for (RasterTask::Vector::iterator it = completed_tasks_.begin(); |
| 58 it != completed_tasks_.end(); | 56 it != completed_tasks_.end(); |
| 59 ++it) { | 57 ++it) { |
| 60 RasterTask* task = it->get(); | 58 RasterTask* task = it->get(); |
| 61 | 59 |
| 62 task->WillComplete(); | 60 task->WillComplete(); |
| 63 task->CompleteOnOriginThread(this); | 61 task->CompleteOnOriginThread(this); |
| 64 task->DidComplete(); | 62 task->DidComplete(); |
| 65 | 63 |
| 66 task->RunReplyOnOriginThread(); | 64 task->RunReplyOnOriginThread(); |
| 67 } | 65 } |
| 68 completed_tasks_.clear(); | 66 completed_tasks_.clear(); |
| 69 } | 67 } |
| 70 | 68 |
| 71 // Overridden from RasterizerTaskClient: | 69 // Overridden from TileTaskClient: |
| 72 scoped_ptr<RasterBuffer> AcquireBufferForRaster( | 70 scoped_ptr<RasterBuffer> AcquireBufferForRaster( |
| 73 const Resource* resource) override { | 71 const Resource* resource) override { |
| 74 return nullptr; | 72 return nullptr; |
| 75 } | 73 } |
| 76 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override {} | 74 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override {} |
| 77 | 75 |
| 78 private: | 76 private: |
| 79 RasterTask::Vector completed_tasks_; | 77 RasterTask::Vector completed_tasks_; |
| 80 }; | 78 }; |
| 81 base::LazyInstance<FakeRasterizerImpl> g_fake_rasterizer = | 79 base::LazyInstance<FakeTileTaskRunnerImpl> g_fake_tile_task_runner = |
| 82 LAZY_INSTANCE_INITIALIZER; | 80 LAZY_INSTANCE_INITIALIZER; |
| 83 | 81 |
| 84 class TileManagerPerfTest : public testing::Test { | 82 class TileManagerPerfTest : public testing::Test { |
| 85 public: | 83 public: |
| 86 TileManagerPerfTest() | 84 TileManagerPerfTest() |
| 87 : memory_limit_policy_(ALLOW_ANYTHING), | 85 : memory_limit_policy_(ALLOW_ANYTHING), |
| 88 max_tiles_(10000), | 86 max_tiles_(10000), |
| 89 id_(7), | 87 id_(7), |
| 90 proxy_(base::MessageLoopProxy::current()), | 88 proxy_(base::MessageLoopProxy::current()), |
| 91 host_impl_(ImplSidePaintingSettings(10000), | 89 host_impl_(ImplSidePaintingSettings(10000), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 111 host_impl_.tile_manager()->SetGlobalStateForTesting(state); | 109 host_impl_.tile_manager()->SetGlobalStateForTesting(state); |
| 112 } | 110 } |
| 113 | 111 |
| 114 void SetUp() override { | 112 void SetUp() override { |
| 115 InitializeRenderer(); | 113 InitializeRenderer(); |
| 116 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 114 SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
| 117 } | 115 } |
| 118 | 116 |
| 119 virtual void InitializeRenderer() { | 117 virtual void InitializeRenderer() { |
| 120 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d().Pass()); | 118 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d().Pass()); |
| 121 tile_manager()->SetRasterizerForTesting(g_fake_rasterizer.Pointer()); | 119 tile_manager()->SetTileTaskRunnerForTesting( |
| 120 g_fake_tile_task_runner.Pointer()); |
| 122 } | 121 } |
| 123 | 122 |
| 124 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 123 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 125 scoped_refptr<FakePicturePileImpl> pending_pile = | 124 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 126 FakePicturePileImpl::CreateFilledPile(kDefaultTileSize, layer_bounds); | 125 FakePicturePileImpl::CreateFilledPile(kDefaultTileSize, layer_bounds); |
| 127 scoped_refptr<FakePicturePileImpl> active_pile = | 126 scoped_refptr<FakePicturePileImpl> active_pile = |
| 128 FakePicturePileImpl::CreateFilledPile(kDefaultTileSize, layer_bounds); | 127 FakePicturePileImpl::CreateFilledPile(kDefaultTileSize, layer_bounds); |
| 129 | 128 |
| 130 SetupTrees(pending_pile, active_pile); | 129 SetupTrees(pending_pile, active_pile); |
| 131 } | 130 } |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 state.soft_memory_limit_in_bytes = | 384 state.soft_memory_limit_in_bytes = |
| 386 10000u * 4u * | 385 10000u * 4u * |
| 387 static_cast<size_t>(tile_size.width() * tile_size.height()); | 386 static_cast<size_t>(tile_size.width() * tile_size.height()); |
| 388 state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes; | 387 state.hard_memory_limit_in_bytes = state.soft_memory_limit_in_bytes; |
| 389 state.num_resources_limit = 10000; | 388 state.num_resources_limit = 10000; |
| 390 state.memory_limit_policy = ALLOW_ANYTHING; | 389 state.memory_limit_policy = ALLOW_ANYTHING; |
| 391 state.tree_priority = SMOOTHNESS_TAKES_PRIORITY; | 390 state.tree_priority = SMOOTHNESS_TAKES_PRIORITY; |
| 392 return state; | 391 return state; |
| 393 } | 392 } |
| 394 | 393 |
| 395 void RunManageTilesTest(const std::string& test_name, | 394 void RunPrepareTilesTest(const std::string& test_name, |
| 396 int layer_count, | 395 int layer_count, |
| 397 int approximate_tile_count_per_layer) { | 396 int approximate_tile_count_per_layer) { |
| 398 std::vector<LayerImpl*> layers = | 397 std::vector<LayerImpl*> layers = |
| 399 CreateLayers(layer_count, approximate_tile_count_per_layer); | 398 CreateLayers(layer_count, approximate_tile_count_per_layer); |
| 400 timer_.Reset(); | 399 timer_.Reset(); |
| 401 bool resourceless_software_draw = false; | 400 bool resourceless_software_draw = false; |
| 402 do { | 401 do { |
| 403 BeginFrameArgs args = | 402 BeginFrameArgs args = |
| 404 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 403 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 405 host_impl_.UpdateCurrentBeginFrameArgs(args); | 404 host_impl_.UpdateCurrentBeginFrameArgs(args); |
| 406 for (unsigned i = 0; i < layers.size(); ++i) { | 405 for (unsigned i = 0; i < layers.size(); ++i) { |
| 407 layers[i]->UpdateTiles(Occlusion(), resourceless_software_draw); | 406 layers[i]->UpdateTiles(Occlusion(), resourceless_software_draw); |
| 408 } | 407 } |
| 409 | 408 |
| 410 GlobalStateThatImpactsTilePriority global_state(GlobalStateForTest()); | 409 GlobalStateThatImpactsTilePriority global_state(GlobalStateForTest()); |
| 411 tile_manager()->ManageTiles(global_state); | 410 tile_manager()->PrepareTiles(global_state); |
| 412 tile_manager()->UpdateVisibleTiles(); | 411 tile_manager()->UpdateVisibleTiles(); |
| 413 timer_.NextLap(); | 412 timer_.NextLap(); |
| 414 host_impl_.ResetCurrentBeginFrameArgsForNextFrame(); | 413 host_impl_.ResetCurrentBeginFrameArgsForNextFrame(); |
| 415 } while (!timer_.HasTimeLimitExpired()); | 414 } while (!timer_.HasTimeLimitExpired()); |
| 416 | 415 |
| 417 perf_test::PrintResult( | 416 perf_test::PrintResult("prepare_tiles", "", test_name, |
| 418 "manage_tiles", "", test_name, timer_.LapsPerSecond(), "runs/s", true); | 417 timer_.LapsPerSecond(), "runs/s", true); |
| 419 } | 418 } |
| 420 | 419 |
| 421 TileManager* tile_manager() { return host_impl_.tile_manager(); } | 420 TileManager* tile_manager() { return host_impl_.tile_manager(); } |
| 422 | 421 |
| 423 protected: | 422 protected: |
| 424 GlobalStateThatImpactsTilePriority global_state_; | 423 GlobalStateThatImpactsTilePriority global_state_; |
| 425 | 424 |
| 426 TestSharedBitmapManager shared_bitmap_manager_; | 425 TestSharedBitmapManager shared_bitmap_manager_; |
| 427 TileMemoryLimitPolicy memory_limit_policy_; | 426 TileMemoryLimitPolicy memory_limit_policy_; |
| 428 int max_tiles_; | 427 int max_tiles_; |
| 429 int id_; | 428 int id_; |
| 430 FakeImplProxy proxy_; | 429 FakeImplProxy proxy_; |
| 431 FakeLayerTreeHostImpl host_impl_; | 430 FakeLayerTreeHostImpl host_impl_; |
| 432 FakePictureLayerImpl* pending_root_layer_; | 431 FakePictureLayerImpl* pending_root_layer_; |
| 433 FakePictureLayerImpl* active_root_layer_; | 432 FakePictureLayerImpl* active_root_layer_; |
| 434 LapTimer timer_; | 433 LapTimer timer_; |
| 435 LayerTreeSettings settings_; | 434 LayerTreeSettings settings_; |
| 436 | 435 |
| 437 static const gfx::Size kDefaultTileSize; | 436 static const gfx::Size kDefaultTileSize; |
| 438 }; | 437 }; |
| 439 | 438 |
| 440 const gfx::Size TileManagerPerfTest::kDefaultTileSize(100, 100); | 439 const gfx::Size TileManagerPerfTest::kDefaultTileSize(100, 100); |
| 441 | 440 |
| 442 TEST_F(TileManagerPerfTest, ManageTiles) { | 441 TEST_F(TileManagerPerfTest, PrepareTiles) { |
| 443 RunManageTilesTest("2_100", 2, 100); | 442 RunPrepareTilesTest("2_100", 2, 100); |
| 444 RunManageTilesTest("2_500", 2, 500); | 443 RunPrepareTilesTest("2_500", 2, 500); |
| 445 RunManageTilesTest("2_1000", 2, 1000); | 444 RunPrepareTilesTest("2_1000", 2, 1000); |
| 446 RunManageTilesTest("10_100", 10, 100); | 445 RunPrepareTilesTest("10_100", 10, 100); |
| 447 RunManageTilesTest("10_500", 10, 500); | 446 RunPrepareTilesTest("10_500", 10, 500); |
| 448 RunManageTilesTest("10_1000", 10, 1000); | 447 RunPrepareTilesTest("10_1000", 10, 1000); |
| 449 RunManageTilesTest("50_100", 100, 100); | 448 RunPrepareTilesTest("50_100", 100, 100); |
| 450 RunManageTilesTest("50_500", 100, 500); | 449 RunPrepareTilesTest("50_500", 100, 500); |
| 451 RunManageTilesTest("50_1000", 100, 1000); | 450 RunPrepareTilesTest("50_1000", 100, 1000); |
| 452 } | 451 } |
| 453 | 452 |
| 454 TEST_F(TileManagerPerfTest, RasterTileQueueConstruct) { | 453 TEST_F(TileManagerPerfTest, RasterTileQueueConstruct) { |
| 455 RunRasterQueueConstructTest("2", 2); | 454 RunRasterQueueConstructTest("2", 2); |
| 456 RunRasterQueueConstructTest("10", 10); | 455 RunRasterQueueConstructTest("10", 10); |
| 457 RunRasterQueueConstructTest("50", 50); | 456 RunRasterQueueConstructTest("50", 50); |
| 458 } | 457 } |
| 459 | 458 |
| 460 TEST_F(TileManagerPerfTest, RasterTileQueueConstructAndIterate) { | 459 TEST_F(TileManagerPerfTest, RasterTileQueueConstructAndIterate) { |
| 461 RunRasterQueueConstructAndIterateTest("2_16", 2, 16); | 460 RunRasterQueueConstructAndIterateTest("2_16", 2, 16); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 489 RunEvictionQueueConstructAndIterateTest("10_128", 10, 128); | 488 RunEvictionQueueConstructAndIterateTest("10_128", 10, 128); |
| 490 RunEvictionQueueConstructAndIterateTest("50_16", 50, 16); | 489 RunEvictionQueueConstructAndIterateTest("50_16", 50, 16); |
| 491 RunEvictionQueueConstructAndIterateTest("50_32", 50, 32); | 490 RunEvictionQueueConstructAndIterateTest("50_32", 50, 32); |
| 492 RunEvictionQueueConstructAndIterateTest("50_64", 50, 64); | 491 RunEvictionQueueConstructAndIterateTest("50_64", 50, 64); |
| 493 RunEvictionQueueConstructAndIterateTest("50_128", 50, 128); | 492 RunEvictionQueueConstructAndIterateTest("50_128", 50, 128); |
| 494 } | 493 } |
| 495 | 494 |
| 496 } // namespace | 495 } // namespace |
| 497 | 496 |
| 498 } // namespace cc | 497 } // namespace cc |
| OLD | NEW |