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/logging.h" | 10 #include "base/logging.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 int layer_tree_host_id, | 80 int layer_tree_host_id, |
81 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 81 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
82 scoped_ptr<BeginFrameSource> external_begin_frame_source, | 82 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
83 SchedulerFrameSourcesConstructor* frame_sources_constructor) | 83 SchedulerFrameSourcesConstructor* frame_sources_constructor) |
84 : frame_source_(), | 84 : frame_source_(), |
85 primary_frame_source_(NULL), | 85 primary_frame_source_(NULL), |
86 background_frame_source_(NULL), | 86 background_frame_source_(NULL), |
87 primary_frame_source_internal_(external_begin_frame_source.Pass()), | 87 primary_frame_source_internal_(external_begin_frame_source.Pass()), |
88 background_frame_source_internal_(), | 88 background_frame_source_internal_(), |
89 vsync_observer_(NULL), | 89 vsync_observer_(NULL), |
| 90 authoritative_vsync_interval_(base::TimeDelta()), |
| 91 last_vsync_timebase_(base::TimeTicks()), |
90 throttle_frame_production_(scheduler_settings.throttle_frame_production), | 92 throttle_frame_production_(scheduler_settings.throttle_frame_production), |
91 settings_(scheduler_settings), | 93 settings_(scheduler_settings), |
92 client_(client), | 94 client_(client), |
93 layer_tree_host_id_(layer_tree_host_id), | 95 layer_tree_host_id_(layer_tree_host_id), |
94 task_runner_(task_runner), | 96 task_runner_(task_runner), |
95 state_machine_(scheduler_settings), | 97 state_machine_(scheduler_settings), |
96 inside_process_scheduled_actions_(false), | 98 inside_process_scheduled_actions_(false), |
97 inside_action_(SchedulerStateMachine::ACTION_NONE), | 99 inside_action_(SchedulerStateMachine::ACTION_NONE), |
98 weak_factory_(this) { | 100 weak_factory_(this) { |
99 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 101 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 base::TimeTicks now = gfx::FrameTime::Now(); | 143 base::TimeTicks now = gfx::FrameTime::Now(); |
142 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), | 144 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), |
143 "Scheduler::Now", | 145 "Scheduler::Now", |
144 "now", | 146 "now", |
145 now); | 147 now); |
146 return now; | 148 return now; |
147 } | 149 } |
148 | 150 |
149 void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, | 151 void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, |
150 base::TimeDelta interval) { | 152 base::TimeDelta interval) { |
151 // TODO(brianderson): We should not be receiving 0 intervals. | 153 if (authoritative_vsync_interval_ != base::TimeDelta()) { |
152 if (interval == base::TimeDelta()) | 154 interval = authoritative_vsync_interval_; |
| 155 } else if (interval == base::TimeDelta()) { |
| 156 // TODO(brianderson): We should not be receiving 0 intervals. |
153 interval = BeginFrameArgs::DefaultInterval(); | 157 interval = BeginFrameArgs::DefaultInterval(); |
| 158 } |
| 159 |
| 160 last_vsync_timebase_ = timebase; |
154 | 161 |
155 if (vsync_observer_) | 162 if (vsync_observer_) |
156 vsync_observer_->OnUpdateVSyncParameters(timebase, interval); | 163 vsync_observer_->OnUpdateVSyncParameters(timebase, interval); |
157 } | 164 } |
158 | 165 |
159 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 166 void Scheduler::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
160 DCHECK_GE(draw_time.ToInternalValue(), 0); | 167 DCHECK_GE(draw_time.ToInternalValue(), 0); |
161 estimated_parent_draw_time_ = draw_time; | 168 estimated_parent_draw_time_ = draw_time; |
162 } | 169 } |
163 | 170 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 BeginImplFrame(adjusted_args); | 431 BeginImplFrame(adjusted_args); |
425 } | 432 } |
426 return true; | 433 return true; |
427 } | 434 } |
428 | 435 |
429 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | 436 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
430 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); | 437 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); |
431 ProcessScheduledActions(); | 438 ProcessScheduledActions(); |
432 } | 439 } |
433 | 440 |
| 441 void Scheduler::SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) { |
| 442 authoritative_vsync_interval_ = interval; |
| 443 if (vsync_observer_) |
| 444 vsync_observer_->OnUpdateVSyncParameters(last_vsync_timebase_, interval); |
| 445 } |
| 446 |
434 // BeginRetroFrame is called for BeginFrames that we've deferred because | 447 // BeginRetroFrame is called for BeginFrames that we've deferred because |
435 // the scheduler was in the middle of processing a previous BeginFrame. | 448 // the scheduler was in the middle of processing a previous BeginFrame. |
436 void Scheduler::BeginRetroFrame() { | 449 void Scheduler::BeginRetroFrame() { |
437 TRACE_EVENT0("cc,benchmark", "Scheduler::BeginRetroFrame"); | 450 TRACE_EVENT0("cc,benchmark", "Scheduler::BeginRetroFrame"); |
438 DCHECK(!settings_.using_synchronous_renderer_compositor); | 451 DCHECK(!settings_.using_synchronous_renderer_compositor); |
439 DCHECK(!begin_retro_frame_args_.empty()); | 452 DCHECK(!begin_retro_frame_args_.empty()); |
440 DCHECK(!begin_retro_frame_task_.IsCancelled()); | 453 DCHECK(!begin_retro_frame_task_.IsCancelled()); |
441 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 454 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
442 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 455 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
443 | 456 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 } | 842 } |
830 | 843 |
831 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 844 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
832 return (state_machine_.commit_state() == | 845 return (state_machine_.commit_state() == |
833 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 846 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
834 state_machine_.commit_state() == | 847 state_machine_.commit_state() == |
835 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 848 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
836 } | 849 } |
837 | 850 |
838 } // namespace cc | 851 } // namespace cc |
OLD | NEW |