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 #ifndef CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 5 #ifndef CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
6 #define CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 6 #define CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 bool CommitPending() const { | 52 bool CommitPending() const { |
53 return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS || | 53 return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS || |
54 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; | 54 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; |
55 } | 55 } |
56 | 56 |
57 bool RedrawPending() const { return needs_redraw_; } | 57 bool RedrawPending() const { return needs_redraw_; } |
58 | 58 |
59 enum Action { | 59 enum Action { |
60 ACTION_NONE, | 60 ACTION_NONE, |
61 ACTION_BEGIN_FRAME, | 61 ACTION_BEGIN_MAIN_FRAME, |
62 ACTION_COMMIT, | 62 ACTION_COMMIT, |
63 ACTION_CHECK_FOR_COMPLETED_TILE_UPLOADS, | 63 ACTION_CHECK_FOR_COMPLETED_TILE_UPLOADS, |
64 ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED, | 64 ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED, |
65 ACTION_DRAW_IF_POSSIBLE, | 65 ACTION_DRAW_IF_POSSIBLE, |
66 ACTION_DRAW_FORCED, | 66 ACTION_DRAW_FORCED, |
67 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 67 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
68 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, | 68 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, |
69 }; | 69 }; |
70 Action NextAction() const; | 70 Action NextAction() const; |
71 void UpdateState(Action action); | 71 void UpdateState(Action action); |
72 | 72 |
73 // Indicates whether the scheduler needs a vsync callback in order to make | 73 // Indicates whether the scheduler needs a BeginMainFrame callback in order to |
74 // progress. | 74 // make progress. |
75 bool VSyncCallbackNeeded() const; | 75 bool BeginMainFrameCallbackNeeded() const; |
76 | 76 |
77 // Indicates that the system has entered and left a vsync callback. | 77 // Indicates that the system has entered and left a BeginImplFrame callback. |
78 // The scheduler will not draw more than once in a given vsync callback. | 78 // The scheduler will not draw more than once in a given BeginImplFrame |
79 void DidEnterVSync(); | 79 // callback. |
80 void DidLeaveVSync(); | 80 void DidEnterBeginImplFrame(); |
| 81 void DidLeaveBeginImplFrame(); |
81 | 82 |
82 // Indicates whether the LayerTreeHostImpl is visible. | 83 // Indicates whether the LayerTreeHostImpl is visible. |
83 void SetVisible(bool visible); | 84 void SetVisible(bool visible); |
84 | 85 |
85 // Indicates that a redraw is required, either due to the impl tree changing | 86 // Indicates that a redraw is required, either due to the impl tree changing |
86 // or the screen being damaged and simply needing redisplay. | 87 // or the screen being damaged and simply needing redisplay. |
87 void SetNeedsRedraw(); | 88 void SetNeedsRedraw(); |
88 | 89 |
89 // As SetNeedsRedraw(), but ensures the draw will definitely happen even if | 90 // As SetNeedsRedraw(), but ensures the draw will definitely happen even if |
90 // we are not visible. | 91 // we are not visible. |
91 void SetNeedsForcedRedraw(); | 92 void SetNeedsForcedRedraw(); |
92 | 93 |
93 // Indicates that a redraw is required because we are currently rendering | 94 // Indicates that a redraw is required because we are currently rendering |
94 // with a low resolution or checkerboarded tile. | 95 // with a low resolution or checkerboarded tile. |
95 void DidSwapUseIncompleteTile(); | 96 void DidSwapUseIncompleteTile(); |
96 | 97 |
97 // Indicates whether ACTION_DRAW_IF_POSSIBLE drew to the screen or not. | 98 // Indicates whether ACTION_DRAW_IF_POSSIBLE drew to the screen or not. |
98 void DidDrawIfPossibleCompleted(bool success); | 99 void DidDrawIfPossibleCompleted(bool success); |
99 | 100 |
100 // Indicates that a new commit flow needs to be performed, either to pull | 101 // Indicates that a new commit flow needs to be performed, either to pull |
101 // updates from the main thread to the impl, or to push deltas from the impl | 102 // updates from the main thread to the impl, or to push deltas from the impl |
102 // thread to main. | 103 // thread to main. |
103 void SetNeedsCommit(); | 104 void SetNeedsCommit(); |
104 | 105 |
105 // As SetNeedsCommit(), but ensures the BeginFrame will definitely happen even | 106 // As SetNeedsCommit(), but ensures the BeginMainFrame will definitely happen |
106 // if we are not visible. After this call we expect to go through the forced | 107 // even if we are not visible. After this call we expect to go through the |
107 // commit flow and then return to waiting for a non-forced BeginFrame to | 108 // forced commit flow and then return to waiting for a non-forced |
108 // finish. | 109 // BeginMainFrame to finish. |
109 void SetNeedsForcedCommit(); | 110 void SetNeedsForcedCommit(); |
110 | 111 |
111 // Call this only in response to receiving an ACTION_BEGIN_FRAME | 112 // Call this only in response to receiving an ACTION_BEGIN_MAIN_FRAME |
112 // from NextAction. Indicates that all painting is complete. | 113 // from NextAction. Indicates that all painting is complete. |
113 void BeginFrameComplete(); | 114 void BeginMainFrameComplete(); |
114 | 115 |
115 // Call this only in response to receiving an ACTION_BEGIN_FRAME | 116 // Call this only in response to receiving an ACTION_BEGIN_MAIN_FRAME |
116 // from NextAction if the client rejects the BeginFrame message. | 117 // from NextAction if the client rejects the BeginMainFrame message. |
117 void BeginFrameAborted(); | 118 void BeginMainFrameAborted(); |
118 | 119 |
119 // Request exclusive access to the textures that back single buffered | 120 // Request exclusive access to the textures that back single buffered |
120 // layers on behalf of the main thread. Upon acquisition, | 121 // layers on behalf of the main thread. Upon acquisition, |
121 // ACTION_DRAW_IF_POSSIBLE will not draw until the main thread releases the | 122 // ACTION_DRAW_IF_POSSIBLE will not draw until the main thread releases the |
122 // textures to the impl thread by committing the layers. | 123 // textures to the impl thread by committing the layers. |
123 void SetMainThreadNeedsLayerTextures(); | 124 void SetMainThreadNeedsLayerTextures(); |
124 | 125 |
125 // Set that we can create the first OutputSurface and start the scheduler. | 126 // Set that we can create the first OutputSurface and start the scheduler. |
126 void SetCanStart() { can_start_ = true; } | 127 void SetCanStart() { can_start_ = true; } |
127 | 128 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 int last_frame_number_where_tree_activation_attempted_; | 172 int last_frame_number_where_tree_activation_attempted_; |
172 int last_frame_number_where_check_for_completed_tile_uploads_called_; | 173 int last_frame_number_where_check_for_completed_tile_uploads_called_; |
173 int consecutive_failed_draws_; | 174 int consecutive_failed_draws_; |
174 int maximum_number_of_failed_draws_before_draw_is_forced_; | 175 int maximum_number_of_failed_draws_before_draw_is_forced_; |
175 bool needs_redraw_; | 176 bool needs_redraw_; |
176 bool swap_used_incomplete_tile_; | 177 bool swap_used_incomplete_tile_; |
177 bool needs_forced_redraw_; | 178 bool needs_forced_redraw_; |
178 bool needs_forced_redraw_after_next_commit_; | 179 bool needs_forced_redraw_after_next_commit_; |
179 bool needs_commit_; | 180 bool needs_commit_; |
180 bool needs_forced_commit_; | 181 bool needs_forced_commit_; |
181 bool expect_immediate_begin_frame_; | 182 bool expect_immediate_begin_main_fame_; |
182 bool main_thread_needs_layer_textures_; | 183 bool main_thread_needs_layer_textures_; |
183 bool inside_vsync_; | 184 bool inside_begin_impl_frame_; |
184 bool visible_; | 185 bool visible_; |
185 bool can_start_; | 186 bool can_start_; |
186 bool can_draw_; | 187 bool can_draw_; |
187 bool has_pending_tree_; | 188 bool has_pending_tree_; |
188 bool draw_if_possible_failed_; | 189 bool draw_if_possible_failed_; |
189 TextureState texture_state_; | 190 TextureState texture_state_; |
190 OutputSurfaceState output_surface_state_; | 191 OutputSurfaceState output_surface_state_; |
191 bool did_create_and_initialize_first_output_surface_; | 192 bool did_create_and_initialize_first_output_surface_; |
192 | 193 |
193 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 194 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
194 }; | 195 }; |
195 | 196 |
196 } // namespace cc | 197 } // namespace cc |
197 | 198 |
198 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 199 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |