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 |
| 159 // Indicates whether or not there is a pending tree (which may be null) |
| 160 // and whether the active tree is null or not. This |
| 161 // influences whether or not we can succesfully commit at this time. If the |
158 // last commit is still being processed (but not blocking), it may not | 162 // last commit is still being processed (but not blocking), it may not |
159 // be possible to take another commit yet. This overrides force commit, | 163 // be possible to take another commit yet. This overrides force commit, |
160 // as a commit is already still in flight. | 164 // as a commit is already still in flight. |
161 void SetHasPendingTree(bool has_pending_tree); | 165 void SetHasTrees(bool has_pending_tree, bool active_tree_is_null_); |
162 bool has_pending_tree() const { return has_pending_tree_; } | 166 bool has_pending_tree() const { return has_pending_tree_; } |
163 | 167 |
164 void DidLoseOutputSurface(); | 168 void DidLoseOutputSurface(); |
165 void DidCreateAndInitializeOutputSurface(); | 169 void DidCreateAndInitializeOutputSurface(); |
166 bool HasInitializedOutputSurface() const; | 170 bool HasInitializedOutputSurface() const; |
167 | 171 |
168 // Exposed for testing purposes. | 172 // Exposed for testing purposes. |
169 void SetMaximumNumberOfFailedDrawsBeforeDrawIsForced(int num_draws); | 173 void SetMaximumNumberOfFailedDrawsBeforeDrawIsForced(int num_draws); |
170 | 174 |
171 // True if we need to abort draws to make forward progress. | 175 // True if we need to abort draws to make forward progress. |
172 bool PendingDrawsShouldBeAborted() const; | 176 bool PendingDrawsShouldBeAborted() const; |
173 | 177 |
174 protected: | 178 protected: |
175 bool ShouldDrawForced() const; | 179 bool ShouldDrawForced() const; |
176 bool ShouldDraw() const; | 180 bool ShouldDraw() const; |
177 bool ShouldAttemptTreeActivation() const; | 181 bool ShouldActivatePendingTree() const; |
178 bool ShouldAcquireLayerTexturesForMainThread() const; | 182 bool ShouldAcquireLayerTexturesForMainThread() const; |
179 bool ShouldUpdateVisibleTiles() const; | 183 bool ShouldUpdateVisibleTiles() const; |
180 bool ShouldSendBeginFrameToMainThread() const; | 184 bool ShouldSendBeginFrameToMainThread() const; |
181 | 185 |
182 bool HasDrawnThisFrame() const; | 186 bool HasDrawnThisFrame() const; |
183 bool HasAttemptedTreeActivationThisFrame() const; | 187 bool HasActivatedPendingTreeThisFrame() const; |
184 bool HasUpdatedVisibleTilesThisFrame() const; | 188 bool HasUpdatedVisibleTilesThisFrame() const; |
185 bool HasSentBeginFrameToMainThreadThisFrame() const; | 189 bool HasSentBeginFrameToMainThreadThisFrame() const; |
186 | 190 |
187 void HandleCommitInternal(bool commit_was_aborted); | 191 void HandleCommitInternal(bool commit_was_aborted); |
188 void UpdateStateOnDraw(bool did_swap); | 192 void UpdateStateOnDraw(bool did_swap); |
189 | 193 |
190 const SchedulerSettings settings_; | 194 const SchedulerSettings settings_; |
191 | 195 |
192 OutputSurfaceState output_surface_state_; | 196 OutputSurfaceState output_surface_state_; |
193 CommitState commit_state_; | 197 CommitState commit_state_; |
194 | 198 |
195 int commit_count_; | 199 int commit_count_; |
196 int current_frame_number_; | 200 int current_frame_number_; |
197 int last_frame_number_where_begin_frame_sent_to_main_thread_; | 201 int last_frame_number_where_begin_frame_sent_to_main_thread_; |
198 int last_frame_number_where_draw_was_called_; | 202 int last_frame_number_where_draw_was_called_; |
199 int last_frame_number_where_tree_activation_attempted_; | 203 int last_frame_number_pending_tree_activated_; |
200 int last_frame_number_where_update_visible_tiles_was_called_; | 204 int last_frame_number_where_update_visible_tiles_was_called_; |
201 int consecutive_failed_draws_; | 205 int consecutive_failed_draws_; |
202 int maximum_number_of_failed_draws_before_draw_is_forced_; | 206 int maximum_number_of_failed_draws_before_draw_is_forced_; |
203 bool needs_redraw_; | 207 bool needs_redraw_; |
204 bool swap_used_incomplete_tile_; | 208 bool swap_used_incomplete_tile_; |
205 bool needs_forced_redraw_; | 209 bool needs_forced_redraw_; |
206 bool needs_forced_redraw_after_next_commit_; | 210 bool needs_forced_redraw_after_next_commit_; |
207 bool needs_commit_; | 211 bool needs_commit_; |
208 bool needs_forced_commit_; | 212 bool needs_forced_commit_; |
209 bool expect_immediate_begin_frame_for_main_thread_; | 213 bool expect_immediate_begin_frame_for_main_thread_; |
210 bool main_thread_needs_layer_textures_; | 214 bool main_thread_needs_layer_textures_; |
211 bool inside_begin_frame_; | 215 bool inside_begin_frame_; |
212 BeginFrameArgs last_begin_frame_args_; | 216 BeginFrameArgs last_begin_frame_args_; |
| 217 bool active_tree_has_been_drawn_; |
| 218 bool active_tree_is_null_; |
213 bool visible_; | 219 bool visible_; |
214 bool can_start_; | 220 bool can_start_; |
215 bool can_draw_; | 221 bool can_draw_; |
216 bool has_pending_tree_; | 222 bool has_pending_tree_; |
| 223 bool pending_tree_is_ready_for_activation_; |
217 bool draw_if_possible_failed_; | 224 bool draw_if_possible_failed_; |
218 TextureState texture_state_; | 225 TextureState texture_state_; |
219 bool did_create_and_initialize_first_output_surface_; | 226 bool did_create_and_initialize_first_output_surface_; |
220 | 227 |
221 private: | 228 private: |
222 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 229 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
223 }; | 230 }; |
224 | 231 |
225 } // namespace cc | 232 } // namespace cc |
226 | 233 |
227 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 234 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |