| 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_ || | |
| 573 settings_.main_frame_before_draw_enabled); | |
| 574 DCHECK(visible_); | 570 DCHECK(visible_); |
| 575 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; | 571 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; |
| 576 needs_commit_ = false; | 572 needs_commit_ = false; |
| 577 last_frame_number_begin_main_frame_sent_ = | 573 last_frame_number_begin_main_frame_sent_ = |
| 578 current_frame_number_; | 574 current_frame_number_; |
| 579 return; | 575 return; |
| 580 | 576 |
| 581 case ACTION_COMMIT: { | 577 case ACTION_COMMIT: { |
| 582 bool commit_was_aborted = false; | 578 bool commit_was_aborted = false; |
| 583 UpdateStateOnCommit(commit_was_aborted); | 579 UpdateStateOnCommit(commit_was_aborted); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 613 UpdateStateOnManageTiles(); | 609 UpdateStateOnManageTiles(); |
| 614 return; | 610 return; |
| 615 } | 611 } |
| 616 } | 612 } |
| 617 | 613 |
| 618 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_was_aborted) { | 614 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_was_aborted) { |
| 619 commit_count_++; | 615 commit_count_++; |
| 620 | 616 |
| 621 if (commit_was_aborted || settings_.main_frame_before_activation_enabled) { | 617 if (commit_was_aborted || settings_.main_frame_before_activation_enabled) { |
| 622 commit_state_ = COMMIT_STATE_IDLE; | 618 commit_state_ = COMMIT_STATE_IDLE; |
| 623 } else if (settings_.main_frame_before_draw_enabled) { | 619 } else { |
| 624 commit_state_ = settings_.impl_side_painting | 620 commit_state_ = settings_.impl_side_painting |
| 625 ? COMMIT_STATE_WAITING_FOR_ACTIVATION | 621 ? COMMIT_STATE_WAITING_FOR_ACTIVATION |
| 626 : COMMIT_STATE_IDLE; | 622 : COMMIT_STATE_IDLE; |
| 627 } else { | |
| 628 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; | |
| 629 } | 623 } |
| 630 | 624 |
| 631 // If we are impl-side-painting but the commit was aborted, then we behave | 625 // 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. | 626 // 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; | 627 has_pending_tree_ = settings_.impl_side_painting && !commit_was_aborted; |
| 634 | 628 |
| 635 // Update state related to forced draws. | 629 // Update state related to forced draws. |
| 636 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { | 630 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { |
| 637 forced_redraw_state_ = has_pending_tree_ | 631 forced_redraw_state_ = has_pending_tree_ |
| 638 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION | 632 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 has_pending_tree_ = false; | 673 has_pending_tree_ = false; |
| 680 pending_tree_is_ready_for_activation_ = false; | 674 pending_tree_is_ready_for_activation_ = false; |
| 681 active_tree_needs_first_draw_ = true; | 675 active_tree_needs_first_draw_ = true; |
| 682 needs_redraw_ = true; | 676 needs_redraw_ = true; |
| 683 } | 677 } |
| 684 | 678 |
| 685 void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) { | 679 void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) { |
| 686 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 680 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
| 687 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | 681 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
| 688 | 682 |
| 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; | 683 needs_redraw_ = false; |
| 695 active_tree_needs_first_draw_ = false; | 684 active_tree_needs_first_draw_ = false; |
| 696 | 685 |
| 697 if (did_request_swap) | 686 if (did_request_swap) |
| 698 last_frame_number_swap_requested_ = current_frame_number_; | 687 last_frame_number_swap_requested_ = current_frame_number_; |
| 699 } | 688 } |
| 700 | 689 |
| 701 void SchedulerStateMachine::UpdateStateOnManageTiles() { | 690 void SchedulerStateMachine::UpdateStateOnManageTiles() { |
| 702 needs_manage_tiles_ = false; | 691 needs_manage_tiles_ = false; |
| 703 } | 692 } |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 static_cast<int>(begin_impl_frame_state_), | 1083 static_cast<int>(begin_impl_frame_state_), |
| 1095 static_cast<int>(commit_state_), | 1084 static_cast<int>(commit_state_), |
| 1096 has_pending_tree_ ? 'T' : 'F', | 1085 has_pending_tree_ ? 'T' : 'F', |
| 1097 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1086 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
| 1098 active_tree_needs_first_draw_ ? 'T' : 'F', | 1087 active_tree_needs_first_draw_ ? 'T' : 'F', |
| 1099 max_pending_swaps_, | 1088 max_pending_swaps_, |
| 1100 pending_swaps_); | 1089 pending_swaps_); |
| 1101 } | 1090 } |
| 1102 | 1091 |
| 1103 } // namespace cc | 1092 } // namespace cc |
| OLD | NEW |