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

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

Powered by Google App Engine
This is Rietveld 408576698