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/devtools_instrumentation.h" |
11 #include "cc/debug/traced_value.h" | 12 #include "cc/debug/traced_value.h" |
12 #include "ui/gfx/frame_time.h" | 13 #include "ui/gfx/frame_time.h" |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 | 16 |
16 Scheduler::Scheduler(SchedulerClient* client, | 17 Scheduler::Scheduler(SchedulerClient* client, |
17 const SchedulerSettings& scheduler_settings) | 18 const SchedulerSettings& scheduler_settings, |
| 19 int layer_tree_host_id) |
18 : settings_(scheduler_settings), | 20 : settings_(scheduler_settings), |
19 client_(client), | 21 client_(client), |
| 22 layer_tree_host_id_(layer_tree_host_id), |
20 last_set_needs_begin_impl_frame_(false), | 23 last_set_needs_begin_impl_frame_(false), |
21 state_machine_(scheduler_settings), | 24 state_machine_(scheduler_settings), |
22 inside_process_scheduled_actions_(false), | 25 inside_process_scheduled_actions_(false), |
23 inside_action_(SchedulerStateMachine::ACTION_NONE), | 26 inside_action_(SchedulerStateMachine::ACTION_NONE), |
24 weak_factory_(this) { | 27 weak_factory_(this) { |
25 DCHECK(client_); | 28 DCHECK(client_); |
26 DCHECK(!state_machine_.BeginImplFrameNeeded()); | 29 DCHECK(!state_machine_.BeginImplFrameNeeded()); |
27 } | 30 } |
28 | 31 |
29 Scheduler::~Scheduler() {} | 32 Scheduler::~Scheduler() {} |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 DCHECK(state_machine_.HasInitializedOutputSurface()); | 190 DCHECK(state_machine_.HasInitializedOutputSurface()); |
188 last_begin_impl_frame_args_ = args; | 191 last_begin_impl_frame_args_ = args; |
189 last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate(); | 192 last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate(); |
190 state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_); | 193 state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_); |
191 ProcessScheduledActions(); | 194 ProcessScheduledActions(); |
192 | 195 |
193 if (!state_machine_.HasInitializedOutputSurface()) | 196 if (!state_machine_.HasInitializedOutputSurface()) |
194 return; | 197 return; |
195 | 198 |
196 state_machine_.OnBeginImplFrameDeadlinePending(); | 199 state_machine_.OnBeginImplFrameDeadlinePending(); |
197 | 200 devtools_instrumentation::didBeginFrame(layer_tree_host_id_); |
198 if (settings_.using_synchronous_renderer_compositor) { | 201 if (settings_.using_synchronous_renderer_compositor) { |
199 // The synchronous renderer compositor has to make its GL calls | 202 // The synchronous renderer compositor has to make its GL calls |
200 // within this call to BeginImplFrame. | 203 // within this call to BeginImplFrame. |
201 // TODO(brianderson): Have the OutputSurface initiate the deadline tasks | 204 // TODO(brianderson): Have the OutputSurface initiate the deadline tasks |
202 // so the sychronous renderer compositor can take advantage of splitting | 205 // so the sychronous renderer compositor can take advantage of splitting |
203 // up the BeginImplFrame and deadline as well. | 206 // up the BeginImplFrame and deadline as well. |
204 OnBeginImplFrameDeadline(); | 207 OnBeginImplFrameDeadline(); |
205 } else if (!settings_.deadline_scheduling_enabled) { | 208 } else if (!settings_.deadline_scheduling_enabled) { |
206 // We emulate the old non-deadline scheduler here by posting the | 209 // We emulate the old non-deadline scheduler here by posting the |
207 // deadline task without any delay. | 210 // deadline task without any delay. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 345 |
343 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) | 346 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) |
344 PostBeginImplFrameDeadline(base::TimeTicks()); | 347 PostBeginImplFrameDeadline(base::TimeTicks()); |
345 } | 348 } |
346 | 349 |
347 bool Scheduler::WillDrawIfNeeded() const { | 350 bool Scheduler::WillDrawIfNeeded() const { |
348 return !state_machine_.PendingDrawsShouldBeAborted(); | 351 return !state_machine_.PendingDrawsShouldBeAborted(); |
349 } | 352 } |
350 | 353 |
351 } // namespace cc | 354 } // namespace cc |
OLD | NEW |