| 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" |
| 11 #include "cc/debug/traced_value.h" | 11 #include "cc/debug/traced_value.h" |
| 12 #include "ui/gfx/frame_time.h" |
| 12 | 13 |
| 13 namespace cc { | 14 namespace cc { |
| 14 | 15 |
| 15 Scheduler::Scheduler(SchedulerClient* client, | 16 Scheduler::Scheduler(SchedulerClient* client, |
| 16 const SchedulerSettings& scheduler_settings) | 17 const SchedulerSettings& scheduler_settings) |
| 17 : settings_(scheduler_settings), | 18 : settings_(scheduler_settings), |
| 18 client_(client), | 19 client_(client), |
| 19 last_set_needs_begin_impl_frame_(false), | 20 last_set_needs_begin_impl_frame_(false), |
| 20 state_machine_(scheduler_settings), | 21 state_machine_(scheduler_settings), |
| 21 inside_process_scheduled_actions_(false), | 22 inside_process_scheduled_actions_(false), |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 ProcessScheduledActions(); | 112 ProcessScheduledActions(); |
| 112 } | 113 } |
| 113 | 114 |
| 114 base::TimeTicks Scheduler::AnticipatedDrawTime() { | 115 base::TimeTicks Scheduler::AnticipatedDrawTime() { |
| 115 TRACE_EVENT0("cc", "Scheduler::AnticipatedDrawTime"); | 116 TRACE_EVENT0("cc", "Scheduler::AnticipatedDrawTime"); |
| 116 | 117 |
| 117 if (!last_set_needs_begin_impl_frame_ || | 118 if (!last_set_needs_begin_impl_frame_ || |
| 118 last_begin_impl_frame_args_.interval <= base::TimeDelta()) | 119 last_begin_impl_frame_args_.interval <= base::TimeDelta()) |
| 119 return base::TimeTicks(); | 120 return base::TimeTicks(); |
| 120 | 121 |
| 121 base::TimeTicks now = base::TimeTicks::Now(); | 122 base::TimeTicks now = gfx::FrameTime::Now(); |
| 122 base::TimeTicks timebase = std::max(last_begin_impl_frame_args_.frame_time, | 123 base::TimeTicks timebase = std::max(last_begin_impl_frame_args_.frame_time, |
| 123 last_begin_impl_frame_args_.deadline); | 124 last_begin_impl_frame_args_.deadline); |
| 124 int64 intervals = | 125 int64 intervals = |
| 125 1 + ((now - timebase) / last_begin_impl_frame_args_.interval); | 126 1 + ((now - timebase) / last_begin_impl_frame_args_.interval); |
| 126 return timebase + (last_begin_impl_frame_args_.interval * intervals); | 127 return timebase + (last_begin_impl_frame_args_.interval * intervals); |
| 127 } | 128 } |
| 128 | 129 |
| 129 base::TimeTicks Scheduler::LastBeginImplFrameTime() { | 130 base::TimeTicks Scheduler::LastBeginImplFrameTime() { |
| 130 return last_begin_impl_frame_args_.frame_time; | 131 return last_begin_impl_frame_args_.frame_time; |
| 131 } | 132 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 | 333 |
| 333 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) | 334 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) |
| 334 PostBeginImplFrameDeadline(base::TimeTicks()); | 335 PostBeginImplFrameDeadline(base::TimeTicks()); |
| 335 } | 336 } |
| 336 | 337 |
| 337 bool Scheduler::WillDrawIfNeeded() const { | 338 bool Scheduler::WillDrawIfNeeded() const { |
| 338 return !state_machine_.PendingDrawsShouldBeAborted(); | 339 return !state_machine_.PendingDrawsShouldBeAborted(); |
| 339 } | 340 } |
| 340 | 341 |
| 341 } // namespace cc | 342 } // namespace cc |
| OLD | NEW |