Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: cc/scheduler/scheduler_state_machine.h

Issue 23796002: cc: Implement deadine scheduling disabled by default (Closed) Base URL: http://git.chromium.org/chromium/src.git@schedReadback4
Patch Set: rebase? Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 27 matching lines...) Expand all
38 38
39 enum OutputSurfaceState { 39 enum OutputSurfaceState {
40 OUTPUT_SURFACE_ACTIVE, 40 OUTPUT_SURFACE_ACTIVE,
41 OUTPUT_SURFACE_LOST, 41 OUTPUT_SURFACE_LOST,
42 OUTPUT_SURFACE_CREATING, 42 OUTPUT_SURFACE_CREATING,
43 OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT, 43 OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT,
44 OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION, 44 OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION,
45 }; 45 };
46 static const char* OutputSurfaceStateToString(OutputSurfaceState state); 46 static const char* OutputSurfaceStateToString(OutputSurfaceState state);
47 47
48 // Note: BeginFrameState will always cycle through all the states in order.
49 // Whether or not it actually waits or draws, it will at least try to wait in
50 // BEGIN_FRAME_STATE_DEADLINE_PENDING and try to draw in
51 // BEGIN_FRAME_STATE_INSIDE_DEADLINE
52 enum BeginFrameState {
53 BEGIN_FRAME_STATE_IDLE,
54 BEGIN_FRAME_STATE_INSIDE_BEGIN_FRAME,
55 BEGIN_FRAME_STATE_DEADLINE_PENDING,
56 BEGIN_FRAME_STATE_INSIDE_DEADLINE,
57 };
58 static const char* BeginFrameStateToString(BeginFrameState state);
59
48 enum CommitState { 60 enum CommitState {
49 COMMIT_STATE_IDLE, 61 COMMIT_STATE_IDLE,
50 COMMIT_STATE_FRAME_IN_PROGRESS, 62 COMMIT_STATE_FRAME_IN_PROGRESS,
51 COMMIT_STATE_READY_TO_COMMIT, 63 COMMIT_STATE_READY_TO_COMMIT,
52 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 64 COMMIT_STATE_WAITING_FOR_FIRST_DRAW,
53 }; 65 };
54 static const char* CommitStateToString(CommitState state); 66 static const char* CommitStateToString(CommitState state);
55 67
56 enum TextureState { 68 enum TextureState {
57 LAYER_TEXTURE_STATE_UNLOCKED, 69 LAYER_TEXTURE_STATE_UNLOCKED,
(...skipping 17 matching lines...) Expand all
75 enum ForcedRedrawOnTimeoutState { 87 enum ForcedRedrawOnTimeoutState {
76 FORCED_REDRAW_STATE_IDLE, 88 FORCED_REDRAW_STATE_IDLE,
77 FORCED_REDRAW_STATE_WAITING_FOR_COMMIT, 89 FORCED_REDRAW_STATE_WAITING_FOR_COMMIT,
78 FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION, 90 FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION,
79 FORCED_REDRAW_STATE_WAITING_FOR_DRAW, 91 FORCED_REDRAW_STATE_WAITING_FOR_DRAW,
80 }; 92 };
81 static const char* ForcedRedrawOnTimeoutStateToString( 93 static const char* ForcedRedrawOnTimeoutStateToString(
82 ForcedRedrawOnTimeoutState state); 94 ForcedRedrawOnTimeoutState state);
83 95
84 bool CommitPending() const { 96 bool CommitPending() const {
85 return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS || 97 return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS;
86 commit_state_ == COMMIT_STATE_READY_TO_COMMIT;
87 } 98 }
88 99
89 bool RedrawPending() const { return needs_redraw_; } 100 bool RedrawPending() const { return needs_redraw_; }
90 101
91 enum Action { 102 enum Action {
92 ACTION_NONE, 103 ACTION_NONE,
93 ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, 104 ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
94 ACTION_COMMIT, 105 ACTION_COMMIT,
95 ACTION_UPDATE_VISIBLE_TILES, 106 ACTION_UPDATE_VISIBLE_TILES,
96 ACTION_ACTIVATE_PENDING_TREE, 107 ACTION_ACTIVATE_PENDING_TREE,
97 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 108 ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
98 ACTION_DRAW_AND_SWAP_FORCED, 109 ACTION_DRAW_AND_SWAP_FORCED,
99 ACTION_DRAW_AND_SWAP_ABORT, 110 ACTION_DRAW_AND_SWAP_ABORT,
100 ACTION_DRAW_AND_READBACK, 111 ACTION_DRAW_AND_READBACK,
101 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, 112 ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
102 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, 113 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD,
103 }; 114 };
104 static const char* ActionToString(Action action); 115 static const char* ActionToString(Action action);
105 116
106 scoped_ptr<base::Value> AsValue() const; 117 scoped_ptr<base::Value> AsValue() const;
107 118
108 Action NextAction() const; 119 Action NextAction() const;
109 void UpdateState(Action action); 120 void UpdateState(Action action);
121 void AdvanceBeginFrameStateWhenNoActionsRemain();
122
110 void CheckInvariants(); 123 void CheckInvariants();
111 124
112 // Indicates whether the main thread needs a begin frame callback in order to 125 // Indicates whether the main thread needs a begin frame callback in order to
113 // make progress. 126 // make progress.
127 bool BeginFrameNeededByImplThread() const;
114 bool BeginFrameNeededToDrawByImplThread() const; 128 bool BeginFrameNeededToDrawByImplThread() const;
115 bool ProactiveBeginFrameWantedByImplThread() const; 129 bool ProactiveBeginFrameWantedByImplThread() const;
116 130
117 // Indicates that the system has entered and left a BeginFrame callback. 131 // Indicates that the system has entered and left a BeginFrame callback.
118 // The scheduler will not draw more than once in a given BeginFrame 132 // The scheduler will not draw more than once in a given BeginFrame
119 // callback nor send more than one BeginFrame message. 133 // callback nor send more than one BeginFrame message.
120 void DidEnterBeginFrame(const BeginFrameArgs& args); 134 void OnBeginFrame(const BeginFrameArgs& args);
121 void DidLeaveBeginFrame(); 135 void OnBeginFrameDeadline();
122 bool inside_begin_frame() const { return inside_begin_frame_; } 136 bool ShouldTriggerBeginFrameDeadlineEarly() const;
137 bool InsideBeginFrame() const;
123 138
124 // Indicates whether the LayerTreeHostImpl is visible. 139 // Indicates whether the LayerTreeHostImpl is visible.
125 void SetVisible(bool visible); 140 void SetVisible(bool visible);
126 141
127 // Indicates that a redraw is required, either due to the impl tree changing 142 // Indicates that a redraw is required, either due to the impl tree changing
128 // or the screen being damaged and simply needing redisplay. 143 // or the screen being damaged and simply needing redisplay.
129 void SetNeedsRedraw(); 144 void SetNeedsRedraw();
145 bool needs_redraw() const { return needs_redraw_; }
130 146
131 // Indicates that a redraw is required because we are currently rendering 147 // Indicates that a redraw is required because we are currently rendering
132 // with a low resolution or checkerboarded tile. 148 // with a low resolution or checkerboarded tile.
133 void DidSwapUseIncompleteTile(); 149 void DidSwapUseIncompleteTile();
134 150
135 // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen or 151 // Indicates whether ACTION_DRAW_AND_SWAP_IF_POSSIBLE drew to the screen.
136 // not.
137 void DidDrawIfPossibleCompleted(bool success); 152 void DidDrawIfPossibleCompleted(bool success);
138 153
139 // Indicates that a new commit flow needs to be performed, either to pull 154 // 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 155 // updates from the main thread to the impl, or to push deltas from the impl
141 // thread to main. 156 // thread to main.
142 void SetNeedsCommit(); 157 void SetNeedsCommit();
143 158
144 // As SetNeedsCommit(), but ensures the begin frame will be sent to the main 159 // As SetNeedsCommit(), but ensures the begin frame will be sent to the main
145 // thread even if we are not visible. After this call we expect to go through 160 // thread even if we are not visible. After this call we expect to go through
146 // the forced commit flow and then return to waiting for a non-forced 161 // the forced commit flow and then return to waiting for a non-forced
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 206
192 bool ShouldBeginOutputSurfaceCreation() const; 207 bool ShouldBeginOutputSurfaceCreation() const;
193 bool ShouldDrawForced() const; 208 bool ShouldDrawForced() const;
194 bool ShouldDraw() const; 209 bool ShouldDraw() const;
195 bool ShouldActivatePendingTree() const; 210 bool ShouldActivatePendingTree() const;
196 bool ShouldAcquireLayerTexturesForMainThread() const; 211 bool ShouldAcquireLayerTexturesForMainThread() const;
197 bool ShouldUpdateVisibleTiles() const; 212 bool ShouldUpdateVisibleTiles() const;
198 bool ShouldSendBeginFrameToMainThread() const; 213 bool ShouldSendBeginFrameToMainThread() const;
199 bool ShouldCommit() const; 214 bool ShouldCommit() const;
200 215
201 bool HasDrawnAndSwappedThisFrame() const; 216 bool HasSwappedThisFrame() const;
217 bool HasDrawnThisDrawAttempt() const;
202 bool HasActivatedPendingTreeThisFrame() const; 218 bool HasActivatedPendingTreeThisFrame() const;
203 bool HasUpdatedVisibleTilesThisFrame() const; 219 bool HasUpdatedVisibleTilesThisDrawAttempt() const;
204 bool HasSentBeginFrameToMainThreadThisFrame() const; 220 bool HasSentBeginFrameToMainThreadThisFrame() const;
221 bool HasActivatedPendingTreeThisDrawAttempt() const;
205 222
206 void UpdateStateOnCommit(bool commit_was_aborted); 223 void UpdateStateOnCommit(bool commit_was_aborted);
207 void UpdateStateOnActivation(); 224 void UpdateStateOnActivation();
208 void UpdateStateOnDraw(bool did_swap); 225 void UpdateStateOnDraw(bool did_swap);
209 226
210 const SchedulerSettings settings_; 227 const SchedulerSettings settings_;
211 228
212 OutputSurfaceState output_surface_state_; 229 OutputSurfaceState output_surface_state_;
230 BeginFrameState begin_frame_state_;
213 CommitState commit_state_; 231 CommitState commit_state_;
214 TextureState texture_state_; 232 TextureState texture_state_;
215 ForcedRedrawOnTimeoutState forced_redraw_state_; 233 ForcedRedrawOnTimeoutState forced_redraw_state_;
216 SynchronousReadbackState readback_state_; 234 SynchronousReadbackState readback_state_;
217 235
236 BeginFrameArgs last_begin_frame_args_;
237
218 int commit_count_; 238 int commit_count_;
219 int current_frame_number_; 239 int begin_frame_count_;
220 int last_frame_number_where_begin_frame_sent_to_main_thread_; 240 int draw_attempt_count_;
221 int last_frame_number_swap_performed_; 241 int last_begin_frame_count_swap_performed_;
222 int last_frame_number_where_update_visible_tiles_was_called_; 242 int last_draw_attempt_count_draw_was_called_;
243 int last_begin_frame_count_begin_frame_sent_to_main_thread_;
244 int last_draw_attempt_count_tree_activation_attempted_;
245 int last_draw_attempt_count_update_visible_tiles_was_called_;
246
223 int consecutive_failed_draws_; 247 int consecutive_failed_draws_;
224 bool needs_redraw_; 248 bool needs_redraw_;
225 bool swap_used_incomplete_tile_; 249 bool swap_used_incomplete_tile_;
226 bool needs_commit_; 250 bool needs_commit_;
227 bool main_thread_needs_layer_textures_; 251 bool main_thread_needs_layer_textures_;
228 bool inside_begin_frame_;
229 BeginFrameArgs last_begin_frame_args_;
230 bool visible_; 252 bool visible_;
231 bool can_start_; 253 bool can_start_;
232 bool can_draw_; 254 bool can_draw_;
233 bool has_pending_tree_; 255 bool has_pending_tree_;
234 bool pending_tree_is_ready_for_activation_; 256 bool pending_tree_is_ready_for_activation_;
235 bool active_tree_needs_first_draw_; 257 bool active_tree_needs_first_draw_;
236 bool draw_if_possible_failed_; 258 bool draw_if_possible_failed_;
237 bool did_create_and_initialize_first_output_surface_; 259 bool did_create_and_initialize_first_output_surface_;
238 260
239 private: 261 private:
240 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); 262 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine);
241 }; 263 };
242 264
243 } // namespace cc 265 } // namespace cc
244 266
245 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ 267 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698