| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); | 238 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); |
| 239 // Fail if we need to run 100 tasks in a row. | 239 // Fail if we need to run 100 tasks in a row. |
| 240 task_runner_->SetRunTaskLimit(100); | 240 task_runner_->SetRunTaskLimit(100); |
| 241 } | 241 } |
| 242 | 242 |
| 243 ~SchedulerTest() override {} | 243 ~SchedulerTest() override {} |
| 244 | 244 |
| 245 protected: | 245 protected: |
| 246 TestScheduler* CreateScheduler() { | 246 TestScheduler* CreateScheduler() { |
| 247 BeginFrameSource* frame_source; | 247 BeginFrameSource* frame_source; |
| 248 unthrottled_frame_source_.reset( | 248 unthrottled_frame_source_.reset(new SyntheticBeginFrameSource( |
| 249 new TestBackToBackBeginFrameSource(now_src_.get(), task_runner_.get())); | 249 base::MakeUnique<TestDelayBasedTimeSource>(now_src_.get(), |
| 250 task_runner_.get()))); |
| 251 unthrottled_frame_source_->SetUnthrottled(true); |
| 250 fake_external_begin_frame_source_.reset( | 252 fake_external_begin_frame_source_.reset( |
| 251 new FakeExternalBeginFrameSource(client_.get())); | 253 new FakeExternalBeginFrameSource(client_.get())); |
| 252 synthetic_frame_source_.reset(new TestSyntheticBeginFrameSource( | 254 synthetic_frame_source_.reset(new SyntheticBeginFrameSource( |
| 253 now_src_.get(), task_runner_.get(), BeginFrameArgs::DefaultInterval())); | 255 base::MakeUnique<TestDelayBasedTimeSource>(now_src_.get(), |
| 256 task_runner_.get()))); |
| 254 if (!scheduler_settings_.throttle_frame_production) { | 257 if (!scheduler_settings_.throttle_frame_production) { |
| 255 frame_source = unthrottled_frame_source_.get(); | 258 frame_source = unthrottled_frame_source_.get(); |
| 256 } else if (scheduler_settings_.use_external_begin_frame_source) { | 259 } else if (scheduler_settings_.use_external_begin_frame_source) { |
| 257 frame_source = fake_external_begin_frame_source_.get(); | 260 frame_source = fake_external_begin_frame_source_.get(); |
| 258 } else { | 261 } else { |
| 259 frame_source = synthetic_frame_source_.get(); | 262 frame_source = synthetic_frame_source_.get(); |
| 260 } | 263 } |
| 261 | 264 |
| 262 std::unique_ptr<FakeCompositorTimingHistory> | 265 std::unique_ptr<FakeCompositorTimingHistory> |
| 263 fake_compositor_timing_history = FakeCompositorTimingHistory::Create( | 266 fake_compositor_timing_history = FakeCompositorTimingHistory::Create( |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 bool use_external_begin_frame_source, | 425 bool use_external_begin_frame_source, |
| 423 bool throttle_frame_production); | 426 bool throttle_frame_production); |
| 424 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority, | 427 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority, |
| 425 ScrollHandlerState scroll_handler_state, | 428 ScrollHandlerState scroll_handler_state, |
| 426 base::TimeDelta durations); | 429 base::TimeDelta durations); |
| 427 | 430 |
| 428 std::unique_ptr<base::SimpleTestTickClock> now_src_; | 431 std::unique_ptr<base::SimpleTestTickClock> now_src_; |
| 429 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 432 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
| 430 std::unique_ptr<FakeExternalBeginFrameSource> | 433 std::unique_ptr<FakeExternalBeginFrameSource> |
| 431 fake_external_begin_frame_source_; | 434 fake_external_begin_frame_source_; |
| 432 std::unique_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source_; | 435 std::unique_ptr<SyntheticBeginFrameSource> synthetic_frame_source_; |
| 433 std::unique_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source_; | 436 std::unique_ptr<SyntheticBeginFrameSource> unthrottled_frame_source_; |
| 434 SchedulerSettings scheduler_settings_; | 437 SchedulerSettings scheduler_settings_; |
| 435 std::unique_ptr<FakeSchedulerClient> client_; | 438 std::unique_ptr<FakeSchedulerClient> client_; |
| 436 std::unique_ptr<TestScheduler> scheduler_; | 439 std::unique_ptr<TestScheduler> scheduler_; |
| 437 FakeCompositorTimingHistory* fake_compositor_timing_history_; | 440 FakeCompositorTimingHistory* fake_compositor_timing_history_; |
| 438 }; | 441 }; |
| 439 | 442 |
| 440 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { | 443 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { |
| 441 scheduler_settings_.use_external_begin_frame_source = true; | 444 scheduler_settings_.use_external_begin_frame_source = true; |
| 442 SetUpScheduler(false); | 445 SetUpScheduler(false); |
| 443 scheduler_->SetVisible(true); | 446 scheduler_->SetVisible(true); |
| (...skipping 3251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3695 } | 3698 } |
| 3696 | 3699 |
| 3697 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3700 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
| 3698 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3701 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
| 3699 SMOOTHNESS_TAKES_PRIORITY, | 3702 SMOOTHNESS_TAKES_PRIORITY, |
| 3700 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3703 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
| 3701 } | 3704 } |
| 3702 | 3705 |
| 3703 } // namespace | 3706 } // namespace |
| 3704 } // namespace cc | 3707 } // namespace cc |
| OLD | NEW |