Chromium Code Reviews| Index: cc/scheduler/scheduler.cc |
| diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc |
| index 143c3ff54489573b1e22bf3a2a35ee17fecb1d95..57366e04a1254c123cb7f12dc66053f34e88b8aa 100644 |
| --- a/cc/scheduler/scheduler.cc |
| +++ b/cc/scheduler/scheduler.cc |
| @@ -71,6 +71,17 @@ SchedulerFrameSourcesConstructor::ConstructBackgroundFrameSource( |
| return scheduler->background_frame_source_internal_.get(); |
| } |
| +BeginFrameSource* |
| +SchedulerFrameSourcesConstructor::ConstructUnthrottledFrameSource( |
| + Scheduler* scheduler) { |
| + TRACE_EVENT1("cc", "Scheduler::Scheduler()", "PrimaryFrameSource", |
| + "BackToBackBeginFrameSource"); |
| + DCHECK(!scheduler->unthrottled_frame_source_internal_); |
| + scheduler->unthrottled_frame_source_internal_ = |
| + BackToBackBeginFrameSource::Create(scheduler->task_runner_.get()); |
| + return scheduler->unthrottled_frame_source_internal_.get(); |
| +} |
| + |
| Scheduler::Scheduler( |
| SchedulerClient* client, |
| const SchedulerSettings& scheduler_settings, |
| @@ -85,6 +96,7 @@ Scheduler::Scheduler( |
| primary_frame_source_internal_(external_begin_frame_source.Pass()), |
| background_frame_source_internal_(), |
| vsync_observer_(NULL), |
| + throttle_frame_production_(scheduler_settings.throttle_frame_production), |
| settings_(scheduler_settings), |
| client_(client), |
| layer_tree_host_id_(layer_tree_host_id), |
| @@ -125,6 +137,11 @@ Scheduler::Scheduler( |
| frame_sources_constructor->ConstructBackgroundFrameSource(this); |
| frame_source_->AddSource(background_frame_source_); |
| + // Unthrottled frame source |
| + unthrottled_frame_source_ = |
| + frame_sources_constructor->ConstructUnthrottledFrameSource(this); |
| + frame_source_->AddSource(unthrottled_frame_source_); |
| + |
| SetupPowerMonitoring(); |
| } |
| @@ -184,16 +201,24 @@ void Scheduler::SetCanStart() { |
| ProcessScheduledActions(); |
| } |
| -void Scheduler::SetVisible(bool visible) { |
| - state_machine_.SetVisible(visible); |
| - if (visible) { |
| - frame_source_->SetActiveSource(primary_frame_source_); |
| +void Scheduler::UpdateActiveFrameSource() { |
| + if (state_machine_.visible()) { |
| + if (throttle_frame_production_) { |
| + frame_source_->SetActiveSource(primary_frame_source_); |
| + } else { |
| + frame_source_->SetActiveSource(unthrottled_frame_source_); |
| + } |
| } else { |
| frame_source_->SetActiveSource(background_frame_source_); |
| } |
| ProcessScheduledActions(); |
| } |
| +void Scheduler::SetVisible(bool visible) { |
| + state_machine_.SetVisible(visible); |
| + UpdateActiveFrameSource(); |
| +} |
| + |
| void Scheduler::SetCanDraw(bool can_draw) { |
| state_machine_.SetCanDraw(can_draw); |
| ProcessScheduledActions(); |
| @@ -209,6 +234,11 @@ void Scheduler::NotifyReadyToDraw() { |
| // crbugs 352894, 383157, 421923. |
| } |
| +void Scheduler::SetThrottleFrameProduction(bool throttle) { |
| + throttle_frame_production_ = settings_.throttle_frame_production && throttle; |
|
enne (OOO)
2014/12/15 23:21:07
It's a little odd to my eyes to have both a schedu
brianderson
2014/12/16 22:36:42
Can we make the command line flag only set the ini
|
| + UpdateActiveFrameSource(); |
| +} |
| + |
| void Scheduler::SetNeedsCommit() { |
| state_machine_.SetNeedsCommit(); |
| ProcessScheduledActions(); |