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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 // Note: If SupportsProactiveBeginFrame is false, the scheduler should poll | 727 // 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 | 728 // for changes in it's draw state so it can request a BeginFrame when it's |
728 // actually ready. | 729 // actually ready. |
729 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const { | 730 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const { |
730 // It is undesirable to proactively request BeginFrames if we are | 731 // It is undesirable to proactively request BeginFrames if we are |
731 // using a synchronous compositor because we *must* draw for every | 732 // using a synchronous compositor because we *must* draw for every |
732 // BeginFrame, which could cause duplicate draws. | 733 // BeginFrame, which could cause duplicate draws. |
733 return !settings_.using_synchronous_renderer_compositor; | 734 return !settings_.using_synchronous_renderer_compositor; |
734 } | 735 } |
735 | 736 |
| 737 void SchedulerStateMachine::SetChildrenNeedBeginFrames( |
| 738 bool children_need_begin_frames) { |
| 739 DCHECK(settings_.begin_frame_publisher); |
| 740 children_need_begin_frames_ = children_need_begin_frames; |
| 741 } |
| 742 |
736 // These are the cases where we definitely (or almost definitely) have a | 743 // These are the cases where we definitely (or almost definitely) have a |
737 // new frame to animate and/or draw and can draw. | 744 // new frame to animate and/or draw and can draw. |
738 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { | 745 bool SchedulerStateMachine::BeginFrameNeededToAnimateOrDraw() const { |
739 // The output surface is the provider of BeginImplFrames, so we are not going | 746 // The output surface is the provider of BeginImplFrames, so we are not going |
740 // to get them even if we ask for them. | 747 // to get them even if we ask for them. |
741 if (!HasInitializedOutputSurface()) | 748 if (!HasInitializedOutputSurface()) |
742 return false; | 749 return false; |
743 | 750 |
744 // If we can't draw, don't tick until we are notified that we can draw again. | 751 // If we can't draw, don't tick until we are notified that we can draw again. |
745 if (!can_draw_) | 752 if (!can_draw_) |
746 return false; | 753 return false; |
747 | 754 |
| 755 if (children_need_begin_frames_) |
| 756 return true; |
| 757 |
748 // The forced draw respects our normal draw scheduling, so we need to | 758 // The forced draw respects our normal draw scheduling, so we need to |
749 // request a BeginImplFrame for it. | 759 // request a BeginImplFrame for it. |
750 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) | 760 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) |
751 return true; | 761 return true; |
752 | 762 |
753 // There's no need to produce frames if we are not visible. | 763 // There's no need to produce frames if we are not visible. |
754 if (!visible_) | 764 if (!visible_) |
755 return false; | 765 return false; |
756 | 766 |
757 // We need to draw a more complete frame than we did the last BeginImplFrame, | 767 // We need to draw a more complete frame than we did the last BeginImplFrame, |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 case OUTPUT_SURFACE_ACTIVE: | 1083 case OUTPUT_SURFACE_ACTIVE: |
1074 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: | 1084 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: |
1075 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: | 1085 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: |
1076 return true; | 1086 return true; |
1077 } | 1087 } |
1078 NOTREACHED(); | 1088 NOTREACHED(); |
1079 return false; | 1089 return false; |
1080 } | 1090 } |
1081 | 1091 |
1082 } // namespace cc | 1092 } // namespace cc |
OLD | NEW |