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 13 matching lines...) Expand all Loading... | |
24 // requested, while external state includes things like the current time being | 24 // requested, while external state includes things like the current time being |
25 // near to the vblank time. | 25 // near to the vblank time. |
26 // | 26 // |
27 // The scheduler seperates "what to do next" from the updating of its internal | 27 // The scheduler seperates "what to do next" from the updating of its internal |
28 // state to make testing cleaner. | 28 // state to make testing cleaner. |
29 class CC_EXPORT SchedulerStateMachine { | 29 class CC_EXPORT SchedulerStateMachine { |
30 public: | 30 public: |
31 // settings must be valid for the lifetime of this class. | 31 // settings must be valid for the lifetime of this class. |
32 explicit SchedulerStateMachine(const SchedulerSettings& settings); | 32 explicit SchedulerStateMachine(const SchedulerSettings& settings); |
33 | 33 |
34 enum BeginFrameState { | |
brianderson
2013/06/21 01:27:20
Note: This version of the patch enforces the rule
| |
35 BEGIN_FRAME_IDLE, | |
36 BEGIN_FRAME_STARTING, | |
37 BEGIN_FRAME_WAITING, | |
38 BEGIN_FRAME_DRAWING, | |
39 }; | |
40 | |
34 enum CommitState { | 41 enum CommitState { |
35 COMMIT_STATE_IDLE, | 42 COMMIT_STATE_IDLE, |
36 COMMIT_STATE_FRAME_IN_PROGRESS, | 43 COMMIT_STATE_FRAME_IN_PROGRESS, |
37 COMMIT_STATE_READY_TO_COMMIT, | 44 COMMIT_STATE_READY_TO_COMMIT, |
45 COMMIT_STATE_WAITING_FOR_ACTIVATION, | |
38 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 46 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, |
39 COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, | 47 COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, |
40 }; | 48 }; |
41 | 49 |
42 enum TextureState { | 50 enum TextureState { |
43 LAYER_TEXTURE_STATE_UNLOCKED, | 51 LAYER_TEXTURE_STATE_UNLOCKED, |
44 LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD, | 52 LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD, |
45 LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD, | 53 LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD, |
46 }; | 54 }; |
47 | 55 |
(...skipping 25 matching lines...) Expand all Loading... | |
73 void UpdateState(Action action); | 81 void UpdateState(Action action); |
74 | 82 |
75 // Indicates whether the main thread needs a begin frame callback in order to | 83 // Indicates whether the main thread needs a begin frame callback in order to |
76 // make progress. | 84 // make progress. |
77 bool BeginFrameNeededToDrawByImplThread() const; | 85 bool BeginFrameNeededToDrawByImplThread() const; |
78 bool ProactiveBeginFrameWantedByImplThread() const; | 86 bool ProactiveBeginFrameWantedByImplThread() const; |
79 | 87 |
80 // Indicates that the system has entered and left a BeginFrame callback. | 88 // Indicates that the system has entered and left a BeginFrame callback. |
81 // The scheduler will not draw more than once in a given BeginFrame | 89 // The scheduler will not draw more than once in a given BeginFrame |
82 // callback. | 90 // callback. |
83 void DidEnterBeginFrame(const BeginFrameArgs& args); | 91 void OnBeginFrame(const BeginFrameArgs& args); |
84 void DidLeaveBeginFrame(); | 92 void OnBeginFrameDeadline(); |
85 bool inside_begin_frame() const { return inside_begin_frame_; } | 93 bool ShouldTriggerBeginFrameDeadlineEarly() const; |
94 bool InsideBeginFrame() const; | |
86 | 95 |
87 // Indicates whether the LayerTreeHostImpl is visible. | 96 // Indicates whether the LayerTreeHostImpl is visible. |
88 void SetVisible(bool visible); | 97 void SetVisible(bool visible); |
89 | 98 |
90 // Indicates that a redraw is required, either due to the impl tree changing | 99 // Indicates that a redraw is required, either due to the impl tree changing |
91 // or the screen being damaged and simply needing redisplay. | 100 // or the screen being damaged and simply needing redisplay. |
92 void SetNeedsRedraw(); | 101 void SetNeedsRedraw(); |
93 | 102 |
94 // As SetNeedsRedraw(), but ensures the draw will definitely happen even if | 103 // As SetNeedsRedraw(), but ensures the draw will definitely happen even if |
95 // we are not visible. | 104 // we are not visible. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 | 163 |
155 // False if drawing is not being prevented, true if drawing won't happen | 164 // False if drawing is not being prevented, true if drawing won't happen |
156 // for some reason, such as not being visible. | 165 // for some reason, such as not being visible. |
157 bool DrawSuspendedUntilCommit() const; | 166 bool DrawSuspendedUntilCommit() const; |
158 | 167 |
159 std::string ToString(); | 168 std::string ToString(); |
160 | 169 |
161 protected: | 170 protected: |
162 bool ShouldDrawForced() const; | 171 bool ShouldDrawForced() const; |
163 bool ScheduledToDraw() const; | 172 bool ScheduledToDraw() const; |
173 bool WillDrawNewTree() const; | |
164 bool ShouldDraw() const; | 174 bool ShouldDraw() const; |
175 bool ShouldDrawInternal(BeginFrameState begin_frame_state) const; | |
165 bool ShouldAttemptTreeActivation() const; | 176 bool ShouldAttemptTreeActivation() const; |
166 bool ShouldAcquireLayerTexturesForMainThread() const; | 177 bool ShouldAcquireLayerTexturesForMainThread() const; |
167 bool ShouldCheckForCompletedTileUploads() const; | 178 bool ShouldCheckForCompletedTileUploads() const; |
179 bool ShouldSendBeginFrameToMainThread() const; | |
168 bool HasDrawnThisFrame() const; | 180 bool HasDrawnThisFrame() const; |
169 bool HasAttemptedTreeActivationThisFrame() const; | 181 bool HasAttemptedTreeActivationThisFrameAttempt() const; |
170 bool HasCheckedForCompletedTileUploadsThisFrame() const; | 182 bool HasCheckedForCompletedTileUploadsThisFrameAttempt() const; |
183 bool HasSentBeginFrameToMainThreadThisFrame() const; | |
171 | 184 |
172 const SchedulerSettings settings_; | 185 const SchedulerSettings settings_; |
173 | 186 |
174 CommitState commit_state_; | 187 CommitState commit_state_; |
175 int commit_count_; | 188 int commit_count_; |
176 | 189 |
177 int current_frame_number_; | 190 int current_frame_number_; |
178 int last_frame_number_where_draw_was_called_; | 191 int current_frame_attempt_; |
179 int last_frame_number_where_tree_activation_attempted_; | 192 int last_frame_number_draw_was_called_; |
180 int last_frame_number_where_check_for_completed_tile_uploads_called_; | 193 int last_frame_number_begin_frame_sent_to_main_thread_; |
194 int last_frame_attempt_tree_activation_attempted_; | |
195 int last_frame_attempt_check_for_completed_tile_uploads_called_; | |
181 int consecutive_failed_draws_; | 196 int consecutive_failed_draws_; |
182 int maximum_number_of_failed_draws_before_draw_is_forced_; | 197 int maximum_number_of_failed_draws_before_draw_is_forced_; |
183 bool needs_redraw_; | 198 bool needs_redraw_; |
184 bool swap_used_incomplete_tile_; | 199 bool swap_used_incomplete_tile_; |
185 bool needs_forced_redraw_; | 200 bool needs_forced_redraw_; |
186 bool needs_forced_redraw_after_next_commit_; | 201 bool needs_forced_redraw_after_next_commit_; |
187 bool needs_commit_; | 202 bool needs_commit_; |
188 bool needs_forced_commit_; | 203 bool needs_forced_commit_; |
189 bool expect_immediate_begin_frame_for_main_thread_; | 204 bool expect_immediate_begin_frame_for_main_thread_; |
190 bool main_thread_needs_layer_textures_; | 205 bool main_thread_needs_layer_textures_; |
191 bool inside_begin_frame_; | 206 BeginFrameState begin_frame_state_; |
207 bool commit_tree_has_been_drawn_or_null_; | |
208 bool active_tree_has_been_drawn_or_null_; | |
192 BeginFrameArgs last_begin_frame_args_; | 209 BeginFrameArgs last_begin_frame_args_; |
193 bool visible_; | 210 bool visible_; |
194 bool can_start_; | 211 bool can_start_; |
195 bool can_draw_; | 212 bool can_draw_; |
196 bool has_pending_tree_; | 213 bool has_pending_tree_; |
197 bool draw_if_possible_failed_; | 214 bool draw_if_possible_failed_; |
198 TextureState texture_state_; | 215 TextureState texture_state_; |
199 OutputSurfaceState output_surface_state_; | 216 OutputSurfaceState output_surface_state_; |
200 bool did_create_and_initialize_first_output_surface_; | 217 bool did_create_and_initialize_first_output_surface_; |
201 | 218 |
202 private: | 219 private: |
203 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 220 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
204 }; | 221 }; |
205 | 222 |
206 } // namespace cc | 223 } // namespace cc |
207 | 224 |
208 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 225 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |