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 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 begin_impl_frame_args_.deadline); | 265 begin_impl_frame_args_.deadline); |
266 int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval); | 266 int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval); |
267 return timebase + (begin_impl_frame_args_.interval * intervals); | 267 return timebase + (begin_impl_frame_args_.interval * intervals); |
268 } | 268 } |
269 | 269 |
270 base::TimeTicks Scheduler::LastBeginImplFrameTime() { | 270 base::TimeTicks Scheduler::LastBeginImplFrameTime() { |
271 return begin_impl_frame_args_.frame_time; | 271 return begin_impl_frame_args_.frame_time; |
272 } | 272 } |
273 | 273 |
274 void Scheduler::SetupNextBeginFrameIfNeeded() { | 274 void Scheduler::SetupNextBeginFrameIfNeeded() { |
| 275 if (!impl_task_runner_) |
| 276 return; |
| 277 |
275 bool needs_begin_frame = state_machine_.BeginFrameNeeded(); | 278 bool needs_begin_frame = state_machine_.BeginFrameNeeded(); |
276 | 279 |
277 if (settings_.throttle_frame_production) { | 280 if (settings_.throttle_frame_production) { |
278 SetupNextBeginFrameWhenVSyncThrottlingEnabled(needs_begin_frame); | 281 SetupNextBeginFrameWhenVSyncThrottlingEnabled(needs_begin_frame); |
279 } else { | 282 } else { |
280 SetupNextBeginFrameWhenVSyncThrottlingDisabled(needs_begin_frame); | 283 SetupNextBeginFrameWhenVSyncThrottlingDisabled(needs_begin_frame); |
281 } | 284 } |
282 SetupPollingMechanisms(needs_begin_frame); | 285 SetupPollingMechanisms(needs_begin_frame); |
283 } | 286 } |
284 | 287 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 | 493 |
491 begin_retro_frame_posted_ = true; | 494 begin_retro_frame_posted_ = true; |
492 impl_task_runner_->PostTask(FROM_HERE, begin_retro_frame_closure_); | 495 impl_task_runner_->PostTask(FROM_HERE, begin_retro_frame_closure_); |
493 } | 496 } |
494 | 497 |
495 // BeginImplFrame starts a compositor frame that will wait up until a deadline | 498 // BeginImplFrame starts a compositor frame that will wait up until a deadline |
496 // for a BeginMainFrame+activation to complete before it times out and draws | 499 // for a BeginMainFrame+activation to complete before it times out and draws |
497 // any asynchronous animation and scroll/pinch updates. | 500 // any asynchronous animation and scroll/pinch updates. |
498 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { | 501 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { |
499 TRACE_EVENT1("cc", "Scheduler::BeginImplFrame", "args", ToTrace(args)); | 502 TRACE_EVENT1("cc", "Scheduler::BeginImplFrame", "args", ToTrace(args)); |
500 DCHECK(state_machine_.begin_impl_frame_state() == | 503 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
501 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 504 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
502 DCHECK(state_machine_.HasInitializedOutputSurface()); | 505 DCHECK(state_machine_.HasInitializedOutputSurface()); |
503 | 506 |
504 advance_commit_state_task_.Cancel(); | 507 advance_commit_state_task_.Cancel(); |
505 | 508 |
506 base::TimeDelta draw_duration_estimate = client_->DrawDurationEstimate(); | 509 base::TimeDelta draw_duration_estimate = client_->DrawDurationEstimate(); |
507 begin_impl_frame_args_ = args; | 510 begin_impl_frame_args_ = args; |
508 begin_impl_frame_args_.deadline -= draw_duration_estimate; | 511 begin_impl_frame_args_.deadline -= draw_duration_estimate; |
509 | 512 |
510 if (!state_machine_.smoothness_takes_priority() && | 513 if (!state_machine_.smoothness_takes_priority() && |
511 state_machine_.MainThreadIsInHighLatencyMode() && | 514 state_machine_.MainThreadIsInHighLatencyMode() && |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 } | 750 } |
748 | 751 |
749 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 752 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
750 return (state_machine_.commit_state() == | 753 return (state_machine_.commit_state() == |
751 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 754 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
752 state_machine_.commit_state() == | 755 state_machine_.commit_state() == |
753 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 756 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
754 } | 757 } |
755 | 758 |
756 } // namespace cc | 759 } // namespace cc |
OLD | NEW |