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

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

Issue 835783003: Convert the enum objects in cc/scheduler/scheduler_state_machine.h to C++ "enum class" objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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_state_machine.h" 5 #include "cc/scheduler/scheduler_state_machine.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/debug/trace_event_argument.h" 8 #include "base/debug/trace_event_argument.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/values.h" 12 #include "base/values.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 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) 17 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
18 : settings_(settings), 18 : settings_(settings),
19 output_surface_state_(OUTPUT_SURFACE_LOST), 19 output_surface_state_(OutputSurfaceState::LOST),
20 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), 20 begin_impl_frame_state_(BeginImplFrameState::IDLE),
21 commit_state_(COMMIT_STATE_IDLE), 21 commit_state_(CommitState::IDLE),
22 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), 22 forced_redraw_state_(ForcedRedrawOnTimeoutState::IDLE),
23 commit_count_(0), 23 commit_count_(0),
24 current_frame_number_(0), 24 current_frame_number_(0),
25 last_frame_number_animate_performed_(-1), 25 last_frame_number_animate_performed_(-1),
26 last_frame_number_swap_performed_(-1), 26 last_frame_number_swap_performed_(-1),
27 last_frame_number_swap_requested_(-1), 27 last_frame_number_swap_requested_(-1),
28 last_frame_number_begin_main_frame_sent_(-1), 28 last_frame_number_begin_main_frame_sent_(-1),
29 prepare_tiles_funnel_(0), 29 prepare_tiles_funnel_(0),
30 consecutive_checkerboard_animations_(0), 30 consecutive_checkerboard_animations_(0),
31 max_pending_swaps_(1), 31 max_pending_swaps_(1),
32 pending_swaps_(0), 32 pending_swaps_(0),
(...skipping 14 matching lines...) Expand all
47 skip_next_begin_main_frame_to_reduce_latency_(false), 47 skip_next_begin_main_frame_to_reduce_latency_(false),
48 skip_begin_main_frame_to_reduce_latency_(false), 48 skip_begin_main_frame_to_reduce_latency_(false),
49 continuous_painting_(false), 49 continuous_painting_(false),
50 impl_latency_takes_priority_on_battery_(false), 50 impl_latency_takes_priority_on_battery_(false),
51 children_need_begin_frames_(false) { 51 children_need_begin_frames_(false) {
52 } 52 }
53 53
54 const char* SchedulerStateMachine::OutputSurfaceStateToString( 54 const char* SchedulerStateMachine::OutputSurfaceStateToString(
55 OutputSurfaceState state) { 55 OutputSurfaceState state) {
56 switch (state) { 56 switch (state) {
57 case OUTPUT_SURFACE_ACTIVE: 57 case OutputSurfaceState::ACTIVE:
58 return "OUTPUT_SURFACE_ACTIVE"; 58 return "OutputSurfaceState::ACTIVE";
59 case OUTPUT_SURFACE_LOST: 59 case OutputSurfaceState::LOST:
60 return "OUTPUT_SURFACE_LOST"; 60 return "OutputSurfaceState::LOST";
61 case OUTPUT_SURFACE_CREATING: 61 case OutputSurfaceState::CREATING:
62 return "OUTPUT_SURFACE_CREATING"; 62 return "OutputSurfaceState::CREATING";
63 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 63 case OutputSurfaceState::WAITING_FOR_FIRST_COMMIT:
64 return "OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT"; 64 return "OutputSurfaceState::WAITING_FOR_FIRST_COMMIT";
65 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 65 case OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION:
66 return "OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION"; 66 return "OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION";
67 } 67 }
68 NOTREACHED(); 68 NOTREACHED();
69 return "???"; 69 return "???";
70 } 70 }
71 71
72 const char* SchedulerStateMachine::BeginImplFrameStateToString( 72 const char* SchedulerStateMachine::BeginImplFrameStateToString(
73 BeginImplFrameState state) { 73 BeginImplFrameState state) {
74 switch (state) { 74 switch (state) {
75 case BEGIN_IMPL_FRAME_STATE_IDLE: 75 case BeginImplFrameState::IDLE:
76 return "BEGIN_IMPL_FRAME_STATE_IDLE"; 76 return "BeginImplFrameState::IDLE";
77 case BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING: 77 case BeginImplFrameState::BEGIN_FRAME_STARTING:
78 return "BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING"; 78 return "BeginImplFrameState::BEGIN_FRAME_STARTING";
79 case BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME: 79 case BeginImplFrameState::INSIDE_BEGIN_FRAME:
80 return "BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME"; 80 return "BeginImplFrameState::INSIDE_BEGIN_FRAME";
81 case BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE: 81 case BeginImplFrameState::INSIDE_DEADLINE:
82 return "BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE"; 82 return "BeginImplFrameState::INSIDE_DEADLINE";
83 } 83 }
84 NOTREACHED(); 84 NOTREACHED();
85 return "???"; 85 return "???";
86 } 86 }
87 87
88 const char* SchedulerStateMachine::CommitStateToString(CommitState state) { 88 const char* SchedulerStateMachine::CommitStateToString(CommitState state) {
89 switch (state) { 89 switch (state) {
90 case COMMIT_STATE_IDLE: 90 case CommitState::IDLE:
91 return "COMMIT_STATE_IDLE"; 91 return "CommitState::IDLE";
92 case COMMIT_STATE_BEGIN_MAIN_FRAME_SENT: 92 case CommitState::BEGIN_MAIN_FRAME_SENT:
93 return "COMMIT_STATE_BEGIN_MAIN_FRAME_SENT"; 93 return "CommitState::BEGIN_MAIN_FRAME_SENT";
94 case COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED: 94 case CommitState::BEGIN_MAIN_FRAME_STARTED:
95 return "COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED"; 95 return "CommitState::BEGIN_MAIN_FRAME_STARTED";
96 case COMMIT_STATE_READY_TO_COMMIT: 96 case CommitState::READY_TO_COMMIT:
97 return "COMMIT_STATE_READY_TO_COMMIT"; 97 return "CommitState::READY_TO_COMMIT";
98 case COMMIT_STATE_WAITING_FOR_ACTIVATION: 98 case CommitState::WAITING_FOR_ACTIVATION:
99 return "COMMIT_STATE_WAITING_FOR_ACTIVATION"; 99 return "CommitState::WAITING_FOR_ACTIVATION";
100 case COMMIT_STATE_WAITING_FOR_DRAW: 100 case CommitState::WAITING_FOR_DRAW:
101 return "COMMIT_STATE_WAITING_FOR_DRAW"; 101 return "CommitState::WAITING_FOR_DRAW";
102 } 102 }
103 NOTREACHED(); 103 NOTREACHED();
104 return "???"; 104 return "???";
105 } 105 }
106 106
107 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString( 107 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString(
108 ForcedRedrawOnTimeoutState state) { 108 ForcedRedrawOnTimeoutState state) {
109 switch (state) { 109 switch (state) {
110 case FORCED_REDRAW_STATE_IDLE: 110 case ForcedRedrawOnTimeoutState::IDLE:
111 return "FORCED_REDRAW_STATE_IDLE"; 111 return "ForcedRedrawOnTimeoutState::IDLE";
112 case FORCED_REDRAW_STATE_WAITING_FOR_COMMIT: 112 case ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT:
113 return "FORCED_REDRAW_STATE_WAITING_FOR_COMMIT"; 113 return "ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT";
114 case FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION: 114 case ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION:
115 return "FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION"; 115 return "ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION";
116 case FORCED_REDRAW_STATE_WAITING_FOR_DRAW: 116 case ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW:
117 return "FORCED_REDRAW_STATE_WAITING_FOR_DRAW"; 117 return "ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW";
118 } 118 }
119 NOTREACHED(); 119 NOTREACHED();
120 return "???"; 120 return "???";
121 } 121 }
122 122
123 const char* SchedulerStateMachine::ActionToString(Action action) { 123 const char* SchedulerStateMachine::ActionToString(Action action) {
124 switch (action) { 124 switch (action) {
125 case ACTION_NONE: 125 case Action::NONE:
126 return "ACTION_NONE"; 126 return "Action::NONE";
127 case ACTION_ANIMATE: 127 case Action::ANIMATE:
128 return "ACTION_ANIMATE"; 128 return "Action::ANIMATE";
129 case ACTION_SEND_BEGIN_MAIN_FRAME: 129 case Action::SEND_BEGIN_MAIN_FRAME:
130 return "ACTION_SEND_BEGIN_MAIN_FRAME"; 130 return "Action::SEND_BEGIN_MAIN_FRAME";
131 case ACTION_COMMIT: 131 case Action::COMMIT:
132 return "ACTION_COMMIT"; 132 return "Action::COMMIT";
133 case ACTION_ACTIVATE_SYNC_TREE: 133 case Action::ACTIVATE_SYNC_TREE:
134 return "ACTION_ACTIVATE_SYNC_TREE"; 134 return "Action::ACTIVATE_SYNC_TREE";
135 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: 135 case Action::DRAW_AND_SWAP_IF_POSSIBLE:
136 return "ACTION_DRAW_AND_SWAP_IF_POSSIBLE"; 136 return "Action::DRAW_AND_SWAP_IF_POSSIBLE";
137 case ACTION_DRAW_AND_SWAP_FORCED: 137 case Action::DRAW_AND_SWAP_FORCED:
138 return "ACTION_DRAW_AND_SWAP_FORCED"; 138 return "Action::DRAW_AND_SWAP_FORCED";
139 case ACTION_DRAW_AND_SWAP_ABORT: 139 case Action::DRAW_AND_SWAP_ABORT:
140 return "ACTION_DRAW_AND_SWAP_ABORT"; 140 return "Action::DRAW_AND_SWAP_ABORT";
141 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: 141 case Action::BEGIN_OUTPUT_SURFACE_CREATION:
142 return "ACTION_BEGIN_OUTPUT_SURFACE_CREATION"; 142 return "Action::BEGIN_OUTPUT_SURFACE_CREATION";
143 case ACTION_PREPARE_TILES: 143 case Action::PREPARE_TILES:
144 return "ACTION_PREPARE_TILES"; 144 return "Action::PREPARE_TILES";
145 } 145 }
146 NOTREACHED(); 146 NOTREACHED();
147 return "???"; 147 return "???";
148 } 148 }
149 149
150 scoped_refptr<base::debug::ConvertableToTraceFormat> 150 scoped_refptr<base::debug::ConvertableToTraceFormat>
151 SchedulerStateMachine::AsValue() const { 151 SchedulerStateMachine::AsValue() const {
152 scoped_refptr<base::debug::TracedValue> state = 152 scoped_refptr<base::debug::TracedValue> state =
153 new base::debug::TracedValue(); 153 new base::debug::TracedValue();
154 AsValueInto(state.get(), gfx::FrameTime::Now()); 154 AsValueInto(state.get(), gfx::FrameTime::Now());
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // Additional states where we should abort draws. 283 // Additional states where we should abort draws.
284 if (!can_draw_) 284 if (!can_draw_)
285 return true; 285 return true;
286 return false; 286 return false;
287 } 287 }
288 288
289 bool SchedulerStateMachine::PendingActivationsShouldBeForced() const { 289 bool SchedulerStateMachine::PendingActivationsShouldBeForced() const {
290 // There is no output surface to trigger our activations. 290 // There is no output surface to trigger our activations.
291 // If we do not force activations to make forward progress, we might deadlock 291 // If we do not force activations to make forward progress, we might deadlock
292 // with the main thread. 292 // with the main thread.
293 if (output_surface_state_ == OUTPUT_SURFACE_LOST) 293 if (output_surface_state_ == OutputSurfaceState::LOST)
294 return true; 294 return true;
295 295
296 // If we're not visible, we should force activation. 296 // If we're not visible, we should force activation.
297 // Since we set RequiresHighResToDraw when becoming visible, we ensure that we 297 // Since we set RequiresHighResToDraw when becoming visible, we ensure that we
298 // don't checkerboard until all visible resources are done. Furthermore, if we 298 // don't checkerboard until all visible resources are done. Furthermore, if we
299 // do keep the pending tree around, when becoming visible we might activate 299 // do keep the pending tree around, when becoming visible we might activate
300 // prematurely causing RequiresHighResToDraw flag to be reset. In all cases, 300 // prematurely causing RequiresHighResToDraw flag to be reset. In all cases,
301 // we can simply activate on becoming invisible since we don't need to draw 301 // we can simply activate on becoming invisible since we don't need to draw
302 // the active tree when we're in this state. 302 // the active tree when we're in this state.
303 if (!visible_) 303 if (!visible_)
304 return true; 304 return true;
305 305
306 return false; 306 return false;
307 } 307 }
308 308
309 bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const { 309 bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const {
310 // Don't try to initialize too early. 310 // Don't try to initialize too early.
311 if (!can_start_) 311 if (!can_start_)
312 return false; 312 return false;
313 313
314 // We only want to start output surface initialization after the 314 // We only want to start output surface initialization after the
315 // previous commit is complete. 315 // previous commit is complete.
316 if (commit_state_ != COMMIT_STATE_IDLE) 316 if (commit_state_ != CommitState::IDLE)
317 return false; 317 return false;
318 318
319 // Make sure the BeginImplFrame from any previous OutputSurfaces 319 // Make sure the BeginImplFrame from any previous OutputSurfaces
320 // are complete before creating the new OutputSurface. 320 // are complete before creating the new OutputSurface.
321 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_IDLE) 321 if (begin_impl_frame_state_ != BeginImplFrameState::IDLE)
322 return false; 322 return false;
323 323
324 // We want to clear the pipline of any pending draws and activations 324 // We want to clear the pipline of any pending draws and activations
325 // before starting output surface initialization. This allows us to avoid 325 // before starting output surface initialization. This allows us to avoid
326 // weird corner cases where we abort draws or force activation while we 326 // weird corner cases where we abort draws or force activation while we
327 // are initializing the output surface. 327 // are initializing the output surface.
328 if (active_tree_needs_first_draw_ || has_pending_tree_) 328 if (active_tree_needs_first_draw_ || has_pending_tree_)
329 return false; 329 return false;
330 330
331 // We need to create the output surface if we don't have one and we haven't 331 // We need to create the output surface if we don't have one and we haven't
332 // started creating one yet. 332 // started creating one yet.
333 return output_surface_state_ == OUTPUT_SURFACE_LOST; 333 return output_surface_state_ == OutputSurfaceState::LOST;
334 } 334 }
335 335
336 bool SchedulerStateMachine::ShouldDraw() const { 336 bool SchedulerStateMachine::ShouldDraw() const {
337 // If we need to abort draws, we should do so ASAP since the draw could 337 // If we need to abort draws, we should do so ASAP since the draw could
338 // be blocking other important actions (like output surface initialization), 338 // be blocking other important actions (like output surface initialization),
339 // from occuring. If we are waiting for the first draw, then perfom the 339 // from occuring. If we are waiting for the first draw, then perfom the
340 // aborted draw to keep things moving. If we are not waiting for the first 340 // aborted draw to keep things moving. If we are not waiting for the first
341 // draw however, we don't want to abort for no reason. 341 // draw however, we don't want to abort for no reason.
342 if (PendingDrawsShouldBeAborted()) 342 if (PendingDrawsShouldBeAborted())
343 return active_tree_needs_first_draw_; 343 return active_tree_needs_first_draw_;
344 344
345 // Don't draw if we are waiting on the first commit after a surface. 345 // Don't draw if we are waiting on the first commit after a surface.
346 if (output_surface_state_ != OUTPUT_SURFACE_ACTIVE) 346 if (output_surface_state_ != OutputSurfaceState::ACTIVE)
347 return false; 347 return false;
348 348
349 // If a commit has occurred after the animate call, we need to call animate 349 // If a commit has occurred after the animate call, we need to call animate
350 // again before we should draw. 350 // again before we should draw.
351 if (did_commit_after_animating_) 351 if (did_commit_after_animating_)
352 return false; 352 return false;
353 353
354 // After this line, we only want to send a swap request once per frame. 354 // After this line, we only want to send a swap request once per frame.
355 if (HasRequestedSwapThisFrame()) 355 if (HasRequestedSwapThisFrame())
356 return false; 356 return false;
357 357
358 // Do not queue too many swaps. 358 // Do not queue too many swaps.
359 if (pending_swaps_ >= max_pending_swaps_) 359 if (pending_swaps_ >= max_pending_swaps_)
360 return false; 360 return false;
361 361
362 // Except for the cases above, do not draw outside of the BeginImplFrame 362 // Except for the cases above, do not draw outside of the BeginImplFrame
363 // deadline. 363 // deadline.
364 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) 364 if (begin_impl_frame_state_ != BeginImplFrameState::INSIDE_DEADLINE)
365 return false; 365 return false;
366 366
367 // Only handle forced redraws due to timeouts on the regular deadline. 367 // Only handle forced redraws due to timeouts on the regular deadline.
368 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 368 if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)
369 return true; 369 return true;
370 370
371 return needs_redraw_; 371 return needs_redraw_;
372 } 372 }
373 373
374 bool SchedulerStateMachine::ShouldActivatePendingTree() const { 374 bool SchedulerStateMachine::ShouldActivatePendingTree() const {
375 // There is nothing to activate. 375 // There is nothing to activate.
376 if (!has_pending_tree_) 376 if (!has_pending_tree_)
377 return false; 377 return false;
378 378
379 // We should not activate a second tree before drawing the first one. 379 // We should not activate a second tree before drawing the first one.
380 // Even if we need to force activation of the pending tree, we should abort 380 // Even if we need to force activation of the pending tree, we should abort
381 // drawing the active tree first. 381 // drawing the active tree first.
382 if (active_tree_needs_first_draw_) 382 if (active_tree_needs_first_draw_)
383 return false; 383 return false;
384 384
385 // If we want to force activation, do so ASAP. 385 // If we want to force activation, do so ASAP.
386 if (PendingActivationsShouldBeForced()) 386 if (PendingActivationsShouldBeForced())
387 return true; 387 return true;
388 388
389 // At this point, only activate if we are ready to activate. 389 // At this point, only activate if we are ready to activate.
390 return pending_tree_is_ready_for_activation_; 390 return pending_tree_is_ready_for_activation_;
391 } 391 }
392 392
393 bool SchedulerStateMachine::ShouldAnimate() const { 393 bool SchedulerStateMachine::ShouldAnimate() const {
394 // Don't animate if we are waiting on the first commit after a surface. 394 // Don't animate if we are waiting on the first commit after a surface.
395 if (output_surface_state_ != OUTPUT_SURFACE_ACTIVE) 395 if (output_surface_state_ != OutputSurfaceState::ACTIVE)
396 return false; 396 return false;
397 397
398 // If a commit occurred after our last call, we need to do animation again. 398 // If a commit occurred after our last call, we need to do animation again.
399 if (HasAnimatedThisFrame() && !did_commit_after_animating_) 399 if (HasAnimatedThisFrame() && !did_commit_after_animating_)
400 return false; 400 return false;
401 401
402 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING && 402 if (begin_impl_frame_state_ != BeginImplFrameState::BEGIN_FRAME_STARTING &&
403 begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) 403 begin_impl_frame_state_ != BeginImplFrameState::INSIDE_DEADLINE)
404 return false; 404 return false;
405 405
406 return needs_redraw_ || needs_animate_; 406 return needs_redraw_ || needs_animate_;
407 } 407 }
408 408
409 bool SchedulerStateMachine::CouldSendBeginMainFrame() const { 409 bool SchedulerStateMachine::CouldSendBeginMainFrame() const {
410 if (!needs_commit_) 410 if (!needs_commit_)
411 return false; 411 return false;
412 412
413 // We can not perform commits if we are not visible. 413 // We can not perform commits if we are not visible.
414 if (!visible_) 414 if (!visible_)
415 return false; 415 return false;
416 416
417 return true; 417 return true;
418 } 418 }
419 419
420 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { 420 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
421 if (!CouldSendBeginMainFrame()) 421 if (!CouldSendBeginMainFrame())
422 return false; 422 return false;
423 423
424 // Only send BeginMainFrame when there isn't another commit pending already. 424 // Only send BeginMainFrame when there isn't another commit pending already.
425 if (commit_state_ != COMMIT_STATE_IDLE) 425 if (commit_state_ != CommitState::IDLE)
426 return false; 426 return false;
427 427
428 // Don't send BeginMainFrame early if we are prioritizing the active tree 428 // Don't send BeginMainFrame early if we are prioritizing the active tree
429 // because of impl_latency_takes_priority_. 429 // because of impl_latency_takes_priority_.
430 if (impl_latency_takes_priority_ && 430 if (impl_latency_takes_priority_ &&
431 (has_pending_tree_ || active_tree_needs_first_draw_)) { 431 (has_pending_tree_ || active_tree_needs_first_draw_)) {
432 return false; 432 return false;
433 } 433 }
434 434
435 // We should not send BeginMainFrame while we are in 435 // We should not send BeginMainFrame while we are in
436 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new 436 // BeginImplFrameState::IDLE since we might have new
437 // user input arriving soon. 437 // user input arriving soon.
438 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main 438 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main
439 // thread isn't consuming user input. 439 // thread isn't consuming user input.
440 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE && 440 if (begin_impl_frame_state_ == BeginImplFrameState::IDLE &&
441 BeginFrameNeeded()) 441 BeginFrameNeeded())
442 return false; 442 return false;
443 443
444 // We need a new commit for the forced redraw. This honors the 444 // We need a new commit for the forced redraw. This honors the
445 // single commit per interval because the result will be swapped to screen. 445 // single commit per interval because the result will be swapped to screen.
446 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) 446 if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT)
447 return true; 447 return true;
448 448
449 // After this point, we only start a commit once per frame. 449 // After this point, we only start a commit once per frame.
450 if (HasSentBeginMainFrameThisFrame()) 450 if (HasSentBeginMainFrameThisFrame())
451 return false; 451 return false;
452 452
453 // We shouldn't normally accept commits if there isn't an OutputSurface. 453 // We shouldn't normally accept commits if there isn't an OutputSurface.
454 if (!HasInitializedOutputSurface()) 454 if (!HasInitializedOutputSurface())
455 return false; 455 return false;
456 456
457 // SwapAck throttle the BeginMainFrames unless we just swapped. 457 // SwapAck throttle the BeginMainFrames unless we just swapped.
458 // TODO(brianderson): Remove this restriction to improve throughput. 458 // TODO(brianderson): Remove this restriction to improve throughput.
459 bool just_swapped_in_deadline = 459 bool just_swapped_in_deadline =
460 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && 460 begin_impl_frame_state_ == BeginImplFrameState::INSIDE_DEADLINE &&
461 HasSwappedThisFrame(); 461 HasSwappedThisFrame();
462 if (pending_swaps_ >= max_pending_swaps_ && !just_swapped_in_deadline) 462 if (pending_swaps_ >= max_pending_swaps_ && !just_swapped_in_deadline)
463 return false; 463 return false;
464 464
465 if (skip_begin_main_frame_to_reduce_latency_) 465 if (skip_begin_main_frame_to_reduce_latency_)
466 return false; 466 return false;
467 467
468 return true; 468 return true;
469 } 469 }
470 470
471 bool SchedulerStateMachine::ShouldCommit() const { 471 bool SchedulerStateMachine::ShouldCommit() const {
472 if (commit_state_ != COMMIT_STATE_READY_TO_COMMIT) 472 if (commit_state_ != CommitState::READY_TO_COMMIT)
473 return false; 473 return false;
474 474
475 // We must not finish the commit until the pending tree is free. 475 // We must not finish the commit until the pending tree is free.
476 if (has_pending_tree_) { 476 if (has_pending_tree_) {
477 DCHECK(settings_.main_frame_before_activation_enabled); 477 DCHECK(settings_.main_frame_before_activation_enabled);
478 return false; 478 return false;
479 } 479 }
480 480
481 // Prioritize drawing the previous commit before finishing the next commit. 481 // Prioritize drawing the previous commit before finishing the next commit.
482 if (active_tree_needs_first_draw_) 482 if (active_tree_needs_first_draw_)
483 return false; 483 return false;
484 484
485 return true; 485 return true;
486 } 486 }
487 487
488 bool SchedulerStateMachine::ShouldPrepareTiles() const { 488 bool SchedulerStateMachine::ShouldPrepareTiles() const {
489 // PrepareTiles only really needs to be called immediately after commit 489 // PrepareTiles only really needs to be called immediately after commit
490 // and then periodically after that. Use a funnel to make sure we average 490 // and then periodically after that. Use a funnel to make sure we average
491 // one PrepareTiles per BeginImplFrame in the long run. 491 // one PrepareTiles per BeginImplFrame in the long run.
492 if (prepare_tiles_funnel_ > 0) 492 if (prepare_tiles_funnel_ > 0)
493 return false; 493 return false;
494 494
495 // Limiting to once per-frame is not enough, since we only want to 495 // Limiting to once per-frame is not enough, since we only want to
496 // prepare tiles _after_ draws. Polling for draw triggers and 496 // prepare tiles _after_ draws. Polling for draw triggers and
497 // begin-frame are mutually exclusive, so we limit to these two cases. 497 // begin-frame are mutually exclusive, so we limit to these two cases.
498 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && 498 if (begin_impl_frame_state_ != BeginImplFrameState::INSIDE_DEADLINE &&
499 !inside_poll_for_anticipated_draw_triggers_) 499 !inside_poll_for_anticipated_draw_triggers_)
500 return false; 500 return false;
501 return needs_prepare_tiles_; 501 return needs_prepare_tiles_;
502 } 502 }
503 503
504 SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { 504 SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
505 if (ShouldActivatePendingTree()) 505 if (ShouldActivatePendingTree())
506 return ACTION_ACTIVATE_SYNC_TREE; 506 return Action::ACTIVATE_SYNC_TREE;
507 if (ShouldCommit()) 507 if (ShouldCommit())
508 return ACTION_COMMIT; 508 return Action::COMMIT;
509 if (ShouldAnimate()) 509 if (ShouldAnimate())
510 return ACTION_ANIMATE; 510 return Action::ANIMATE;
511 if (ShouldDraw()) { 511 if (ShouldDraw()) {
512 if (PendingDrawsShouldBeAborted()) 512 if (PendingDrawsShouldBeAborted())
513 return ACTION_DRAW_AND_SWAP_ABORT; 513 return Action::DRAW_AND_SWAP_ABORT;
514 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 514 else if (forced_redraw_state_ ==
515 return ACTION_DRAW_AND_SWAP_FORCED; 515 ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)
516 return Action::DRAW_AND_SWAP_FORCED;
516 else 517 else
517 return ACTION_DRAW_AND_SWAP_IF_POSSIBLE; 518 return Action::DRAW_AND_SWAP_IF_POSSIBLE;
518 } 519 }
519 if (ShouldPrepareTiles()) 520 if (ShouldPrepareTiles())
520 return ACTION_PREPARE_TILES; 521 return Action::PREPARE_TILES;
521 if (ShouldSendBeginMainFrame()) 522 if (ShouldSendBeginMainFrame())
522 return ACTION_SEND_BEGIN_MAIN_FRAME; 523 return Action::SEND_BEGIN_MAIN_FRAME;
523 if (ShouldBeginOutputSurfaceCreation()) 524 if (ShouldBeginOutputSurfaceCreation())
524 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION; 525 return Action::BEGIN_OUTPUT_SURFACE_CREATION;
525 return ACTION_NONE; 526 return Action::NONE;
526 } 527 }
527 528
528 void SchedulerStateMachine::UpdateState(Action action) { 529 void SchedulerStateMachine::UpdateState(Action action) {
529 switch (action) { 530 switch (action) {
530 case ACTION_NONE: 531 case Action::NONE:
531 return; 532 return;
532 533
533 case ACTION_ACTIVATE_SYNC_TREE: 534 case Action::ACTIVATE_SYNC_TREE:
534 UpdateStateOnActivation(); 535 UpdateStateOnActivation();
535 return; 536 return;
536 537
537 case ACTION_ANIMATE: 538 case Action::ANIMATE:
538 last_frame_number_animate_performed_ = current_frame_number_; 539 last_frame_number_animate_performed_ = current_frame_number_;
539 needs_animate_ = false; 540 needs_animate_ = false;
540 did_commit_after_animating_ = false; 541 did_commit_after_animating_ = false;
541 // TODO(skyostil): Instead of assuming this, require the client to tell 542 // TODO(skyostil): Instead of assuming this, require the client to tell
542 // us. 543 // us.
543 SetNeedsRedraw(); 544 SetNeedsRedraw();
544 return; 545 return;
545 546
546 case ACTION_SEND_BEGIN_MAIN_FRAME: 547 case Action::SEND_BEGIN_MAIN_FRAME:
547 DCHECK(!has_pending_tree_ || 548 DCHECK(!has_pending_tree_ ||
548 settings_.main_frame_before_activation_enabled); 549 settings_.main_frame_before_activation_enabled);
549 DCHECK(visible_); 550 DCHECK(visible_);
550 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; 551 commit_state_ = CommitState::BEGIN_MAIN_FRAME_SENT;
551 needs_commit_ = false; 552 needs_commit_ = false;
552 last_frame_number_begin_main_frame_sent_ = 553 last_frame_number_begin_main_frame_sent_ =
553 current_frame_number_; 554 current_frame_number_;
554 return; 555 return;
555 556
556 case ACTION_COMMIT: { 557 case Action::COMMIT: {
557 bool commit_has_no_updates = false; 558 bool commit_has_no_updates = false;
558 UpdateStateOnCommit(commit_has_no_updates); 559 UpdateStateOnCommit(commit_has_no_updates);
559 return; 560 return;
560 } 561 }
561 562
562 case ACTION_DRAW_AND_SWAP_FORCED: 563 case Action::DRAW_AND_SWAP_FORCED:
563 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { 564 case Action::DRAW_AND_SWAP_IF_POSSIBLE: {
564 bool did_request_swap = true; 565 bool did_request_swap = true;
565 UpdateStateOnDraw(did_request_swap); 566 UpdateStateOnDraw(did_request_swap);
566 return; 567 return;
567 } 568 }
568 569
569 case ACTION_DRAW_AND_SWAP_ABORT: { 570 case Action::DRAW_AND_SWAP_ABORT: {
570 bool did_request_swap = false; 571 bool did_request_swap = false;
571 UpdateStateOnDraw(did_request_swap); 572 UpdateStateOnDraw(did_request_swap);
572 return; 573 return;
573 } 574 }
574 575
575 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: 576 case Action::BEGIN_OUTPUT_SURFACE_CREATION:
576 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST); 577 DCHECK_EQ(output_surface_state_, OutputSurfaceState::LOST);
577 output_surface_state_ = OUTPUT_SURFACE_CREATING; 578 output_surface_state_ = OutputSurfaceState::CREATING;
578 579
579 // The following DCHECKs make sure we are in the proper quiescent state. 580 // The following DCHECKs make sure we are in the proper quiescent state.
580 // The pipeline should be flushed entirely before we start output 581 // The pipeline should be flushed entirely before we start output
581 // surface creation to avoid complicated corner cases. 582 // surface creation to avoid complicated corner cases.
582 DCHECK_EQ(commit_state_, COMMIT_STATE_IDLE); 583 DCHECK_EQ(commit_state_, CommitState::IDLE);
583 DCHECK(!has_pending_tree_); 584 DCHECK(!has_pending_tree_);
584 DCHECK(!active_tree_needs_first_draw_); 585 DCHECK(!active_tree_needs_first_draw_);
585 return; 586 return;
586 587
587 case ACTION_PREPARE_TILES: 588 case Action::PREPARE_TILES:
588 UpdateStateOnPrepareTiles(); 589 UpdateStateOnPrepareTiles();
589 return; 590 return;
590 } 591 }
591 } 592 }
592 593
593 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_has_no_updates) { 594 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_has_no_updates) {
594 commit_count_++; 595 commit_count_++;
595 596
596 if (!commit_has_no_updates && HasAnimatedThisFrame()) 597 if (!commit_has_no_updates && HasAnimatedThisFrame())
597 did_commit_after_animating_ = true; 598 did_commit_after_animating_ = true;
598 599
599 if (commit_has_no_updates || settings_.main_frame_before_activation_enabled) { 600 if (commit_has_no_updates || settings_.main_frame_before_activation_enabled) {
600 commit_state_ = COMMIT_STATE_IDLE; 601 commit_state_ = CommitState::IDLE;
601 } else if (settings_.impl_side_painting) { 602 } else if (settings_.impl_side_painting) {
602 commit_state_ = COMMIT_STATE_WAITING_FOR_ACTIVATION; 603 commit_state_ = CommitState::WAITING_FOR_ACTIVATION;
603 } else { 604 } else {
604 commit_state_ = settings_.main_thread_should_always_be_low_latency 605 commit_state_ = settings_.main_thread_should_always_be_low_latency
605 ? COMMIT_STATE_WAITING_FOR_DRAW 606 ? CommitState::WAITING_FOR_DRAW
606 : COMMIT_STATE_IDLE; 607 : CommitState::IDLE;
607 } 608 }
608 609
609 // If we are impl-side-painting but the commit was aborted, then we behave 610 // If we are impl-side-painting but the commit was aborted, then we behave
610 // mostly as if we are not impl-side-painting since there is no pending tree. 611 // mostly as if we are not impl-side-painting since there is no pending tree.
611 has_pending_tree_ = settings_.impl_side_painting && !commit_has_no_updates; 612 has_pending_tree_ = settings_.impl_side_painting && !commit_has_no_updates;
612 613
613 // Update state related to forced draws. 614 // Update state related to forced draws.
614 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { 615 if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT) {
615 forced_redraw_state_ = has_pending_tree_ 616 forced_redraw_state_ =
616 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION 617 has_pending_tree_ ? ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION
617 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; 618 : ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW;
618 } 619 }
619 620
620 // Update the output surface state. 621 // Update the output surface state.
621 DCHECK_NE(output_surface_state_, OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION); 622 DCHECK_NE(output_surface_state_,
622 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) { 623 OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION);
624 if (output_surface_state_ == OutputSurfaceState::WAITING_FOR_FIRST_COMMIT) {
623 if (has_pending_tree_) { 625 if (has_pending_tree_) {
624 output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION; 626 output_surface_state_ = OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION;
625 } else { 627 } else {
626 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; 628 output_surface_state_ = OutputSurfaceState::ACTIVE;
627 needs_redraw_ = true; 629 needs_redraw_ = true;
628 } 630 }
629 } 631 }
630 632
631 // Update state if we have a new active tree to draw, or if the active tree 633 // Update state if we have a new active tree to draw, or if the active tree
632 // was unchanged but we need to do a forced draw. 634 // was unchanged but we need to do a forced draw.
633 if (!has_pending_tree_ && 635 if (!has_pending_tree_ &&
634 (!commit_has_no_updates || 636 (!commit_has_no_updates ||
635 forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)) { 637 forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)) {
636 needs_redraw_ = true; 638 needs_redraw_ = true;
637 active_tree_needs_first_draw_ = true; 639 active_tree_needs_first_draw_ = true;
638 } 640 }
639 641
640 // This post-commit work is common to both completed and aborted commits. 642 // This post-commit work is common to both completed and aborted commits.
641 pending_tree_is_ready_for_activation_ = false; 643 pending_tree_is_ready_for_activation_ = false;
642 644
643 if (continuous_painting_) 645 if (continuous_painting_)
644 needs_commit_ = true; 646 needs_commit_ = true;
645 } 647 }
646 648
647 void SchedulerStateMachine::UpdateStateOnActivation() { 649 void SchedulerStateMachine::UpdateStateOnActivation() {
648 if (commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION) { 650 if (commit_state_ == CommitState::WAITING_FOR_ACTIVATION) {
649 commit_state_ = settings_.main_thread_should_always_be_low_latency 651 commit_state_ = settings_.main_thread_should_always_be_low_latency
650 ? COMMIT_STATE_WAITING_FOR_DRAW 652 ? CommitState::WAITING_FOR_DRAW
651 : COMMIT_STATE_IDLE; 653 : CommitState::IDLE;
652 } 654 }
653 655
654 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION) 656 if (output_surface_state_ == OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION)
655 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; 657 output_surface_state_ = OutputSurfaceState::ACTIVE;
656 658
657 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) 659 if (forced_redraw_state_ ==
658 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; 660 ForcedRedrawOnTimeoutState::WAITING_FOR_ACTIVATION)
661 forced_redraw_state_ = ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW;
659 662
660 has_pending_tree_ = false; 663 has_pending_tree_ = false;
661 pending_tree_is_ready_for_activation_ = false; 664 pending_tree_is_ready_for_activation_ = false;
662 active_tree_needs_first_draw_ = true; 665 active_tree_needs_first_draw_ = true;
663 needs_redraw_ = true; 666 needs_redraw_ = true;
664 } 667 }
665 668
666 void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) { 669 void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) {
667 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 670 if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)
668 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; 671 forced_redraw_state_ = ForcedRedrawOnTimeoutState::IDLE;
669 672
670 if (commit_state_ == COMMIT_STATE_WAITING_FOR_DRAW) 673 if (commit_state_ == CommitState::WAITING_FOR_DRAW)
671 commit_state_ = COMMIT_STATE_IDLE; 674 commit_state_ = CommitState::IDLE;
672 675
673 needs_redraw_ = false; 676 needs_redraw_ = false;
674 active_tree_needs_first_draw_ = false; 677 active_tree_needs_first_draw_ = false;
675 678
676 if (did_request_swap) 679 if (did_request_swap)
677 last_frame_number_swap_requested_ = current_frame_number_; 680 last_frame_number_swap_requested_ = current_frame_number_;
678 } 681 }
679 682
680 void SchedulerStateMachine::UpdateStateOnPrepareTiles() { 683 void SchedulerStateMachine::UpdateStateOnPrepareTiles() {
681 needs_prepare_tiles_ = false; 684 needs_prepare_tiles_ = false;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 726
724 // Never call SetNeedsBeginFrames if the frame source has the right value. 727 // Never call SetNeedsBeginFrames if the frame source has the right value.
725 if (needs_begin_frame == frame_source_needs_begin_frames) 728 if (needs_begin_frame == frame_source_needs_begin_frames)
726 return false; 729 return false;
727 730
728 // Always request the BeginFrame immediately if it's needed. 731 // Always request the BeginFrame immediately if it's needed.
729 if (needs_begin_frame) 732 if (needs_begin_frame)
730 return true; 733 return true;
731 734
732 // Stop requesting BeginFrames after a deadline. 735 // Stop requesting BeginFrames after a deadline.
733 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) 736 if (begin_impl_frame_state_ == BeginImplFrameState::INSIDE_DEADLINE)
734 return true; 737 return true;
735 738
736 // Stop requesting BeginFrames immediately when output surface is lost. 739 // Stop requesting BeginFrames immediately when output surface is lost.
737 if (!HasInitializedOutputSurface()) 740 if (!HasInitializedOutputSurface())
738 return true; 741 return true;
739 742
740 return false; 743 return false;
741 } 744 }
742 745
743 bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const { 746 bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const {
(...skipping 23 matching lines...) Expand all
767 bool children_need_begin_frames) { 770 bool children_need_begin_frames) {
768 DCHECK(settings_.forward_begin_frames_to_children); 771 DCHECK(settings_.forward_begin_frames_to_children);
769 children_need_begin_frames_ = children_need_begin_frames; 772 children_need_begin_frames_ = children_need_begin_frames;
770 } 773 }
771 774
772 // These are the cases where we definitely (or almost definitely) have a 775 // These are the cases where we definitely (or almost definitely) have a
773 // new frame to animate and/or draw and can draw. 776 // new frame to animate and/or draw and can draw.
774 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { 777 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const {
775 // The forced draw respects our normal draw scheduling, so we need to 778 // The forced draw respects our normal draw scheduling, so we need to
776 // request a BeginImplFrame for it. 779 // request a BeginImplFrame for it.
777 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 780 if (forced_redraw_state_ == ForcedRedrawOnTimeoutState::WAITING_FOR_DRAW)
778 return true; 781 return true;
779 782
780 return needs_animate_ || needs_redraw_; 783 return needs_animate_ || needs_redraw_;
781 } 784 }
782 785
783 // These are cases where we are very likely to draw soon, but might not 786 // These are cases where we are very likely to draw soon, but might not
784 // actually have a new frame to draw when we receive the next BeginImplFrame. 787 // actually have a new frame to draw when we receive the next BeginImplFrame.
785 // Proactively requesting the BeginImplFrame helps hide the round trip latency 788 // Proactively requesting the BeginImplFrame helps hide the round trip latency
786 // of the SetNeedsBeginFrame request that has to go to the Browser. 789 // of the SetNeedsBeginFrame request that has to go to the Browser.
787 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { 790 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const {
788 // Do not be proactive when invisible. 791 // Do not be proactive when invisible.
789 if (!visible_) 792 if (!visible_)
790 return false; 793 return false;
791 794
792 // We should proactively request a BeginImplFrame if a commit is pending 795 // We should proactively request a BeginImplFrame if a commit is pending
793 // because we will want to draw if the commit completes quickly. 796 // because we will want to draw if the commit completes quickly.
794 if (needs_commit_ || commit_state_ != COMMIT_STATE_IDLE) 797 if (needs_commit_ || commit_state_ != CommitState::IDLE)
795 return true; 798 return true;
796 799
797 // If the pending tree activates quickly, we'll want a BeginImplFrame soon 800 // If the pending tree activates quickly, we'll want a BeginImplFrame soon
798 // to draw the new active tree. 801 // to draw the new active tree.
799 if (has_pending_tree_) 802 if (has_pending_tree_)
800 return true; 803 return true;
801 804
802 // Changing priorities may allow us to activate (given the new priorities), 805 // Changing priorities may allow us to activate (given the new priorities),
803 // which may result in a new frame. 806 // which may result in a new frame.
804 if (needs_prepare_tiles_) 807 if (needs_prepare_tiles_)
805 return true; 808 return true;
806 809
807 // If we just sent a swap request, it's likely that we are going to produce 810 // If we just sent a swap request, it's likely that we are going to produce
808 // another frame soon. This helps avoid negative glitches in our 811 // another frame soon. This helps avoid negative glitches in our
809 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame 812 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame
810 // provider and get sampled at an inopportune time, delaying the next 813 // provider and get sampled at an inopportune time, delaying the next
811 // BeginImplFrame. 814 // BeginImplFrame.
812 if (HasRequestedSwapThisFrame()) 815 if (HasRequestedSwapThisFrame())
813 return true; 816 return true;
814 817
815 return false; 818 return false;
816 } 819 }
817 820
818 void SchedulerStateMachine::OnBeginImplFrame(const BeginFrameArgs& args) { 821 void SchedulerStateMachine::OnBeginImplFrame(const BeginFrameArgs& args) {
819 AdvanceCurrentFrameNumber(); 822 AdvanceCurrentFrameNumber();
820 begin_impl_frame_args_ = args; 823 begin_impl_frame_args_ = args;
821 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_IDLE) 824 DCHECK_EQ(begin_impl_frame_state_, BeginImplFrameState::IDLE)
822 << AsValue()->ToString(); 825 << AsValue()->ToString();
823 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; 826 begin_impl_frame_state_ = BeginImplFrameState::BEGIN_FRAME_STARTING;
824 } 827 }
825 828
826 void SchedulerStateMachine::OnBeginImplFrameDeadlinePending() { 829 void SchedulerStateMachine::OnBeginImplFrameDeadlinePending() {
827 DCHECK_EQ(begin_impl_frame_state_, 830 DCHECK_EQ(begin_impl_frame_state_, BeginImplFrameState::BEGIN_FRAME_STARTING)
828 BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING)
829 << AsValue()->ToString(); 831 << AsValue()->ToString();
830 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; 832 begin_impl_frame_state_ = BeginImplFrameState::INSIDE_BEGIN_FRAME;
831 } 833 }
832 834
833 void SchedulerStateMachine::OnBeginImplFrameDeadline() { 835 void SchedulerStateMachine::OnBeginImplFrameDeadline() {
834 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) 836 DCHECK_EQ(begin_impl_frame_state_, BeginImplFrameState::INSIDE_BEGIN_FRAME)
835 << AsValue()->ToString(); 837 << AsValue()->ToString();
836 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; 838 begin_impl_frame_state_ = BeginImplFrameState::INSIDE_DEADLINE;
837 } 839 }
838 840
839 void SchedulerStateMachine::OnBeginImplFrameIdle() { 841 void SchedulerStateMachine::OnBeginImplFrameIdle() {
840 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) 842 DCHECK_EQ(begin_impl_frame_state_, BeginImplFrameState::INSIDE_DEADLINE)
841 << AsValue()->ToString(); 843 << AsValue()->ToString();
842 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; 844 begin_impl_frame_state_ = BeginImplFrameState::IDLE;
843 } 845 }
844 846
845 SchedulerStateMachine::BeginImplFrameDeadlineMode 847 SchedulerStateMachine::BeginImplFrameDeadlineMode
846 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { 848 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const {
847 if (ShouldTriggerBeginImplFrameDeadlineImmediately()) { 849 if (ShouldTriggerBeginImplFrameDeadlineImmediately()) {
848 return BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE; 850 return BeginImplFrameDeadlineMode::IMMEDIATE;
849 } else if (needs_redraw_ && pending_swaps_ < max_pending_swaps_) { 851 } else if (needs_redraw_ && pending_swaps_ < max_pending_swaps_) {
850 // We have an animation or fast input path on the impl thread that wants 852 // We have an animation or fast input path on the impl thread that wants
851 // to draw, so don't wait too long for a new active tree. 853 // to draw, so don't wait too long for a new active tree.
852 // If we are swap throttled we should wait until we are unblocked. 854 // If we are swap throttled we should wait until we are unblocked.
853 return BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR; 855 return BeginImplFrameDeadlineMode::REGULAR;
854 } else { 856 } else {
855 // The impl thread doesn't have anything it wants to draw and we are just 857 // The impl thread doesn't have anything it wants to draw and we are just
856 // waiting for a new active tree or we are swap throttled. In short we are 858 // waiting for a new active tree or we are swap throttled. In short we are
857 // blocked. 859 // blocked.
858 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; 860 return BeginImplFrameDeadlineMode::LATE;
859 } 861 }
860 } 862 }
861 863
862 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() 864 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately()
863 const { 865 const {
864 // TODO(brianderson): This should take into account multiple commit sources. 866 // TODO(brianderson): This should take into account multiple commit sources.
865 867
866 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) 868 if (begin_impl_frame_state_ != BeginImplFrameState::INSIDE_BEGIN_FRAME)
867 return false; 869 return false;
868 870
869 // If we've lost the output surface, end the current BeginImplFrame ASAP 871 // If we've lost the output surface, end the current BeginImplFrame ASAP
870 // so we can start creating the next output surface. 872 // so we can start creating the next output surface.
871 if (output_surface_state_ == OUTPUT_SURFACE_LOST) 873 if (output_surface_state_ == OutputSurfaceState::LOST)
872 return true; 874 return true;
873 875
874 // SwapAck throttle the deadline since we wont draw and swap anyway. 876 // SwapAck throttle the deadline since we wont draw and swap anyway.
875 if (pending_swaps_ >= max_pending_swaps_) 877 if (pending_swaps_ >= max_pending_swaps_)
876 return false; 878 return false;
877 879
878 if (active_tree_needs_first_draw_) 880 if (active_tree_needs_first_draw_)
879 return true; 881 return true;
880 882
881 if (!needs_redraw_) 883 if (!needs_redraw_)
882 return false; 884 return false;
883 885
884 // This is used to prioritize impl-thread draws when the main thread isn't 886 // This is used to prioritize impl-thread draws when the main thread isn't
885 // producing anything, e.g., after an aborted commit. We also check that we 887 // producing anything, e.g., after an aborted commit. We also check that we
886 // don't have a pending tree -- otherwise we should give it a chance to 888 // don't have a pending tree -- otherwise we should give it a chance to
887 // activate. 889 // activate.
888 // TODO(skyostil): Revisit this when we have more accurate deadline estimates. 890 // TODO(skyostil): Revisit this when we have more accurate deadline estimates.
889 if (commit_state_ == COMMIT_STATE_IDLE && !has_pending_tree_) 891 if (commit_state_ == CommitState::IDLE && !has_pending_tree_)
890 return true; 892 return true;
891 893
892 // Prioritize impl-thread draws in impl_latency_takes_priority_ mode. 894 // Prioritize impl-thread draws in impl_latency_takes_priority_ mode.
893 if (impl_latency_takes_priority_) 895 if (impl_latency_takes_priority_)
894 return true; 896 return true;
895 897
896 // If we are on battery power and want to prioritize impl latency because 898 // If we are on battery power and want to prioritize impl latency because
897 // we don't trust deadline tasks to execute at the right time. 899 // we don't trust deadline tasks to execute at the right time.
898 if (impl_latency_takes_priority_on_battery_) 900 if (impl_latency_takes_priority_on_battery_)
899 return true; 901 return true;
900 902
901 return false; 903 return false;
902 } 904 }
903 905
904 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const { 906 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const {
905 // If a commit is pending before the previous commit has been drawn, we 907 // If a commit is pending before the previous commit has been drawn, we
906 // are definitely in a high latency mode. 908 // are definitely in a high latency mode.
907 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_)) 909 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_))
908 return true; 910 return true;
909 911
910 // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main 912 // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main
911 // thread is in a low latency mode. 913 // thread is in a low latency mode.
912 if (HasSentBeginMainFrameThisFrame() && 914 if (HasSentBeginMainFrameThisFrame() &&
913 (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING || 915 (begin_impl_frame_state_ == BeginImplFrameState::BEGIN_FRAME_STARTING ||
914 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)) 916 begin_impl_frame_state_ == BeginImplFrameState::INSIDE_BEGIN_FRAME))
915 return false; 917 return false;
916 918
917 // If there's a commit in progress it must either be from the previous frame 919 // If there's a commit in progress it must either be from the previous frame
918 // or it started after the impl thread's deadline. In either case the main 920 // or it started after the impl thread's deadline. In either case the main
919 // thread is in high latency mode. 921 // thread is in high latency mode.
920 if (CommitPending()) 922 if (CommitPending())
921 return true; 923 return true;
922 924
923 // Similarly, if there's a pending tree the main thread is in high latency 925 // Similarly, if there's a pending tree the main thread is in high latency
924 // mode, because either 926 // mode, because either
925 // it's from the previous frame 927 // it's from the previous frame
926 // or 928 // or
927 // we're currently drawing the active tree and the pending tree will thus 929 // we're currently drawing the active tree and the pending tree will thus
928 // only be drawn in the next frame. 930 // only be drawn in the next frame.
929 if (has_pending_tree_) 931 if (has_pending_tree_)
930 return true; 932 return true;
931 933
932 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) { 934 if (begin_impl_frame_state_ == BeginImplFrameState::INSIDE_DEADLINE) {
933 // Even if there's a new active tree to draw at the deadline or we've just 935 // Even if there's a new active tree to draw at the deadline or we've just
934 // swapped it, it may have been triggered by a previous BeginImplFrame, in 936 // swapped it, it may have been triggered by a previous BeginImplFrame, in
935 // which case the main thread is in a high latency mode. 937 // which case the main thread is in a high latency mode.
936 return (active_tree_needs_first_draw_ || HasSwappedThisFrame()) && 938 return (active_tree_needs_first_draw_ || HasSwappedThisFrame()) &&
937 !HasSentBeginMainFrameThisFrame(); 939 !HasSentBeginMainFrameThisFrame();
938 } 940 }
939 941
940 // If the active tree needs its first draw in any other state, we know the 942 // If the active tree needs its first draw in any other state, we know the
941 // main thread is in a high latency mode. 943 // main thread is in a high latency mode.
942 return active_tree_needs_first_draw_; 944 return active_tree_needs_first_draw_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 case INVALID_RESULT: 996 case INVALID_RESULT:
995 NOTREACHED() << "Uninitialized DrawResult."; 997 NOTREACHED() << "Uninitialized DrawResult.";
996 break; 998 break;
997 case DRAW_ABORTED_CANT_DRAW: 999 case DRAW_ABORTED_CANT_DRAW:
998 case DRAW_ABORTED_CONTEXT_LOST: 1000 case DRAW_ABORTED_CONTEXT_LOST:
999 NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:" 1001 NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:"
1000 << result; 1002 << result;
1001 break; 1003 break;
1002 case DRAW_SUCCESS: 1004 case DRAW_SUCCESS:
1003 consecutive_checkerboard_animations_ = 0; 1005 consecutive_checkerboard_animations_ = 0;
1004 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; 1006 forced_redraw_state_ = ForcedRedrawOnTimeoutState::IDLE;
1005 break; 1007 break;
1006 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: 1008 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS:
1007 needs_redraw_ = true; 1009 needs_redraw_ = true;
1008 1010
1009 // If we're already in the middle of a redraw, we don't need to 1011 // If we're already in the middle of a redraw, we don't need to
1010 // restart it. 1012 // restart it.
1011 if (forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE) 1013 if (forced_redraw_state_ != ForcedRedrawOnTimeoutState::IDLE)
1012 return; 1014 return;
1013 1015
1014 needs_commit_ = true; 1016 needs_commit_ = true;
1015 consecutive_checkerboard_animations_++; 1017 consecutive_checkerboard_animations_++;
1016 if (settings_.timeout_and_draw_when_animation_checkerboards && 1018 if (settings_.timeout_and_draw_when_animation_checkerboards &&
1017 consecutive_checkerboard_animations_ >= 1019 consecutive_checkerboard_animations_ >=
1018 settings_.maximum_number_of_failed_draws_before_draw_is_forced_) { 1020 settings_.maximum_number_of_failed_draws_before_draw_is_forced_) {
1019 consecutive_checkerboard_animations_ = 0; 1021 consecutive_checkerboard_animations_ = 0;
1020 // We need to force a draw, but it doesn't make sense to do this until 1022 // We need to force a draw, but it doesn't make sense to do this until
1021 // we've committed and have new textures. 1023 // we've committed and have new textures.
1022 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; 1024 forced_redraw_state_ = ForcedRedrawOnTimeoutState::WAITING_FOR_COMMIT;
1023 } 1025 }
1024 break; 1026 break;
1025 case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT: 1027 case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT:
1026 // It's not clear whether this missing content is because of missing 1028 // It's not clear whether this missing content is because of missing
1027 // pictures (which requires a commit) or because of memory pressure 1029 // pictures (which requires a commit) or because of memory pressure
1028 // removing textures (which might not). To be safe, request a commit 1030 // removing textures (which might not). To be safe, request a commit
1029 // anyway. 1031 // anyway.
1030 needs_commit_ = true; 1032 needs_commit_ = true;
1031 break; 1033 break;
1032 } 1034 }
1033 } 1035 }
1034 1036
1035 void SchedulerStateMachine::SetNeedsCommit() { 1037 void SchedulerStateMachine::SetNeedsCommit() {
1036 needs_commit_ = true; 1038 needs_commit_ = true;
1037 } 1039 }
1038 1040
1039 void SchedulerStateMachine::NotifyReadyToCommit() { 1041 void SchedulerStateMachine::NotifyReadyToCommit() {
1040 DCHECK(commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED) 1042 DCHECK(commit_state_ == CommitState::BEGIN_MAIN_FRAME_STARTED)
1041 << AsValue()->ToString(); 1043 << AsValue()->ToString();
1042 commit_state_ = COMMIT_STATE_READY_TO_COMMIT; 1044 commit_state_ = CommitState::READY_TO_COMMIT;
1043 // In main thread low latency mode, commit should happen right after 1045 // In main thread low latency mode, commit should happen right after
1044 // BeginFrame, meaning when this function is called, next action should be 1046 // BeginFrame, meaning when this function is called, next action should be
1045 // commit. 1047 // commit.
1046 if (settings_.main_thread_should_always_be_low_latency) 1048 if (settings_.main_thread_should_always_be_low_latency)
1047 DCHECK(ShouldCommit()); 1049 DCHECK(ShouldCommit());
1048 } 1050 }
1049 1051
1050 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { 1052 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) {
1051 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); 1053 DCHECK_EQ(commit_state_, CommitState::BEGIN_MAIN_FRAME_SENT);
1052 switch (reason) { 1054 switch (reason) {
1053 case CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST: 1055 case CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST:
1054 case CommitEarlyOutReason::ABORTED_NOT_VISIBLE: 1056 case CommitEarlyOutReason::ABORTED_NOT_VISIBLE:
1055 commit_state_ = COMMIT_STATE_IDLE; 1057 commit_state_ = CommitState::IDLE;
1056 SetNeedsCommit(); 1058 SetNeedsCommit();
1057 return; 1059 return;
1058 case CommitEarlyOutReason::FINISHED_NO_UPDATES: 1060 case CommitEarlyOutReason::FINISHED_NO_UPDATES:
1059 bool commit_has_no_updates = true; 1061 bool commit_has_no_updates = true;
1060 UpdateStateOnCommit(commit_has_no_updates); 1062 UpdateStateOnCommit(commit_has_no_updates);
1061 return; 1063 return;
1062 } 1064 }
1063 } 1065 }
1064 1066
1065 void SchedulerStateMachine::DidPrepareTiles() { 1067 void SchedulerStateMachine::DidPrepareTiles() {
1066 needs_prepare_tiles_ = false; 1068 needs_prepare_tiles_ = false;
1067 // "Fill" the PrepareTiles funnel. 1069 // "Fill" the PrepareTiles funnel.
1068 prepare_tiles_funnel_++; 1070 prepare_tiles_funnel_++;
1069 } 1071 }
1070 1072
1071 void SchedulerStateMachine::DidLoseOutputSurface() { 1073 void SchedulerStateMachine::DidLoseOutputSurface() {
1072 if (output_surface_state_ == OUTPUT_SURFACE_LOST || 1074 if (output_surface_state_ == OutputSurfaceState::LOST ||
1073 output_surface_state_ == OUTPUT_SURFACE_CREATING) 1075 output_surface_state_ == OutputSurfaceState::CREATING)
1074 return; 1076 return;
1075 output_surface_state_ = OUTPUT_SURFACE_LOST; 1077 output_surface_state_ = OutputSurfaceState::LOST;
1076 needs_redraw_ = false; 1078 needs_redraw_ = false;
1077 } 1079 }
1078 1080
1079 void SchedulerStateMachine::NotifyReadyToActivate() { 1081 void SchedulerStateMachine::NotifyReadyToActivate() {
1080 if (has_pending_tree_) 1082 if (has_pending_tree_)
1081 pending_tree_is_ready_for_activation_ = true; 1083 pending_tree_is_ready_for_activation_ = true;
1082 } 1084 }
1083 1085
1084 void SchedulerStateMachine::DidCreateAndInitializeOutputSurface() { 1086 void SchedulerStateMachine::DidCreateAndInitializeOutputSurface() {
1085 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_CREATING); 1087 DCHECK_EQ(output_surface_state_, OutputSurfaceState::CREATING);
1086 output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT; 1088 output_surface_state_ = OutputSurfaceState::WAITING_FOR_FIRST_COMMIT;
1087 1089
1088 if (did_create_and_initialize_first_output_surface_) { 1090 if (did_create_and_initialize_first_output_surface_) {
1089 // TODO(boliu): See if we can remove this when impl-side painting is always 1091 // TODO(boliu): See if we can remove this when impl-side painting is always
1090 // on. Does anything on the main thread need to update after recreate? 1092 // on. Does anything on the main thread need to update after recreate?
1091 needs_commit_ = true; 1093 needs_commit_ = true;
1092 } 1094 }
1093 did_create_and_initialize_first_output_surface_ = true; 1095 did_create_and_initialize_first_output_surface_ = true;
1094 pending_swaps_ = 0; 1096 pending_swaps_ = 0;
1095 } 1097 }
1096 1098
1097 void SchedulerStateMachine::NotifyBeginMainFrameStarted() { 1099 void SchedulerStateMachine::NotifyBeginMainFrameStarted() {
1098 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); 1100 DCHECK_EQ(commit_state_, CommitState::BEGIN_MAIN_FRAME_SENT);
1099 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED; 1101 commit_state_ = CommitState::BEGIN_MAIN_FRAME_STARTED;
1100 } 1102 }
1101 1103
1102 bool SchedulerStateMachine::HasInitializedOutputSurface() const { 1104 bool SchedulerStateMachine::HasInitializedOutputSurface() const {
1103 switch (output_surface_state_) { 1105 switch (output_surface_state_) {
1104 case OUTPUT_SURFACE_LOST: 1106 case OutputSurfaceState::LOST:
1105 case OUTPUT_SURFACE_CREATING: 1107 case OutputSurfaceState::CREATING:
1106 return false; 1108 return false;
1107 1109
1108 case OUTPUT_SURFACE_ACTIVE: 1110 case OutputSurfaceState::ACTIVE:
1109 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 1111 case OutputSurfaceState::WAITING_FOR_FIRST_COMMIT:
1110 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 1112 case OutputSurfaceState::WAITING_FOR_FIRST_ACTIVATION:
1111 return true; 1113 return true;
1112 } 1114 }
1113 NOTREACHED(); 1115 NOTREACHED();
1114 return false; 1116 return false;
1115 } 1117 }
1116 1118
1117 std::string SchedulerStateMachine::GetStatesForDebugging() const { 1119 std::string SchedulerStateMachine::GetStatesForDebugging() const {
1118 return base::StringPrintf("%c %d %d %d %c %c %c %d %d", 1120 return base::StringPrintf("%c %d %d %d %c %c %c %d %d",
1119 needs_commit_ ? 'T' : 'F', 1121 needs_commit_ ? 'T' : 'F',
1120 static_cast<int>(output_surface_state_), 1122 static_cast<int>(output_surface_state_),
1121 static_cast<int>(begin_impl_frame_state_), 1123 static_cast<int>(begin_impl_frame_state_),
1122 static_cast<int>(commit_state_), 1124 static_cast<int>(commit_state_),
1123 has_pending_tree_ ? 'T' : 'F', 1125 has_pending_tree_ ? 'T' : 'F',
1124 pending_tree_is_ready_for_activation_ ? 'T' : 'F', 1126 pending_tree_is_ready_for_activation_ ? 'T' : 'F',
1125 active_tree_needs_first_draw_ ? 'T' : 'F', 1127 active_tree_needs_first_draw_ ? 'T' : 'F',
1126 max_pending_swaps_, 1128 max_pending_swaps_,
1127 pending_swaps_); 1129 pending_swaps_);
1128 } 1130 }
1129 1131
1130 } // namespace cc 1132 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698