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

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

Issue 16871016: cc: Use BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@bfargs2
Patch Set: Tweaks; Address more comments; Created 7 years, 6 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 13 matching lines...) Expand all
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 // Note: BeginFrameState will always cycle through all the states in order.
35 // Whether or not it actually waits or draws, it will at least try to wait in
36 // BEGIN_FRAME_STATE_DEADLINE_PENDING and try to draw in
37 // BEGIN_FRAME_STATE_INSIDE_DEADLINE
38 enum BeginFrameState {
39 BEGIN_FRAME_STATE_IDLE,
40 BEGIN_FRAME_STATE_INSIDE_BEGIN_FRAME,
41 BEGIN_FRAME_STATE_DEADLINE_PENDING,
42 BEGIN_FRAME_STATE_INSIDE_DEADLINE,
43 };
44
34 enum CommitState { 45 enum CommitState {
35 COMMIT_STATE_IDLE, 46 COMMIT_STATE_IDLE,
36 COMMIT_STATE_FRAME_IN_PROGRESS, 47 COMMIT_STATE_FRAME_IN_PROGRESS,
37 COMMIT_STATE_READY_TO_COMMIT, 48 COMMIT_STATE_READY_TO_COMMIT,
49 COMMIT_STATE_WAITING_FOR_ACTIVATION,
38 COMMIT_STATE_WAITING_FOR_FIRST_DRAW, 50 COMMIT_STATE_WAITING_FOR_FIRST_DRAW,
39 COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW, 51 COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW,
40 }; 52 };
41 53
42 enum TextureState { 54 enum TextureState {
43 LAYER_TEXTURE_STATE_UNLOCKED, 55 LAYER_TEXTURE_STATE_UNLOCKED,
44 LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD, 56 LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD,
45 LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD, 57 LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD,
46 }; 58 };
47 59
(...skipping 25 matching lines...) Expand all
73 void UpdateState(Action action); 85 void UpdateState(Action action);
74 86
75 // Indicates whether the main thread needs a begin frame callback in order to 87 // Indicates whether the main thread needs a begin frame callback in order to
76 // make progress. 88 // make progress.
77 bool BeginFrameNeededToDrawByImplThread() const; 89 bool BeginFrameNeededToDrawByImplThread() const;
78 bool ProactiveBeginFrameWantedByImplThread() const; 90 bool ProactiveBeginFrameWantedByImplThread() const;
79 91
80 // Indicates that the system has entered and left a BeginFrame callback. 92 // Indicates that the system has entered and left a BeginFrame callback.
81 // The scheduler will not draw more than once in a given BeginFrame 93 // The scheduler will not draw more than once in a given BeginFrame
82 // callback. 94 // callback.
83 void DidEnterBeginFrame(const BeginFrameArgs& args); 95 void OnBeginFrame(const BeginFrameArgs& args);
84 void DidLeaveBeginFrame(); 96 void OnBeginFrameDeadline();
85 bool inside_begin_frame() const { return inside_begin_frame_; } 97 bool ShouldTriggerBeginFrameDeadlineEarly() const;
98 bool InsideBeginFrame() const;
86 99
87 // Indicates whether the LayerTreeHostImpl is visible. 100 // Indicates whether the LayerTreeHostImpl is visible.
88 void SetVisible(bool visible); 101 void SetVisible(bool visible);
89 102
90 // Indicates that a redraw is required, either due to the impl tree changing 103 // Indicates that a redraw is required, either due to the impl tree changing
91 // or the screen being damaged and simply needing redisplay. 104 // or the screen being damaged and simply needing redisplay.
92 void SetNeedsRedraw(); 105 void SetNeedsRedraw();
93 106
94 // As SetNeedsRedraw(), but ensures the draw will definitely happen even if 107 // As SetNeedsRedraw(), but ensures the draw will definitely happen even if
95 // we are not visible. 108 // we are not visible.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 167
155 // False if drawing is not being prevented, true if drawing won't happen 168 // False if drawing is not being prevented, true if drawing won't happen
156 // for some reason, such as not being visible. 169 // for some reason, such as not being visible.
157 bool DrawSuspendedUntilCommit() const; 170 bool DrawSuspendedUntilCommit() const;
158 171
159 std::string ToString(); 172 std::string ToString();
160 173
161 protected: 174 protected:
162 bool ShouldDrawForced() const; 175 bool ShouldDrawForced() const;
163 bool ScheduledToDraw() const; 176 bool ScheduledToDraw() const;
177 bool WillDrawNewTree() const;
164 bool ShouldDraw() const; 178 bool ShouldDraw() const;
179 bool ShouldDrawInternal(BeginFrameState begin_frame_state) const;
165 bool ShouldAttemptTreeActivation() const; 180 bool ShouldAttemptTreeActivation() const;
166 bool ShouldAcquireLayerTexturesForMainThread() const; 181 bool ShouldAcquireLayerTexturesForMainThread() const;
167 bool ShouldCheckForCompletedTileUploads() const; 182 bool ShouldCheckForCompletedTileUploads() const;
183 bool ShouldSendBeginFrameToMainThread() const;
168 bool HasDrawnThisFrame() const; 184 bool HasDrawnThisFrame() const;
169 bool HasAttemptedTreeActivationThisFrame() const; 185 bool HasAttemptedTreeActivationThisDrawAttempt() const;
170 bool HasCheckedForCompletedTileUploadsThisFrame() const; 186 bool HasCheckedForCompletedTileUploadsThisDrawAttempt() const;
187 bool HasSentBeginFrameToMainThreadThisFrame() const;
171 188
172 const SchedulerSettings settings_; 189 const SchedulerSettings settings_;
173 190
174 CommitState commit_state_; 191 CommitState commit_state_;
175 int commit_count_; 192 int commit_count_;
176 193
177 int current_frame_number_; 194 int begin_frame_count_;
178 int last_frame_number_where_draw_was_called_; 195 int draw_attempt_count_;
179 int last_frame_number_where_tree_activation_attempted_; 196 int last_begin_frame_count_draw_was_called_;
180 int last_frame_number_where_check_for_completed_tile_uploads_called_; 197 int last_begin_frame_count_begin_frame_sent_to_main_thread_;
198 int last_draw_attempt_count_tree_activation_attempted_;
199 int last_draw_attempt_count_completed_tile_uploads_checked_;
181 int consecutive_failed_draws_; 200 int consecutive_failed_draws_;
182 int maximum_number_of_failed_draws_before_draw_is_forced_; 201 int maximum_number_of_failed_draws_before_draw_is_forced_;
183 bool needs_redraw_; 202 bool needs_redraw_;
184 bool swap_used_incomplete_tile_; 203 bool swap_used_incomplete_tile_;
185 bool needs_forced_redraw_; 204 bool needs_forced_redraw_;
186 bool needs_forced_redraw_after_next_commit_; 205 bool needs_forced_redraw_after_next_commit_;
187 bool needs_commit_; 206 bool needs_commit_;
188 bool needs_forced_commit_; 207 bool needs_forced_commit_;
189 bool expect_immediate_begin_frame_for_main_thread_; 208 bool expect_immediate_begin_frame_for_main_thread_;
190 bool main_thread_needs_layer_textures_; 209 bool main_thread_needs_layer_textures_;
191 bool inside_begin_frame_; 210 BeginFrameState begin_frame_state_;
211 bool commit_tree_has_been_drawn_or_null_;
212 bool active_tree_has_been_drawn_or_null_;
192 BeginFrameArgs last_begin_frame_args_; 213 BeginFrameArgs last_begin_frame_args_;
193 bool visible_; 214 bool visible_;
194 bool can_start_; 215 bool can_start_;
195 bool can_draw_; 216 bool can_draw_;
196 bool has_pending_tree_; 217 bool has_pending_tree_;
197 bool draw_if_possible_failed_; 218 bool draw_if_possible_failed_;
198 TextureState texture_state_; 219 TextureState texture_state_;
199 OutputSurfaceState output_surface_state_; 220 OutputSurfaceState output_surface_state_;
200 bool did_create_and_initialize_first_output_surface_; 221 bool did_create_and_initialize_first_output_surface_;
201 222
202 private: 223 private:
203 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); 224 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine);
204 }; 225 };
205 226
206 } // namespace cc 227 } // namespace cc
207 228
208 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ 229 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698