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

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

Issue 423773002: Unified BeginFrame scheduling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 2 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
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 29 matching lines...) Expand all
40 visible_(false), 40 visible_(false),
41 can_start_(false), 41 can_start_(false),
42 can_draw_(false), 42 can_draw_(false),
43 has_pending_tree_(false), 43 has_pending_tree_(false),
44 pending_tree_is_ready_for_activation_(false), 44 pending_tree_is_ready_for_activation_(false),
45 active_tree_needs_first_draw_(false), 45 active_tree_needs_first_draw_(false),
46 did_create_and_initialize_first_output_surface_(false), 46 did_create_and_initialize_first_output_surface_(false),
47 impl_latency_takes_priority_(false), 47 impl_latency_takes_priority_(false),
48 skip_next_begin_main_frame_to_reduce_latency_(false), 48 skip_next_begin_main_frame_to_reduce_latency_(false),
49 skip_begin_main_frame_to_reduce_latency_(false), 49 skip_begin_main_frame_to_reduce_latency_(false),
50 continuous_painting_(false) { 50 continuous_painting_(false),
51 children_need_begin_frames_(false) {
51 } 52 }
52 53
53 const char* SchedulerStateMachine::OutputSurfaceStateToString( 54 const char* SchedulerStateMachine::OutputSurfaceStateToString(
54 OutputSurfaceState state) { 55 OutputSurfaceState state) {
55 switch (state) { 56 switch (state) {
56 case OUTPUT_SURFACE_ACTIVE: 57 case OUTPUT_SURFACE_ACTIVE:
57 return "OUTPUT_SURFACE_ACTIVE"; 58 return "OUTPUT_SURFACE_ACTIVE";
58 case OUTPUT_SURFACE_LOST: 59 case OUTPUT_SURFACE_LOST:
59 return "OUTPUT_SURFACE_LOST"; 60 return "OUTPUT_SURFACE_LOST";
60 case OUTPUT_SURFACE_CREATING: 61 case OUTPUT_SURFACE_CREATING:
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { 706 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() {
706 skip_next_begin_main_frame_to_reduce_latency_ = true; 707 skip_next_begin_main_frame_to_reduce_latency_ = true;
707 } 708 }
708 709
709 bool SchedulerStateMachine::BeginFrameNeeded() const { 710 bool SchedulerStateMachine::BeginFrameNeeded() const {
710 // Proactive BeginFrames are bad for the synchronous compositor because we 711 // Proactive BeginFrames are bad for the synchronous compositor because we
711 // have to draw when we get the BeginFrame and could end up drawing many 712 // have to draw when we get the BeginFrame and could end up drawing many
712 // duplicate frames if our new frame isn't ready in time. 713 // duplicate frames if our new frame isn't ready in time.
713 // To poll for state with the synchronous compositor without having to draw, 714 // To poll for state with the synchronous compositor without having to draw,
714 // we rely on ShouldPollForAnticipatedDrawTriggers instead. 715 // we rely on ShouldPollForAnticipatedDrawTriggers instead.
715 if (!SupportsProactiveBeginFrame()) 716 if (!SupportsProactiveBeginFrame()) {
717 DCHECK(!BeginFrameNeededToChildren());
716 return BeginFrameNeededToAnimateOrDraw(); 718 return BeginFrameNeededToAnimateOrDraw();
719 }
717 720
718 return BeginFrameNeededToAnimateOrDraw() || ProactiveBeginFrameWanted(); 721 return (BeginFrameNeededToAnimateOrDraw() || BeginFrameNeededToChildren() ||
722 ProactiveBeginFrameWanted());
719 } 723 }
720 724
721 bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const { 725 bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const {
722 // ShouldPollForAnticipatedDrawTriggers is what we use in place of 726 // ShouldPollForAnticipatedDrawTriggers is what we use in place of
723 // ProactiveBeginFrameWanted when we are using the synchronous 727 // ProactiveBeginFrameWanted when we are using the synchronous
724 // compositor. 728 // compositor.
725 if (!SupportsProactiveBeginFrame()) { 729 if (!SupportsProactiveBeginFrame()) {
726 return !BeginFrameNeededToAnimateOrDraw() && ProactiveBeginFrameWanted(); 730 return !BeginFrameNeededToAnimateOrDraw() && ProactiveBeginFrameWanted();
727 } 731 }
728 732
729 // Non synchronous compositors should rely on 733 // Non synchronous compositors should rely on
730 // ProactiveBeginFrameWanted to poll for state instead. 734 // ProactiveBeginFrameWanted to poll for state instead.
731 return false; 735 return false;
732 } 736 }
733 737
734 // Note: If SupportsProactiveBeginFrame is false, the scheduler should poll 738 // Note: If SupportsProactiveBeginFrame is false, the scheduler should poll
735 // for changes in it's draw state so it can request a BeginFrame when it's 739 // for changes in it's draw state so it can request a BeginFrame when it's
736 // actually ready. 740 // actually ready.
737 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const { 741 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const {
738 // It is undesirable to proactively request BeginFrames if we are 742 // It is undesirable to proactively request BeginFrames if we are
739 // using a synchronous compositor because we *must* draw for every 743 // using a synchronous compositor because we *must* draw for every
740 // BeginFrame, which could cause duplicate draws. 744 // BeginFrame, which could cause duplicate draws.
741 return !settings_.using_synchronous_renderer_compositor; 745 return !settings_.using_synchronous_renderer_compositor;
742 } 746 }
743 747
748 void SchedulerStateMachine::SetChildrenNeedBeginFrames(
749 bool children_need_begin_frames) {
750 #if !defined(OS_ANDROID) && !defined(OS_MACOSX)
751 DCHECK(settings_.begin_frame_publisher && !settings_.begin_frame_receiver);
752 #endif
753 children_need_begin_frames_ = children_need_begin_frames;
754 }
755
744 // These are the cases where we definitely (or almost definitely) have a 756 // These are the cases where we definitely (or almost definitely) have a
745 // new frame to animate and/or draw and can draw. 757 // new frame to animate and/or draw and can draw.
746 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { 758 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const {
747 // The output surface is the provider of BeginImplFrames, so we are not going 759 // The output surface is the provider of BeginImplFrames, so we are not going
748 // to get them even if we ask for them. 760 // to get them even if we ask for them.
749 if (!HasInitializedOutputSurface()) 761 if (!HasInitializedOutputSurface())
750 return false; 762 return false;
751 763
752 // If we can't draw, don't tick until we are notified that we can draw again. 764 // If we can't draw, don't tick until we are notified that we can draw again.
753 if (!can_draw_) 765 if (!can_draw_)
(...skipping 13 matching lines...) Expand all
767 // additional visible tiles. 779 // additional visible tiles.
768 if (swap_used_incomplete_tile_) 780 if (swap_used_incomplete_tile_)
769 return true; 781 return true;
770 782
771 if (needs_animate_) 783 if (needs_animate_)
772 return true; 784 return true;
773 785
774 return needs_redraw_; 786 return needs_redraw_;
775 } 787 }
776 788
789 bool SchedulerStateMachine::BeginFrameNeededToChildren() const {
790 if (!HasInitializedOutputSurface())
791 return false;
792
793 // If we can't draw, don't tick until we are notified that we can draw again.
794 if (!can_draw_)
795 return false;
796
797 return children_need_begin_frames_;
798 }
799
777 // These are cases where we are very likely to draw soon, but might not 800 // These are cases where we are very likely to draw soon, but might not
778 // actually have a new frame to draw when we receive the next BeginImplFrame. 801 // actually have a new frame to draw when we receive the next BeginImplFrame.
779 // Proactively requesting the BeginImplFrame helps hide the round trip latency 802 // Proactively requesting the BeginImplFrame helps hide the round trip latency
780 // of the SetNeedsBeginFrame request that has to go to the Browser. 803 // of the SetNeedsBeginFrame request that has to go to the Browser.
781 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { 804 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const {
782 // The output surface is the provider of BeginImplFrames, 805 // The output surface is the provider of BeginImplFrames,
783 // so we are not going to get them even if we ask for them. 806 // so we are not going to get them even if we ask for them.
784 if (!HasInitializedOutputSurface()) 807 if (!HasInitializedOutputSurface())
785 return false; 808 return false;
786 809
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 static_cast<int>(begin_impl_frame_state_), 1117 static_cast<int>(begin_impl_frame_state_),
1095 static_cast<int>(commit_state_), 1118 static_cast<int>(commit_state_),
1096 has_pending_tree_ ? 'T' : 'F', 1119 has_pending_tree_ ? 'T' : 'F',
1097 pending_tree_is_ready_for_activation_ ? 'T' : 'F', 1120 pending_tree_is_ready_for_activation_ ? 'T' : 'F',
1098 active_tree_needs_first_draw_ ? 'T' : 'F', 1121 active_tree_needs_first_draw_ ? 'T' : 'F',
1099 max_pending_swaps_, 1122 max_pending_swaps_,
1100 pending_swaps_); 1123 pending_swaps_);
1101 } 1124 }
1102 1125
1103 } // namespace cc 1126 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698