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 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 78 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
79 base::PowerMonitor* power_monitor, | 79 base::PowerMonitor* power_monitor, |
80 scoped_ptr<BeginFrameSource> external_begin_frame_source, | 80 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
81 SchedulerFrameSourcesConstructor* frame_sources_constructor) | 81 SchedulerFrameSourcesConstructor* frame_sources_constructor) |
82 : frame_source_(), | 82 : frame_source_(), |
83 primary_frame_source_(NULL), | 83 primary_frame_source_(NULL), |
84 background_frame_source_(NULL), | 84 background_frame_source_(NULL), |
85 primary_frame_source_internal_(external_begin_frame_source.Pass()), | 85 primary_frame_source_internal_(external_begin_frame_source.Pass()), |
86 background_frame_source_internal_(), | 86 background_frame_source_internal_(), |
87 vsync_observer_(NULL), | 87 vsync_observer_(NULL), |
| 88 authoritative_vsync_interval_(base::TimeDelta()), |
88 settings_(scheduler_settings), | 89 settings_(scheduler_settings), |
89 client_(client), | 90 client_(client), |
90 layer_tree_host_id_(layer_tree_host_id), | 91 layer_tree_host_id_(layer_tree_host_id), |
91 task_runner_(task_runner), | 92 task_runner_(task_runner), |
92 power_monitor_(power_monitor), | 93 power_monitor_(power_monitor), |
93 begin_retro_frame_posted_(false), | 94 begin_retro_frame_posted_(false), |
94 state_machine_(scheduler_settings), | 95 state_machine_(scheduler_settings), |
95 inside_process_scheduled_actions_(false), | 96 inside_process_scheduled_actions_(false), |
96 inside_action_(SchedulerStateMachine::ACTION_NONE), | 97 inside_action_(SchedulerStateMachine::ACTION_NONE), |
97 weak_factory_(this) { | 98 weak_factory_(this) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 160 } |
160 } | 161 } |
161 | 162 |
162 void Scheduler::OnPowerStateChange(bool on_battery_power) { | 163 void Scheduler::OnPowerStateChange(bool on_battery_power) { |
163 DCHECK(settings_.disable_hi_res_timer_tasks_on_battery); | 164 DCHECK(settings_.disable_hi_res_timer_tasks_on_battery); |
164 state_machine_.SetImplLatencyTakesPriorityOnBattery(on_battery_power); | 165 state_machine_.SetImplLatencyTakesPriorityOnBattery(on_battery_power); |
165 } | 166 } |
166 | 167 |
167 void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, | 168 void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, |
168 base::TimeDelta interval) { | 169 base::TimeDelta interval) { |
169 // TODO(brianderson): We should not be receiving 0 intervals. | 170 base::TimeDelta vsync_interval; |
170 if (interval == base::TimeDelta()) | 171 if (authoritative_vsync_interval_ != base::TimeDelta()) { |
171 interval = BeginFrameArgs::DefaultInterval(); | 172 vsync_interval = authoritative_vsync_interval_; |
| 173 } else if (interval == base::TimeDelta()) { |
| 174 // TODO(brianderson): We should not be receiving 0 intervals. |
| 175 vsync_interval = BeginFrameArgs::DefaultInterval(); |
| 176 } else { |
| 177 vsync_interval = interval; |
| 178 } |
172 | 179 |
173 if (vsync_observer_) | 180 if (vsync_observer_) |
174 vsync_observer_->OnUpdateVSyncParameters(timebase, interval); | 181 vsync_observer_->OnUpdateVSyncParameters(timebase, vsync_interval); |
175 } | 182 } |
176 | 183 |
177 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 184 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
178 DCHECK_GE(draw_time.ToInternalValue(), 0); | 185 DCHECK_GE(draw_time.ToInternalValue(), 0); |
179 estimated_parent_draw_time_ = draw_time; | 186 estimated_parent_draw_time_ = draw_time; |
180 } | 187 } |
181 | 188 |
182 void Scheduler::SetCanStart() { | 189 void Scheduler::SetCanStart() { |
183 state_machine_.SetCanStart(); | 190 state_machine_.SetCanStart(); |
184 ProcessScheduledActions(); | 191 ProcessScheduledActions(); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 } | 449 } |
443 return true; | 450 return true; |
444 } | 451 } |
445 | 452 |
446 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | 453 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
447 DCHECK(settings_.forward_begin_frames_to_children); | 454 DCHECK(settings_.forward_begin_frames_to_children); |
448 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); | 455 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); |
449 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); | 456 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); |
450 } | 457 } |
451 | 458 |
| 459 void Scheduler::SetAuthoritativeVSyncInterval(base::TimeDelta interval) { |
| 460 authoritative_vsync_interval_ = interval; |
| 461 } |
| 462 |
452 // BeginRetroFrame is called for BeginFrames that we've deferred because | 463 // BeginRetroFrame is called for BeginFrames that we've deferred because |
453 // the scheduler was in the middle of processing a previous BeginFrame. | 464 // the scheduler was in the middle of processing a previous BeginFrame. |
454 void Scheduler::BeginRetroFrame() { | 465 void Scheduler::BeginRetroFrame() { |
455 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame"); | 466 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame"); |
456 DCHECK(!settings_.using_synchronous_renderer_compositor); | 467 DCHECK(!settings_.using_synchronous_renderer_compositor); |
457 DCHECK(begin_retro_frame_posted_); | 468 DCHECK(begin_retro_frame_posted_); |
458 begin_retro_frame_posted_ = false; | 469 begin_retro_frame_posted_ = false; |
459 | 470 |
460 // If there aren't any retroactive BeginFrames, then we've lost the | 471 // If there aren't any retroactive BeginFrames, then we've lost the |
461 // OutputSurface and should abort. | 472 // OutputSurface and should abort. |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 } | 814 } |
804 | 815 |
805 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 816 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
806 return (state_machine_.commit_state() == | 817 return (state_machine_.commit_state() == |
807 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 818 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
808 state_machine_.commit_state() == | 819 state_machine_.commit_state() == |
809 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 820 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
810 } | 821 } |
811 | 822 |
812 } // namespace cc | 823 } // namespace cc |
OLD | NEW |