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

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

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/scheduler/scheduler_state_machine.h" 5 #include "cc/scheduler/scheduler_state_machine.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/debug/trace_event_argument.h" 8 #include "base/debug/trace_event_argument.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 case COMMIT_STATE_IDLE: 90 case COMMIT_STATE_IDLE:
91 return "COMMIT_STATE_IDLE"; 91 return "COMMIT_STATE_IDLE";
92 case COMMIT_STATE_BEGIN_MAIN_FRAME_SENT: 92 case COMMIT_STATE_BEGIN_MAIN_FRAME_SENT:
93 return "COMMIT_STATE_BEGIN_MAIN_FRAME_SENT"; 93 return "COMMIT_STATE_BEGIN_MAIN_FRAME_SENT";
94 case COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED: 94 case COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED:
95 return "COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED"; 95 return "COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED";
96 case COMMIT_STATE_READY_TO_COMMIT: 96 case COMMIT_STATE_READY_TO_COMMIT:
97 return "COMMIT_STATE_READY_TO_COMMIT"; 97 return "COMMIT_STATE_READY_TO_COMMIT";
98 case COMMIT_STATE_WAITING_FOR_ACTIVATION: 98 case COMMIT_STATE_WAITING_FOR_ACTIVATION:
99 return "COMMIT_STATE_WAITING_FOR_ACTIVATION"; 99 return "COMMIT_STATE_WAITING_FOR_ACTIVATION";
100 case COMMIT_STATE_WAITING_FOR_DRAW:
101 return "COMMIT_STATE_WAITING_FOR_DRAW";
100 } 102 }
101 NOTREACHED(); 103 NOTREACHED();
102 return "???"; 104 return "???";
103 } 105 }
104 106
105 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString( 107 const char* SchedulerStateMachine::ForcedRedrawOnTimeoutStateToString(
106 ForcedRedrawOnTimeoutState state) { 108 ForcedRedrawOnTimeoutState state) {
107 switch (state) { 109 switch (state) {
108 case FORCED_REDRAW_STATE_IDLE: 110 case FORCED_REDRAW_STATE_IDLE:
109 return "FORCED_REDRAW_STATE_IDLE"; 111 return "FORCED_REDRAW_STATE_IDLE";
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 } 587 }
586 588
587 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_was_aborted) { 589 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_was_aborted) {
588 commit_count_++; 590 commit_count_++;
589 591
590 if (!commit_was_aborted && HasAnimatedThisFrame()) 592 if (!commit_was_aborted && HasAnimatedThisFrame())
591 did_commit_after_animating_ = true; 593 did_commit_after_animating_ = true;
592 594
593 if (commit_was_aborted || settings_.main_frame_before_activation_enabled) { 595 if (commit_was_aborted || settings_.main_frame_before_activation_enabled) {
594 commit_state_ = COMMIT_STATE_IDLE; 596 commit_state_ = COMMIT_STATE_IDLE;
597 } else if (settings_.impl_side_painting) {
598 commit_state_ = COMMIT_STATE_WAITING_FOR_ACTIVATION;
595 } else { 599 } else {
596 commit_state_ = settings_.impl_side_painting 600 commit_state_ = settings_.main_thread_should_always_be_low_latency
597 ? COMMIT_STATE_WAITING_FOR_ACTIVATION 601 ? COMMIT_STATE_WAITING_FOR_DRAW
598 : COMMIT_STATE_IDLE; 602 : COMMIT_STATE_IDLE;
599 } 603 }
600 604
601 // If we are impl-side-painting but the commit was aborted, then we behave 605 // If we are impl-side-painting but the commit was aborted, then we behave
602 // mostly as if we are not impl-side-painting since there is no pending tree. 606 // mostly as if we are not impl-side-painting since there is no pending tree.
603 has_pending_tree_ = settings_.impl_side_painting && !commit_was_aborted; 607 has_pending_tree_ = settings_.impl_side_painting && !commit_was_aborted;
604 608
605 // Update state related to forced draws. 609 // Update state related to forced draws.
606 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { 610 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) {
607 forced_redraw_state_ = has_pending_tree_ 611 forced_redraw_state_ = has_pending_tree_
(...skipping 22 matching lines...) Expand all
630 } 634 }
631 635
632 // This post-commit work is common to both completed and aborted commits. 636 // This post-commit work is common to both completed and aborted commits.
633 pending_tree_is_ready_for_activation_ = false; 637 pending_tree_is_ready_for_activation_ = false;
634 638
635 if (continuous_painting_) 639 if (continuous_painting_)
636 needs_commit_ = true; 640 needs_commit_ = true;
637 } 641 }
638 642
639 void SchedulerStateMachine::UpdateStateOnActivation() { 643 void SchedulerStateMachine::UpdateStateOnActivation() {
640 if (commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION) 644 if (commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION) {
641 commit_state_ = COMMIT_STATE_IDLE; 645 commit_state_ = settings_.main_thread_should_always_be_low_latency
646 ? COMMIT_STATE_WAITING_FOR_DRAW
647 : COMMIT_STATE_IDLE;
648 }
642 649
643 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION) 650 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION)
644 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; 651 output_surface_state_ = OUTPUT_SURFACE_ACTIVE;
645 652
646 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION) 653 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION)
647 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW; 654 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_DRAW;
648 655
649 has_pending_tree_ = false; 656 has_pending_tree_ = false;
650 pending_tree_is_ready_for_activation_ = false; 657 pending_tree_is_ready_for_activation_ = false;
651 active_tree_needs_first_draw_ = true; 658 active_tree_needs_first_draw_ = true;
652 needs_redraw_ = true; 659 needs_redraw_ = true;
653 } 660 }
654 661
655 void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) { 662 void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) {
656 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 663 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
657 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; 664 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
658 665
666 if (commit_state_ == COMMIT_STATE_WAITING_FOR_DRAW)
667 commit_state_ = COMMIT_STATE_IDLE;
668
659 needs_redraw_ = false; 669 needs_redraw_ = false;
660 active_tree_needs_first_draw_ = false; 670 active_tree_needs_first_draw_ = false;
661 671
662 if (did_request_swap) 672 if (did_request_swap)
663 last_frame_number_swap_requested_ = current_frame_number_; 673 last_frame_number_swap_requested_ = current_frame_number_;
664 } 674 }
665 675
666 void SchedulerStateMachine::UpdateStateOnManageTiles() { 676 void SchedulerStateMachine::UpdateStateOnManageTiles() {
667 needs_manage_tiles_ = false; 677 needs_manage_tiles_ = false;
668 } 678 }
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 } 994 }
985 995
986 void SchedulerStateMachine::SetNeedsCommit() { 996 void SchedulerStateMachine::SetNeedsCommit() {
987 needs_commit_ = true; 997 needs_commit_ = true;
988 } 998 }
989 999
990 void SchedulerStateMachine::NotifyReadyToCommit() { 1000 void SchedulerStateMachine::NotifyReadyToCommit() {
991 DCHECK(commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED) 1001 DCHECK(commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED)
992 << AsValue()->ToString(); 1002 << AsValue()->ToString();
993 commit_state_ = COMMIT_STATE_READY_TO_COMMIT; 1003 commit_state_ = COMMIT_STATE_READY_TO_COMMIT;
1004 // In main thread low latency mode, commit should happen right after
1005 // BeginFrame, meaning when this function is called, next action should be
1006 // commit.
1007 if (settings_.main_thread_should_always_be_low_latency)
1008 DCHECK(ShouldCommit());
994 } 1009 }
995 1010
996 void SchedulerStateMachine::BeginMainFrameAborted(bool did_handle) { 1011 void SchedulerStateMachine::BeginMainFrameAborted(bool did_handle) {
997 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); 1012 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT);
998 if (did_handle) { 1013 if (did_handle) {
999 bool commit_was_aborted = true; 1014 bool commit_was_aborted = true;
1000 UpdateStateOnCommit(commit_was_aborted); 1015 UpdateStateOnCommit(commit_was_aborted);
1001 } else { 1016 } else {
1002 commit_state_ = COMMIT_STATE_IDLE; 1017 commit_state_ = COMMIT_STATE_IDLE;
1003 SetNeedsCommit(); 1018 SetNeedsCommit();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 static_cast<int>(begin_impl_frame_state_), 1078 static_cast<int>(begin_impl_frame_state_),
1064 static_cast<int>(commit_state_), 1079 static_cast<int>(commit_state_),
1065 has_pending_tree_ ? 'T' : 'F', 1080 has_pending_tree_ ? 'T' : 'F',
1066 pending_tree_is_ready_for_activation_ ? 'T' : 'F', 1081 pending_tree_is_ready_for_activation_ ? 'T' : 'F',
1067 active_tree_needs_first_draw_ ? 'T' : 'F', 1082 active_tree_needs_first_draw_ ? 'T' : 'F',
1068 max_pending_swaps_, 1083 max_pending_swaps_,
1069 pending_swaps_); 1084 pending_swaps_);
1070 } 1085 }
1071 1086
1072 } // namespace cc 1087 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698