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

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

Issue 817603002: cc: Make scheduling be driven by vsync for android webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not reset active_tree_needs_first_draw_ Created 5 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
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/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
11 #include "base/trace_event/trace_event_argument.h" 11 #include "base/trace_event/trace_event_argument.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_(OUTPUT_SURFACE_LOST),
20 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), 20 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE),
21 commit_state_(COMMIT_STATE_IDLE), 21 commit_state_(COMMIT_STATE_IDLE),
22 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), 22 forced_redraw_state_(FORCED_REDRAW_STATE_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 last_frame_number_invalidate_output_surface_performed_(-1),
29 animate_funnel_(false), 30 animate_funnel_(false),
30 perform_swap_funnel_(false),
31 request_swap_funnel_(false), 31 request_swap_funnel_(false),
32 send_begin_main_frame_funnel_(false), 32 send_begin_main_frame_funnel_(false),
33 invalidate_output_surface_funnel_(false),
33 prepare_tiles_funnel_(0), 34 prepare_tiles_funnel_(0),
34 consecutive_checkerboard_animations_(0), 35 consecutive_checkerboard_animations_(0),
35 max_pending_swaps_(1), 36 max_pending_swaps_(1),
36 pending_swaps_(0), 37 pending_swaps_(0),
37 needs_redraw_(false), 38 needs_redraw_(false),
38 needs_animate_(false), 39 needs_animate_(false),
39 needs_prepare_tiles_(false), 40 needs_prepare_tiles_(false),
40 needs_commit_(false), 41 needs_commit_(false),
41 inside_poll_for_anticipated_draw_triggers_(false),
42 visible_(false), 42 visible_(false),
43 can_start_(false), 43 can_start_(false),
44 can_draw_(false), 44 can_draw_(false),
45 has_pending_tree_(false), 45 has_pending_tree_(false),
46 pending_tree_is_ready_for_activation_(false), 46 pending_tree_is_ready_for_activation_(false),
47 active_tree_needs_first_draw_(false), 47 active_tree_needs_first_draw_(false),
48 did_create_and_initialize_first_output_surface_(false), 48 did_create_and_initialize_first_output_surface_(false),
49 impl_latency_takes_priority_(false), 49 impl_latency_takes_priority_(false),
50 skip_next_begin_main_frame_to_reduce_latency_(false), 50 skip_next_begin_main_frame_to_reduce_latency_(false),
51 skip_begin_main_frame_to_reduce_latency_(false), 51 skip_begin_main_frame_to_reduce_latency_(false),
52 continuous_painting_(false), 52 continuous_painting_(false),
53 children_need_begin_frames_(false), 53 children_need_begin_frames_(false),
54 defer_commits_(false), 54 defer_commits_(false),
55 last_commit_had_no_updates_(false) { 55 last_commit_had_no_updates_(false),
56 did_request_swap_in_last_frame_(false),
57 did_perform_swap_in_last_draw_(false) {
56 } 58 }
57 59
58 const char* SchedulerStateMachine::OutputSurfaceStateToString( 60 const char* SchedulerStateMachine::OutputSurfaceStateToString(
59 OutputSurfaceState state) { 61 OutputSurfaceState state) {
60 switch (state) { 62 switch (state) {
61 case OUTPUT_SURFACE_ACTIVE: 63 case OUTPUT_SURFACE_ACTIVE:
62 return "OUTPUT_SURFACE_ACTIVE"; 64 return "OUTPUT_SURFACE_ACTIVE";
63 case OUTPUT_SURFACE_LOST: 65 case OUTPUT_SURFACE_LOST:
64 return "OUTPUT_SURFACE_LOST"; 66 return "OUTPUT_SURFACE_LOST";
65 case OUTPUT_SURFACE_CREATING: 67 case OUTPUT_SURFACE_CREATING:
(...skipping 16 matching lines...) Expand all
82 return "BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING"; 84 return "BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING";
83 case BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME: 85 case BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME:
84 return "BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME"; 86 return "BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME";
85 case BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE: 87 case BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE:
86 return "BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE"; 88 return "BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE";
87 } 89 }
88 NOTREACHED(); 90 NOTREACHED();
89 return "???"; 91 return "???";
90 } 92 }
91 93
94 const char* SchedulerStateMachine::BeginImplFrameDeadlineModeToString(
95 BeginImplFrameDeadlineMode mode) {
96 switch (mode) {
97 case BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE:
98 return "BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE";
99 case BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE:
100 return "BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE";
101 case BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR:
102 return "BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR";
103 case BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE:
104 return "BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE";
105 }
106 NOTREACHED();
107 return "???";
108 }
109
92 const char* SchedulerStateMachine::CommitStateToString(CommitState state) { 110 const char* SchedulerStateMachine::CommitStateToString(CommitState state) {
93 switch (state) { 111 switch (state) {
94 case COMMIT_STATE_IDLE: 112 case COMMIT_STATE_IDLE:
95 return "COMMIT_STATE_IDLE"; 113 return "COMMIT_STATE_IDLE";
96 case COMMIT_STATE_BEGIN_MAIN_FRAME_SENT: 114 case COMMIT_STATE_BEGIN_MAIN_FRAME_SENT:
97 return "COMMIT_STATE_BEGIN_MAIN_FRAME_SENT"; 115 return "COMMIT_STATE_BEGIN_MAIN_FRAME_SENT";
98 case COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED: 116 case COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED:
99 return "COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED"; 117 return "COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED";
100 case COMMIT_STATE_READY_TO_COMMIT: 118 case COMMIT_STATE_READY_TO_COMMIT:
101 return "COMMIT_STATE_READY_TO_COMMIT"; 119 return "COMMIT_STATE_READY_TO_COMMIT";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: 157 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE:
140 return "ACTION_DRAW_AND_SWAP_IF_POSSIBLE"; 158 return "ACTION_DRAW_AND_SWAP_IF_POSSIBLE";
141 case ACTION_DRAW_AND_SWAP_FORCED: 159 case ACTION_DRAW_AND_SWAP_FORCED:
142 return "ACTION_DRAW_AND_SWAP_FORCED"; 160 return "ACTION_DRAW_AND_SWAP_FORCED";
143 case ACTION_DRAW_AND_SWAP_ABORT: 161 case ACTION_DRAW_AND_SWAP_ABORT:
144 return "ACTION_DRAW_AND_SWAP_ABORT"; 162 return "ACTION_DRAW_AND_SWAP_ABORT";
145 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: 163 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
146 return "ACTION_BEGIN_OUTPUT_SURFACE_CREATION"; 164 return "ACTION_BEGIN_OUTPUT_SURFACE_CREATION";
147 case ACTION_PREPARE_TILES: 165 case ACTION_PREPARE_TILES:
148 return "ACTION_PREPARE_TILES"; 166 return "ACTION_PREPARE_TILES";
167 case ACTION_INVALIDATE_OUTPUT_SURFACE:
168 return "ACTION_INVALIDATE_OUTPUT_SURFACE";
149 } 169 }
150 NOTREACHED(); 170 NOTREACHED();
151 return "???"; 171 return "???";
152 } 172 }
153 173
154 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 174 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
155 SchedulerStateMachine::AsValue() const { 175 SchedulerStateMachine::AsValue() const {
156 scoped_refptr<base::trace_event::TracedValue> state = 176 scoped_refptr<base::trace_event::TracedValue> state =
157 new base::trace_event::TracedValue(); 177 new base::trace_event::TracedValue();
158 AsValueInto(state.get()); 178 AsValueInto(state.get());
(...skipping 18 matching lines...) Expand all
177 state->SetInteger("current_frame_number", current_frame_number_); 197 state->SetInteger("current_frame_number", current_frame_number_);
178 state->SetInteger("last_frame_number_animate_performed", 198 state->SetInteger("last_frame_number_animate_performed",
179 last_frame_number_animate_performed_); 199 last_frame_number_animate_performed_);
180 state->SetInteger("last_frame_number_swap_performed", 200 state->SetInteger("last_frame_number_swap_performed",
181 last_frame_number_swap_performed_); 201 last_frame_number_swap_performed_);
182 state->SetInteger("last_frame_number_swap_requested", 202 state->SetInteger("last_frame_number_swap_requested",
183 last_frame_number_swap_requested_); 203 last_frame_number_swap_requested_);
184 state->SetInteger("last_frame_number_begin_main_frame_sent", 204 state->SetInteger("last_frame_number_begin_main_frame_sent",
185 last_frame_number_begin_main_frame_sent_); 205 last_frame_number_begin_main_frame_sent_);
186 state->SetBoolean("funnel: animate_funnel", animate_funnel_); 206 state->SetBoolean("funnel: animate_funnel", animate_funnel_);
187 state->SetBoolean("funnel: perform_swap_funnel", perform_swap_funnel_);
188 state->SetBoolean("funnel: request_swap_funnel", request_swap_funnel_); 207 state->SetBoolean("funnel: request_swap_funnel", request_swap_funnel_);
189 state->SetBoolean("funnel: send_begin_main_frame_funnel", 208 state->SetBoolean("funnel: send_begin_main_frame_funnel",
190 send_begin_main_frame_funnel_); 209 send_begin_main_frame_funnel_);
191 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_); 210 state->SetInteger("funnel: prepare_tiles_funnel", prepare_tiles_funnel_);
211 state->SetBoolean("funnel: invalidate_output_surface_funnel",
212 invalidate_output_surface_funnel_);
192 state->SetInteger("consecutive_checkerboard_animations", 213 state->SetInteger("consecutive_checkerboard_animations",
193 consecutive_checkerboard_animations_); 214 consecutive_checkerboard_animations_);
194 state->SetInteger("max_pending_swaps_", max_pending_swaps_); 215 state->SetInteger("max_pending_swaps_", max_pending_swaps_);
195 state->SetInteger("pending_swaps_", pending_swaps_); 216 state->SetInteger("pending_swaps_", pending_swaps_);
196 state->SetBoolean("needs_redraw", needs_redraw_); 217 state->SetBoolean("needs_redraw", needs_redraw_);
197 state->SetBoolean("needs_animate_", needs_animate_); 218 state->SetBoolean("needs_animate_", needs_animate_);
198 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_); 219 state->SetBoolean("needs_prepare_tiles", needs_prepare_tiles_);
199 state->SetBoolean("needs_commit", needs_commit_); 220 state->SetBoolean("needs_commit", needs_commit_);
200 state->SetBoolean("visible", visible_); 221 state->SetBoolean("visible", visible_);
201 state->SetBoolean("can_start", can_start_); 222 state->SetBoolean("can_start", can_start_);
202 state->SetBoolean("can_draw", can_draw_); 223 state->SetBoolean("can_draw", can_draw_);
203 state->SetBoolean("has_pending_tree", has_pending_tree_); 224 state->SetBoolean("has_pending_tree", has_pending_tree_);
204 state->SetBoolean("pending_tree_is_ready_for_activation", 225 state->SetBoolean("pending_tree_is_ready_for_activation",
205 pending_tree_is_ready_for_activation_); 226 pending_tree_is_ready_for_activation_);
206 state->SetBoolean("active_tree_needs_first_draw", 227 state->SetBoolean("active_tree_needs_first_draw",
207 active_tree_needs_first_draw_); 228 active_tree_needs_first_draw_);
208 state->SetBoolean("did_create_and_initialize_first_output_surface", 229 state->SetBoolean("did_create_and_initialize_first_output_surface",
209 did_create_and_initialize_first_output_surface_); 230 did_create_and_initialize_first_output_surface_);
210 state->SetBoolean("impl_latency_takes_priority", 231 state->SetBoolean("impl_latency_takes_priority",
211 impl_latency_takes_priority_); 232 impl_latency_takes_priority_);
212 state->SetBoolean("main_thread_is_in_high_latency_mode", 233 state->SetBoolean("main_thread_is_in_high_latency_mode",
213 MainThreadIsInHighLatencyMode()); 234 MainThreadIsInHighLatencyMode());
214 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", 235 state->SetBoolean("skip_begin_main_frame_to_reduce_latency",
215 skip_begin_main_frame_to_reduce_latency_); 236 skip_begin_main_frame_to_reduce_latency_);
216 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", 237 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency",
217 skip_next_begin_main_frame_to_reduce_latency_); 238 skip_next_begin_main_frame_to_reduce_latency_);
218 state->SetBoolean("continuous_painting", continuous_painting_); 239 state->SetBoolean("continuous_painting", continuous_painting_);
219 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); 240 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_);
220 state->SetBoolean("defer_commits", defer_commits_); 241 state->SetBoolean("defer_commits", defer_commits_);
242 state->SetBoolean("last_commit_had_no_updates", last_commit_had_no_updates_);
243 state->SetBoolean("did_request_swap_in_last_frame",
244 did_request_swap_in_last_frame_);
245 state->SetBoolean("did_perform_swap_in_last_draw",
246 did_perform_swap_in_last_draw_);
221 state->EndDictionary(); 247 state->EndDictionary();
222 } 248 }
223 249
224 void SchedulerStateMachine::AdvanceCurrentFrameNumber() {
225 current_frame_number_++;
226
227 animate_funnel_ = false;
228 perform_swap_funnel_ = false;
229 request_swap_funnel_ = false;
230 send_begin_main_frame_funnel_ = false;
231
232 // "Drain" the PrepareTiles funnel.
233 if (prepare_tiles_funnel_ > 0)
234 prepare_tiles_funnel_--;
235
236 skip_begin_main_frame_to_reduce_latency_ =
237 skip_next_begin_main_frame_to_reduce_latency_;
238 skip_next_begin_main_frame_to_reduce_latency_ = false;
239 }
240
241 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { 250 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const {
242 // These are all the cases where we normally cannot or do not want to draw 251 // These are all the cases where we normally cannot or do not want to draw
243 // but, if needs_redraw_ is true and we do not draw to make forward progress, 252 // but, if needs_redraw_ is true and we do not draw to make forward progress,
244 // we might deadlock with the main thread. 253 // we might deadlock with the main thread.
245 // This should be a superset of PendingActivationsShouldBeForced() since 254 // This should be a superset of PendingActivationsShouldBeForced() since
246 // activation of the pending tree is blocked by drawing of the active tree and 255 // activation of the pending tree is blocked by drawing of the active tree and
247 // the main thread might be blocked on activation of the most recent commit. 256 // the main thread might be blocked on activation of the most recent commit.
248 if (PendingActivationsShouldBeForced()) 257 if (PendingActivationsShouldBeForced())
249 return true; 258 return true;
250 259
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 return true; 429 return true;
421 430
422 // We shouldn't normally accept commits if there isn't an OutputSurface. 431 // We shouldn't normally accept commits if there isn't an OutputSurface.
423 if (!HasInitializedOutputSurface()) 432 if (!HasInitializedOutputSurface())
424 return false; 433 return false;
425 434
426 // SwapAck throttle the BeginMainFrames unless we just swapped. 435 // SwapAck throttle the BeginMainFrames unless we just swapped.
427 // TODO(brianderson): Remove this restriction to improve throughput. 436 // TODO(brianderson): Remove this restriction to improve throughput.
428 bool just_swapped_in_deadline = 437 bool just_swapped_in_deadline =
429 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && 438 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE &&
430 perform_swap_funnel_; 439 did_perform_swap_in_last_draw_;
431 if (pending_swaps_ >= max_pending_swaps_ && !just_swapped_in_deadline) 440 if (pending_swaps_ >= max_pending_swaps_ && !just_swapped_in_deadline)
432 return false; 441 return false;
433 442
434 if (skip_begin_main_frame_to_reduce_latency_) 443 if (skip_begin_main_frame_to_reduce_latency_)
435 return false; 444 return false;
436 445
437 return true; 446 return true;
438 } 447 }
439 448
440 bool SchedulerStateMachine::ShouldCommit() const { 449 bool SchedulerStateMachine::ShouldCommit() const {
(...skipping 14 matching lines...) Expand all
455 } 464 }
456 465
457 bool SchedulerStateMachine::ShouldPrepareTiles() const { 466 bool SchedulerStateMachine::ShouldPrepareTiles() const {
458 // PrepareTiles only really needs to be called immediately after commit 467 // PrepareTiles only really needs to be called immediately after commit
459 // and then periodically after that. Use a funnel to make sure we average 468 // and then periodically after that. Use a funnel to make sure we average
460 // one PrepareTiles per BeginImplFrame in the long run. 469 // one PrepareTiles per BeginImplFrame in the long run.
461 if (prepare_tiles_funnel_ > 0) 470 if (prepare_tiles_funnel_ > 0)
462 return false; 471 return false;
463 472
464 // Limiting to once per-frame is not enough, since we only want to 473 // Limiting to once per-frame is not enough, since we only want to
465 // prepare tiles _after_ draws. Polling for draw triggers and 474 // prepare tiles _after_ draws.
466 // begin-frame are mutually exclusive, so we limit to these two cases. 475 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
467 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE &&
468 !inside_poll_for_anticipated_draw_triggers_)
469 return false; 476 return false;
477
470 return needs_prepare_tiles_; 478 return needs_prepare_tiles_;
471 } 479 }
472 480
481 bool SchedulerStateMachine::ShouldInvalidateOutputSurface() const {
482 // Do not invalidate too many times in a frame.
483 if (invalidate_output_surface_funnel_)
484 return false;
485
486 // Only the synchronous compositor requires invalidations.
487 if (!settings_.using_synchronous_renderer_compositor)
488 return false;
489
490 // Invalidations are only performed inside a BeginFrame.
491 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING)
492 return false;
493
494 return needs_redraw_ || needs_prepare_tiles_;
brianderson 2015/04/01 00:23:38 Can you add a TODO explaining what would need to h
sunnyps 2015/04/01 19:53:01 Done.
495 }
496
473 SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { 497 SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
474 if (ShouldActivatePendingTree()) 498 if (ShouldActivatePendingTree())
475 return ACTION_ACTIVATE_SYNC_TREE; 499 return ACTION_ACTIVATE_SYNC_TREE;
476 if (ShouldCommit()) 500 if (ShouldCommit())
477 return ACTION_COMMIT; 501 return ACTION_COMMIT;
478 if (ShouldAnimate()) 502 if (ShouldAnimate())
479 return ACTION_ANIMATE; 503 return ACTION_ANIMATE;
480 if (ShouldDraw()) { 504 if (ShouldDraw()) {
481 if (PendingDrawsShouldBeAborted()) 505 if (PendingDrawsShouldBeAborted())
482 return ACTION_DRAW_AND_SWAP_ABORT; 506 return ACTION_DRAW_AND_SWAP_ABORT;
483 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 507 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
484 return ACTION_DRAW_AND_SWAP_FORCED; 508 return ACTION_DRAW_AND_SWAP_FORCED;
485 else 509 else
486 return ACTION_DRAW_AND_SWAP_IF_POSSIBLE; 510 return ACTION_DRAW_AND_SWAP_IF_POSSIBLE;
487 } 511 }
488 if (ShouldPrepareTiles()) 512 if (ShouldPrepareTiles())
489 return ACTION_PREPARE_TILES; 513 return ACTION_PREPARE_TILES;
490 if (ShouldSendBeginMainFrame()) 514 if (ShouldSendBeginMainFrame())
491 return ACTION_SEND_BEGIN_MAIN_FRAME; 515 return ACTION_SEND_BEGIN_MAIN_FRAME;
516 if (ShouldInvalidateOutputSurface())
517 return ACTION_INVALIDATE_OUTPUT_SURFACE;
492 if (ShouldBeginOutputSurfaceCreation()) 518 if (ShouldBeginOutputSurfaceCreation())
493 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION; 519 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION;
494 return ACTION_NONE; 520 return ACTION_NONE;
495 } 521 }
496 522
497 void SchedulerStateMachine::UpdateState(Action action) { 523 void SchedulerStateMachine::UpdateState(Action action) {
498 switch (action) { 524 switch (action) {
499 case ACTION_NONE: 525 case ACTION_NONE:
500 return; 526 return;
501 527
502 case ACTION_ACTIVATE_SYNC_TREE: 528 case ACTION_ACTIVATE_SYNC_TREE:
503 UpdateStateOnActivation(); 529 UpdateStateOnActivation();
504 return; 530 return;
505 531
506 case ACTION_ANIMATE: 532 case ACTION_ANIMATE:
507 DCHECK(!animate_funnel_); 533 UpdateStateOnAnimate();
508 last_frame_number_animate_performed_ = current_frame_number_;
509 animate_funnel_ = true;
510 needs_animate_ = false;
511 // TODO(skyostil): Instead of assuming this, require the client to tell
512 // us.
513 SetNeedsRedraw();
514 return; 534 return;
515 535
516 case ACTION_SEND_BEGIN_MAIN_FRAME: 536 case ACTION_SEND_BEGIN_MAIN_FRAME:
517 DCHECK(!has_pending_tree_ || 537 UpdateStateOnSendBeginMainFrame();
518 settings_.main_frame_before_activation_enabled);
519 DCHECK(visible_);
520 DCHECK(!send_begin_main_frame_funnel_);
521 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT;
522 needs_commit_ = false;
523 send_begin_main_frame_funnel_ = true;
524 last_frame_number_begin_main_frame_sent_ =
525 current_frame_number_;
526 return; 538 return;
527 539
528 case ACTION_COMMIT: { 540 case ACTION_COMMIT: {
529 bool commit_has_no_updates = false; 541 bool commit_has_no_updates = false;
530 UpdateStateOnCommit(commit_has_no_updates); 542 UpdateStateOnCommit(commit_has_no_updates);
531 return; 543 return;
532 } 544 }
533 545
534 case ACTION_DRAW_AND_SWAP_FORCED: 546 case ACTION_DRAW_AND_SWAP_FORCED:
535 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { 547 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: {
536 bool did_request_swap = true; 548 bool did_request_swap = true;
537 UpdateStateOnDraw(did_request_swap); 549 UpdateStateOnDraw(did_request_swap);
538 return; 550 return;
539 } 551 }
540 552
541 case ACTION_DRAW_AND_SWAP_ABORT: { 553 case ACTION_DRAW_AND_SWAP_ABORT: {
542 bool did_request_swap = false; 554 bool did_request_swap = false;
543 UpdateStateOnDraw(did_request_swap); 555 UpdateStateOnDraw(did_request_swap);
544 return; 556 return;
545 } 557 }
546 558
547 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: 559 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
548 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST); 560 UpdateStateOnBeginOutputSurfaceCreation();
549 output_surface_state_ = OUTPUT_SURFACE_CREATING;
550
551 // The following DCHECKs make sure we are in the proper quiescent state.
552 // The pipeline should be flushed entirely before we start output
553 // surface creation to avoid complicated corner cases.
554 DCHECK_EQ(commit_state_, COMMIT_STATE_IDLE);
555 DCHECK(!has_pending_tree_);
556 DCHECK(!active_tree_needs_first_draw_);
557 return; 561 return;
558 562
559 case ACTION_PREPARE_TILES: 563 case ACTION_PREPARE_TILES:
560 UpdateStateOnPrepareTiles(); 564 UpdateStateOnPrepareTiles();
561 return; 565 return;
566
567 case ACTION_INVALIDATE_OUTPUT_SURFACE:
568 UpdateStateOnInvalidateOutputSurface();
569 return;
562 } 570 }
563 } 571 }
564 572
573 void SchedulerStateMachine::UpdateStateOnAnimate() {
574 DCHECK(!animate_funnel_);
575 last_frame_number_animate_performed_ = current_frame_number_;
576 animate_funnel_ = true;
577 needs_animate_ = false;
578 // TODO(skyostil): Instead of assuming this, require the client to tell us.
579 SetNeedsRedraw();
580 }
581
582 void SchedulerStateMachine::UpdateStateOnSendBeginMainFrame() {
583 DCHECK(!has_pending_tree_ || settings_.main_frame_before_activation_enabled);
584 DCHECK(visible_);
585 DCHECK(!send_begin_main_frame_funnel_);
586 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT;
587 needs_commit_ = false;
588 send_begin_main_frame_funnel_ = true;
589 last_frame_number_begin_main_frame_sent_ = current_frame_number_;
590 }
591
565 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_has_no_updates) { 592 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_has_no_updates) {
566 commit_count_++; 593 commit_count_++;
567 594
595 // Animate after commit even if we've already animated.
568 if (!commit_has_no_updates) 596 if (!commit_has_no_updates)
569 animate_funnel_ = false; 597 animate_funnel_ = false;
570 598
571 if (commit_has_no_updates || settings_.main_frame_before_activation_enabled) { 599 if (commit_has_no_updates || settings_.main_frame_before_activation_enabled) {
572 commit_state_ = COMMIT_STATE_IDLE; 600 commit_state_ = COMMIT_STATE_IDLE;
573 } else if (settings_.impl_side_painting) { 601 } else if (settings_.impl_side_painting) {
574 commit_state_ = COMMIT_STATE_WAITING_FOR_ACTIVATION; 602 commit_state_ = COMMIT_STATE_WAITING_FOR_ACTIVATION;
575 } else { 603 } else {
576 commit_state_ = settings_.main_thread_should_always_be_low_latency 604 commit_state_ = settings_.main_thread_should_always_be_low_latency
577 ? COMMIT_STATE_WAITING_FOR_DRAW 605 ? COMMIT_STATE_WAITING_FOR_DRAW
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 670
643 if (commit_state_ == COMMIT_STATE_WAITING_FOR_DRAW) 671 if (commit_state_ == COMMIT_STATE_WAITING_FOR_DRAW)
644 commit_state_ = COMMIT_STATE_IDLE; 672 commit_state_ = COMMIT_STATE_IDLE;
645 673
646 needs_redraw_ = false; 674 needs_redraw_ = false;
647 active_tree_needs_first_draw_ = false; 675 active_tree_needs_first_draw_ = false;
648 676
649 if (did_request_swap) { 677 if (did_request_swap) {
650 DCHECK(!request_swap_funnel_); 678 DCHECK(!request_swap_funnel_);
651 request_swap_funnel_ = true; 679 request_swap_funnel_ = true;
680 did_request_swap_in_last_frame_ = true;
652 last_frame_number_swap_requested_ = current_frame_number_; 681 last_frame_number_swap_requested_ = current_frame_number_;
653 } 682 }
654 } 683 }
655 684
656 void SchedulerStateMachine::UpdateStateOnPrepareTiles() { 685 void SchedulerStateMachine::UpdateStateOnPrepareTiles() {
657 needs_prepare_tiles_ = false; 686 needs_prepare_tiles_ = false;
658 } 687 }
659 688
689 void SchedulerStateMachine::UpdateStateOnBeginOutputSurfaceCreation() {
690 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST);
691 output_surface_state_ = OUTPUT_SURFACE_CREATING;
692
693 // The following DCHECKs make sure we are in the proper quiescent state.
694 // The pipeline should be flushed entirely before we start output
695 // surface creation to avoid complicated corner cases.
696 DCHECK_EQ(commit_state_, COMMIT_STATE_IDLE);
697 DCHECK(!has_pending_tree_);
698 DCHECK(!active_tree_needs_first_draw_);
699 }
700
701 void SchedulerStateMachine::UpdateStateOnInvalidateOutputSurface() {
702 DCHECK(!invalidate_output_surface_funnel_);
703 invalidate_output_surface_funnel_ = true;
704 last_frame_number_invalidate_output_surface_performed_ =
705 current_frame_number_;
706 }
707
660 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { 708 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() {
661 TRACE_EVENT_INSTANT0("cc", 709 TRACE_EVENT_INSTANT0("cc",
662 "Scheduler: SkipNextBeginMainFrameToReduceLatency", 710 "Scheduler: SkipNextBeginMainFrameToReduceLatency",
663 TRACE_EVENT_SCOPE_THREAD); 711 TRACE_EVENT_SCOPE_THREAD);
664 skip_next_begin_main_frame_to_reduce_latency_ = true; 712 skip_next_begin_main_frame_to_reduce_latency_ = true;
665 } 713 }
666 714
667 bool SchedulerStateMachine::BeginFrameNeededForChildren() const { 715 bool SchedulerStateMachine::BeginFrameNeededForChildren() const {
668 if (HasInitializedOutputSurface()) 716 return children_need_begin_frames_;
669 return children_need_begin_frames_;
670
671 return false;
672 } 717 }
673 718
674 bool SchedulerStateMachine::BeginFrameNeeded() const { 719 bool SchedulerStateMachine::BeginFrameNeeded() const {
675 // We can't handle BeginFrames when output surface isn't initialized. 720 // We can't handle BeginFrames when output surface isn't initialized.
676 // TODO(brianderson): Support output surface creation inside a BeginFrame. 721 // TODO(brianderson): Support output surface creation inside a BeginFrame.
677 if (!HasInitializedOutputSurface()) 722 if (!HasInitializedOutputSurface())
678 return false; 723 return false;
679 724 return (BeginFrameNeededToAnimateOrDraw() || BeginFrameNeededForChildren() ||
680 if (SupportsProactiveBeginFrame()) { 725 ProactiveBeginFrameWanted());
681 return (BeginFrameNeededToAnimateOrDraw() ||
682 BeginFrameNeededForChildren() ||
683 ProactiveBeginFrameWanted());
684 }
685
686 // Proactive BeginFrames are bad for the synchronous compositor because we
687 // have to draw when we get the BeginFrame and could end up drawing many
688 // duplicate frames if our new frame isn't ready in time.
689 // To poll for state with the synchronous compositor without having to draw,
690 // we rely on ShouldPollForAnticipatedDrawTriggers instead.
691 // Synchronous compositor doesn't have a browser.
692 DCHECK(!children_need_begin_frames_);
693 return BeginFrameNeededToAnimateOrDraw();
694 }
695
696 bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const {
697 // ShouldPollForAnticipatedDrawTriggers is what we use in place of
698 // ProactiveBeginFrameWanted when we are using the synchronous
699 // compositor.
700 if (!SupportsProactiveBeginFrame()) {
701 return !BeginFrameNeededToAnimateOrDraw() && ProactiveBeginFrameWanted();
702 }
703
704 // Non synchronous compositors should rely on
705 // ProactiveBeginFrameWanted to poll for state instead.
706 return false;
707 }
708
709 // Note: If SupportsProactiveBeginFrame is false, the scheduler should poll
710 // for changes in it's draw state so it can request a BeginFrame when it's
711 // actually ready.
712 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const {
713 // It is undesirable to proactively request BeginFrames if we are
714 // using a synchronous compositor because we *must* draw for every
715 // BeginFrame, which could cause duplicate draws.
716 return !settings_.using_synchronous_renderer_compositor;
717 } 726 }
718 727
719 void SchedulerStateMachine::SetChildrenNeedBeginFrames( 728 void SchedulerStateMachine::SetChildrenNeedBeginFrames(
720 bool children_need_begin_frames) { 729 bool children_need_begin_frames) {
721 children_need_begin_frames_ = children_need_begin_frames; 730 children_need_begin_frames_ = children_need_begin_frames;
722 } 731 }
723 732
724 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) { 733 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) {
725 defer_commits_ = defer_commits; 734 defer_commits_ = defer_commits;
726 } 735 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 // Changing priorities may allow us to activate (given the new priorities), 767 // Changing priorities may allow us to activate (given the new priorities),
759 // which may result in a new frame. 768 // which may result in a new frame.
760 if (needs_prepare_tiles_) 769 if (needs_prepare_tiles_)
761 return true; 770 return true;
762 771
763 // If we just sent a swap request, it's likely that we are going to produce 772 // If we just sent a swap request, it's likely that we are going to produce
764 // another frame soon. This helps avoid negative glitches in our 773 // another frame soon. This helps avoid negative glitches in our
765 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame 774 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame
766 // provider and get sampled at an inopportune time, delaying the next 775 // provider and get sampled at an inopportune time, delaying the next
767 // BeginImplFrame. 776 // BeginImplFrame.
768 if (request_swap_funnel_) 777 if (did_request_swap_in_last_frame_)
769 return true; 778 return true;
770 779
771 // If the last commit was aborted because of early out (no updates), we should 780 // If the last commit was aborted because of early out (no updates), we should
772 // still want a begin frame in case there is a commit coming again. 781 // still want a begin frame in case there is a commit coming again.
773 if (last_commit_had_no_updates_) 782 if (last_commit_had_no_updates_)
774 return true; 783 return true;
775 784
776 return false; 785 return false;
777 } 786 }
778 787
779 void SchedulerStateMachine::OnBeginImplFrame() { 788 void SchedulerStateMachine::OnBeginImplFrame() {
780 AdvanceCurrentFrameNumber();
781 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_IDLE)
782 << AsValue()->ToString();
783 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; 789 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING;
790 current_frame_number_++;
791
784 last_commit_had_no_updates_ = false; 792 last_commit_had_no_updates_ = false;
793 did_request_swap_in_last_frame_ = false;
794
795 // Clear funnels for any actions we perform during the frame.
796 animate_funnel_ = false;
797 send_begin_main_frame_funnel_ = false;
798 invalidate_output_surface_funnel_ = false;
799
800 // "Drain" the PrepareTiles funnel.
801 if (prepare_tiles_funnel_ > 0)
802 prepare_tiles_funnel_--;
803
804 skip_begin_main_frame_to_reduce_latency_ =
805 skip_next_begin_main_frame_to_reduce_latency_;
806 skip_next_begin_main_frame_to_reduce_latency_ = false;
785 } 807 }
786 808
787 void SchedulerStateMachine::OnBeginImplFrameDeadlinePending() { 809 void SchedulerStateMachine::OnBeginImplFrameDeadlinePending() {
788 DCHECK_EQ(begin_impl_frame_state_,
789 BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING)
790 << AsValue()->ToString();
791 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME; 810 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME;
792 } 811 }
793 812
794 void SchedulerStateMachine::OnBeginImplFrameDeadline() { 813 void SchedulerStateMachine::OnBeginImplFrameDeadline() {
795 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)
796 << AsValue()->ToString();
797 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE; 814 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE;
815
816 did_perform_swap_in_last_draw_ = false;
817
818 // Clear funnels for any actions we perform during the deadline.
819 request_swap_funnel_ = false;
798 } 820 }
799 821
800 void SchedulerStateMachine::OnBeginImplFrameIdle() { 822 void SchedulerStateMachine::OnBeginImplFrameIdle() {
801 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
802 << AsValue()->ToString();
803 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; 823 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE;
804 } 824 }
805 825
806 SchedulerStateMachine::BeginImplFrameDeadlineMode 826 SchedulerStateMachine::BeginImplFrameDeadlineMode
807 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const { 827 SchedulerStateMachine::CurrentBeginImplFrameDeadlineMode() const {
808 if (ShouldTriggerBeginImplFrameDeadlineImmediately()) { 828 if (settings_.using_synchronous_renderer_compositor) {
829 // No deadline for synchronous compositor.
830 return BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE;
831 } else if (ShouldTriggerBeginImplFrameDeadlineImmediately()) {
809 return BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE; 832 return BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE;
810 } else if (needs_redraw_ && pending_swaps_ < max_pending_swaps_) { 833 } else if (needs_redraw_ && pending_swaps_ < max_pending_swaps_) {
811 // We have an animation or fast input path on the impl thread that wants 834 // We have an animation or fast input path on the impl thread that wants
812 // to draw, so don't wait too long for a new active tree. 835 // to draw, so don't wait too long for a new active tree.
813 // If we are swap throttled we should wait until we are unblocked. 836 // If we are swap throttled we should wait until we are unblocked.
814 return BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR; 837 return BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR;
815 } else { 838 } else {
816 // The impl thread doesn't have anything it wants to draw and we are just 839 // The impl thread doesn't have anything it wants to draw and we are just
817 // waiting for a new active tree or we are swap throttled. In short we are 840 // waiting for a new active tree or we are swap throttled. In short we are
818 // blocked. 841 // blocked.
819 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE; 842 return BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE;
820 } 843 }
821 } 844 }
822 845
823 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately() 846 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineImmediately()
824 const { 847 const {
825 // TODO(brianderson): This should take into account multiple commit sources. 848 // TODO(brianderson): This should take into account multiple commit sources.
826
827 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) 849 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)
828 return false; 850 return false;
829 851
830 // If we've lost the output surface, end the current BeginImplFrame ASAP 852 // If we've lost the output surface, end the current BeginImplFrame ASAP
831 // so we can start creating the next output surface. 853 // so we can start creating the next output surface.
832 if (output_surface_state_ == OUTPUT_SURFACE_LOST) 854 if (output_surface_state_ == OUTPUT_SURFACE_LOST)
833 return true; 855 return true;
834 856
835 // SwapAck throttle the deadline since we wont draw and swap anyway. 857 // SwapAck throttle the deadline since we wont draw and swap anyway.
836 if (pending_swaps_ >= max_pending_swaps_) 858 if (pending_swaps_ >= max_pending_swaps_)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // or 904 // or
883 // we're currently drawing the active tree and the pending tree will thus 905 // we're currently drawing the active tree and the pending tree will thus
884 // only be drawn in the next frame. 906 // only be drawn in the next frame.
885 if (has_pending_tree_) 907 if (has_pending_tree_)
886 return true; 908 return true;
887 909
888 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) { 910 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) {
889 // Even if there's a new active tree to draw at the deadline or we've just 911 // Even if there's a new active tree to draw at the deadline or we've just
890 // swapped it, it may have been triggered by a previous BeginImplFrame, in 912 // swapped it, it may have been triggered by a previous BeginImplFrame, in
891 // which case the main thread is in a high latency mode. 913 // which case the main thread is in a high latency mode.
892 return (active_tree_needs_first_draw_ || perform_swap_funnel_) && 914 return (active_tree_needs_first_draw_ || did_perform_swap_in_last_draw_) &&
893 !send_begin_main_frame_funnel_; 915 !send_begin_main_frame_funnel_;
894 } 916 }
895 917
896 // If the active tree needs its first draw in any other state, we know the 918 // If the active tree needs its first draw in any other state, we know the
897 // main thread is in a high latency mode. 919 // main thread is in a high latency mode.
898 return active_tree_needs_first_draw_; 920 return active_tree_needs_first_draw_;
899 } 921 }
900 922
901 void SchedulerStateMachine::DidEnterPollForAnticipatedDrawTriggers() {
902 AdvanceCurrentFrameNumber();
903 inside_poll_for_anticipated_draw_triggers_ = true;
904 }
905
906 void SchedulerStateMachine::DidLeavePollForAnticipatedDrawTriggers() {
907 inside_poll_for_anticipated_draw_triggers_ = false;
908 }
909
910 void SchedulerStateMachine::SetVisible(bool visible) { visible_ = visible; } 923 void SchedulerStateMachine::SetVisible(bool visible) { visible_ = visible; }
911 924
912 void SchedulerStateMachine::SetCanDraw(bool can_draw) { can_draw_ = can_draw; } 925 void SchedulerStateMachine::SetCanDraw(bool can_draw) { can_draw_ = can_draw; }
913 926
914 void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; } 927 void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; }
915 928
916 void SchedulerStateMachine::SetNeedsAnimate() { 929 void SchedulerStateMachine::SetNeedsAnimate() {
917 needs_animate_ = true; 930 needs_animate_ = true;
918 } 931 }
919 932
920 void SchedulerStateMachine::SetNeedsPrepareTiles() { 933 void SchedulerStateMachine::SetNeedsPrepareTiles() {
921 if (!needs_prepare_tiles_) { 934 if (!needs_prepare_tiles_) {
922 TRACE_EVENT0("cc", "SchedulerStateMachine::SetNeedsPrepareTiles"); 935 TRACE_EVENT0("cc", "SchedulerStateMachine::SetNeedsPrepareTiles");
923 needs_prepare_tiles_ = true; 936 needs_prepare_tiles_ = true;
924 } 937 }
925 } 938 }
926 939
927 void SchedulerStateMachine::SetMaxSwapsPending(int max) { 940 void SchedulerStateMachine::SetMaxSwapsPending(int max) {
928 max_pending_swaps_ = max; 941 max_pending_swaps_ = max;
929 } 942 }
930 943
931 void SchedulerStateMachine::DidSwapBuffers() { 944 void SchedulerStateMachine::DidSwapBuffers() {
932 pending_swaps_++; 945 pending_swaps_++;
933 DCHECK_LE(pending_swaps_, max_pending_swaps_); 946 DCHECK_LE(pending_swaps_, max_pending_swaps_);
934 DCHECK(!perform_swap_funnel_);
935 947
936 perform_swap_funnel_ = true; 948 did_perform_swap_in_last_draw_ = true;
937 last_frame_number_swap_performed_ = current_frame_number_; 949 last_frame_number_swap_performed_ = current_frame_number_;
938 } 950 }
939 951
940 void SchedulerStateMachine::DidSwapBuffersComplete() { 952 void SchedulerStateMachine::DidSwapBuffersComplete() {
941 DCHECK_GT(pending_swaps_, 0); 953 DCHECK_GT(pending_swaps_, 0);
942 pending_swaps_--; 954 pending_swaps_--;
943 } 955 }
944 956
945 void SchedulerStateMachine::SetImplLatencyTakesPriority( 957 void SchedulerStateMachine::SetImplLatencyTakesPriority(
946 bool impl_latency_takes_priority) { 958 bool impl_latency_takes_priority) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 static_cast<int>(begin_impl_frame_state_), 1092 static_cast<int>(begin_impl_frame_state_),
1081 static_cast<int>(commit_state_), 1093 static_cast<int>(commit_state_),
1082 has_pending_tree_ ? 'T' : 'F', 1094 has_pending_tree_ ? 'T' : 'F',
1083 pending_tree_is_ready_for_activation_ ? 'T' : 'F', 1095 pending_tree_is_ready_for_activation_ ? 'T' : 'F',
1084 active_tree_needs_first_draw_ ? 'T' : 'F', 1096 active_tree_needs_first_draw_ ? 'T' : 'F',
1085 max_pending_swaps_, 1097 max_pending_swaps_,
1086 pending_swaps_); 1098 pending_swaps_);
1087 } 1099 }
1088 1100
1089 } // namespace cc 1101 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698