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/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" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 case COMMIT_STATE_IDLE: | 89 case COMMIT_STATE_IDLE: |
| 90 return "COMMIT_STATE_IDLE"; | 90 return "COMMIT_STATE_IDLE"; |
| 91 case COMMIT_STATE_BEGIN_MAIN_FRAME_SENT: | 91 case COMMIT_STATE_BEGIN_MAIN_FRAME_SENT: |
| 92 return "COMMIT_STATE_BEGIN_MAIN_FRAME_SENT"; | 92 return "COMMIT_STATE_BEGIN_MAIN_FRAME_SENT"; |
| 93 case COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED: | 93 case COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED: |
| 94 return "COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED"; | 94 return "COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED"; |
| 95 case COMMIT_STATE_READY_TO_COMMIT: | 95 case COMMIT_STATE_READY_TO_COMMIT: |
| 96 return "COMMIT_STATE_READY_TO_COMMIT"; | 96 return "COMMIT_STATE_READY_TO_COMMIT"; |
| 97 case COMMIT_STATE_WAITING_FOR_ACTIVATION: | 97 case COMMIT_STATE_WAITING_FOR_ACTIVATION: |
| 98 return "COMMIT_STATE_WAITING_FOR_ACTIVATION"; | 98 return "COMMIT_STATE_WAITING_FOR_ACTIVATION"; |
| 99 case COMMIT_STATE_WAITING_FOR_FIRST_DRAW: | |
| 100 return "COMMIT_STATE_WAITING_FOR_FIRST_DRAW"; | |
| 101 } | 99 } |
| 102 NOTREACHED(); | 100 NOTREACHED(); |
| 103 return "???"; | 101 return "???"; |
| 104 } | 102 } |
| 105 | 103 |
| 106 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString( | 104 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString( |
| 107 ForcedRedrawOnTimeoutState state) { | 105 ForcedRedrawOnTimeoutState state) { |
| 108 switch (state) { | 106 switch (state) { |
| 109 case FORCED_REDRAW_STATE_IDLE: | 107 case FORCED_REDRAW_STATE_IDLE: |
| 110 return "FORCED_REDRAW_STATE_IDLE"; | 108 return "FORCED_REDRAW_STATE_IDLE"; |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 last_frame_number_animate_performed_ = current_frame_number_; | 560 last_frame_number_animate_performed_ = current_frame_number_; |
| 563 needs_animate_ = false; | 561 needs_animate_ = false; |
| 564 // TODO(skyostil): Instead of assuming this, require the client to tell | 562 // TODO(skyostil): Instead of assuming this, require the client to tell |
| 565 // us. | 563 // us. |
| 566 SetNeedsRedraw(); | 564 SetNeedsRedraw(); |
| 567 return; | 565 return; |
| 568 | 566 |
| 569 case ACTION_SEND_BEGIN_MAIN_FRAME: | 567 case ACTION_SEND_BEGIN_MAIN_FRAME: |
| 570 DCHECK(!has_pending_tree_ || | 568 DCHECK(!has_pending_tree_ || |
| 571 settings_.main_frame_before_activation_enabled); | 569 settings_.main_frame_before_activation_enabled); |
| 572 DCHECK(!active_tree_needs_first_draw_ || | 570 DCHECK(!active_tree_needs_first_draw_); |
|
brianderson
2014/09/27 02:30:26
DCHECK no longer needed.
orglofch
2014/09/27 21:46:42
Done.
| |
| 573 settings_.main_frame_before_draw_enabled); | |
| 574 DCHECK(visible_); | 571 DCHECK(visible_); |
| 575 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; | 572 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; |
| 576 needs_commit_ = false; | 573 needs_commit_ = false; |
| 577 last_frame_number_begin_main_frame_sent_ = | 574 last_frame_number_begin_main_frame_sent_ = |
| 578 current_frame_number_; | 575 current_frame_number_; |
| 579 return; | 576 return; |
| 580 | 577 |
| 581 case ACTION_COMMIT: { | 578 case ACTION_COMMIT: { |
| 582 bool commit_was_aborted = false; | 579 bool commit_was_aborted = false; |
| 583 UpdateStateOnCommit(commit_was_aborted); | 580 UpdateStateOnCommit(commit_was_aborted); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 613 UpdateStateOnManageTiles(); | 610 UpdateStateOnManageTiles(); |
| 614 return; | 611 return; |
| 615 } | 612 } |
| 616 } | 613 } |
| 617 | 614 |
| 618 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_was_aborted) { | 615 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_was_aborted) { |
| 619 commit_count_++; | 616 commit_count_++; |
| 620 | 617 |
| 621 if (commit_was_aborted || settings_.main_frame_before_activation_enabled) { | 618 if (commit_was_aborted || settings_.main_frame_before_activation_enabled) { |
| 622 commit_state_ = COMMIT_STATE_IDLE; | 619 commit_state_ = COMMIT_STATE_IDLE; |
| 623 } else if (settings_.main_frame_before_draw_enabled) { | 620 } else { |
| 624 commit_state_ = settings_.impl_side_painting | 621 commit_state_ = settings_.impl_side_painting |
| 625 ? COMMIT_STATE_WAITING_FOR_ACTIVATION | 622 ? COMMIT_STATE_WAITING_FOR_ACTIVATION |
| 626 : COMMIT_STATE_IDLE; | 623 : COMMIT_STATE_IDLE; |
| 627 } else { | |
| 628 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; | |
| 629 } | 624 } |
| 630 | 625 |
| 631 // If we are impl-side-painting but the commit was aborted, then we behave | 626 // If we are impl-side-painting but the commit was aborted, then we behave |
| 632 // mostly as if we are not impl-side-painting since there is no pending tree. | 627 // mostly as if we are not impl-side-painting since there is no pending tree. |
| 633 has_pending_tree_ = settings_.impl_side_painting && !commit_was_aborted; | 628 has_pending_tree_ = settings_.impl_side_painting && !commit_was_aborted; |
| 634 | 629 |
| 635 // Update state related to forced draws. | 630 // Update state related to forced draws. |
| 636 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { | 631 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { |
| 637 forced_redraw_state_ = has_pending_tree_ | 632 forced_redraw_state_ = has_pending_tree_ |
| 638 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION | 633 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 has_pending_tree_ = false; | 674 has_pending_tree_ = false; |
| 680 pending_tree_is_ready_for_activation_ = false; | 675 pending_tree_is_ready_for_activation_ = false; |
| 681 active_tree_needs_first_draw_ = true; | 676 active_tree_needs_first_draw_ = true; |
| 682 needs_redraw_ = true; | 677 needs_redraw_ = true; |
| 683 } | 678 } |
| 684 | 679 |
| 685 void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) { | 680 void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) { |
| 686 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 681 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
| 687 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | 682 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
| 688 | 683 |
| 689 if (!has_pending_tree_ && | |
| 690 commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) { | |
| 691 commit_state_ = COMMIT_STATE_IDLE; | |
| 692 } | |
| 693 | |
| 694 needs_redraw_ = false; | 684 needs_redraw_ = false; |
| 695 active_tree_needs_first_draw_ = false; | 685 active_tree_needs_first_draw_ = false; |
| 696 | 686 |
| 697 if (did_request_swap) | 687 if (did_request_swap) |
| 698 last_frame_number_swap_requested_ = current_frame_number_; | 688 last_frame_number_swap_requested_ = current_frame_number_; |
| 699 } | 689 } |
| 700 | 690 |
| 701 void SchedulerStateMachine::UpdateStateOnManageTiles() { | 691 void SchedulerStateMachine::UpdateStateOnManageTiles() { |
| 702 needs_manage_tiles_ = false; | 692 needs_manage_tiles_ = false; |
| 703 } | 693 } |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1094 static_cast<int>(begin_impl_frame_state_), | 1084 static_cast<int>(begin_impl_frame_state_), |
| 1095 static_cast<int>(commit_state_), | 1085 static_cast<int>(commit_state_), |
| 1096 has_pending_tree_ ? 'T' : 'F', | 1086 has_pending_tree_ ? 'T' : 'F', |
| 1097 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1087 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
| 1098 active_tree_needs_first_draw_ ? 'T' : 'F', | 1088 active_tree_needs_first_draw_ ? 'T' : 'F', |
| 1099 max_pending_swaps_, | 1089 max_pending_swaps_, |
| 1100 pending_swaps_); | 1090 pending_swaps_); |
| 1101 } | 1091 } |
| 1102 | 1092 |
| 1103 } // namespace cc | 1093 } // namespace cc |
| OLD | NEW |