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 if (authoritative_vsync_interval_ != base::TimeDelta()) { |
170 if (interval == base::TimeDelta()) | 171 interval = authoritative_vsync_interval_; |
172 } else if (interval == base::TimeDelta()) { | |
173 // TODO(brianderson): We should not be receiving 0 intervals. | |
171 interval = BeginFrameArgs::DefaultInterval(); | 174 interval = BeginFrameArgs::DefaultInterval(); |
175 } | |
172 | 176 |
173 if (vsync_observer_) | 177 if (vsync_observer_) |
174 vsync_observer_->OnUpdateVSyncParameters(timebase, interval); | 178 vsync_observer_->OnUpdateVSyncParameters(timebase, interval); |
175 } | 179 } |
176 | 180 |
177 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 181 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
178 DCHECK_GE(draw_time.ToInternalValue(), 0); | 182 DCHECK_GE(draw_time.ToInternalValue(), 0); |
179 estimated_parent_draw_time_ = draw_time; | 183 estimated_parent_draw_time_ = draw_time; |
180 } | 184 } |
181 | 185 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 } | 446 } |
443 return true; | 447 return true; |
444 } | 448 } |
445 | 449 |
446 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | 450 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
447 DCHECK(settings_.forward_begin_frames_to_children); | 451 DCHECK(settings_.forward_begin_frames_to_children); |
448 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); | 452 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); |
449 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); | 453 DCHECK_EQ(state_machine_.NextAction(), SchedulerStateMachine::ACTION_NONE); |
450 } | 454 } |
451 | 455 |
456 void Scheduler::SetAuthoritativeVSyncInterval(base::TimeDelta interval) { | |
simonhong
2014/12/11 23:09:46
nit: How about add DCHECK(settings_.forward_begin_
| |
457 authoritative_vsync_interval_ = interval; | |
458 } | |
459 | |
452 // BeginRetroFrame is called for BeginFrames that we've deferred because | 460 // BeginRetroFrame is called for BeginFrames that we've deferred because |
453 // the scheduler was in the middle of processing a previous BeginFrame. | 461 // the scheduler was in the middle of processing a previous BeginFrame. |
454 void Scheduler::BeginRetroFrame() { | 462 void Scheduler::BeginRetroFrame() { |
455 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame"); | 463 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame"); |
456 DCHECK(!settings_.using_synchronous_renderer_compositor); | 464 DCHECK(!settings_.using_synchronous_renderer_compositor); |
457 DCHECK(begin_retro_frame_posted_); | 465 DCHECK(begin_retro_frame_posted_); |
458 begin_retro_frame_posted_ = false; | 466 begin_retro_frame_posted_ = false; |
459 | 467 |
460 // If there aren't any retroactive BeginFrames, then we've lost the | 468 // If there aren't any retroactive BeginFrames, then we've lost the |
461 // OutputSurface and should abort. | 469 // OutputSurface and should abort. |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
800 } | 808 } |
801 | 809 |
802 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 810 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
803 return (state_machine_.commit_state() == | 811 return (state_machine_.commit_state() == |
804 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 812 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
805 state_machine_.commit_state() == | 813 state_machine_.commit_state() == |
806 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 814 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
807 } | 815 } |
808 | 816 |
809 } // namespace cc | 817 } // namespace cc |
OLD | NEW |