| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/debug/trace_event_argument.h" | 10 #include "base/debug/trace_event_argument.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 BeginFrameSource* Scheduler::GetPrimaryBeginFrameSource() { | 54 BeginFrameSource* Scheduler::GetPrimaryBeginFrameSource() { |
| 55 if (!settings_.throttle_frame_production) { | 55 if (!settings_.throttle_frame_production) { |
| 56 TRACE_EVENT1("cc", | 56 TRACE_EVENT1("cc", |
| 57 "Scheduler::Scheduler()", | 57 "Scheduler::Scheduler()", |
| 58 "PrimaryFrameSource", | 58 "PrimaryFrameSource", |
| 59 "BackToBackBeginFrameSource"); | 59 "BackToBackBeginFrameSource"); |
| 60 primary_frame_source_internal_ = | 60 primary_frame_source_internal_ = |
| 61 BackToBackBeginFrameSource::Create(task_runner_.get()); | 61 BackToBackBeginFrameSource::Create(task_runner_.get()); |
| 62 return primary_frame_source_internal_.get(); | 62 return primary_frame_source_internal_.get(); |
| 63 } else if (settings_.begin_frame_scheduling_enabled) { | 63 } else if (settings_.begin_frame_scheduling_enabled) { |
| 64 TRACE_EVENT1("cc", | 64 TRACE_EVENT1( |
| 65 "Scheduler::Scheduler()", | 65 "cc", "Scheduler::Scheduler()", "PrimaryFrameSource", "OutputSurface"); |
| 66 "PrimaryFrameSource", | 66 return NULL; |
| 67 "SchedulerClient"); | |
| 68 return client_->GetExternalBeginFrameSource(); | |
| 69 } else { | 67 } else { |
| 70 TRACE_EVENT1("cc", | 68 TRACE_EVENT1("cc", |
| 71 "Scheduler::Scheduler()", | 69 "Scheduler::Scheduler()", |
| 72 "PrimaryFrameSource", | 70 "PrimaryFrameSource", |
| 73 "SyntheticBeginFrameSource"); | 71 "SyntheticBeginFrameSource"); |
| 74 scoped_ptr<SyntheticBeginFrameSource> synthetic_source = | 72 scoped_ptr<SyntheticBeginFrameSource> synthetic_source = |
| 75 SyntheticBeginFrameSource::Create( | 73 SyntheticBeginFrameSource::Create( |
| 76 task_runner_.get(), Now(), BeginFrameArgs::DefaultInterval()); | 74 task_runner_.get(), Now(), BeginFrameArgs::DefaultInterval()); |
| 77 vsync_observer_ = synthetic_source.get(); | 75 vsync_observer_ = synthetic_source.get(); |
| 78 primary_frame_source_internal_ = synthetic_source.Pass(); | 76 primary_frame_source_internal_ = synthetic_source.Pass(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 121 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
| 124 DCHECK_GE(draw_time.ToInternalValue(), 0); | 122 DCHECK_GE(draw_time.ToInternalValue(), 0); |
| 125 estimated_parent_draw_time_ = draw_time; | 123 estimated_parent_draw_time_ = draw_time; |
| 126 } | 124 } |
| 127 | 125 |
| 128 void Scheduler::SetCanStart() { | 126 void Scheduler::SetCanStart() { |
| 129 state_machine_.SetCanStart(); | 127 state_machine_.SetCanStart(); |
| 130 ProcessScheduledActions(); | 128 ProcessScheduledActions(); |
| 131 } | 129 } |
| 132 | 130 |
| 131 void Scheduler::UpdateActiveFrameSource() { |
| 132 if (state_machine_.visible() && primary_frame_source_) { |
| 133 frame_source_->SetActiveSource(primary_frame_source_); |
| 134 } else { |
| 135 frame_source_->SetActiveSource(background_frame_source_); |
| 136 } |
| 137 } |
| 138 |
| 133 void Scheduler::SetVisible(bool visible) { | 139 void Scheduler::SetVisible(bool visible) { |
| 134 state_machine_.SetVisible(visible); | 140 state_machine_.SetVisible(visible); |
| 135 if (visible) { | 141 UpdateActiveFrameSource(); |
| 136 frame_source_->SetActiveSource(primary_frame_source_); | |
| 137 } else { | |
| 138 frame_source_->SetActiveSource(background_frame_source_); | |
| 139 } | |
| 140 ProcessScheduledActions(); | 142 ProcessScheduledActions(); |
| 141 } | 143 } |
| 142 | 144 |
| 143 void Scheduler::SetCanDraw(bool can_draw) { | 145 void Scheduler::SetCanDraw(bool can_draw) { |
| 144 state_machine_.SetCanDraw(can_draw); | 146 state_machine_.SetCanDraw(can_draw); |
| 145 ProcessScheduledActions(); | 147 ProcessScheduledActions(); |
| 146 } | 148 } |
| 147 | 149 |
| 148 void Scheduler::NotifyReadyToActivate() { | 150 void Scheduler::NotifyReadyToActivate() { |
| 149 state_machine_.NotifyReadyToActivate(); | 151 state_machine_.NotifyReadyToActivate(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 ProcessScheduledActions(); | 214 ProcessScheduledActions(); |
| 213 } | 215 } |
| 214 | 216 |
| 215 void Scheduler::DidManageTiles() { | 217 void Scheduler::DidManageTiles() { |
| 216 state_machine_.DidManageTiles(); | 218 state_machine_.DidManageTiles(); |
| 217 } | 219 } |
| 218 | 220 |
| 219 void Scheduler::DidLoseOutputSurface() { | 221 void Scheduler::DidLoseOutputSurface() { |
| 220 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface"); | 222 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface"); |
| 221 state_machine_.DidLoseOutputSurface(); | 223 state_machine_.DidLoseOutputSurface(); |
| 224 |
| 225 if (settings_.throttle_frame_production && |
| 226 settings_.begin_frame_scheduling_enabled && primary_frame_source_) { |
| 227 frame_source_->RemoveSource(primary_frame_source_); |
| 228 primary_frame_source_ = NULL; |
| 229 UpdateActiveFrameSource(); |
| 230 } |
| 231 |
| 222 if (frame_source_->NeedsBeginFrames()) | 232 if (frame_source_->NeedsBeginFrames()) |
| 223 frame_source_->SetNeedsBeginFrames(false); | 233 frame_source_->SetNeedsBeginFrames(false); |
| 234 |
| 224 begin_retro_frame_args_.clear(); | 235 begin_retro_frame_args_.clear(); |
| 225 ProcessScheduledActions(); | 236 ProcessScheduledActions(); |
| 226 } | 237 } |
| 227 | 238 |
| 228 void Scheduler::DidCreateAndInitializeOutputSurface() { | 239 void Scheduler::DidCreateAndInitializeOutputSurface( |
| 240 OutputSurface* output_surface) { |
| 229 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); | 241 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); |
| 230 DCHECK(!frame_source_->NeedsBeginFrames()); | |
| 231 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); | 242 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); |
| 243 |
| 244 if (settings_.throttle_frame_production && |
| 245 settings_.begin_frame_scheduling_enabled) { |
| 246 DCHECK(!primary_frame_source_); |
| 247 primary_frame_source_ = output_surface; |
| 248 frame_source_->AddSource(primary_frame_source_); |
| 249 } |
| 250 UpdateActiveFrameSource(); |
| 232 state_machine_.DidCreateAndInitializeOutputSurface(); | 251 state_machine_.DidCreateAndInitializeOutputSurface(); |
| 233 ProcessScheduledActions(); | 252 ProcessScheduledActions(); |
| 234 } | 253 } |
| 235 | 254 |
| 236 void Scheduler::NotifyBeginMainFrameStarted() { | 255 void Scheduler::NotifyBeginMainFrameStarted() { |
| 237 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); | 256 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); |
| 238 state_machine_.NotifyBeginMainFrameStarted(); | 257 state_machine_.NotifyBeginMainFrameStarted(); |
| 239 } | 258 } |
| 240 | 259 |
| 241 base::TimeTicks Scheduler::AnticipatedDrawTime() const { | 260 base::TimeTicks Scheduler::AnticipatedDrawTime() const { |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 } | 718 } |
| 700 | 719 |
| 701 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 720 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 702 return (state_machine_.commit_state() == | 721 return (state_machine_.commit_state() == |
| 703 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 722 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
| 704 state_machine_.commit_state() == | 723 state_machine_.commit_state() == |
| 705 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 724 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
| 706 } | 725 } |
| 707 | 726 |
| 708 } // namespace cc | 727 } // namespace cc |
| OLD | NEW |