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

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

Issue 22926024: cc: Control activation from the Scheduler (Closed) Base URL: http://git.chromium.org/chromium/src.git@schedOutputSurface4
Patch Set: remove hacks, address comments, force activation to prevent deadlock Created 7 years, 4 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 that the pending tree is ready for activation.
157 void NotifyReadyToActivate();
158
156 // Indicates whether or not there is a pending tree. This influences 159 // Indicates whether or not there is a pending tree. This influences
157 // whether or not we can succesfully commit at this time. If the 160 // 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 161 // last commit is still being processed (but not blocking), it may not
159 // be possible to take another commit yet. This overrides force commit, 162 // be possible to take another commit yet. This overrides force commit,
160 // as a commit is already still in flight. 163 // as a commit is already still in flight.
161 void SetHasPendingTree(bool has_pending_tree); 164 void SetHasPendingTree(bool has_pending_tree);
162 bool has_pending_tree() const { return has_pending_tree_; } 165 bool has_pending_tree() const { return has_pending_tree_; }
163 166
164 void DidLoseOutputSurface(); 167 void DidLoseOutputSurface();
165 void DidCreateAndInitializeOutputSurface(); 168 void DidCreateAndInitializeOutputSurface();
166 bool HasInitializedOutputSurface() const; 169 bool HasInitializedOutputSurface() const;
167 170
168 // Exposed for testing purposes. 171 // Exposed for testing purposes.
169 void SetMaximumNumberOfFailedDrawsBeforeDrawIsForced(int num_draws); 172 void SetMaximumNumberOfFailedDrawsBeforeDrawIsForced(int num_draws);
170 173
171 // True if we need to abort draws to make forward progress. 174 // True if we need to abort draws to make forward progress.
172 bool PendingDrawsShouldBeAborted() const; 175 bool PendingDrawsShouldBeAborted() const;
173 176
174 protected: 177 protected:
178 // True if we need to force activations to make forward progress.
179 bool PendingActivationsShouldBeForced() const;
180
175 bool ShouldDrawForced() const; 181 bool ShouldDrawForced() const;
176 bool ShouldDraw() const; 182 bool ShouldDraw() const;
177 bool ShouldAttemptTreeActivation() const; 183 bool ShouldActivatePendingTree() const;
178 bool ShouldAcquireLayerTexturesForMainThread() const; 184 bool ShouldAcquireLayerTexturesForMainThread() const;
179 bool ShouldUpdateVisibleTiles() const; 185 bool ShouldUpdateVisibleTiles() const;
180 bool ShouldSendBeginFrameToMainThread() const; 186 bool ShouldSendBeginFrameToMainThread() const;
181 187
182 bool HasDrawnThisFrame() const; 188 bool HasDrawnThisFrame() const;
183 bool HasAttemptedTreeActivationThisFrame() const; 189 bool HasActivatedPendingTreeThisFrame() const;
184 bool HasUpdatedVisibleTilesThisFrame() const; 190 bool HasUpdatedVisibleTilesThisFrame() const;
185 bool HasSentBeginFrameToMainThreadThisFrame() const; 191 bool HasSentBeginFrameToMainThreadThisFrame() const;
186 192
187 void HandleCommitInternal(bool commit_was_aborted); 193 void HandleCommitInternal(bool commit_was_aborted);
188 void UpdateStateOnDraw(bool did_swap); 194 void UpdateStateOnDraw(bool did_swap);
189 195
190 const SchedulerSettings settings_; 196 const SchedulerSettings settings_;
191 197
192 OutputSurfaceState output_surface_state_; 198 OutputSurfaceState output_surface_state_;
193 CommitState commit_state_; 199 CommitState commit_state_;
194 200
195 int commit_count_; 201 int commit_count_;
196 int current_frame_number_; 202 int current_frame_number_;
197 int last_frame_number_where_begin_frame_sent_to_main_thread_; 203 int last_frame_number_where_begin_frame_sent_to_main_thread_;
198 int last_frame_number_where_draw_was_called_; 204 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_; 205 int last_frame_number_where_update_visible_tiles_was_called_;
201 int consecutive_failed_draws_; 206 int consecutive_failed_draws_;
202 int maximum_number_of_failed_draws_before_draw_is_forced_; 207 int maximum_number_of_failed_draws_before_draw_is_forced_;
203 bool needs_redraw_; 208 bool needs_redraw_;
204 bool swap_used_incomplete_tile_; 209 bool swap_used_incomplete_tile_;
205 bool needs_forced_redraw_; 210 bool needs_forced_redraw_;
206 bool needs_forced_redraw_after_next_commit_; 211 bool needs_forced_redraw_after_next_commit_;
207 bool needs_commit_; 212 bool needs_commit_;
208 bool needs_forced_commit_; 213 bool needs_forced_commit_;
209 bool expect_immediate_begin_frame_for_main_thread_; 214 bool expect_immediate_begin_frame_for_main_thread_;
210 bool main_thread_needs_layer_textures_; 215 bool main_thread_needs_layer_textures_;
211 bool inside_begin_frame_; 216 bool inside_begin_frame_;
212 BeginFrameArgs last_begin_frame_args_; 217 BeginFrameArgs last_begin_frame_args_;
213 bool visible_; 218 bool visible_;
214 bool can_start_; 219 bool can_start_;
215 bool can_draw_; 220 bool can_draw_;
216 bool has_pending_tree_; 221 bool has_pending_tree_;
222 bool pending_tree_is_ready_for_activation_;
223 bool has_active_tree_;
224 bool active_tree_has_been_drawn_;
217 bool draw_if_possible_failed_; 225 bool draw_if_possible_failed_;
218 TextureState texture_state_; 226 TextureState texture_state_;
219 bool did_create_and_initialize_first_output_surface_; 227 bool did_create_and_initialize_first_output_surface_;
220 228
221 private: 229 private:
222 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); 230 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine);
223 }; 231 };
224 232
225 } // namespace cc 233 } // namespace cc
226 234
227 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ 235 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698