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

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

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/debug/trace_event.h"
8 #include "base/debug/trace_event_argument.h"
9 #include "base/format_macros.h" 7 #include "base/format_macros.h"
10 #include "base/logging.h" 8 #include "base/logging.h"
11 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/trace_event.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),
(...skipping 19 matching lines...) Expand all
41 has_pending_tree_(false), 41 has_pending_tree_(false),
42 pending_tree_is_ready_for_activation_(false), 42 pending_tree_is_ready_for_activation_(false),
43 active_tree_needs_first_draw_(false), 43 active_tree_needs_first_draw_(false),
44 did_commit_after_animating_(false), 44 did_commit_after_animating_(false),
45 did_create_and_initialize_first_output_surface_(false), 45 did_create_and_initialize_first_output_surface_(false),
46 impl_latency_takes_priority_(false), 46 impl_latency_takes_priority_(false),
47 skip_next_begin_main_frame_to_reduce_latency_(false), 47 skip_next_begin_main_frame_to_reduce_latency_(false),
48 skip_begin_main_frame_to_reduce_latency_(false), 48 skip_begin_main_frame_to_reduce_latency_(false),
49 continuous_painting_(false), 49 continuous_painting_(false),
50 impl_latency_takes_priority_on_battery_(false), 50 impl_latency_takes_priority_on_battery_(false),
51 children_need_begin_frames_(false) { 51 children_need_begin_frames_(false),
52 defer_commits_(false) {
52 } 53 }
53 54
54 const char* SchedulerStateMachine::OutputSurfaceStateToString( 55 const char* SchedulerStateMachine::OutputSurfaceStateToString(
55 OutputSurfaceState state) { 56 OutputSurfaceState state) {
56 switch (state) { 57 switch (state) {
57 case OUTPUT_SURFACE_ACTIVE: 58 case OUTPUT_SURFACE_ACTIVE:
58 return "OUTPUT_SURFACE_ACTIVE"; 59 return "OUTPUT_SURFACE_ACTIVE";
59 case OUTPUT_SURFACE_LOST: 60 case OUTPUT_SURFACE_LOST:
60 return "OUTPUT_SURFACE_LOST"; 61 return "OUTPUT_SURFACE_LOST";
61 case OUTPUT_SURFACE_CREATING: 62 case OUTPUT_SURFACE_CREATING:
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 state->SetBoolean("main_thread_is_in_high_latency_mode", 232 state->SetBoolean("main_thread_is_in_high_latency_mode",
232 MainThreadIsInHighLatencyMode()); 233 MainThreadIsInHighLatencyMode());
233 state->SetBoolean("skip_begin_main_frame_to_reduce_latency", 234 state->SetBoolean("skip_begin_main_frame_to_reduce_latency",
234 skip_begin_main_frame_to_reduce_latency_); 235 skip_begin_main_frame_to_reduce_latency_);
235 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", 236 state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency",
236 skip_next_begin_main_frame_to_reduce_latency_); 237 skip_next_begin_main_frame_to_reduce_latency_);
237 state->SetBoolean("continuous_painting", continuous_painting_); 238 state->SetBoolean("continuous_painting", continuous_painting_);
238 state->SetBoolean("impl_latency_takes_priority_on_battery", 239 state->SetBoolean("impl_latency_takes_priority_on_battery",
239 impl_latency_takes_priority_on_battery_); 240 impl_latency_takes_priority_on_battery_);
240 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_); 241 state->SetBoolean("children_need_begin_frames", children_need_begin_frames_);
242 state->SetBoolean("defer_commits", defer_commits_);
241 state->EndDictionary(); 243 state->EndDictionary();
242 } 244 }
243 245
244 void SchedulerStateMachine::AdvanceCurrentFrameNumber() { 246 void SchedulerStateMachine::AdvanceCurrentFrameNumber() {
245 current_frame_number_++; 247 current_frame_number_++;
246 248
247 // "Drain" the PrepareTiles funnel. 249 // "Drain" the PrepareTiles funnel.
248 if (prepare_tiles_funnel_ > 0) 250 if (prepare_tiles_funnel_ > 0)
249 prepare_tiles_funnel_--; 251 prepare_tiles_funnel_--;
250 252
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 409 }
408 410
409 bool SchedulerStateMachine::CouldSendBeginMainFrame() const { 411 bool SchedulerStateMachine::CouldSendBeginMainFrame() const {
410 if (!needs_commit_) 412 if (!needs_commit_)
411 return false; 413 return false;
412 414
413 // We can not perform commits if we are not visible. 415 // We can not perform commits if we are not visible.
414 if (!visible_) 416 if (!visible_)
415 return false; 417 return false;
416 418
419 // Do not make a new commits when it is deferred.
420 if (defer_commits_)
421 return false;
422
417 return true; 423 return true;
418 } 424 }
419 425
420 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const { 426 bool SchedulerStateMachine::ShouldSendBeginMainFrame() const {
421 if (!CouldSendBeginMainFrame()) 427 if (!CouldSendBeginMainFrame())
422 return false; 428 return false;
423 429
424 // Only send BeginMainFrame when there isn't another commit pending already. 430 // Only send BeginMainFrame when there isn't another commit pending already.
425 if (commit_state_ != COMMIT_STATE_IDLE) 431 if (commit_state_ != COMMIT_STATE_IDLE)
426 return false; 432 return false;
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 // BeginFrame, which could cause duplicate draws. 768 // BeginFrame, which could cause duplicate draws.
763 return !settings_.using_synchronous_renderer_compositor; 769 return !settings_.using_synchronous_renderer_compositor;
764 } 770 }
765 771
766 void SchedulerStateMachine::SetChildrenNeedBeginFrames( 772 void SchedulerStateMachine::SetChildrenNeedBeginFrames(
767 bool children_need_begin_frames) { 773 bool children_need_begin_frames) {
768 DCHECK(settings_.forward_begin_frames_to_children); 774 DCHECK(settings_.forward_begin_frames_to_children);
769 children_need_begin_frames_ = children_need_begin_frames; 775 children_need_begin_frames_ = children_need_begin_frames;
770 } 776 }
771 777
778 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) {
779 defer_commits_ = defer_commits;
780 }
781
772 // These are the cases where we definitely (or almost definitely) have a 782 // These are the cases where we definitely (or almost definitely) have a
773 // new frame to animate and/or draw and can draw. 783 // new frame to animate and/or draw and can draw.
774 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { 784 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const {
775 // The forced draw respects our normal draw scheduling, so we need to 785 // The forced draw respects our normal draw scheduling, so we need to
776 // request a BeginImplFrame for it. 786 // request a BeginImplFrame for it.
777 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 787 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
778 return true; 788 return true;
779 789
780 return needs_animate_ || needs_redraw_; 790 return needs_animate_ || needs_redraw_;
781 } 791 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 // commit. 1055 // commit.
1046 if (settings_.main_thread_should_always_be_low_latency) 1056 if (settings_.main_thread_should_always_be_low_latency)
1047 DCHECK(ShouldCommit()); 1057 DCHECK(ShouldCommit());
1048 } 1058 }
1049 1059
1050 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) { 1060 void SchedulerStateMachine::BeginMainFrameAborted(CommitEarlyOutReason reason) {
1051 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT); 1061 DCHECK_EQ(commit_state_, COMMIT_STATE_BEGIN_MAIN_FRAME_SENT);
1052 switch (reason) { 1062 switch (reason) {
1053 case CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST: 1063 case CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST:
1054 case CommitEarlyOutReason::ABORTED_NOT_VISIBLE: 1064 case CommitEarlyOutReason::ABORTED_NOT_VISIBLE:
1065 case CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT:
1055 commit_state_ = COMMIT_STATE_IDLE; 1066 commit_state_ = COMMIT_STATE_IDLE;
1056 SetNeedsCommit(); 1067 SetNeedsCommit();
1057 return; 1068 return;
1058 case CommitEarlyOutReason::FINISHED_NO_UPDATES: 1069 case CommitEarlyOutReason::FINISHED_NO_UPDATES:
1059 bool commit_has_no_updates = true; 1070 bool commit_has_no_updates = true;
1060 UpdateStateOnCommit(commit_has_no_updates); 1071 UpdateStateOnCommit(commit_has_no_updates);
1061 return; 1072 return;
1062 } 1073 }
1063 } 1074 }
1064 1075
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 static_cast<int>(begin_impl_frame_state_), 1132 static_cast<int>(begin_impl_frame_state_),
1122 static_cast<int>(commit_state_), 1133 static_cast<int>(commit_state_),
1123 has_pending_tree_ ? 'T' : 'F', 1134 has_pending_tree_ ? 'T' : 'F',
1124 pending_tree_is_ready_for_activation_ ? 'T' : 'F', 1135 pending_tree_is_ready_for_activation_ ? 'T' : 'F',
1125 active_tree_needs_first_draw_ ? 'T' : 'F', 1136 active_tree_needs_first_draw_ ? 'T' : 'F',
1126 max_pending_swaps_, 1137 max_pending_swaps_,
1127 pending_swaps_); 1138 pending_swaps_);
1128 } 1139 }
1129 1140
1130 } // namespace cc 1141 } // 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