Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/scheduler/scheduler_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/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "ui/gfx/frame_time.h" | 12 #include "ui/gfx/frame_time.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) | 16 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) |
| 17 : settings_(settings), | 17 : settings_(settings), |
| 18 output_surface_state_(OUTPUT_SURFACE_LOST), | 18 output_surface_state_(OUTPUT_SURFACE_LOST), |
| 19 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), | 19 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), |
| 20 commit_state_(COMMIT_STATE_IDLE), | 20 commit_state_(COMMIT_STATE_IDLE), |
| 21 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), | 21 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), |
| 22 readback_state_(READBACK_STATE_IDLE), | |
| 23 commit_count_(0), | 22 commit_count_(0), |
| 24 current_frame_number_(0), | 23 current_frame_number_(0), |
| 25 last_frame_number_animate_performed_(-1), | 24 last_frame_number_animate_performed_(-1), |
| 26 last_frame_number_swap_performed_(-1), | 25 last_frame_number_swap_performed_(-1), |
| 27 last_frame_number_swap_requested_(-1), | 26 last_frame_number_swap_requested_(-1), |
| 28 last_frame_number_begin_main_frame_sent_(-1), | 27 last_frame_number_begin_main_frame_sent_(-1), |
| 29 last_frame_number_update_visible_tiles_was_called_(-1), | 28 last_frame_number_update_visible_tiles_was_called_(-1), |
| 30 manage_tiles_funnel_(0), | 29 manage_tiles_funnel_(0), |
| 31 consecutive_checkerboard_animations_(0), | 30 consecutive_checkerboard_animations_(0), |
| 32 max_pending_swaps_(1), | 31 max_pending_swaps_(1), |
| 33 pending_swaps_(0), | 32 pending_swaps_(0), |
| 34 needs_redraw_(false), | 33 needs_redraw_(false), |
| 35 needs_animate_(false), | 34 needs_animate_(false), |
| 36 needs_manage_tiles_(false), | 35 needs_manage_tiles_(false), |
| 37 swap_used_incomplete_tile_(false), | 36 swap_used_incomplete_tile_(false), |
| 38 needs_commit_(false), | 37 needs_commit_(false), |
| 39 inside_poll_for_anticipated_draw_triggers_(false), | 38 inside_poll_for_anticipated_draw_triggers_(false), |
| 40 visible_(false), | 39 visible_(false), |
| 41 can_start_(false), | 40 can_start_(false), |
| 42 can_draw_(false), | 41 can_draw_(false), |
| 43 has_pending_tree_(false), | 42 has_pending_tree_(false), |
| 44 pending_tree_is_ready_for_activation_(false), | 43 pending_tree_is_ready_for_activation_(false), |
| 45 active_tree_needs_first_draw_(false), | 44 active_tree_needs_first_draw_(false), |
| 46 did_create_and_initialize_first_output_surface_(false), | 45 did_create_and_initialize_first_output_surface_(false), |
| 47 smoothness_takes_priority_(false), | 46 smoothness_takes_priority_(false), |
| 48 skip_next_begin_main_frame_to_reduce_latency_(false), | 47 skip_next_begin_main_frame_to_reduce_latency_(false), |
| 49 skip_begin_main_frame_to_reduce_latency_(false), | 48 skip_begin_main_frame_to_reduce_latency_(false), |
| 50 continuous_painting_(false), | 49 continuous_painting_(false) { |
| 51 needs_back_to_back_readback_(false) { | |
| 52 } | 50 } |
| 53 | 51 |
| 54 const char* SchedulerStateMachine::OutputSurfaceStateToString( | 52 const char* SchedulerStateMachine::OutputSurfaceStateToString( |
| 55 OutputSurfaceState state) { | 53 OutputSurfaceState state) { |
| 56 switch (state) { | 54 switch (state) { |
| 57 case OUTPUT_SURFACE_ACTIVE: | 55 case OUTPUT_SURFACE_ACTIVE: |
| 58 return "OUTPUT_SURFACE_ACTIVE"; | 56 return "OUTPUT_SURFACE_ACTIVE"; |
| 59 case OUTPUT_SURFACE_LOST: | 57 case OUTPUT_SURFACE_LOST: |
| 60 return "OUTPUT_SURFACE_LOST"; | 58 return "OUTPUT_SURFACE_LOST"; |
| 61 case OUTPUT_SURFACE_CREATING: | 59 case OUTPUT_SURFACE_CREATING: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 return "COMMIT_STATE_READY_TO_COMMIT"; | 95 return "COMMIT_STATE_READY_TO_COMMIT"; |
| 98 case COMMIT_STATE_WAITING_FOR_ACTIVATION: | 96 case COMMIT_STATE_WAITING_FOR_ACTIVATION: |
| 99 return "COMMIT_STATE_WAITING_FOR_ACTIVATION"; | 97 return "COMMIT_STATE_WAITING_FOR_ACTIVATION"; |
| 100 case COMMIT_STATE_WAITING_FOR_FIRST_DRAW: | 98 case COMMIT_STATE_WAITING_FOR_FIRST_DRAW: |
| 101 return "COMMIT_STATE_WAITING_FOR_FIRST_DRAW"; | 99 return "COMMIT_STATE_WAITING_FOR_FIRST_DRAW"; |
| 102 } | 100 } |
| 103 NOTREACHED(); | 101 NOTREACHED(); |
| 104 return "???"; | 102 return "???"; |
| 105 } | 103 } |
| 106 | 104 |
| 107 const char* SchedulerStateMachine::SynchronousReadbackStateToString( | |
| 108 SynchronousReadbackState state) { | |
| 109 switch (state) { | |
| 110 case READBACK_STATE_IDLE: | |
| 111 return "READBACK_STATE_IDLE"; | |
| 112 case READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME: | |
| 113 return "READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME"; | |
| 114 case READBACK_STATE_WAITING_FOR_COMMIT: | |
| 115 return "READBACK_STATE_WAITING_FOR_COMMIT"; | |
| 116 case READBACK_STATE_WAITING_FOR_ACTIVATION: | |
| 117 return "READBACK_STATE_WAITING_FOR_ACTIVATION"; | |
| 118 case READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK: | |
| 119 return "READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK"; | |
| 120 case READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT: | |
| 121 return "READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT"; | |
| 122 case READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION: | |
| 123 return "READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION"; | |
| 124 } | |
| 125 NOTREACHED(); | |
| 126 return "???"; | |
| 127 } | |
| 128 | |
| 129 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString( | 105 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString( |
| 130 ForcedRedrawOnTimeoutState state) { | 106 ForcedRedrawOnTimeoutState state) { |
| 131 switch (state) { | 107 switch (state) { |
| 132 case FORCED_REDRAW_STATE_IDLE: | 108 case FORCED_REDRAW_STATE_IDLE: |
| 133 return "FORCED_REDRAW_STATE_IDLE"; | 109 return "FORCED_REDRAW_STATE_IDLE"; |
| 134 case FORCED_REDRAW_STATE_WAITING_FOR_COMMIT: | 110 case FORCED_REDRAW_STATE_WAITING_FOR_COMMIT: |
| 135 return "FORCED_REDRAW_STATE_WAITING_FOR_COMMIT"; | 111 return "FORCED_REDRAW_STATE_WAITING_FOR_COMMIT"; |
| 136 case FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION: | 112 case FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION: |
| 137 return "FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION"; | 113 return "FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION"; |
| 138 case FORCED_REDRAW_STATE_WAITING_FOR_DRAW: | 114 case FORCED_REDRAW_STATE_WAITING_FOR_DRAW: |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 155 case ACTION_UPDATE_VISIBLE_TILES: | 131 case ACTION_UPDATE_VISIBLE_TILES: |
| 156 return "ACTION_UPDATE_VISIBLE_TILES"; | 132 return "ACTION_UPDATE_VISIBLE_TILES"; |
| 157 case ACTION_ACTIVATE_PENDING_TREE: | 133 case ACTION_ACTIVATE_PENDING_TREE: |
| 158 return "ACTION_ACTIVATE_PENDING_TREE"; | 134 return "ACTION_ACTIVATE_PENDING_TREE"; |
| 159 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: | 135 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: |
| 160 return "ACTION_DRAW_AND_SWAP_IF_POSSIBLE"; | 136 return "ACTION_DRAW_AND_SWAP_IF_POSSIBLE"; |
| 161 case ACTION_DRAW_AND_SWAP_FORCED: | 137 case ACTION_DRAW_AND_SWAP_FORCED: |
| 162 return "ACTION_DRAW_AND_SWAP_FORCED"; | 138 return "ACTION_DRAW_AND_SWAP_FORCED"; |
| 163 case ACTION_DRAW_AND_SWAP_ABORT: | 139 case ACTION_DRAW_AND_SWAP_ABORT: |
| 164 return "ACTION_DRAW_AND_SWAP_ABORT"; | 140 return "ACTION_DRAW_AND_SWAP_ABORT"; |
| 165 case ACTION_DRAW_AND_READBACK: | |
| 166 return "ACTION_DRAW_AND_READBACK"; | |
| 167 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: | 141 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: |
| 168 return "ACTION_BEGIN_OUTPUT_SURFACE_CREATION"; | 142 return "ACTION_BEGIN_OUTPUT_SURFACE_CREATION"; |
| 169 case ACTION_MANAGE_TILES: | 143 case ACTION_MANAGE_TILES: |
| 170 return "ACTION_MANAGE_TILES"; | 144 return "ACTION_MANAGE_TILES"; |
| 171 } | 145 } |
| 172 NOTREACHED(); | 146 NOTREACHED(); |
| 173 return "???"; | 147 return "???"; |
| 174 } | 148 } |
| 175 | 149 |
| 176 scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const { | 150 scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const { |
| 177 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); | 151 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); |
| 178 | 152 |
| 179 scoped_ptr<base::DictionaryValue> major_state(new base::DictionaryValue); | 153 scoped_ptr<base::DictionaryValue> major_state(new base::DictionaryValue); |
| 180 major_state->SetString("next_action", ActionToString(NextAction())); | 154 major_state->SetString("next_action", ActionToString(NextAction())); |
| 181 major_state->SetString("begin_impl_frame_state", | 155 major_state->SetString("begin_impl_frame_state", |
| 182 BeginImplFrameStateToString(begin_impl_frame_state_)); | 156 BeginImplFrameStateToString(begin_impl_frame_state_)); |
| 183 major_state->SetString("commit_state", CommitStateToString(commit_state_)); | 157 major_state->SetString("commit_state", CommitStateToString(commit_state_)); |
| 184 major_state->SetString("output_surface_state_", | 158 major_state->SetString("output_surface_state_", |
| 185 OutputSurfaceStateToString(output_surface_state_)); | 159 OutputSurfaceStateToString(output_surface_state_)); |
| 186 major_state->SetString( | 160 major_state->SetString( |
| 187 "forced_redraw_state", | 161 "forced_redraw_state", |
| 188 ForcedRedrawOnTimeoutStateToString(forced_redraw_state_)); | 162 ForcedRedrawOnTimeoutStateToString(forced_redraw_state_)); |
| 189 major_state->SetString("readback_state", | |
| 190 SynchronousReadbackStateToString(readback_state_)); | |
| 191 state->Set("major_state", major_state.release()); | 163 state->Set("major_state", major_state.release()); |
| 192 | 164 |
| 193 scoped_ptr<base::DictionaryValue> timestamps_state(new base::DictionaryValue); | 165 scoped_ptr<base::DictionaryValue> timestamps_state(new base::DictionaryValue); |
| 194 base::TimeTicks now = gfx::FrameTime::Now(); | 166 base::TimeTicks now = gfx::FrameTime::Now(); |
| 195 timestamps_state->SetDouble( | 167 timestamps_state->SetDouble( |
| 196 "0_interval", begin_impl_frame_args_.interval.InMicroseconds() / 1000.0L); | 168 "0_interval", begin_impl_frame_args_.interval.InMicroseconds() / 1000.0L); |
| 197 timestamps_state->SetDouble( | 169 timestamps_state->SetDouble( |
| 198 "1_now_to_deadline", | 170 "1_now_to_deadline", |
| 199 (begin_impl_frame_args_.deadline - now).InMicroseconds() / 1000.0L); | 171 (begin_impl_frame_args_.deadline - now).InMicroseconds() / 1000.0L); |
| 200 timestamps_state->SetDouble( | 172 timestamps_state->SetDouble( |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 return false; | 313 return false; |
| 342 | 314 |
| 343 // Make sure the BeginImplFrame from any previous OutputSurfaces | 315 // Make sure the BeginImplFrame from any previous OutputSurfaces |
| 344 // are complete before creating the new OutputSurface. | 316 // are complete before creating the new OutputSurface. |
| 345 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_IDLE) | 317 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_IDLE) |
| 346 return false; | 318 return false; |
| 347 | 319 |
| 348 // We want to clear the pipline of any pending draws and activations | 320 // We want to clear the pipline of any pending draws and activations |
| 349 // before starting output surface initialization. This allows us to avoid | 321 // before starting output surface initialization. This allows us to avoid |
| 350 // weird corner cases where we abort draws or force activation while we | 322 // weird corner cases where we abort draws or force activation while we |
| 351 // are initializing the output surface and can potentially have a pending | 323 // are initializing the output surface. |
| 352 // readback. | |
| 353 if (active_tree_needs_first_draw_ || has_pending_tree_) | 324 if (active_tree_needs_first_draw_ || has_pending_tree_) |
|
danakj
2014/05/16 17:19:17
Think this can go away entirely?
brianderson
2014/05/16 21:38:17
Not having the replacement commit makes the pipeli
| |
| 354 return false; | 325 return false; |
| 355 | 326 |
| 356 // We need to create the output surface if we don't have one and we haven't | 327 // We need to create the output surface if we don't have one and we haven't |
| 357 // started creating one yet. | 328 // started creating one yet. |
| 358 return output_surface_state_ == OUTPUT_SURFACE_LOST; | 329 return output_surface_state_ == OUTPUT_SURFACE_LOST; |
| 359 } | 330 } |
| 360 | 331 |
| 361 bool SchedulerStateMachine::ShouldDraw() const { | 332 bool SchedulerStateMachine::ShouldDraw() const { |
| 362 // After a readback, make sure not to draw again until we've replaced the | |
| 363 // readback commit with a real one. | |
| 364 if (readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT || | |
| 365 readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION) | |
| 366 return false; | |
| 367 | |
| 368 // Draw immediately for readbacks to unblock the main thread quickly. | |
| 369 if (readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK) | |
| 370 return true; | |
| 371 | |
| 372 // If we need to abort draws, we should do so ASAP since the draw could | 333 // If we need to abort draws, we should do so ASAP since the draw could |
| 373 // be blocking other important actions (like output surface initialization), | 334 // be blocking other important actions (like output surface initialization), |
| 374 // from occuring. If we are waiting for the first draw, then perfom the | 335 // from occuring. If we are waiting for the first draw, then perfom the |
| 375 // aborted draw to keep things moving. If we are not waiting for the first | 336 // aborted draw to keep things moving. If we are not waiting for the first |
| 376 // draw however, we don't want to abort for no reason. | 337 // draw however, we don't want to abort for no reason. |
| 377 if (PendingDrawsShouldBeAborted()) | 338 if (PendingDrawsShouldBeAborted()) |
| 378 return active_tree_needs_first_draw_; | 339 return active_tree_needs_first_draw_; |
| 379 | 340 |
| 380 // After this line, we only want to send a swap request once per frame. | 341 // After this line, we only want to send a swap request once per frame. |
| 381 if (HasRequestedSwapThisFrame()) | 342 if (HasRequestedSwapThisFrame()) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 if (commit_state_ != COMMIT_STATE_IDLE) | 423 if (commit_state_ != COMMIT_STATE_IDLE) |
| 463 return false; | 424 return false; |
| 464 | 425 |
| 465 // Don't send BeginMainFrame early if we are prioritizing the active tree | 426 // Don't send BeginMainFrame early if we are prioritizing the active tree |
| 466 // because of smoothness_takes_priority. | 427 // because of smoothness_takes_priority. |
| 467 if (smoothness_takes_priority_ && | 428 if (smoothness_takes_priority_ && |
| 468 (has_pending_tree_ || active_tree_needs_first_draw_)) { | 429 (has_pending_tree_ || active_tree_needs_first_draw_)) { |
| 469 return false; | 430 return false; |
| 470 } | 431 } |
| 471 | 432 |
| 472 // We want to handle readback commits immediately to unblock the main thread. | 433 // We do not need commits if we are not visible. |
| 473 // Note: This BeginMainFrame will correspond to the replacement commit that | |
| 474 // comes after the readback commit itself, so we only send the BeginMainFrame | |
| 475 // if a commit isn't already pending behind the readback. | |
| 476 if (readback_state_ == READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME) | |
| 477 return !CommitPending(); | |
| 478 | |
| 479 // We do not need commits if we are not visible, unless there's a | |
| 480 // request for a readback. | |
| 481 if (!visible_) | 434 if (!visible_) |
| 482 return false; | 435 return false; |
| 483 | 436 |
| 484 // We want to start the first commit after we get a new output surface ASAP. | 437 // We want to start the first commit after we get a new output surface ASAP. |
| 485 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) | 438 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) |
| 486 return true; | 439 return true; |
| 487 | 440 |
| 488 // We should not send BeginMainFrame while we are in | 441 // We should not send BeginMainFrame while we are in |
| 489 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new | 442 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new |
| 490 // user input arriving soon. | 443 // user input arriving soon. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { | 507 SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { |
| 555 if (ShouldUpdateVisibleTiles()) | 508 if (ShouldUpdateVisibleTiles()) |
| 556 return ACTION_UPDATE_VISIBLE_TILES; | 509 return ACTION_UPDATE_VISIBLE_TILES; |
| 557 if (ShouldActivatePendingTree()) | 510 if (ShouldActivatePendingTree()) |
| 558 return ACTION_ACTIVATE_PENDING_TREE; | 511 return ACTION_ACTIVATE_PENDING_TREE; |
| 559 if (ShouldCommit()) | 512 if (ShouldCommit()) |
| 560 return ACTION_COMMIT; | 513 return ACTION_COMMIT; |
| 561 if (ShouldAnimate()) | 514 if (ShouldAnimate()) |
| 562 return ACTION_ANIMATE; | 515 return ACTION_ANIMATE; |
| 563 if (ShouldDraw()) { | 516 if (ShouldDraw()) { |
| 564 if (readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK) | 517 if (PendingDrawsShouldBeAborted()) |
| 565 return ACTION_DRAW_AND_READBACK; | |
| 566 else if (PendingDrawsShouldBeAborted()) | |
| 567 return ACTION_DRAW_AND_SWAP_ABORT; | 518 return ACTION_DRAW_AND_SWAP_ABORT; |
| 568 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 519 else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
| 569 return ACTION_DRAW_AND_SWAP_FORCED; | 520 return ACTION_DRAW_AND_SWAP_FORCED; |
| 570 else | 521 else |
| 571 return ACTION_DRAW_AND_SWAP_IF_POSSIBLE; | 522 return ACTION_DRAW_AND_SWAP_IF_POSSIBLE; |
| 572 } | 523 } |
| 573 if (ShouldManageTiles()) | 524 if (ShouldManageTiles()) |
| 574 return ACTION_MANAGE_TILES; | 525 return ACTION_MANAGE_TILES; |
| 575 if (ShouldSendBeginMainFrame()) | 526 if (ShouldSendBeginMainFrame()) |
| 576 return ACTION_SEND_BEGIN_MAIN_FRAME; | 527 return ACTION_SEND_BEGIN_MAIN_FRAME; |
| 577 if (ShouldBeginOutputSurfaceCreation()) | 528 if (ShouldBeginOutputSurfaceCreation()) |
| 578 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION; | 529 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION; |
| 579 return ACTION_NONE; | 530 return ACTION_NONE; |
| 580 } | 531 } |
| 581 | 532 |
| 582 void SchedulerStateMachine::CheckInvariants() { | |
|
brianderson
2014/05/16 21:38:17
Sad to see this method go, but we can bring it bac
danakj
2014/05/16 22:16:03
ya, it's just not checking anything anymore, soo..
| |
| 583 // We should never try to perform a draw for readback and forced draw due to | |
| 584 // timeout simultaneously. | |
| 585 DCHECK(!(forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW && | |
| 586 readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK)); | |
| 587 } | |
| 588 | |
| 589 void SchedulerStateMachine::UpdateState(Action action) { | 533 void SchedulerStateMachine::UpdateState(Action action) { |
| 590 switch (action) { | 534 switch (action) { |
| 591 case ACTION_NONE: | 535 case ACTION_NONE: |
| 592 return; | 536 return; |
| 593 | 537 |
| 594 case ACTION_UPDATE_VISIBLE_TILES: | 538 case ACTION_UPDATE_VISIBLE_TILES: |
| 595 last_frame_number_update_visible_tiles_was_called_ = | 539 last_frame_number_update_visible_tiles_was_called_ = |
| 596 current_frame_number_; | 540 current_frame_number_; |
| 597 return; | 541 return; |
| 598 | 542 |
| 599 case ACTION_ACTIVATE_PENDING_TREE: | 543 case ACTION_ACTIVATE_PENDING_TREE: |
| 600 UpdateStateOnActivation(); | 544 UpdateStateOnActivation(); |
| 601 return; | 545 return; |
| 602 | 546 |
| 603 case ACTION_ANIMATE: | 547 case ACTION_ANIMATE: |
| 604 last_frame_number_animate_performed_ = current_frame_number_; | 548 last_frame_number_animate_performed_ = current_frame_number_; |
| 605 needs_animate_ = false; | 549 needs_animate_ = false; |
| 606 // TODO(skyostil): Instead of assuming this, require the client to tell | 550 // TODO(skyostil): Instead of assuming this, require the client to tell |
| 607 // us. | 551 // us. |
| 608 SetNeedsRedraw(); | 552 SetNeedsRedraw(); |
| 609 return; | 553 return; |
| 610 | 554 |
| 611 case ACTION_SEND_BEGIN_MAIN_FRAME: | 555 case ACTION_SEND_BEGIN_MAIN_FRAME: |
| 612 DCHECK(!has_pending_tree_ || | 556 DCHECK(!has_pending_tree_ || |
| 613 settings_.main_frame_before_activation_enabled); | 557 settings_.main_frame_before_activation_enabled); |
| 614 DCHECK(!active_tree_needs_first_draw_ || | 558 DCHECK(!active_tree_needs_first_draw_ || |
| 615 settings_.main_frame_before_draw_enabled); | 559 settings_.main_frame_before_draw_enabled); |
| 616 DCHECK(visible_ || | 560 DCHECK(visible_); |
| 617 readback_state_ == READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME); | |
| 618 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; | 561 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; |
| 619 needs_commit_ = false; | 562 needs_commit_ = false; |
| 620 if (readback_state_ == READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME) | |
| 621 readback_state_ = READBACK_STATE_WAITING_FOR_COMMIT; | |
| 622 last_frame_number_begin_main_frame_sent_ = | 563 last_frame_number_begin_main_frame_sent_ = |
| 623 current_frame_number_; | 564 current_frame_number_; |
| 624 return; | 565 return; |
| 625 | 566 |
| 626 case ACTION_COMMIT: { | 567 case ACTION_COMMIT: { |
| 627 bool commit_was_aborted = false; | 568 bool commit_was_aborted = false; |
| 628 UpdateStateOnCommit(commit_was_aborted); | 569 UpdateStateOnCommit(commit_was_aborted); |
| 629 return; | 570 return; |
| 630 } | 571 } |
| 631 | 572 |
| 632 case ACTION_DRAW_AND_SWAP_FORCED: | 573 case ACTION_DRAW_AND_SWAP_FORCED: |
| 633 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { | 574 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { |
| 634 bool did_request_swap = true; | 575 bool did_request_swap = true; |
| 635 UpdateStateOnDraw(did_request_swap); | 576 UpdateStateOnDraw(did_request_swap); |
| 636 return; | 577 return; |
| 637 } | 578 } |
| 638 | 579 |
| 639 case ACTION_DRAW_AND_SWAP_ABORT: | 580 case ACTION_DRAW_AND_SWAP_ABORT: { |
| 640 case ACTION_DRAW_AND_READBACK: { | |
| 641 bool did_request_swap = false; | 581 bool did_request_swap = false; |
| 642 UpdateStateOnDraw(did_request_swap); | 582 UpdateStateOnDraw(did_request_swap); |
| 643 return; | 583 return; |
| 644 } | 584 } |
| 645 | 585 |
| 646 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: | 586 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: |
| 647 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST); | 587 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST); |
| 648 output_surface_state_ = OUTPUT_SURFACE_CREATING; | 588 output_surface_state_ = OUTPUT_SURFACE_CREATING; |
| 649 | 589 |
| 650 // The following DCHECKs make sure we are in the proper quiescent state. | 590 // The following DCHECKs make sure we are in the proper quiescent state. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 671 ? COMMIT_STATE_WAITING_FOR_ACTIVATION | 611 ? COMMIT_STATE_WAITING_FOR_ACTIVATION |
| 672 : COMMIT_STATE_IDLE; | 612 : COMMIT_STATE_IDLE; |
| 673 } else { | 613 } else { |
| 674 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; | 614 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; |
| 675 } | 615 } |
| 676 | 616 |
| 677 // If we are impl-side-painting but the commit was aborted, then we behave | 617 // If we are impl-side-painting but the commit was aborted, then we behave |
| 678 // mostly as if we are not impl-side-painting since there is no pending tree. | 618 // mostly as if we are not impl-side-painting since there is no pending tree. |
| 679 has_pending_tree_ = settings_.impl_side_painting && !commit_was_aborted; | 619 has_pending_tree_ = settings_.impl_side_painting && !commit_was_aborted; |
| 680 | 620 |
| 681 // Update state related to readbacks. | 621 // Update state related to forced draws. |
| 682 if (readback_state_ == READBACK_STATE_WAITING_FOR_COMMIT) { | 622 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { |
| 683 // Update the state if this is the readback commit. | 623 forced_redraw_state_ = has_pending_tree_ |
| 684 readback_state_ = has_pending_tree_ | 624 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION |
| 685 ? READBACK_STATE_WAITING_FOR_ACTIVATION | 625 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
| 686 : READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK; | |
| 687 } else if (readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT) { | |
| 688 // Update the state if this is the commit replacing the readback commit. | |
| 689 readback_state_ = has_pending_tree_ | |
| 690 ? READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION | |
| 691 : READBACK_STATE_IDLE; | |
| 692 } else { | |
| 693 DCHECK(readback_state_ == READBACK_STATE_IDLE); | |
| 694 } | 626 } |
| 695 | 627 |
| 696 // Readbacks can interrupt output surface initialization and forced draws, | 628 // Update the output surface state. |
| 697 // so we do not want to advance those states if we are in the middle of a | 629 DCHECK_NE(output_surface_state_, OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION); |
| 698 // readback. Note: It is possible for the readback's replacement commit to | 630 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) { |
| 699 // be the output surface's first commit and/or the forced redraw's commit. | 631 if (has_pending_tree_) { |
| 700 if (readback_state_ == READBACK_STATE_IDLE || | 632 output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION; |
| 701 readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION) { | 633 } else { |
| 702 // Update state related to forced draws. | 634 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; |
| 703 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { | 635 needs_redraw_ = true; |
| 704 forced_redraw_state_ = has_pending_tree_ | |
| 705 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION | |
| 706 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | |
| 707 } | |
| 708 | |
| 709 // Update the output surface state. | |
| 710 DCHECK_NE(output_surface_state_, | |
| 711 OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION); | |
| 712 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) { | |
| 713 if (has_pending_tree_) { | |
| 714 output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION; | |
| 715 } else { | |
| 716 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; | |
| 717 needs_redraw_ = true; | |
| 718 } | |
| 719 } | 636 } |
| 720 } | 637 } |
| 721 | 638 |
| 722 // Update state if we have a new active tree to draw, or if the active tree | 639 // Update state if we have a new active tree to draw, or if the active tree |
| 723 // was unchanged but we need to do a readback or forced draw. | 640 // was unchanged but we need to do a forced draw. |
| 724 if (!has_pending_tree_ && | 641 if (!has_pending_tree_ && |
| 725 (!commit_was_aborted || | 642 (!commit_was_aborted || |
| 726 readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK || | |
| 727 forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)) { | 643 forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)) { |
| 728 needs_redraw_ = true; | 644 needs_redraw_ = true; |
| 729 active_tree_needs_first_draw_ = true; | 645 active_tree_needs_first_draw_ = true; |
| 730 } | 646 } |
| 731 | 647 |
| 732 // This post-commit work is common to both completed and aborted commits. | 648 // This post-commit work is common to both completed and aborted commits. |
| 733 pending_tree_is_ready_for_activation_ = false; | 649 pending_tree_is_ready_for_activation_ = false; |
| 734 | 650 |
| 735 if (continuous_painting_) | 651 if (continuous_painting_) |
| 736 needs_commit_ = true; | 652 needs_commit_ = true; |
| 737 } | 653 } |
| 738 | 654 |
| 739 void SchedulerStateMachine::UpdateStateOnActivation() { | 655 void SchedulerStateMachine::UpdateStateOnActivation() { |
| 740 if (commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION) | 656 if (commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION) |
| 741 commit_state_ = COMMIT_STATE_IDLE; | 657 commit_state_ = COMMIT_STATE_IDLE; |
| 742 | 658 |
| 743 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION) | 659 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION) |
| 744 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; | 660 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; |
| 745 | 661 |
| 746 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) | 662 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) |
| 747 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 663 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
| 748 | 664 |
| 749 if (readback_state_ == READBACK_STATE_WAITING_FOR_ACTIVATION) { | |
| 750 readback_state_ = READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK; | |
| 751 } else if (readback_state_ == | |
| 752 READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION) { | |
| 753 if (needs_back_to_back_readback_) { | |
| 754 if (commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_SENT) { | |
| 755 // If main_frame_before_activation_enabled is true, it is possible that | |
| 756 // we will have already sent the BeginMainFrame here. | |
| 757 readback_state_ = READBACK_STATE_WAITING_FOR_COMMIT; | |
| 758 } else { | |
| 759 // Replacement commit for incoming forced commit should be scheduled | |
| 760 // after current commit's draw & swap is finished. | |
| 761 needs_commit_ = true; | |
| 762 readback_state_ = READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME; | |
| 763 } | |
| 764 needs_back_to_back_readback_ = false; | |
| 765 } else { | |
| 766 readback_state_ = READBACK_STATE_IDLE; | |
| 767 } | |
| 768 } | |
| 769 | |
| 770 has_pending_tree_ = false; | 665 has_pending_tree_ = false; |
| 771 pending_tree_is_ready_for_activation_ = false; | 666 pending_tree_is_ready_for_activation_ = false; |
| 772 active_tree_needs_first_draw_ = true; | 667 active_tree_needs_first_draw_ = true; |
| 773 needs_redraw_ = true; | 668 needs_redraw_ = true; |
| 774 } | 669 } |
| 775 | 670 |
| 776 void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) { | 671 void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) { |
| 777 DCHECK(readback_state_ != READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT && | 672 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
| 778 readback_state_ != READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION) | |
| 779 << *AsValue(); | |
| 780 | |
| 781 if (readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK) { | |
| 782 // The draw corresponds to a readback commit. | |
| 783 // We are blocking commits from the main thread until after this draw, so | |
| 784 // we should not have a pending tree. | |
| 785 DCHECK(!has_pending_tree_); | |
| 786 // We transition to COMMIT_STATE_BEGIN_MAIN_FRAME_SENT because there is a | |
| 787 // pending BeginMainFrame behind the readback request. | |
| 788 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; | |
| 789 readback_state_ = READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT; | |
| 790 } else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) { | |
| 791 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | 673 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
| 792 } | |
| 793 | 674 |
| 794 if (!has_pending_tree_ && | 675 if (!has_pending_tree_ && |
| 795 commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) { | 676 commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) { |
| 796 commit_state_ = COMMIT_STATE_IDLE; | 677 commit_state_ = COMMIT_STATE_IDLE; |
| 797 } | 678 } |
| 798 | 679 |
| 799 needs_redraw_ = false; | 680 needs_redraw_ = false; |
| 800 active_tree_needs_first_draw_ = false; | 681 active_tree_needs_first_draw_ = false; |
| 801 | 682 |
| 802 if (did_request_swap) | 683 if (did_request_swap) |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 | 822 |
| 942 void SchedulerStateMachine::OnBeginImplFrameIdle() { | 823 void SchedulerStateMachine::OnBeginImplFrameIdle() { |
| 943 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) | 824 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) |
| 944 << *AsValue(); | 825 << *AsValue(); |
| 945 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; | 826 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_IDLE; |
| 946 } | 827 } |
| 947 | 828 |
| 948 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineEarly() const { | 829 bool SchedulerStateMachine::ShouldTriggerBeginImplFrameDeadlineEarly() const { |
| 949 // TODO(brianderson): This should take into account multiple commit sources. | 830 // TODO(brianderson): This should take into account multiple commit sources. |
| 950 | 831 |
| 951 // If we are in the middle of the readback, we won't swap, so there is | |
| 952 // no reason to trigger the deadline early. | |
| 953 if (readback_state_ != READBACK_STATE_IDLE) | |
| 954 return false; | |
| 955 | |
| 956 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) | 832 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) |
| 957 return false; | 833 return false; |
| 958 | 834 |
| 959 // If we've lost the output surface, end the current BeginImplFrame ASAP | 835 // If we've lost the output surface, end the current BeginImplFrame ASAP |
| 960 // so we can start creating the next output surface. | 836 // so we can start creating the next output surface. |
| 961 if (output_surface_state_ == OUTPUT_SURFACE_LOST) | 837 if (output_surface_state_ == OUTPUT_SURFACE_LOST) |
| 962 return true; | 838 return true; |
| 963 | 839 |
| 964 // SwapAck throttle the deadline since we wont draw and swap anyway. | 840 // SwapAck throttle the deadline since we wont draw and swap anyway. |
| 965 if (pending_swaps_ >= max_pending_swaps_) | 841 if (pending_swaps_ >= max_pending_swaps_) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1079 bool smoothness_takes_priority) { | 955 bool smoothness_takes_priority) { |
| 1080 smoothness_takes_priority_ = smoothness_takes_priority; | 956 smoothness_takes_priority_ = smoothness_takes_priority; |
| 1081 } | 957 } |
| 1082 | 958 |
| 1083 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { | 959 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { |
| 1084 switch (result) { | 960 switch (result) { |
| 1085 case INVALID_RESULT: | 961 case INVALID_RESULT: |
| 1086 NOTREACHED() << "Uninitialized DrawResult."; | 962 NOTREACHED() << "Uninitialized DrawResult."; |
| 1087 break; | 963 break; |
| 1088 case DRAW_ABORTED_CANT_DRAW: | 964 case DRAW_ABORTED_CANT_DRAW: |
| 1089 case DRAW_ABORTED_CANT_READBACK: | |
| 1090 case DRAW_ABORTED_CONTEXT_LOST: | 965 case DRAW_ABORTED_CONTEXT_LOST: |
| 1091 NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:" | 966 NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:" |
| 1092 << result; | 967 << result; |
| 1093 break; | 968 break; |
| 1094 case DRAW_SUCCESS: | 969 case DRAW_SUCCESS: |
| 1095 consecutive_checkerboard_animations_ = 0; | 970 consecutive_checkerboard_animations_ = 0; |
| 1096 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | 971 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
| 1097 break; | 972 break; |
| 1098 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: | 973 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: |
| 1099 needs_redraw_ = true; | 974 needs_redraw_ = true; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1119 // pictures (which requires a commit) or because of memory pressure | 994 // pictures (which requires a commit) or because of memory pressure |
| 1120 // removing textures (which might not). To be safe, request a commit | 995 // removing textures (which might not). To be safe, request a commit |
| 1121 // anyway. | 996 // anyway. |
| 1122 needs_commit_ = true; | 997 needs_commit_ = true; |
| 1123 break; | 998 break; |
| 1124 } | 999 } |
| 1125 } | 1000 } |
| 1126 | 1001 |
| 1127 void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; } | 1002 void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; } |
| 1128 | 1003 |
| 1129 void SchedulerStateMachine::SetNeedsForcedCommitForReadback() { | |
| 1130 // If this is called in READBACK_STATE_IDLE, this is a "first" readback | |
| 1131 // request. | |
| 1132 // If this is called in READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT, this | |
| 1133 // is a back-to-back readback request that started before the replacement | |
| 1134 // commit had a chance to land. | |
| 1135 // If this is called in READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION, | |
| 1136 // this is a readback-commit-readback request when replacement commit is in | |
| 1137 // impl-side painting. | |
| 1138 DCHECK(readback_state_ == READBACK_STATE_IDLE || | |
| 1139 readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT || | |
| 1140 readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION); | |
| 1141 | |
| 1142 if (readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION) { | |
| 1143 // If new forced commit is requested when impl-side painting of replacement | |
| 1144 // commit is in progress, it should not interrupt the draw & swap of current | |
| 1145 // commit(replacement commit). New commit(incoming forced commit) should be | |
| 1146 // started after current commit is finished. | |
| 1147 needs_back_to_back_readback_ = true; | |
| 1148 } else if (commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_SENT) { | |
| 1149 // If there is already a commit in progress when we get the readback request | |
| 1150 // then we don't need to send a BeginMainFrame for the replacement commit, | |
| 1151 // since there's already a BeginMainFrame behind the readback request. In | |
| 1152 // that case, we can skip READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME and go | |
| 1153 // directly to READBACK_STATE_WAITING_FOR_COMMIT. | |
| 1154 readback_state_ = READBACK_STATE_WAITING_FOR_COMMIT; | |
| 1155 } else { | |
| 1156 // Set needs_commit_ to true to trigger scheduling BeginMainFrame(). | |
| 1157 needs_commit_ = true; | |
| 1158 readback_state_ = READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME; | |
| 1159 } | |
| 1160 } | |
| 1161 | |
| 1162 void SchedulerStateMachine::NotifyReadyToCommit() { | 1004 void SchedulerStateMachine::NotifyReadyToCommit() { |
| 1163 DCHECK(commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED) << *AsValue(); | 1005 DCHECK(commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED) << *AsValue(); |
| 1164 commit_state_ = COMMIT_STATE_READY_TO_COMMIT; | 1006 commit_state_ = COMMIT_STATE_READY_TO_COMMIT; |
| 1165 } | 1007 } |
| 1166 | 1008 |
| 1167 void SchedulerStateMachine::BeginMainFrameAborted(bool did_handle) { | 1009 void SchedulerStateMachine::BeginMainFrameAborted(bool did_handle) { |
| 1168 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); | 1010 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); |
| 1169 if (did_handle) { | 1011 if (did_handle) { |
| 1170 bool commit_was_aborted = true; | 1012 bool commit_was_aborted = true; |
| 1171 UpdateStateOnCommit(commit_was_aborted); | 1013 UpdateStateOnCommit(commit_was_aborted); |
| 1172 } else { | 1014 } else { |
| 1173 DCHECK_NE(readback_state_, READBACK_STATE_WAITING_FOR_COMMIT); | |
| 1174 commit_state_ = COMMIT_STATE_IDLE; | 1015 commit_state_ = COMMIT_STATE_IDLE; |
| 1175 SetNeedsCommit(); | 1016 SetNeedsCommit(); |
| 1176 } | 1017 } |
| 1177 } | 1018 } |
| 1178 | 1019 |
| 1179 void SchedulerStateMachine::DidManageTiles() { | 1020 void SchedulerStateMachine::DidManageTiles() { |
| 1180 needs_manage_tiles_ = false; | 1021 needs_manage_tiles_ = false; |
| 1181 // "Fill" the ManageTiles funnel. | 1022 // "Fill" the ManageTiles funnel. |
| 1182 manage_tiles_funnel_++; | 1023 manage_tiles_funnel_++; |
| 1183 } | 1024 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1203 // TODO(boliu): See if we can remove this when impl-side painting is always | 1044 // TODO(boliu): See if we can remove this when impl-side painting is always |
| 1204 // on. Does anything on the main thread need to update after recreate? | 1045 // on. Does anything on the main thread need to update after recreate? |
| 1205 needs_commit_ = true; | 1046 needs_commit_ = true; |
| 1206 } | 1047 } |
| 1207 did_create_and_initialize_first_output_surface_ = true; | 1048 did_create_and_initialize_first_output_surface_ = true; |
| 1208 pending_swaps_ = 0; | 1049 pending_swaps_ = 0; |
| 1209 } | 1050 } |
| 1210 | 1051 |
| 1211 void SchedulerStateMachine::NotifyBeginMainFrameStarted() { | 1052 void SchedulerStateMachine::NotifyBeginMainFrameStarted() { |
| 1212 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); | 1053 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); |
| 1213 | |
| 1214 DCHECK(readback_state_ == READBACK_STATE_IDLE || | |
| 1215 readback_state_ == READBACK_STATE_WAITING_FOR_COMMIT || | |
| 1216 readback_state_ == READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT); | |
| 1217 | |
| 1218 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED; | 1054 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED; |
| 1219 } | 1055 } |
| 1220 | 1056 |
| 1221 bool SchedulerStateMachine::HasInitializedOutputSurface() const { | 1057 bool SchedulerStateMachine::HasInitializedOutputSurface() const { |
| 1222 switch (output_surface_state_) { | 1058 switch (output_surface_state_) { |
| 1223 case OUTPUT_SURFACE_LOST: | 1059 case OUTPUT_SURFACE_LOST: |
| 1224 case OUTPUT_SURFACE_CREATING: | 1060 case OUTPUT_SURFACE_CREATING: |
| 1225 return false; | 1061 return false; |
| 1226 | 1062 |
| 1227 case OUTPUT_SURFACE_ACTIVE: | 1063 case OUTPUT_SURFACE_ACTIVE: |
| 1228 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: | 1064 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: |
| 1229 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: | 1065 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: |
| 1230 return true; | 1066 return true; |
| 1231 } | 1067 } |
| 1232 NOTREACHED(); | 1068 NOTREACHED(); |
| 1233 return false; | 1069 return false; |
| 1234 } | 1070 } |
| 1235 | 1071 |
| 1236 } // namespace cc | 1072 } // namespace cc |
| OLD | NEW |