| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 base::TimeTicks Scheduler::Now() const { | 122 base::TimeTicks Scheduler::Now() const { |
| 123 base::TimeTicks now = gfx::FrameTime::Now(); | 123 base::TimeTicks now = gfx::FrameTime::Now(); |
| 124 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), | 124 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.now"), |
| 125 "Scheduler::Now", | 125 "Scheduler::Now", |
| 126 "now", | 126 "now", |
| 127 now); | 127 now); |
| 128 return now; | 128 return now; |
| 129 } | 129 } |
| 130 | 130 |
| 131 void Scheduler::SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) { | |
| 132 authoritative_vsync_interval_ = interval; | |
| 133 if (vsync_observer_) | |
| 134 vsync_observer_->OnUpdateVSyncParameters(last_vsync_timebase_, interval); | |
| 135 } | |
| 136 | |
| 137 void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, | 131 void Scheduler::CommitVSyncParameters(base::TimeTicks timebase, |
| 138 base::TimeDelta interval) { | 132 base::TimeDelta interval) { |
| 139 TRACE_EVENT2("cc", "Scheduler::CommitVSyncParameters", "timebase", | |
| 140 (timebase - base::TimeTicks()).InSecondsF(), "interval", | |
| 141 interval.InSecondsF()); | |
| 142 | |
| 143 if (authoritative_vsync_interval_ != base::TimeDelta()) { | 133 if (authoritative_vsync_interval_ != base::TimeDelta()) { |
| 144 interval = authoritative_vsync_interval_; | 134 interval = authoritative_vsync_interval_; |
| 145 } else if (interval == base::TimeDelta()) { | 135 } else if (interval == base::TimeDelta()) { |
| 146 // TODO(brianderson): We should not be receiving 0 intervals. | 136 // TODO(brianderson): We should not be receiving 0 intervals. |
| 147 interval = BeginFrameArgs::DefaultInterval(); | 137 interval = BeginFrameArgs::DefaultInterval(); |
| 148 } | 138 } |
| 149 | 139 |
| 150 last_vsync_timebase_ = timebase; | 140 last_vsync_timebase_ = timebase; |
| 151 | 141 |
| 152 if (vsync_observer_) | 142 if (vsync_observer_) |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 BeginImplFrameWithDeadline(adjusted_args); | 387 BeginImplFrameWithDeadline(adjusted_args); |
| 398 } | 388 } |
| 399 return true; | 389 return true; |
| 400 } | 390 } |
| 401 | 391 |
| 402 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | 392 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { |
| 403 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); | 393 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); |
| 404 ProcessScheduledActions(); | 394 ProcessScheduledActions(); |
| 405 } | 395 } |
| 406 | 396 |
| 397 void Scheduler::SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) { |
| 398 authoritative_vsync_interval_ = interval; |
| 399 if (vsync_observer_) |
| 400 vsync_observer_->OnUpdateVSyncParameters(last_vsync_timebase_, interval); |
| 401 } |
| 402 |
| 407 void Scheduler::OnDrawForOutputSurface() { | 403 void Scheduler::OnDrawForOutputSurface() { |
| 408 DCHECK(settings_.using_synchronous_renderer_compositor); | 404 DCHECK(settings_.using_synchronous_renderer_compositor); |
| 409 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 405 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
| 410 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 406 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 411 DCHECK(!BeginImplFrameDeadlinePending()); | 407 DCHECK(!BeginImplFrameDeadlinePending()); |
| 412 | 408 |
| 413 state_machine_.OnBeginImplFrameDeadline(); | 409 state_machine_.OnBeginImplFrameDeadline(); |
| 414 ProcessScheduledActions(); | 410 ProcessScheduledActions(); |
| 415 | 411 |
| 416 state_machine_.OnBeginImplFrameIdle(); | 412 state_machine_.OnBeginImplFrameIdle(); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 } | 824 } |
| 829 | 825 |
| 830 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 826 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 831 return (state_machine_.commit_state() == | 827 return (state_machine_.commit_state() == |
| 832 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 828 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
| 833 state_machine_.commit_state() == | 829 state_machine_.commit_state() == |
| 834 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 830 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
| 835 } | 831 } |
| 836 | 832 |
| 837 } // namespace cc | 833 } // namespace cc |
| OLD | NEW |