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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; | 66 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; |
67 } | 67 } |
68 | 68 |
69 bool RedrawPending() const { return needs_redraw_; } | 69 bool RedrawPending() const { return needs_redraw_; } |
70 | 70 |
71 enum Action { | 71 enum Action { |
72 ACTION_NONE, | 72 ACTION_NONE, |
73 ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, | 73 ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, |
74 ACTION_COMMIT, | 74 ACTION_COMMIT, |
75 ACTION_UPDATE_VISIBLE_TILES, | 75 ACTION_UPDATE_VISIBLE_TILES, |
76 ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED, | 76 ACTION_ACTIVATE_PENDING_TREE, |
77 ACTION_DRAW_IF_POSSIBLE, | 77 ACTION_DRAW_IF_POSSIBLE, |
78 ACTION_DRAW_FORCED, | 78 ACTION_DRAW_FORCED, |
79 ACTION_DRAW_AND_SWAP_ABORT, | 79 ACTION_DRAW_AND_SWAP_ABORT, |
80 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 80 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
81 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, | 81 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, |
82 }; | 82 }; |
83 static const char* ActionToString(Action action); | 83 static const char* ActionToString(Action action); |
84 | 84 |
85 scoped_ptr<base::Value> AsValue() const; | 85 scoped_ptr<base::Value> AsValue() const; |
86 | 86 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 void SetMainThreadNeedsLayerTextures(); | 146 void SetMainThreadNeedsLayerTextures(); |
147 | 147 |
148 // Set that we can create the first OutputSurface and start the scheduler. | 148 // Set that we can create the first OutputSurface and start the scheduler. |
149 void SetCanStart() { can_start_ = true; } | 149 void SetCanStart() { can_start_ = true; } |
150 | 150 |
151 // Indicates whether drawing would, at this time, make sense. | 151 // Indicates whether drawing would, at this time, make sense. |
152 // CanDraw can be used to supress flashes or checkerboarding | 152 // CanDraw can be used to supress flashes or checkerboarding |
153 // when such behavior would be undesirable. | 153 // when such behavior would be undesirable. |
154 void SetCanDraw(bool can); | 154 void SetCanDraw(bool can); |
155 | 155 |
156 // Indicates whether or not there is a pending tree. This influences | 156 // Indicates that the pending tree is ready for activation. |
157 // whether or not we can succesfully commit at this time. If the | 157 void NotifyReadyToActivate(); |
158 // last commit is still being processed (but not blocking), it may not | 158 |
159 // be possible to take another commit yet. This overrides force commit, | |
160 // as a commit is already still in flight. | |
161 void SetHasPendingTree(bool has_pending_tree); | |
162 bool has_pending_tree() const { return has_pending_tree_; } | 159 bool has_pending_tree() const { return has_pending_tree_; } |
163 | 160 |
164 void DidLoseOutputSurface(); | 161 void DidLoseOutputSurface(); |
165 void DidCreateAndInitializeOutputSurface(); | 162 void DidCreateAndInitializeOutputSurface(); |
166 bool HasInitializedOutputSurface() const; | 163 bool HasInitializedOutputSurface() const; |
167 | 164 |
168 // Exposed for testing purposes. | 165 // Exposed for testing purposes. |
169 void SetMaximumNumberOfFailedDrawsBeforeDrawIsForced(int num_draws); | 166 void SetMaximumNumberOfFailedDrawsBeforeDrawIsForced(int num_draws); |
170 | 167 |
171 // True if we need to abort draws to make forward progress. | 168 // True if we need to abort draws to make forward progress. |
172 bool PendingDrawsShouldBeAborted() const; | 169 bool PendingDrawsShouldBeAborted() const; |
173 | 170 |
174 protected: | 171 protected: |
| 172 // True if we need to force activations to make forward progress. |
| 173 bool PendingActivationsShouldBeForced() const; |
| 174 |
| 175 bool ShouldBeginOutputSurfaceCreation() const; |
175 bool ShouldDrawForced() const; | 176 bool ShouldDrawForced() const; |
176 bool ShouldDraw() const; | 177 bool ShouldDraw() const; |
177 bool ShouldAttemptTreeActivation() const; | 178 bool ShouldActivatePendingTree() const; |
178 bool ShouldAcquireLayerTexturesForMainThread() const; | 179 bool ShouldAcquireLayerTexturesForMainThread() const; |
179 bool ShouldUpdateVisibleTiles() const; | 180 bool ShouldUpdateVisibleTiles() const; |
180 bool ShouldSendBeginFrameToMainThread() const; | 181 bool ShouldSendBeginFrameToMainThread() const; |
181 | 182 |
182 bool HasDrawnThisFrame() const; | 183 bool HasDrawnThisFrame() const; |
183 bool HasAttemptedTreeActivationThisFrame() const; | 184 bool HasActivatedPendingTreeThisFrame() const; |
184 bool HasUpdatedVisibleTilesThisFrame() const; | 185 bool HasUpdatedVisibleTilesThisFrame() const; |
185 bool HasSentBeginFrameToMainThreadThisFrame() const; | 186 bool HasSentBeginFrameToMainThreadThisFrame() const; |
186 | 187 |
187 void HandleCommitInternal(bool commit_was_aborted); | 188 void UpdateStateOnCommit(bool commit_was_aborted); |
| 189 void UpdateStateOnActivation(); |
188 void UpdateStateOnDraw(bool did_swap); | 190 void UpdateStateOnDraw(bool did_swap); |
189 | 191 |
190 const SchedulerSettings settings_; | 192 const SchedulerSettings settings_; |
191 | 193 |
192 OutputSurfaceState output_surface_state_; | 194 OutputSurfaceState output_surface_state_; |
193 CommitState commit_state_; | 195 CommitState commit_state_; |
194 | 196 |
195 int commit_count_; | 197 int commit_count_; |
196 int current_frame_number_; | 198 int current_frame_number_; |
197 int last_frame_number_where_begin_frame_sent_to_main_thread_; | 199 int last_frame_number_where_begin_frame_sent_to_main_thread_; |
198 int last_frame_number_where_draw_was_called_; | 200 int last_frame_number_where_draw_was_called_; |
199 int last_frame_number_where_tree_activation_attempted_; | |
200 int last_frame_number_where_update_visible_tiles_was_called_; | 201 int last_frame_number_where_update_visible_tiles_was_called_; |
201 int consecutive_failed_draws_; | 202 int consecutive_failed_draws_; |
202 int maximum_number_of_failed_draws_before_draw_is_forced_; | 203 int maximum_number_of_failed_draws_before_draw_is_forced_; |
203 bool needs_redraw_; | 204 bool needs_redraw_; |
204 bool swap_used_incomplete_tile_; | 205 bool swap_used_incomplete_tile_; |
205 bool needs_forced_redraw_; | 206 bool needs_forced_redraw_; |
206 bool needs_forced_redraw_after_next_commit_; | 207 bool needs_forced_redraw_after_next_commit_; |
207 bool needs_commit_; | 208 bool needs_commit_; |
208 bool needs_forced_commit_; | 209 bool needs_forced_commit_; |
209 bool expect_immediate_begin_frame_for_main_thread_; | 210 bool expect_immediate_begin_frame_for_main_thread_; |
210 bool main_thread_needs_layer_textures_; | 211 bool main_thread_needs_layer_textures_; |
211 bool inside_begin_frame_; | 212 bool inside_begin_frame_; |
212 BeginFrameArgs last_begin_frame_args_; | 213 BeginFrameArgs last_begin_frame_args_; |
213 bool visible_; | 214 bool visible_; |
214 bool can_start_; | 215 bool can_start_; |
215 bool can_draw_; | 216 bool can_draw_; |
216 bool has_pending_tree_; | 217 bool has_pending_tree_; |
| 218 bool pending_tree_is_ready_for_activation_; |
| 219 bool active_tree_has_been_drawn_; |
217 bool draw_if_possible_failed_; | 220 bool draw_if_possible_failed_; |
218 TextureState texture_state_; | 221 TextureState texture_state_; |
219 bool did_create_and_initialize_first_output_surface_; | 222 bool did_create_and_initialize_first_output_surface_; |
220 | 223 |
221 private: | 224 private: |
222 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 225 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
223 }; | 226 }; |
224 | 227 |
225 } // namespace cc | 228 } // namespace cc |
226 | 229 |
227 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 230 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |