| 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()), | |
| 92 throttle_frame_production_(scheduler_settings.throttle_frame_production), | 90 throttle_frame_production_(scheduler_settings.throttle_frame_production), |
| 93 settings_(scheduler_settings), | 91 settings_(scheduler_settings), |
| 94 client_(client), | 92 client_(client), |
| 95 layer_tree_host_id_(layer_tree_host_id), | 93 layer_tree_host_id_(layer_tree_host_id), |
| 96 task_runner_(task_runner), | 94 task_runner_(task_runner), |
| 97 state_machine_(scheduler_settings), | 95 state_machine_(scheduler_settings), |
| 98 inside_process_scheduled_actions_(false), | 96 inside_process_scheduled_actions_(false), |
| 99 inside_action_(SchedulerStateMachine::ACTION_NONE), | 97 inside_action_(SchedulerStateMachine::ACTION_NONE), |
| 100 weak_factory_(this) { | 98 weak_factory_(this) { |
| 101 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 99 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 139 |
| 142 base::TimeTicks Scheduler::Now() const { | 140 base::TimeTicks Scheduler::Now() const { |
| 143 base::TimeTicks now = gfx::FrameTime::Now(); | 141 base::TimeTicks now = gfx::FrameTime::Now(); |
| 144 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), | 142 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), |
| 145 "Scheduler::Now", | 143 "Scheduler::Now", |
| 146 "now", | 144 "now", |
| 147 now); | 145 now); |
| 148 return now; | 146 return now; |
| 149 } | 147 } |
| 150 | 148 |
| 149 void Scheduler::SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) { |
| 150 authoritative_vsync_interval_ = interval; |
| 151 if (vsync_observer_) |
| 152 vsync_observer_->OnUpdateVSyncParameters(last_vsync_timebase_, interval); |
| 153 } |
| 154 |
| 151 void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, | 155 void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, |
| 152 base::TimeDelta interval) { | 156 base::TimeDelta interval) { |
| 157 TRACE_EVENT2("cc", "Scheduler::CommitVSyncParameters", "timebase", |
| 158 (timebase - base::TimeTicks()).InSecondsF(), "interval", |
| 159 interval.InSecondsF()); |
| 160 |
| 153 if (authoritative_vsync_interval_ != base::TimeDelta()) { | 161 if (authoritative_vsync_interval_ != base::TimeDelta()) { |
| 154 interval = authoritative_vsync_interval_; | 162 interval = authoritative_vsync_interval_; |
| 155 } else if (interval == base::TimeDelta()) { | 163 } else if (interval == base::TimeDelta()) { |
| 156 // TODO(brianderson): We should not be receiving 0 intervals. | 164 // TODO(brianderson): We should not be receiving 0 intervals. |
| 157 interval = BeginFrameArgs::DefaultInterval(); | 165 interval = BeginFrameArgs::DefaultInterval(); |
| 158 } | 166 } |
| 159 | 167 |
| 160 last_vsync_timebase_ = timebase; | 168 last_vsync_timebase_ = timebase; |
| 161 | 169 |
| 162 if (vsync_observer_) | 170 if (vsync_observer_) |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 BeginImplFrame(adjusted_args); | 439 BeginImplFrame(adjusted_args); |
| 432 } | 440 } |
| 433 return true; | 441 return true; |
| 434 } | 442 } |
| 435 | 443 |
| 436 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | 444 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
| 437 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); | 445 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); |
| 438 ProcessScheduledActions(); | 446 ProcessScheduledActions(); |
| 439 } | 447 } |
| 440 | 448 |
| 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 | |
| 447 // BeginRetroFrame is called for BeginFrames that we've deferred because | 449 // BeginRetroFrame is called for BeginFrames that we've deferred because |
| 448 // the scheduler was in the middle of processing a previous BeginFrame. | 450 // the scheduler was in the middle of processing a previous BeginFrame. |
| 449 void Scheduler::BeginRetroFrame() { | 451 void Scheduler::BeginRetroFrame() { |
| 450 TRACE_EVENT0("cc,benchmark", "Scheduler::BeginRetroFrame"); | 452 TRACE_EVENT0("cc,benchmark", "Scheduler::BeginRetroFrame"); |
| 451 DCHECK(!settings_.using_synchronous_renderer_compositor); | 453 DCHECK(!settings_.using_synchronous_renderer_compositor); |
| 452 DCHECK(!begin_retro_frame_args_.empty()); | 454 DCHECK(!begin_retro_frame_args_.empty()); |
| 453 DCHECK(!begin_retro_frame_task_.IsCancelled()); | 455 DCHECK(!begin_retro_frame_task_.IsCancelled()); |
| 454 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 456 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
| 455 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 457 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 456 | 458 |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 } | 844 } |
| 843 | 845 |
| 844 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 846 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 845 return (state_machine_.commit_state() == | 847 return (state_machine_.commit_state() == |
| 846 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 848 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
| 847 state_machine_.commit_state() == | 849 state_machine_.commit_state() == |
| 848 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 850 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
| 849 } | 851 } |
| 850 | 852 |
| 851 } // namespace cc | 853 } // namespace cc |
| OLD | NEW |