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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, | 93 ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, |
94 ACTION_COMMIT, | 94 ACTION_COMMIT, |
95 ACTION_UPDATE_VISIBLE_TILES, | 95 ACTION_UPDATE_VISIBLE_TILES, |
96 ACTION_ACTIVATE_PENDING_TREE, | 96 ACTION_ACTIVATE_PENDING_TREE, |
97 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, | 97 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, |
98 ACTION_DRAW_AND_SWAP_FORCED, | 98 ACTION_DRAW_AND_SWAP_FORCED, |
99 ACTION_DRAW_AND_SWAP_ABORT, | 99 ACTION_DRAW_AND_SWAP_ABORT, |
100 ACTION_DRAW_AND_READBACK, | 100 ACTION_DRAW_AND_READBACK, |
101 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 101 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
102 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, | 102 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, |
| 103 ACTION_MANAGE_TILES, |
103 }; | 104 }; |
104 static const char* ActionToString(Action action); | 105 static const char* ActionToString(Action action); |
105 | 106 |
106 scoped_ptr<base::Value> AsValue() const; | 107 scoped_ptr<base::Value> AsValue() const; |
107 | 108 |
108 Action NextAction() const; | 109 Action NextAction() const; |
109 void UpdateState(Action action); | 110 void UpdateState(Action action); |
110 void CheckInvariants(); | 111 void CheckInvariants(); |
111 | 112 |
112 // Indicates whether the main thread needs a begin frame callback in order to | 113 // Indicates whether the main thread needs a begin frame callback in order to |
113 // make progress. | 114 // make progress. |
114 bool BeginFrameNeededToDrawByImplThread() const; | 115 bool BeginFrameNeededToDrawByImplThread() const; |
115 bool ProactiveBeginFrameWantedByImplThread() const; | 116 bool ProactiveBeginFrameWantedByImplThread() const; |
116 | 117 |
117 // Indicates that the system has entered and left a BeginFrame callback. | 118 // Indicates that the system has entered and left a BeginFrame callback. |
118 // The scheduler will not draw more than once in a given BeginFrame | 119 // The scheduler will not draw more than once in a given BeginFrame |
119 // callback nor send more than one BeginFrame message. | 120 // callback nor send more than one BeginFrame message. |
120 void DidEnterBeginFrame(const BeginFrameArgs& args); | 121 void DidEnterBeginFrame(const BeginFrameArgs& args); |
121 void DidLeaveBeginFrame(); | 122 void DidLeaveBeginFrame(); |
122 bool inside_begin_frame() const { return inside_begin_frame_; } | 123 bool inside_begin_frame() const { return inside_begin_frame_; } |
123 | 124 |
124 // Indicates whether the LayerTreeHostImpl is visible. | 125 // Indicates whether the LayerTreeHostImpl is visible. |
125 void SetVisible(bool visible); | 126 void SetVisible(bool visible); |
126 | 127 |
127 // Indicates that a redraw is required, either due to the impl tree changing | 128 // Indicates that a redraw is required, either due to the impl tree changing |
128 // or the screen being damaged and simply needing redisplay. | 129 // or the screen being damaged and simply needing redisplay. |
129 void SetNeedsRedraw(); | 130 void SetNeedsRedraw(); |
130 | 131 |
| 132 // Indicates that manage-tiles is required. This guarantees another |
| 133 // ManageTiles will occur shortly (even if no redraw is required). |
| 134 void SetNeedsManageTiles(); |
| 135 |
131 // Indicates whether a redraw is required because we are currently rendering | 136 // Indicates whether a redraw is required because we are currently rendering |
132 // with a low resolution or checkerboarded tile. | 137 // with a low resolution or checkerboarded tile. |
133 void SetSwapUsedIncompleteTile(bool used_incomplete_tile); | 138 void SetSwapUsedIncompleteTile(bool used_incomplete_tile); |
134 | 139 |
135 // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen or | 140 // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen or |
136 // not. | 141 // not. |
137 void DidDrawIfPossibleCompleted(bool success); | 142 void DidDrawIfPossibleCompleted(bool success); |
138 | 143 |
139 // Indicates that a new commit flow needs to be performed, either to pull | 144 // Indicates that a new commit flow needs to be performed, either to pull |
140 // updates from the main thread to the impl, or to push deltas from the impl | 145 // updates from the main thread to the impl, or to push deltas from the impl |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bool PendingActivationsShouldBeForced() const; | 195 bool PendingActivationsShouldBeForced() const; |
191 | 196 |
192 bool ShouldBeginOutputSurfaceCreation() const; | 197 bool ShouldBeginOutputSurfaceCreation() const; |
193 bool ShouldDrawForced() const; | 198 bool ShouldDrawForced() const; |
194 bool ShouldDraw() const; | 199 bool ShouldDraw() const; |
195 bool ShouldActivatePendingTree() const; | 200 bool ShouldActivatePendingTree() const; |
196 bool ShouldAcquireLayerTexturesForMainThread() const; | 201 bool ShouldAcquireLayerTexturesForMainThread() const; |
197 bool ShouldUpdateVisibleTiles() const; | 202 bool ShouldUpdateVisibleTiles() const; |
198 bool ShouldSendBeginFrameToMainThread() const; | 203 bool ShouldSendBeginFrameToMainThread() const; |
199 bool ShouldCommit() const; | 204 bool ShouldCommit() const; |
| 205 bool ShouldManageTiles() const; |
200 | 206 |
201 bool HasDrawnAndSwappedThisFrame() const; | 207 bool HasDrawnAndSwappedThisFrame() const; |
202 bool HasActivatedPendingTreeThisFrame() const; | 208 bool HasActivatedPendingTreeThisFrame() const; |
203 bool HasUpdatedVisibleTilesThisFrame() const; | 209 bool HasUpdatedVisibleTilesThisFrame() const; |
204 bool HasSentBeginFrameToMainThreadThisFrame() const; | 210 bool HasSentBeginFrameToMainThreadThisFrame() const; |
205 | 211 |
206 void UpdateStateOnCommit(bool commit_was_aborted); | 212 void UpdateStateOnCommit(bool commit_was_aborted); |
207 void UpdateStateOnActivation(); | 213 void UpdateStateOnActivation(); |
208 void UpdateStateOnDraw(bool did_swap); | 214 void UpdateStateOnDraw(bool did_swap); |
| 215 void UpdateStateOnManageTiles(); |
209 | 216 |
210 const SchedulerSettings settings_; | 217 const SchedulerSettings settings_; |
211 | 218 |
212 OutputSurfaceState output_surface_state_; | 219 OutputSurfaceState output_surface_state_; |
213 CommitState commit_state_; | 220 CommitState commit_state_; |
214 TextureState texture_state_; | 221 TextureState texture_state_; |
215 ForcedRedrawOnTimeoutState forced_redraw_state_; | 222 ForcedRedrawOnTimeoutState forced_redraw_state_; |
216 SynchronousReadbackState readback_state_; | 223 SynchronousReadbackState readback_state_; |
217 | 224 |
218 int commit_count_; | 225 int commit_count_; |
219 int current_frame_number_; | 226 int current_frame_number_; |
220 int last_frame_number_where_begin_frame_sent_to_main_thread_; | 227 int last_frame_number_where_begin_frame_sent_to_main_thread_; |
221 int last_frame_number_swap_performed_; | 228 int last_frame_number_swap_performed_; |
222 int last_frame_number_where_update_visible_tiles_was_called_; | 229 int last_frame_number_where_update_visible_tiles_was_called_; |
223 int consecutive_failed_draws_; | 230 int consecutive_failed_draws_; |
224 bool needs_redraw_; | 231 bool needs_redraw_; |
| 232 bool needs_manage_tiles_; |
225 bool swap_used_incomplete_tile_; | 233 bool swap_used_incomplete_tile_; |
226 bool needs_commit_; | 234 bool needs_commit_; |
227 bool main_thread_needs_layer_textures_; | 235 bool main_thread_needs_layer_textures_; |
228 bool inside_begin_frame_; | 236 bool inside_begin_frame_; |
229 BeginFrameArgs last_begin_frame_args_; | 237 BeginFrameArgs last_begin_frame_args_; |
230 bool visible_; | 238 bool visible_; |
231 bool can_start_; | 239 bool can_start_; |
232 bool can_draw_; | 240 bool can_draw_; |
233 bool has_pending_tree_; | 241 bool has_pending_tree_; |
234 bool pending_tree_is_ready_for_activation_; | 242 bool pending_tree_is_ready_for_activation_; |
235 bool active_tree_needs_first_draw_; | 243 bool active_tree_needs_first_draw_; |
236 bool draw_if_possible_failed_; | 244 bool draw_if_possible_failed_; |
237 bool did_create_and_initialize_first_output_surface_; | 245 bool did_create_and_initialize_first_output_surface_; |
238 | 246 |
239 private: | 247 private: |
240 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 248 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
241 }; | 249 }; |
242 | 250 |
243 } // namespace cc | 251 } // namespace cc |
244 | 252 |
245 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 253 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |