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

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

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