| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/scheduler/scheduler.h" | 5 #include "cc/scheduler/scheduler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // to be > BeginFrameArgs::DefaultInterval() | 249 // to be > BeginFrameArgs::DefaultInterval() |
| 250 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); | 250 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); |
| 251 // Fail if we need to run 100 tasks in a row. | 251 // Fail if we need to run 100 tasks in a row. |
| 252 task_runner_->SetRunTaskLimit(100); | 252 task_runner_->SetRunTaskLimit(100); |
| 253 } | 253 } |
| 254 | 254 |
| 255 ~SchedulerTest() override {} | 255 ~SchedulerTest() override {} |
| 256 | 256 |
| 257 protected: | 257 protected: |
| 258 TestScheduler* CreateScheduler() { | 258 TestScheduler* CreateScheduler() { |
| 259 if (scheduler_settings_.use_external_begin_frame_source) { | 259 BeginFrameSource* frame_source; |
| 260 if (!scheduler_settings_.throttle_frame_production) { |
| 261 unthrottled_frame_source_ = TestBackToBackBeginFrameSource::Create( |
| 262 now_src_.get(), task_runner_.get()); |
| 263 frame_source = unthrottled_frame_source_.get(); |
| 264 } else if (scheduler_settings_.use_external_begin_frame_source) { |
| 260 fake_external_begin_frame_source_.reset( | 265 fake_external_begin_frame_source_.reset( |
| 261 new FakeExternalBeginFrameSource(client_.get())); | 266 new FakeExternalBeginFrameSource(client_.get())); |
| 267 frame_source = fake_external_begin_frame_source_.get(); |
| 268 } else { |
| 269 synthetic_frame_source_ = TestSyntheticBeginFrameSource::Create( |
| 270 now_src_.get(), task_runner_.get(), |
| 271 BeginFrameArgs::DefaultInterval()); |
| 272 frame_source = synthetic_frame_source_.get(); |
| 262 } | 273 } |
| 263 | 274 |
| 264 scoped_ptr<FakeCompositorTimingHistory> fake_compositor_timing_history = | 275 scoped_ptr<FakeCompositorTimingHistory> fake_compositor_timing_history = |
| 265 FakeCompositorTimingHistory::Create( | 276 FakeCompositorTimingHistory::Create( |
| 266 scheduler_settings_.using_synchronous_renderer_compositor); | 277 scheduler_settings_.using_synchronous_renderer_compositor); |
| 267 fake_compositor_timing_history_ = fake_compositor_timing_history.get(); | 278 fake_compositor_timing_history_ = fake_compositor_timing_history.get(); |
| 268 | 279 |
| 269 scheduler_ = TestScheduler::Create( | 280 scheduler_.reset( |
| 270 now_src_.get(), client_.get(), scheduler_settings_, 0, | 281 new TestScheduler(now_src_.get(), client_.get(), scheduler_settings_, 0, |
| 271 task_runner_.get(), fake_external_begin_frame_source_.get(), | 282 task_runner_.get(), frame_source, |
| 272 std::move(fake_compositor_timing_history)); | 283 std::move(fake_compositor_timing_history))); |
| 273 DCHECK(scheduler_); | 284 DCHECK(scheduler_); |
| 274 client_->set_scheduler(scheduler_.get()); | 285 client_->set_scheduler(scheduler_.get()); |
| 275 | 286 |
| 276 // Use large estimates by default to avoid latency recovery in most tests. | 287 // Use large estimates by default to avoid latency recovery in most tests. |
| 277 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); | 288 fake_compositor_timing_history_->SetAllEstimatesTo(kSlowDuration); |
| 278 | 289 |
| 279 return scheduler_.get(); | 290 return scheduler_.get(); |
| 280 } | 291 } |
| 281 | 292 |
| 282 void CreateSchedulerAndInitSurface() { | 293 void CreateSchedulerAndInitSurface() { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 void BeginFramesNotFromClient_SwapThrottled( | 433 void BeginFramesNotFromClient_SwapThrottled( |
| 423 bool use_external_begin_frame_source, | 434 bool use_external_begin_frame_source, |
| 424 bool throttle_frame_production); | 435 bool throttle_frame_production); |
| 425 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority, | 436 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority, |
| 426 ScrollHandlerState scroll_handler_state, | 437 ScrollHandlerState scroll_handler_state, |
| 427 base::TimeDelta durations); | 438 base::TimeDelta durations); |
| 428 | 439 |
| 429 scoped_ptr<base::SimpleTestTickClock> now_src_; | 440 scoped_ptr<base::SimpleTestTickClock> now_src_; |
| 430 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 441 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
| 431 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source_; | 442 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source_; |
| 443 scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source_; |
| 444 scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source_; |
| 432 SchedulerSettings scheduler_settings_; | 445 SchedulerSettings scheduler_settings_; |
| 433 scoped_ptr<FakeSchedulerClient> client_; | 446 scoped_ptr<FakeSchedulerClient> client_; |
| 434 scoped_ptr<TestScheduler> scheduler_; | 447 scoped_ptr<TestScheduler> scheduler_; |
| 435 FakeCompositorTimingHistory* fake_compositor_timing_history_; | 448 FakeCompositorTimingHistory* fake_compositor_timing_history_; |
| 436 }; | 449 }; |
| 437 | 450 |
| 438 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { | 451 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { |
| 439 scheduler_settings_.use_external_begin_frame_source = true; | 452 scheduler_settings_.use_external_begin_frame_source = true; |
| 440 SetUpScheduler(false); | 453 SetUpScheduler(false); |
| 441 scheduler_->SetVisible(true); | 454 scheduler_->SetVisible(true); |
| (...skipping 2997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3439 scheduler_->SetNeedsBeginMainFrame(); | 3452 scheduler_->SetNeedsBeginMainFrame(); |
| 3440 EXPECT_SCOPED(AdvanceFrame()); | 3453 EXPECT_SCOPED(AdvanceFrame()); |
| 3441 | 3454 |
| 3442 EXPECT_EQ(initial_interval, scheduler_->BeginImplFrameInterval()); | 3455 EXPECT_EQ(initial_interval, scheduler_->BeginImplFrameInterval()); |
| 3443 | 3456 |
| 3444 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); | 3457 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); |
| 3445 scheduler_->NotifyReadyToCommit(); | 3458 scheduler_->NotifyReadyToCommit(); |
| 3446 scheduler_->NotifyReadyToActivate(); | 3459 scheduler_->NotifyReadyToActivate(); |
| 3447 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 3460 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 3448 | 3461 |
| 3449 scheduler_->SetAuthoritativeVSyncInterval(authoritative_interval); | 3462 // Test changing the interval on the frame source external to the scheduler. |
| 3463 synthetic_frame_source_->OnUpdateVSyncParameters(now_src_->NowTicks(), |
| 3464 authoritative_interval); |
| 3450 | 3465 |
| 3451 EXPECT_SCOPED(AdvanceFrame()); | 3466 EXPECT_SCOPED(AdvanceFrame()); |
| 3452 | 3467 |
| 3453 // At the next BeginFrame, authoritative interval is used instead of previous | 3468 // At the next BeginFrame, authoritative interval is used instead of previous |
| 3454 // interval. | 3469 // interval. |
| 3455 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval()); | 3470 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval()); |
| 3456 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval()); | 3471 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval()); |
| 3457 } | 3472 } |
| 3458 | 3473 |
| 3459 TEST_F(SchedulerTest, ImplLatencyTakesPriority) { | 3474 TEST_F(SchedulerTest, ImplLatencyTakesPriority) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3561 } | 3576 } |
| 3562 | 3577 |
| 3563 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3578 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
| 3564 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3579 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
| 3565 SMOOTHNESS_TAKES_PRIORITY, | 3580 SMOOTHNESS_TAKES_PRIORITY, |
| 3566 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3581 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
| 3567 } | 3582 } |
| 3568 | 3583 |
| 3569 } // namespace | 3584 } // namespace |
| 3570 } // namespace cc | 3585 } // namespace cc |
| OLD | NEW |