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 { | |
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, |
38 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 45 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, |
39 COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, | 46 COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, |
40 }; | 47 }; |
41 | 48 |
42 enum TextureState { | 49 enum TextureState { |
43 LAYER_TEXTURE_STATE_UNLOCKED, | 50 LAYER_TEXTURE_STATE_UNLOCKED, |
(...skipping 28 matching lines...) Expand all Loading... | |
72 Action NextAction() const; | 79 Action NextAction() const; |
73 void UpdateState(Action action); | 80 void UpdateState(Action action); |
74 | 81 |
75 // Indicates whether the main thread needs a begin frame callback in order to | 82 // Indicates whether the main thread needs a begin frame callback in order to |
76 // make progress. | 83 // make progress. |
77 bool BeginFrameNeededByImplThread() const; | 84 bool BeginFrameNeededByImplThread() const; |
78 | 85 |
79 // Indicates that the system has entered and left a BeginFrame callback. | 86 // Indicates that the system has entered and left a BeginFrame callback. |
80 // The scheduler will not draw more than once in a given BeginFrame | 87 // The scheduler will not draw more than once in a given BeginFrame |
81 // callback. | 88 // callback. |
82 void DidEnterBeginFrame(BeginFrameArgs args); | 89 void StartBeginFrame(BeginFrameArgs args); |
Sami
2013/06/14 15:59:20
bikeshed: StartBeginFrame sounds weird :) How abou
brianderson
2013/06/14 18:42:36
OnBeginFrame sounds good.
| |
83 void DidLeaveBeginFrame(); | 90 void OnBeginFrameDeadline(); |
84 bool inside_begin_frame() const { return inside_begin_frame_; } | 91 BeginFrameState begin_frame_state() const { return begin_frame_state_; } |
85 | 92 |
86 // Indicates whether the LayerTreeHostImpl is visible. | 93 // Indicates whether the LayerTreeHostImpl is visible. |
87 void SetVisible(bool visible); | 94 void SetVisible(bool visible); |
88 | 95 |
89 // Indicates that a redraw is required, either due to the impl tree changing | 96 // Indicates that a redraw is required, either due to the impl tree changing |
90 // or the screen being damaged and simply needing redisplay. | 97 // or the screen being damaged and simply needing redisplay. |
91 void SetNeedsRedraw(); | 98 void SetNeedsRedraw(); |
92 | 99 |
93 // As SetNeedsRedraw(), but ensures the draw will definitely happen even if | 100 // As SetNeedsRedraw(), but ensures the draw will definitely happen even if |
94 // we are not visible. | 101 // we are not visible. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 bool HasDrawnThisFrame() const; | 174 bool HasDrawnThisFrame() const; |
168 bool HasAttemptedTreeActivationThisFrame() const; | 175 bool HasAttemptedTreeActivationThisFrame() const; |
169 bool HasCheckedForCompletedTileUploadsThisFrame() const; | 176 bool HasCheckedForCompletedTileUploadsThisFrame() const; |
170 | 177 |
171 const SchedulerSettings settings_; | 178 const SchedulerSettings settings_; |
172 | 179 |
173 CommitState commit_state_; | 180 CommitState commit_state_; |
174 int commit_count_; | 181 int commit_count_; |
175 | 182 |
176 int current_frame_number_; | 183 int current_frame_number_; |
177 int last_frame_number_where_draw_was_called_; | 184 int current_frame_attempt_; |
brianderson
2013/06/14 04:16:29
current_frame_attempt_ allows us to reset the last
| |
178 int last_frame_number_where_tree_activation_attempted_; | 185 int last_frame_attempt_draw_was_called_; |
179 int last_frame_number_where_check_for_completed_tile_uploads_called_; | 186 int last_frame_attempt_tree_activation_attempted_; |
187 int last_frame_attempt_check_for_completed_tile_uploads_called_; | |
180 int consecutive_failed_draws_; | 188 int consecutive_failed_draws_; |
181 int maximum_number_of_failed_draws_before_draw_is_forced_; | 189 int maximum_number_of_failed_draws_before_draw_is_forced_; |
182 bool needs_redraw_; | 190 bool needs_redraw_; |
183 bool swap_used_incomplete_tile_; | 191 bool swap_used_incomplete_tile_; |
184 bool needs_forced_redraw_; | 192 bool needs_forced_redraw_; |
185 bool needs_forced_redraw_after_next_commit_; | 193 bool needs_forced_redraw_after_next_commit_; |
186 bool needs_commit_; | 194 bool needs_commit_; |
187 bool needs_forced_commit_; | 195 bool needs_forced_commit_; |
188 bool expect_immediate_begin_frame_for_main_thread_; | 196 bool expect_immediate_begin_frame_for_main_thread_; |
189 bool main_thread_needs_layer_textures_; | 197 bool main_thread_needs_layer_textures_; |
190 bool inside_begin_frame_; | 198 BeginFrameState begin_frame_state_; |
199 bool active_tree_has_been_drawn_; | |
191 BeginFrameArgs last_begin_frame_args_; | 200 BeginFrameArgs last_begin_frame_args_; |
192 bool visible_; | 201 bool visible_; |
193 bool can_start_; | 202 bool can_start_; |
194 bool can_draw_; | 203 bool can_draw_; |
195 bool has_pending_tree_; | 204 bool has_pending_tree_; |
196 bool draw_if_possible_failed_; | 205 bool draw_if_possible_failed_; |
197 TextureState texture_state_; | 206 TextureState texture_state_; |
198 OutputSurfaceState output_surface_state_; | 207 OutputSurfaceState output_surface_state_; |
199 bool did_create_and_initialize_first_output_surface_; | 208 bool did_create_and_initialize_first_output_surface_; |
200 | 209 |
201 private: | 210 private: |
202 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 211 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
203 }; | 212 }; |
204 | 213 |
205 } // namespace cc | 214 } // namespace cc |
206 | 215 |
207 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 216 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |