OLD | NEW |
---|---|
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 Loading... | |
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 smoothness_takes_priority_(false), | 47 smoothness_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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
698 skip_next_begin_main_frame_to_reduce_latency_ = true; | 699 skip_next_begin_main_frame_to_reduce_latency_ = true; |
699 } | 700 } |
700 | 701 |
701 bool SchedulerStateMachine::BeginFrameNeeded() const { | 702 bool SchedulerStateMachine::BeginFrameNeeded() const { |
702 // Proactive BeginFrames are bad for the synchronous compositor because we | 703 // Proactive BeginFrames are bad for the synchronous compositor because we |
703 // have to draw when we get the BeginFrame and could end up drawing many | 704 // have to draw when we get the BeginFrame and could end up drawing many |
704 // duplicate frames if our new frame isn't ready in time. | 705 // duplicate frames if our new frame isn't ready in time. |
705 // To poll for state with the synchronous compositor without having to draw, | 706 // To poll for state with the synchronous compositor without having to draw, |
706 // we rely on ShouldPollForAnticipatedDrawTriggers instead. | 707 // we rely on ShouldPollForAnticipatedDrawTriggers instead. |
707 if (!SupportsProactiveBeginFrame()) | 708 if (!SupportsProactiveBeginFrame()) |
708 return BeginFrameNeededToAnimateOrDraw(); | 709 return (BeginFrameNeededToAnimateOrDraw() || BeginFrameNeededToChildren()); |
brianderson
2014/08/28 02:48:07
This should not include BeginFrameNeededToChildren
simonhong
2014/09/03 21:02:23
Done.
| |
709 | 710 |
710 return BeginFrameNeededToAnimateOrDraw() || ProactiveBeginFrameWanted(); | 711 return (BeginFrameNeededToAnimateOrDraw() || |
712 BeginFrameNeededToChildren() || | |
brianderson
2014/08/28 02:48:07
BeginFrameNeededToChildren belongs in ProactiveBeg
simonhong
2014/09/03 21:02:23
How Browser knows whether Renderer is slow or not
brianderson
2014/09/04 18:45:45
Nevermind about my comment here. What you have is
| |
713 ProactiveBeginFrameWanted()); | |
711 } | 714 } |
712 | 715 |
713 bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const { | 716 bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const { |
714 // ShouldPollForAnticipatedDrawTriggers is what we use in place of | 717 // ShouldPollForAnticipatedDrawTriggers is what we use in place of |
715 // ProactiveBeginFrameWanted when we are using the synchronous | 718 // ProactiveBeginFrameWanted when we are using the synchronous |
716 // compositor. | 719 // compositor. |
717 if (!SupportsProactiveBeginFrame()) { | 720 if (!SupportsProactiveBeginFrame()) { |
718 return !BeginFrameNeededToAnimateOrDraw() && ProactiveBeginFrameWanted(); | 721 return !BeginFrameNeededToAnimateOrDraw() && ProactiveBeginFrameWanted(); |
719 } | 722 } |
720 | 723 |
721 // Non synchronous compositors should rely on | 724 // Non synchronous compositors should rely on |
722 // ProactiveBeginFrameWanted to poll for state instead. | 725 // ProactiveBeginFrameWanted to poll for state instead. |
723 return false; | 726 return false; |
724 } | 727 } |
725 | 728 |
726 // Note: If SupportsProactiveBeginFrame is false, the scheduler should poll | 729 // Note: If SupportsProactiveBeginFrame is false, the scheduler should poll |
727 // for changes in it's draw state so it can request a BeginFrame when it's | 730 // for changes in it's draw state so it can request a BeginFrame when it's |
728 // actually ready. | 731 // actually ready. |
729 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const { | 732 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const { |
730 // It is undesirable to proactively request BeginFrames if we are | 733 // It is undesirable to proactively request BeginFrames if we are |
731 // using a synchronous compositor because we *must* draw for every | 734 // using a synchronous compositor because we *must* draw for every |
732 // BeginFrame, which could cause duplicate draws. | 735 // BeginFrame, which could cause duplicate draws. |
733 return !settings_.using_synchronous_renderer_compositor; | 736 return !settings_.using_synchronous_renderer_compositor; |
734 } | 737 } |
735 | 738 |
739 void SchedulerStateMachine::SetChildrenNeedBeginFrames( | |
740 bool children_need_begin_frames) { | |
741 DCHECK(settings_.begin_frame_publisher && !settings_.begin_frame_receiver); | |
742 children_need_begin_frames_ = children_need_begin_frames; | |
743 } | |
744 | |
736 // These are the cases where we definitely (or almost definitely) have a | 745 // These are the cases where we definitely (or almost definitely) have a |
737 // new frame to animate and/or draw and can draw. | 746 // new frame to animate and/or draw and can draw. |
738 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { | 747 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { |
739 // The output surface is the provider of BeginImplFrames, so we are not going | 748 // The output surface is the provider of BeginImplFrames, so we are not going |
740 // to get them even if we ask for them. | 749 // to get them even if we ask for them. |
741 if (!HasInitializedOutputSurface()) | 750 if (!HasInitializedOutputSurface()) |
742 return false; | 751 return false; |
743 | 752 |
744 // If we can't draw, don't tick until we are notified that we can draw again. | 753 // If we can't draw, don't tick until we are notified that we can draw again. |
745 if (!can_draw_) | 754 if (!can_draw_) |
(...skipping 13 matching lines...) Expand all Loading... | |
759 // additional visible tiles. | 768 // additional visible tiles. |
760 if (swap_used_incomplete_tile_) | 769 if (swap_used_incomplete_tile_) |
761 return true; | 770 return true; |
762 | 771 |
763 if (needs_animate_) | 772 if (needs_animate_) |
764 return true; | 773 return true; |
765 | 774 |
766 return needs_redraw_; | 775 return needs_redraw_; |
767 } | 776 } |
768 | 777 |
778 bool SchedulerStateMachine::BeginFrameNeededToChildren() const { | |
779 if (!HasInitializedOutputSurface()) | |
780 return false; | |
781 | |
782 // If we can't draw, don't tick until we are notified that we can draw again. | |
783 if (!can_draw_) | |
784 return false; | |
785 | |
786 return children_need_begin_frames_; | |
787 } | |
788 | |
769 // These are cases where we are very likely to draw soon, but might not | 789 // These are cases where we are very likely to draw soon, but might not |
770 // actually have a new frame to draw when we receive the next BeginImplFrame. | 790 // actually have a new frame to draw when we receive the next BeginImplFrame. |
771 // Proactively requesting the BeginImplFrame helps hide the round trip latency | 791 // Proactively requesting the BeginImplFrame helps hide the round trip latency |
772 // of the SetNeedsBeginFrame request that has to go to the Browser. | 792 // of the SetNeedsBeginFrame request that has to go to the Browser. |
773 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { | 793 bool SchedulerStateMachine::ProactiveBeginFrameWanted() const { |
774 // The output surface is the provider of BeginImplFrames, | 794 // The output surface is the provider of BeginImplFrames, |
775 // so we are not going to get them even if we ask for them. | 795 // so we are not going to get them even if we ask for them. |
776 if (!HasInitializedOutputSurface()) | 796 if (!HasInitializedOutputSurface()) |
777 return false; | 797 return false; |
778 | 798 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 case OUTPUT_SURFACE_ACTIVE: | 1093 case OUTPUT_SURFACE_ACTIVE: |
1074 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: | 1094 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: |
1075 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: | 1095 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: |
1076 return true; | 1096 return true; |
1077 } | 1097 } |
1078 NOTREACHED(); | 1098 NOTREACHED(); |
1079 return false; | 1099 return false; |
1080 } | 1100 } |
1081 | 1101 |
1082 } // namespace cc | 1102 } // namespace cc |
OLD | NEW |