Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Side by Side Diff: cc/scheduler/scheduler.cc

Issue 218633010: cc: Handle retroactive BeginFrames in the Scheduler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@compositorVsyncDisable
Patch Set: rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_state_machine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/devtools_instrumentation.h"
12 #include "cc/debug/traced_value.h" 12 #include "cc/debug/traced_value.h"
13 #include "ui/gfx/frame_time.h" 13 #include "ui/gfx/frame_time.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 Scheduler::Scheduler( 17 Scheduler::Scheduler(
18 SchedulerClient* client, 18 SchedulerClient* client,
19 const SchedulerSettings& scheduler_settings, 19 const SchedulerSettings& scheduler_settings,
20 int layer_tree_host_id, 20 int layer_tree_host_id,
21 const scoped_refptr<base::SequencedTaskRunner>& impl_task_runner) 21 const scoped_refptr<base::SequencedTaskRunner>& impl_task_runner)
22 : settings_(scheduler_settings), 22 : settings_(scheduler_settings),
23 client_(client), 23 client_(client),
24 layer_tree_host_id_(layer_tree_host_id), 24 layer_tree_host_id_(layer_tree_host_id),
25 impl_task_runner_(impl_task_runner), 25 impl_task_runner_(impl_task_runner),
26 last_set_needs_begin_impl_frame_(false), 26 last_set_needs_begin_frame_(false),
27 begin_retro_frame_posted_(false),
27 state_machine_(scheduler_settings), 28 state_machine_(scheduler_settings),
28 inside_process_scheduled_actions_(false), 29 inside_process_scheduled_actions_(false),
29 inside_action_(SchedulerStateMachine::ACTION_NONE), 30 inside_action_(SchedulerStateMachine::ACTION_NONE),
30 weak_factory_(this) { 31 weak_factory_(this) {
31 DCHECK(client_); 32 DCHECK(client_);
32 DCHECK(!state_machine_.BeginImplFrameNeeded()); 33 DCHECK(!state_machine_.BeginFrameNeeded());
33 if (settings_.main_frame_before_activation_enabled) { 34 if (settings_.main_frame_before_activation_enabled) {
34 DCHECK(settings_.main_frame_before_draw_enabled); 35 DCHECK(settings_.main_frame_before_draw_enabled);
35 } 36 }
36 } 37 }
37 38
38 Scheduler::~Scheduler() {} 39 Scheduler::~Scheduler() {}
39 40
40 void Scheduler::SetCanStart() { 41 void Scheduler::SetCanStart() {
41 state_machine_.SetCanStart(); 42 state_machine_.SetCanStart();
42 ProcessScheduledActions(); 43 ProcessScheduledActions();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ProcessScheduledActions(); 110 ProcessScheduledActions();
110 } 111 }
111 112
112 void Scheduler::DidManageTiles() { 113 void Scheduler::DidManageTiles() {
113 state_machine_.DidManageTiles(); 114 state_machine_.DidManageTiles();
114 } 115 }
115 116
116 void Scheduler::DidLoseOutputSurface() { 117 void Scheduler::DidLoseOutputSurface() {
117 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface"); 118 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface");
118 state_machine_.DidLoseOutputSurface(); 119 state_machine_.DidLoseOutputSurface();
119 last_set_needs_begin_impl_frame_ = false; 120 last_set_needs_begin_frame_ = false;
121 begin_retro_frame_args_.clear();
120 ProcessScheduledActions(); 122 ProcessScheduledActions();
121 } 123 }
122 124
123 void Scheduler::DidCreateAndInitializeOutputSurface() { 125 void Scheduler::DidCreateAndInitializeOutputSurface() {
124 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); 126 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface");
125 DCHECK(!last_set_needs_begin_impl_frame_); 127 DCHECK(!last_set_needs_begin_frame_);
126 DCHECK(begin_impl_frame_deadline_closure_.IsCancelled()); 128 DCHECK(begin_impl_frame_deadline_closure_.IsCancelled());
127 state_machine_.DidCreateAndInitializeOutputSurface(); 129 state_machine_.DidCreateAndInitializeOutputSurface();
128 ProcessScheduledActions(); 130 ProcessScheduledActions();
129 } 131 }
130 132
131 void Scheduler::NotifyBeginMainFrameStarted() { 133 void Scheduler::NotifyBeginMainFrameStarted() {
132 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted"); 134 TRACE_EVENT0("cc", "Scheduler::NotifyBeginMainFrameStarted");
133 state_machine_.NotifyBeginMainFrameStarted(); 135 state_machine_.NotifyBeginMainFrameStarted();
134 } 136 }
135 137
136 base::TimeTicks Scheduler::AnticipatedDrawTime() const { 138 base::TimeTicks Scheduler::AnticipatedDrawTime() const {
137 if (!last_set_needs_begin_impl_frame_ || 139 if (!last_set_needs_begin_frame_ ||
138 last_begin_impl_frame_args_.interval <= base::TimeDelta()) 140 begin_impl_frame_args_.interval <= base::TimeDelta())
139 return base::TimeTicks(); 141 return base::TimeTicks();
140 142
141 base::TimeTicks now = gfx::FrameTime::Now(); 143 base::TimeTicks now = gfx::FrameTime::Now();
142 base::TimeTicks timebase = std::max(last_begin_impl_frame_args_.frame_time, 144 base::TimeTicks timebase = std::max(begin_impl_frame_args_.frame_time,
143 last_begin_impl_frame_args_.deadline); 145 begin_impl_frame_args_.deadline);
144 int64 intervals = 146 int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval);
145 1 + ((now - timebase) / last_begin_impl_frame_args_.interval); 147 return timebase + (begin_impl_frame_args_.interval * intervals);
146 return timebase + (last_begin_impl_frame_args_.interval * intervals);
147 } 148 }
148 149
149 base::TimeTicks Scheduler::LastBeginImplFrameTime() { 150 base::TimeTicks Scheduler::LastBeginImplFrameTime() {
150 return last_begin_impl_frame_args_.frame_time; 151 return begin_impl_frame_args_.frame_time;
151 } 152 }
152 153
153 void Scheduler::SetupNextBeginImplFrameIfNeeded() { 154 void Scheduler::SetupNextBeginFrameIfNeeded() {
154 bool needs_begin_impl_frame = 155 bool needs_begin_frame = state_machine_.BeginFrameNeeded();
155 state_machine_.BeginImplFrameNeeded();
156 156
157 bool at_end_of_deadline = 157 bool at_end_of_deadline =
158 state_machine_.begin_impl_frame_state() == 158 state_machine_.begin_impl_frame_state() ==
159 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; 159 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE;
160 160
161 bool should_call_set_needs_begin_impl_frame = 161 bool should_call_set_needs_begin_frame =
162 // Always request the BeginImplFrame immediately if it wasn't needed 162 // Always request the BeginFrame immediately if it wasn't needed before.
163 // before. 163 (needs_begin_frame && !last_set_needs_begin_frame_) ||
164 (needs_begin_impl_frame && !last_set_needs_begin_impl_frame_) || 164 // Only stop requesting the BeginFrame at the end of a deadline.
165 // We always need to explicitly request our next BeginImplFrame. 165 ((!needs_begin_frame && last_set_needs_begin_frame_) &&
166 at_end_of_deadline; 166 at_end_of_deadline);
167 167
168 if (should_call_set_needs_begin_impl_frame) { 168 if (should_call_set_needs_begin_frame) {
169 client_->SetNeedsBeginImplFrame(needs_begin_impl_frame); 169 client_->SetNeedsBeginFrame(needs_begin_frame);
170 last_set_needs_begin_impl_frame_ = needs_begin_impl_frame; 170 last_set_needs_begin_frame_ = needs_begin_frame;
171 }
172
173 // Handle retroactive BeginFrames.
174 if (needs_begin_frame && !begin_retro_frame_posted_ &&
175 !begin_retro_frame_args_.empty() &&
176 state_machine_.begin_impl_frame_state() ==
177 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) {
178 begin_retro_frame_posted_ = true;
179 impl_task_runner_->PostTask(
180 FROM_HERE,
181 base::Bind(&Scheduler::BeginRetroFrame, weak_factory_.GetWeakPtr()));
171 } 182 }
172 183
173 bool needs_advance_commit_state_timer = false; 184 bool needs_advance_commit_state_timer = false;
174 // Setup PollForAnticipatedDrawTriggers if we need to monitor state but 185 // Setup PollForAnticipatedDrawTriggers if we need to monitor state but
175 // aren't expecting any more BeginImplFrames. This should only be needed by 186 // aren't expecting any more BeginFrames. This should only be needed by
176 // the synchronous compositor when BeginImplFrameNeeded is false. 187 // the synchronous compositor when BeginFrameNeeded is false.
177 if (state_machine_.ShouldPollForAnticipatedDrawTriggers()) { 188 if (state_machine_.ShouldPollForAnticipatedDrawTriggers()) {
178 DCHECK(!state_machine_.SupportsProactiveBeginImplFrame()); 189 DCHECK(!state_machine_.SupportsProactiveBeginFrame());
179 DCHECK(!needs_begin_impl_frame); 190 DCHECK(!needs_begin_frame);
180 if (poll_for_draw_triggers_closure_.IsCancelled()) { 191 if (poll_for_draw_triggers_closure_.IsCancelled()) {
181 poll_for_draw_triggers_closure_.Reset( 192 poll_for_draw_triggers_closure_.Reset(
182 base::Bind(&Scheduler::PollForAnticipatedDrawTriggers, 193 base::Bind(&Scheduler::PollForAnticipatedDrawTriggers,
183 weak_factory_.GetWeakPtr())); 194 weak_factory_.GetWeakPtr()));
184 impl_task_runner_->PostDelayedTask( 195 impl_task_runner_->PostDelayedTask(
185 FROM_HERE, 196 FROM_HERE,
186 poll_for_draw_triggers_closure_.callback(), 197 poll_for_draw_triggers_closure_.callback(),
187 last_begin_impl_frame_args_.interval); 198 begin_impl_frame_args_.interval);
188 } 199 }
189 } else { 200 } else {
190 poll_for_draw_triggers_closure_.Cancel(); 201 poll_for_draw_triggers_closure_.Cancel();
191 202
192 // At this point we'd prefer to advance through the commit flow by 203 // At this point we'd prefer to advance through the commit flow by
193 // drawing a frame, however it's possible that the frame rate controller 204 // drawing a frame, however it's possible that the frame rate controller
194 // will not give us a BeginImplFrame until the commit completes. See 205 // will not give us a BeginFrame until the commit completes. See
195 // crbug.com/317430 for an example of a swap ack being held on commit. Thus 206 // crbug.com/317430 for an example of a swap ack being held on commit. Thus
196 // we set a repeating timer to poll on ProcessScheduledActions until we 207 // we set a repeating timer to poll on ProcessScheduledActions until we
197 // successfully reach BeginImplFrame. Synchronous compositor does not use 208 // successfully reach BeginFrame. Synchronous compositor does not use
198 // frame rate controller or have the circular wait in the bug. 209 // frame rate controller or have the circular wait in the bug.
199 if (IsBeginMainFrameSentOrStarted() && 210 if (IsBeginMainFrameSentOrStarted() &&
200 !settings_.using_synchronous_renderer_compositor) { 211 !settings_.using_synchronous_renderer_compositor) {
201 needs_advance_commit_state_timer = true; 212 needs_advance_commit_state_timer = true;
202 } 213 }
203 } 214 }
204 if (needs_advance_commit_state_timer != 215 if (needs_advance_commit_state_timer !=
205 advance_commit_state_timer_.IsRunning()) { 216 advance_commit_state_timer_.IsRunning()) {
206 if (needs_advance_commit_state_timer && 217 if (needs_advance_commit_state_timer && begin_impl_frame_args_.IsValid()) {
207 last_begin_impl_frame_args_.IsValid()) {
208 // Since we'd rather get a BeginImplFrame by the normal mechanism, we 218 // Since we'd rather get a BeginImplFrame by the normal mechanism, we
209 // set the interval to twice the interval from the previous frame. 219 // set the interval to twice the interval from the previous frame.
210 advance_commit_state_timer_.Start( 220 advance_commit_state_timer_.Start(
211 FROM_HERE, 221 FROM_HERE,
212 last_begin_impl_frame_args_.interval * 2, 222 begin_impl_frame_args_.interval * 2,
213 base::Bind(&Scheduler::ProcessScheduledActions, 223 base::Bind(&Scheduler::ProcessScheduledActions,
214 base::Unretained(this))); 224 base::Unretained(this)));
215 } else { 225 } else {
216 advance_commit_state_timer_.Stop(); 226 advance_commit_state_timer_.Stop();
217 } 227 }
218 } 228 }
219 } 229 }
220 230
231 void Scheduler::BeginFrame(const BeginFrameArgs& args) {
232 if (last_set_needs_begin_frame_ && begin_retro_frame_args_.empty() &&
233 state_machine_.begin_impl_frame_state() ==
234 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) {
235 BeginImplFrame(args);
236 } else {
237 begin_retro_frame_args_.push_back(args);
238 TRACE_EVENT_INSTANT0(
239 "cc", "Scheduler::BeginFrame deferred", TRACE_EVENT_SCOPE_THREAD);
240 }
241 }
242
243 void Scheduler::BeginRetroFrame() {
244 TRACE_EVENT0("cc", "Scheduler::BeginRetroFrame");
245 DCHECK(!begin_retro_frame_args_.empty());
246
247 // Discard expired BeginRetroFrames
248 base::TimeTicks now = gfx::FrameTime::Now();
249 while (!begin_retro_frame_args_.empty() &&
250 now <
brianderson 2014/04/02 16:57:49 Yay for unit tests. This should have been a >. Fix
251 AdjustedBeginImplFrameDeadline(begin_retro_frame_args_.front())) {
252 begin_retro_frame_args_.pop_front();
253 }
254
255 if (begin_retro_frame_args_.empty()) {
256 TRACE_EVENT_INSTANT0(
257 "cc", "Scheduler::BeginRetroFrames expired", TRACE_EVENT_SCOPE_THREAD);
258 } else {
259 BeginImplFrame(begin_retro_frame_args_.front());
260 begin_retro_frame_args_.pop_front();
261 }
262
263 begin_retro_frame_posted_ = false;
264 }
265
221 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { 266 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
222 TRACE_EVENT0("cc", "Scheduler::BeginImplFrame"); 267 TRACE_EVENT0("cc", "Scheduler::BeginImplFrame");
223 DCHECK(state_machine_.begin_impl_frame_state() == 268 DCHECK(state_machine_.begin_impl_frame_state() ==
224 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 269 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
225 DCHECK(state_machine_.HasInitializedOutputSurface()); 270 DCHECK(state_machine_.HasInitializedOutputSurface());
226 271
227 last_begin_impl_frame_args_ = args;
228 last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate();
229
230 if (!state_machine_.smoothness_takes_priority() && 272 if (!state_machine_.smoothness_takes_priority() &&
231 state_machine_.MainThreadIsInHighLatencyMode() && 273 state_machine_.MainThreadIsInHighLatencyMode() &&
232 CanCommitAndActivateBeforeDeadline()) { 274 CanCommitAndActivateBeforeDeadline()) {
233 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); 275 state_machine_.SetSkipNextBeginMainFrameToReduceLatency();
234 } 276 }
235 277
236 state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_); 278 begin_impl_frame_args_ = args;
279 begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate();
280
281 client_->WillBeginImplFrame(begin_impl_frame_args_);
282 state_machine_.OnBeginImplFrame(begin_impl_frame_args_);
237 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); 283 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_);
238 284
239 ProcessScheduledActions(); 285 ProcessScheduledActions();
240 286
241 if (!state_machine_.HasInitializedOutputSurface()) 287 if (!state_machine_.HasInitializedOutputSurface())
242 return; 288 return;
243 289
244 state_machine_.OnBeginImplFrameDeadlinePending(); 290 state_machine_.OnBeginImplFrameDeadlinePending();
245 base::TimeTicks adjusted_deadline = AdjustedBeginImplFrameDeadline(); 291 ScheduleBeginImplFrameDeadline(AdjustedBeginImplFrameDeadline(args));
246 ScheduleBeginImplFrameDeadline(adjusted_deadline);
247 } 292 }
248 293
249 base::TimeTicks Scheduler::AdjustedBeginImplFrameDeadline() const { 294 base::TimeTicks Scheduler::AdjustedBeginImplFrameDeadline(
295 const BeginFrameArgs& args) const {
250 if (settings_.using_synchronous_renderer_compositor) { 296 if (settings_.using_synchronous_renderer_compositor) {
251 // The synchronous compositor needs to draw right away. 297 // The synchronous compositor needs to draw right away.
252 return base::TimeTicks(); 298 return base::TimeTicks();
253 } else if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) { 299 } else if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) {
254 // We are ready to draw a new active tree immediately. 300 // We are ready to draw a new active tree immediately.
255 return base::TimeTicks(); 301 return base::TimeTicks();
256 } else if (state_machine_.needs_redraw()) { 302 } else if (state_machine_.needs_redraw()) {
257 // We have an animation or fast input path on the impl thread that wants 303 // We have an animation or fast input path on the impl thread that wants
258 // to draw, so don't wait too long for a new active tree. 304 // to draw, so don't wait too long for a new active tree.
259 return last_begin_impl_frame_args_.deadline; 305 return args.deadline - client_->DrawDurationEstimate();
260 } else { 306 } else {
261 // The impl thread doesn't have anything it wants to draw and we are just 307 // The impl thread doesn't have anything it wants to draw and we are just
262 // waiting for a new active tree, so post the deadline for the next 308 // waiting for a new active tree, so post the deadline for the next
263 // expected BeginImplFrame start. This allows us to draw immediately when 309 // expected BeginImplFrame start. This allows us to draw immediately when
264 // there is a new active tree, instead of waiting for the next 310 // there is a new active tree, instead of waiting for the next
265 // BeginImplFrame. 311 // BeginImplFrame.
266 // TODO(brianderson): Handle long deadlines (that are past the next frame's 312 // TODO(brianderson): Handle long deadlines (that are past the next frame's
267 // frame time) properly instead of using this hack. 313 // frame time) properly instead of using this hack.
268 return last_begin_impl_frame_args_.frame_time + 314 return args.frame_time + args.interval;
269 last_begin_impl_frame_args_.interval;
270 } 315 }
271 } 316 }
272 317
273 void Scheduler::ScheduleBeginImplFrameDeadline(base::TimeTicks deadline) { 318 void Scheduler::ScheduleBeginImplFrameDeadline(base::TimeTicks deadline) {
274 if (settings_.using_synchronous_renderer_compositor) { 319 if (settings_.using_synchronous_renderer_compositor) {
275 // The synchronous renderer compositor has to make its GL calls 320 // The synchronous renderer compositor has to make its GL calls
276 // within this call. 321 // within this call.
277 // TODO(brianderson): Have the OutputSurface initiate the deadline tasks 322 // TODO(brianderson): Have the OutputSurface initiate the deadline tasks
278 // so the sychronous renderer compositor can take advantage of splitting 323 // so the sychronous renderer compositor can take advantage of splitting
279 // up the BeginImplFrame and deadline as well. 324 // up the BeginImplFrame and deadline as well.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 break; 436 break;
392 case SchedulerStateMachine::ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: 437 case SchedulerStateMachine::ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD:
393 client_->ScheduledActionAcquireLayerTexturesForMainThread(); 438 client_->ScheduledActionAcquireLayerTexturesForMainThread();
394 break; 439 break;
395 case SchedulerStateMachine::ACTION_MANAGE_TILES: 440 case SchedulerStateMachine::ACTION_MANAGE_TILES:
396 client_->ScheduledActionManageTiles(); 441 client_->ScheduledActionManageTiles();
397 break; 442 break;
398 } 443 }
399 } while (action != SchedulerStateMachine::ACTION_NONE); 444 } while (action != SchedulerStateMachine::ACTION_NONE);
400 445
401 SetupNextBeginImplFrameIfNeeded(); 446 SetupNextBeginFrameIfNeeded();
402 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); 447 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime());
403 448
404 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) { 449 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) {
405 DCHECK(!settings_.using_synchronous_renderer_compositor); 450 DCHECK(!settings_.using_synchronous_renderer_compositor);
406 ScheduleBeginImplFrameDeadline(base::TimeTicks()); 451 ScheduleBeginImplFrameDeadline(base::TimeTicks());
407 } 452 }
408 } 453 }
409 454
410 bool Scheduler::WillDrawIfNeeded() const { 455 bool Scheduler::WillDrawIfNeeded() const {
411 return !state_machine_.PendingDrawsShouldBeAborted(); 456 return !state_machine_.PendingDrawsShouldBeAborted();
(...skipping 16 matching lines...) Expand all
428 "commit_to_activate_duration_estimate_ms", 473 "commit_to_activate_duration_estimate_ms",
429 client_->CommitToActivateDurationEstimate().InMillisecondsF()); 474 client_->CommitToActivateDurationEstimate().InMillisecondsF());
430 state->Set("client_state", client_state.release()); 475 state->Set("client_state", client_state.release());
431 return state.PassAs<base::Value>(); 476 return state.PassAs<base::Value>();
432 } 477 }
433 478
434 bool Scheduler::CanCommitAndActivateBeforeDeadline() const { 479 bool Scheduler::CanCommitAndActivateBeforeDeadline() const {
435 // Check if the main thread computation and commit can be finished before the 480 // Check if the main thread computation and commit can be finished before the
436 // impl thread's deadline. 481 // impl thread's deadline.
437 base::TimeTicks estimated_draw_time = 482 base::TimeTicks estimated_draw_time =
438 last_begin_impl_frame_args_.frame_time + 483 begin_impl_frame_args_.frame_time +
439 client_->BeginMainFrameToCommitDurationEstimate() + 484 client_->BeginMainFrameToCommitDurationEstimate() +
440 client_->CommitToActivateDurationEstimate(); 485 client_->CommitToActivateDurationEstimate();
441 486
442 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), 487 TRACE_EVENT2(
443 "CanCommitAndActivateBeforeDeadline", 488 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
444 "time_left_after_drawing_ms", 489 "CanCommitAndActivateBeforeDeadline",
445 (last_begin_impl_frame_args_.deadline - estimated_draw_time) 490 "time_left_after_drawing_ms",
446 .InMillisecondsF(), 491 (begin_impl_frame_args_.deadline - estimated_draw_time).InMillisecondsF(),
447 "state", 492 "state",
448 TracedValue::FromValue(StateAsValue().release())); 493 TracedValue::FromValue(StateAsValue().release()));
449 494
450 return estimated_draw_time < last_begin_impl_frame_args_.deadline; 495 return estimated_draw_time < begin_impl_frame_args_.deadline;
451 } 496 }
452 497
453 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 498 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
454 return (state_machine_.commit_state() == 499 return (state_machine_.commit_state() ==
455 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 500 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
456 state_machine_.commit_state() == 501 state_machine_.commit_state() ==
457 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 502 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
458 } 503 }
459 504
460 } // namespace cc 505 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_state_machine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698