| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // to be > BeginFrameArgs::DefaultInterval() | 262 // to be > BeginFrameArgs::DefaultInterval() |
| 263 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); | 263 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); |
| 264 // Fail if we need to run 100 tasks in a row. | 264 // Fail if we need to run 100 tasks in a row. |
| 265 task_runner_->SetRunTaskLimit(100); | 265 task_runner_->SetRunTaskLimit(100); |
| 266 } | 266 } |
| 267 | 267 |
| 268 ~SchedulerTest() override {} | 268 ~SchedulerTest() override {} |
| 269 | 269 |
| 270 protected: | 270 protected: |
| 271 TestScheduler* CreateScheduler() { | 271 TestScheduler* CreateScheduler() { |
| 272 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source; | |
| 273 if (scheduler_settings_.use_external_begin_frame_source) { | 272 if (scheduler_settings_.use_external_begin_frame_source) { |
| 274 fake_external_begin_frame_source.reset( | 273 fake_external_begin_frame_source_.reset( |
| 275 new FakeExternalBeginFrameSource(client_.get())); | 274 new FakeExternalBeginFrameSource(client_.get())); |
| 276 fake_external_begin_frame_source_ = | |
| 277 fake_external_begin_frame_source.get(); | |
| 278 } | 275 } |
| 279 scheduler_ = TestScheduler::Create(now_src_.get(), client_.get(), | 276 scheduler_ = TestScheduler::Create( |
| 280 scheduler_settings_, 0, task_runner_, | 277 now_src_.get(), client_.get(), scheduler_settings_, 0, |
| 281 fake_external_begin_frame_source.Pass()); | 278 task_runner_.get(), fake_external_begin_frame_source_.get()); |
| 282 DCHECK(scheduler_); | 279 DCHECK(scheduler_); |
| 283 client_->set_scheduler(scheduler_.get()); | 280 client_->set_scheduler(scheduler_.get()); |
| 284 return scheduler_.get(); | 281 return scheduler_.get(); |
| 285 } | 282 } |
| 286 | 283 |
| 287 void CreateSchedulerAndInitSurface() { | 284 void CreateSchedulerAndInitSurface() { |
| 288 CreateScheduler(); | 285 CreateScheduler(); |
| 289 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); | 286 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); |
| 290 } | 287 } |
| 291 | 288 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 // Creep the time forward so that any BeginFrameArgs is not equal to the | 405 // Creep the time forward so that any BeginFrameArgs is not equal to the |
| 409 // last one otherwise we violate the BeginFrameSource contract. | 406 // last one otherwise we violate the BeginFrameSource contract. |
| 410 now_src_->Advance(BeginFrameArgs::DefaultInterval()); | 407 now_src_->Advance(BeginFrameArgs::DefaultInterval()); |
| 411 BeginFrameArgs args = | 408 BeginFrameArgs args = |
| 412 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 409 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| 413 fake_external_begin_frame_source_->TestOnBeginFrame(args); | 410 fake_external_begin_frame_source_->TestOnBeginFrame(args); |
| 414 return args; | 411 return args; |
| 415 } | 412 } |
| 416 | 413 |
| 417 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { | 414 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { |
| 418 return fake_external_begin_frame_source_; | 415 return fake_external_begin_frame_source_.get(); |
| 419 } | 416 } |
| 420 | 417 |
| 421 void MainFrameInHighLatencyMode( | 418 void MainFrameInHighLatencyMode( |
| 422 int64 begin_main_frame_to_commit_estimate_in_ms, | 419 int64 begin_main_frame_to_commit_estimate_in_ms, |
| 423 int64 commit_to_activate_estimate_in_ms, | 420 int64 commit_to_activate_estimate_in_ms, |
| 424 bool impl_latency_takes_priority, | 421 bool impl_latency_takes_priority, |
| 425 bool should_send_begin_main_frame); | 422 bool should_send_begin_main_frame); |
| 426 void BeginFramesNotFromClient(bool use_external_begin_frame_source, | 423 void BeginFramesNotFromClient(bool use_external_begin_frame_source, |
| 427 bool throttle_frame_production); | 424 bool throttle_frame_production); |
| 428 void BeginFramesNotFromClient_SwapThrottled( | 425 void BeginFramesNotFromClient_SwapThrottled( |
| 429 bool use_external_begin_frame_source, | 426 bool use_external_begin_frame_source, |
| 430 bool throttle_frame_production); | 427 bool throttle_frame_production); |
| 431 void DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency( | 428 void DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency( |
| 432 bool impl_side_painting); | 429 bool impl_side_painting); |
| 433 void DidLoseOutputSurfaceAfterReadyToCommit(bool impl_side_painting); | 430 void DidLoseOutputSurfaceAfterReadyToCommit(bool impl_side_painting); |
| 434 | 431 |
| 435 scoped_ptr<base::SimpleTestTickClock> now_src_; | 432 scoped_ptr<base::SimpleTestTickClock> now_src_; |
| 436 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 433 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
| 437 FakeExternalBeginFrameSource* fake_external_begin_frame_source_; | 434 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source_; |
| 438 SchedulerSettings scheduler_settings_; | 435 SchedulerSettings scheduler_settings_; |
| 439 scoped_ptr<FakeSchedulerClient> client_; | 436 scoped_ptr<FakeSchedulerClient> client_; |
| 440 scoped_ptr<TestScheduler> scheduler_; | 437 scoped_ptr<TestScheduler> scheduler_; |
| 441 }; | 438 }; |
| 442 | 439 |
| 443 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { | 440 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { |
| 444 scheduler_settings_.use_external_begin_frame_source = true; | 441 scheduler_settings_.use_external_begin_frame_source = true; |
| 445 SetUpScheduler(false); | 442 SetUpScheduler(false); |
| 446 scheduler_->SetCanStart(); | 443 scheduler_->SetCanStart(); |
| 447 scheduler_->SetVisible(true); | 444 scheduler_->SetVisible(true); |
| (...skipping 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3034 scheduler_->SetImplLatencyTakesPriority(true); | 3031 scheduler_->SetImplLatencyTakesPriority(true); |
| 3035 scheduler_->SetChildrenNeedBeginFrames(true); | 3032 scheduler_->SetChildrenNeedBeginFrames(true); |
| 3036 | 3033 |
| 3037 EXPECT_SCOPED(AdvanceFrame()); | 3034 EXPECT_SCOPED(AdvanceFrame()); |
| 3038 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 3035 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| 3039 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); | 3036 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); |
| 3040 } | 3037 } |
| 3041 | 3038 |
| 3042 } // namespace | 3039 } // namespace |
| 3043 } // namespace cc | 3040 } // namespace cc |
| OLD | NEW |