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

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

Issue 337693005: cc: Control defer_commits logic by Scheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 28 matching lines...) Expand all
39 visible_(false), 39 visible_(false),
40 can_start_(false), 40 can_start_(false),
41 can_draw_(false), 41 can_draw_(false),
42 has_pending_tree_(false), 42 has_pending_tree_(false),
43 pending_tree_is_ready_for_activation_(false), 43 pending_tree_is_ready_for_activation_(false),
44 active_tree_needs_first_draw_(false), 44 active_tree_needs_first_draw_(false),
45 did_create_and_initialize_first_output_surface_(false), 45 did_create_and_initialize_first_output_surface_(false),
46 smoothness_takes_priority_(false), 46 smoothness_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 defer_commits_(false) {
50 } 51 }
51 52
52 const char* SchedulerStateMachine::OutputSurfaceStateToString( 53 const char* SchedulerStateMachine::OutputSurfaceStateToString(
53 OutputSurfaceState state) { 54 OutputSurfaceState state) {
54 switch (state) { 55 switch (state) {
55 case OUTPUT_SURFACE_ACTIVE: 56 case OUTPUT_SURFACE_ACTIVE:
56 return "OUTPUT_SURFACE_ACTIVE"; 57 return "OUTPUT_SURFACE_ACTIVE";
57 case OUTPUT_SURFACE_LOST: 58 case OUTPUT_SURFACE_LOST:
58 return "OUTPUT_SURFACE_LOST"; 59 return "OUTPUT_SURFACE_LOST";
59 case OUTPUT_SURFACE_CREATING: 60 case OUTPUT_SURFACE_CREATING:
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 did_create_and_initialize_first_output_surface_); 230 did_create_and_initialize_first_output_surface_);
230 minor_state->SetBoolean("smoothness_takes_priority", 231 minor_state->SetBoolean("smoothness_takes_priority",
231 smoothness_takes_priority_); 232 smoothness_takes_priority_);
232 minor_state->SetBoolean("main_thread_is_in_high_latency_mode", 233 minor_state->SetBoolean("main_thread_is_in_high_latency_mode",
233 MainThreadIsInHighLatencyMode()); 234 MainThreadIsInHighLatencyMode());
234 minor_state->SetBoolean("skip_begin_main_frame_to_reduce_latency", 235 minor_state->SetBoolean("skip_begin_main_frame_to_reduce_latency",
235 skip_begin_main_frame_to_reduce_latency_); 236 skip_begin_main_frame_to_reduce_latency_);
236 minor_state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency", 237 minor_state->SetBoolean("skip_next_begin_main_frame_to_reduce_latency",
237 skip_next_begin_main_frame_to_reduce_latency_); 238 skip_next_begin_main_frame_to_reduce_latency_);
238 minor_state->SetBoolean("continuous_painting", continuous_painting_); 239 minor_state->SetBoolean("continuous_painting", continuous_painting_);
240 minor_state->SetBoolean("defer_commits", defer_commits_);
239 state->Set("minor_state", minor_state.release()); 241 state->Set("minor_state", minor_state.release());
240 242
241 return state.PassAs<base::Value>(); 243 return state.PassAs<base::Value>();
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 ManageTiles funnel. 249 // "Drain" the ManageTiles funnel.
248 if (manage_tiles_funnel_ > 0) 250 if (manage_tiles_funnel_ > 0)
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 // because of smoothness_takes_priority. 433 // because of smoothness_takes_priority.
432 if (smoothness_takes_priority_ && 434 if (smoothness_takes_priority_ &&
433 (has_pending_tree_ || active_tree_needs_first_draw_)) { 435 (has_pending_tree_ || active_tree_needs_first_draw_)) {
434 return false; 436 return false;
435 } 437 }
436 438
437 // We do not need commits if we are not visible. 439 // We do not need commits if we are not visible.
438 if (!visible_) 440 if (!visible_)
439 return false; 441 return false;
440 442
443 // We do not need commits if commits are deferred.
444 if (defer_commits_)
445 return false;
446
441 // We want to start the first commit after we get a new output surface ASAP. 447 // We want to start the first commit after we get a new output surface ASAP.
442 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) 448 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT)
443 return true; 449 return true;
444 450
445 // We should not send BeginMainFrame while we are in 451 // We should not send BeginMainFrame while we are in
446 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new 452 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new
447 // user input arriving soon. 453 // user input arriving soon.
448 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main 454 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main
449 // thread isn't consuming user input. 455 // thread isn't consuming user input.
450 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE && 456 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE &&
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 // Note: If SupportsProactiveBeginFrame is false, the scheduler should poll 733 // Note: If SupportsProactiveBeginFrame is false, the scheduler should poll
728 // for changes in it's draw state so it can request a BeginFrame when it's 734 // for changes in it's draw state so it can request a BeginFrame when it's
729 // actually ready. 735 // actually ready.
730 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const { 736 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const {
731 // It is undesirable to proactively request BeginFrames if we are 737 // It is undesirable to proactively request BeginFrames if we are
732 // using a synchronous compositor because we *must* draw for every 738 // using a synchronous compositor because we *must* draw for every
733 // BeginFrame, which could cause duplicate draws. 739 // BeginFrame, which could cause duplicate draws.
734 return !settings_.using_synchronous_renderer_compositor; 740 return !settings_.using_synchronous_renderer_compositor;
735 } 741 }
736 742
743 void SchedulerStateMachine::SetDeferCommits(bool defer_commits) {
744 defer_commits_ = defer_commits;
745 }
746
737 // These are the cases where we definitely (or almost definitely) have a 747 // These are the cases where we definitely (or almost definitely) have a
738 // new frame to animate and/or draw and can draw. 748 // new frame to animate and/or draw and can draw.
739 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { 749 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const {
740 // The output surface is the provider of BeginImplFrames, so we are not going 750 // The output surface is the provider of BeginImplFrames, so we are not going
741 // to get them even if we ask for them. 751 // to get them even if we ask for them.
742 if (!HasInitializedOutputSurface()) 752 if (!HasInitializedOutputSurface())
743 return false; 753 return false;
744 754
745 // If we can't draw, don't tick until we are notified that we can draw again. 755 // If we can't draw, don't tick until we are notified that we can draw again.
746 if (!can_draw_) 756 if (!can_draw_)
747 return false; 757 return false;
748 758
759 if (defer_commits_)
brianderson 2014/06/17 15:57:01 Comment?
simonhong 2014/06/18 21:52:05 Done.
760 return false;
761
749 // The forced draw respects our normal draw scheduling, so we need to 762 // The forced draw respects our normal draw scheduling, so we need to
750 // request a BeginImplFrame for it. 763 // request a BeginImplFrame for it.
751 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 764 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
752 return true; 765 return true;
753 766
754 // There's no need to produce frames if we are not visible. 767 // There's no need to produce frames if we are not visible.
755 if (!visible_) 768 if (!visible_)
756 return false; 769 return false;
757 770
758 // We need to draw a more complete frame than we did the last BeginImplFrame, 771 // We need to draw a more complete frame than we did the last BeginImplFrame,
(...skipping 15 matching lines...) Expand all
774 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { 787 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const {
775 // The output surface is the provider of BeginImplFrames, 788 // The output surface is the provider of BeginImplFrames,
776 // so we are not going to get them even if we ask for them. 789 // so we are not going to get them even if we ask for them.
777 if (!HasInitializedOutputSurface()) 790 if (!HasInitializedOutputSurface())
778 return false; 791 return false;
779 792
780 // Do not be proactive when invisible. 793 // Do not be proactive when invisible.
781 if (!visible_) 794 if (!visible_)
782 return false; 795 return false;
783 796
797 if (defer_commits_)
brianderson 2014/06/17 15:57:01 Comment?
simonhong 2014/06/18 21:52:05 Done.
798 return false;
799
784 // We should proactively request a BeginImplFrame if a commit is pending 800 // We should proactively request a BeginImplFrame if a commit is pending
785 // because we will want to draw if the commit completes quickly. 801 // because we will want to draw if the commit completes quickly.
786 if (needs_commit_ || commit_state_ != COMMIT_STATE_IDLE) 802 if (needs_commit_ || commit_state_ != COMMIT_STATE_IDLE)
787 return true; 803 return true;
788 804
789 // If the pending tree activates quickly, we'll want a BeginImplFrame soon 805 // If the pending tree activates quickly, we'll want a BeginImplFrame soon
790 // to draw the new active tree. 806 // to draw the new active tree.
791 if (has_pending_tree_) 807 if (has_pending_tree_)
792 return true; 808 return true;
793 809
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 case OUTPUT_SURFACE_ACTIVE: 1086 case OUTPUT_SURFACE_ACTIVE:
1071 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 1087 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
1072 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 1088 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
1073 return true; 1089 return true;
1074 } 1090 }
1075 NOTREACHED(); 1091 NOTREACHED();
1076 return false; 1092 return false;
1077 } 1093 }
1078 1094
1079 } // namespace cc 1095 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698