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

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

Issue 817603002: cc: Make scheduling be driven by vsync for android webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix misc bugs introduced in last two patches Created 5 years, 10 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE 57 // BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE
58 enum BeginImplFrameState { 58 enum BeginImplFrameState {
59 BEGIN_IMPL_FRAME_STATE_IDLE, 59 BEGIN_IMPL_FRAME_STATE_IDLE,
60 BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING, 60 BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING,
61 BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME, 61 BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME,
62 BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE, 62 BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE,
63 }; 63 };
64 static const char* BeginImplFrameStateToString(BeginImplFrameState state); 64 static const char* BeginImplFrameStateToString(BeginImplFrameState state);
65 65
66 enum BeginImplFrameDeadlineMode { 66 enum BeginImplFrameDeadlineMode {
67 BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE, 67 BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE_SYNCHRONOUS,
68 BEGIN_IMPL_FRAME_DEADLINE_MODE_IMMEDIATE_ASYNCHRONOUS,
68 BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR, 69 BEGIN_IMPL_FRAME_DEADLINE_MODE_REGULAR,
69 BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE, 70 BEGIN_IMPL_FRAME_DEADLINE_MODE_LATE,
70 }; 71 };
71 static const char* BeginImplFrameDeadlineModeToString( 72 static const char* BeginImplFrameDeadlineModeToString(
72 BeginImplFrameDeadlineMode mode); 73 BeginImplFrameDeadlineMode mode);
73 74
74 enum CommitState { 75 enum CommitState {
75 COMMIT_STATE_IDLE, 76 COMMIT_STATE_IDLE,
76 COMMIT_STATE_BEGIN_MAIN_FRAME_SENT, 77 COMMIT_STATE_BEGIN_MAIN_FRAME_SENT,
77 COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED, 78 COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED,
(...skipping 26 matching lines...) Expand all
104 ACTION_NONE, 105 ACTION_NONE,
105 ACTION_ANIMATE, 106 ACTION_ANIMATE,
106 ACTION_SEND_BEGIN_MAIN_FRAME, 107 ACTION_SEND_BEGIN_MAIN_FRAME,
107 ACTION_COMMIT, 108 ACTION_COMMIT,
108 ACTION_ACTIVATE_SYNC_TREE, 109 ACTION_ACTIVATE_SYNC_TREE,
109 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, 110 ACTION_DRAW_AND_SWAP_IF_POSSIBLE,
110 ACTION_DRAW_AND_SWAP_FORCED, 111 ACTION_DRAW_AND_SWAP_FORCED,
111 ACTION_DRAW_AND_SWAP_ABORT, 112 ACTION_DRAW_AND_SWAP_ABORT,
112 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, 113 ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
113 ACTION_PREPARE_TILES, 114 ACTION_PREPARE_TILES,
115 ACTION_INVALIDATE_OUTPUT_SURFACE,
114 }; 116 };
115 static const char* ActionToString(Action action); 117 static const char* ActionToString(Action action);
116 118
117 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; 119 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValue() const;
118 void AsValueInto(base::trace_event::TracedValue* dict, 120 void AsValueInto(base::trace_event::TracedValue* dict,
119 base::TimeTicks now) const; 121 base::TimeTicks now) const;
120 122
121 Action NextAction() const; 123 Action NextAction() const;
122 void UpdateState(Action action); 124 void UpdateState(Action action);
123 125
124 // Indicates whether the impl thread needs a BeginImplFrame callback in order 126 // Indicates whether the impl thread needs a BeginImplFrame callback in order
125 // to make progress. 127 // to make progress.
126 bool BeginFrameNeeded() const; 128 bool BeginFrameNeeded() const;
127 129
128 // Indicates whether the scheduler should call 130 // Indicates whether the scheduler should call
129 // SetNeedsBeginFrames(BeginFrameNeeded()) on the frame source. 131 // SetNeedsBeginFrames(BeginFrameNeeded()) on the frame source.
130 bool ShouldSetNeedsBeginFrames(bool frame_source_needs_begin_frames) const; 132 bool ShouldSetNeedsBeginFrames(bool frame_source_needs_begin_frames) const;
131 133
132 // Indicates that we need to independently poll for new state and actions
133 // because we can't expect a BeginImplFrame. This is mostly used to avoid
134 // drawing repeat frames with the synchronous compositor without dropping
135 // necessary actions on the floor.
136 bool ShouldPollForAnticipatedDrawTriggers() const;
137
138 // Indicates that the system has entered and left a BeginImplFrame callback. 134 // Indicates that the system has entered and left a BeginImplFrame callback.
139 // The scheduler will not draw more than once in a given BeginImplFrame 135 // The scheduler will not draw more than once in a given BeginImplFrame
140 // callback nor send more than one BeginMainFrame message. 136 // callback nor send more than one BeginMainFrame message.
141 void OnBeginImplFrame(const BeginFrameArgs& args); 137 void OnBeginImplFrame(const BeginFrameArgs& args);
142 void OnBeginImplFrameDeadlinePending(); 138 void OnBeginImplFrameDeadlinePending();
143 void OnBeginImplFrameDeadline(); 139 void OnBeginImplFrameDeadline();
144 void OnBeginImplFrameIdle(); 140 void OnBeginImplFrameIdle();
145 BeginImplFrameState begin_impl_frame_state() const { 141 BeginImplFrameState begin_impl_frame_state() const {
146 return begin_impl_frame_state_; 142 return begin_impl_frame_state_;
147 } 143 }
148 BeginImplFrameDeadlineMode CurrentBeginImplFrameDeadlineMode() const; 144 BeginImplFrameDeadlineMode CurrentBeginImplFrameDeadlineMode() const;
149 145
150 // If the main thread didn't manage to produce a new frame in time for the 146 // If the main thread didn't manage to produce a new frame in time for the
151 // impl thread to draw, it is in a high latency mode. 147 // impl thread to draw, it is in a high latency mode.
152 bool MainThreadIsInHighLatencyMode() const; 148 bool MainThreadIsInHighLatencyMode() const;
153 149
154 // PollForAnticipatedDrawTriggers is used by the synchronous compositor to
155 // avoid requesting BeginImplFrames when we won't actually draw but still
156 // need to advance our state at vsync intervals.
157 void DidEnterPollForAnticipatedDrawTriggers();
158 void DidLeavePollForAnticipatedDrawTriggers();
159 bool inside_poll_for_anticipated_draw_triggers() const {
160 return inside_poll_for_anticipated_draw_triggers_;
161 }
162
163 // Indicates whether the LayerTreeHostImpl is visible. 150 // Indicates whether the LayerTreeHostImpl is visible.
164 void SetVisible(bool visible); 151 void SetVisible(bool visible);
165 bool visible() const { return visible_; } 152 bool visible() const { return visible_; }
166 153
167 // Indicates that a redraw is required, either due to the impl tree changing 154 // Indicates that a redraw is required, either due to the impl tree changing
168 // or the screen being damaged and simply needing redisplay. 155 // or the screen being damaged and simply needing redisplay.
169 void SetNeedsRedraw(); 156 void SetNeedsRedraw();
170 bool needs_redraw() const { return needs_redraw_; } 157 bool needs_redraw() const { return needs_redraw_; }
171 158
172 void SetNeedsAnimate(); 159 void SetNeedsAnimate();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 226 }
240 227
241 void DidPrepareTiles(); 228 void DidPrepareTiles();
242 void DidLoseOutputSurface(); 229 void DidLoseOutputSurface();
243 void DidCreateAndInitializeOutputSurface(); 230 void DidCreateAndInitializeOutputSurface();
244 bool HasInitializedOutputSurface() const; 231 bool HasInitializedOutputSurface() const;
245 232
246 // True if we need to abort draws to make forward progress. 233 // True if we need to abort draws to make forward progress.
247 bool PendingDrawsShouldBeAborted() const; 234 bool PendingDrawsShouldBeAborted() const;
248 235
249 bool SupportsProactiveBeginFrame() const;
250
251 void SetContinuousPainting(bool continuous_painting) { 236 void SetContinuousPainting(bool continuous_painting) {
252 continuous_painting_ = continuous_painting; 237 continuous_painting_ = continuous_painting;
253 } 238 }
254 239
255 bool CouldSendBeginMainFrame() const; 240 bool CouldSendBeginMainFrame() const;
256 241
257 void SetImplLatencyTakesPriorityOnBattery( 242 void SetImplLatencyTakesPriorityOnBattery(
258 bool impl_latency_takes_priority_on_battery) { 243 bool impl_latency_takes_priority_on_battery) {
259 impl_latency_takes_priority_on_battery_ = 244 impl_latency_takes_priority_on_battery_ =
260 impl_latency_takes_priority_on_battery; 245 impl_latency_takes_priority_on_battery;
(...skipping 20 matching lines...) Expand all
281 // True if we need to force activations to make forward progress. 266 // True if we need to force activations to make forward progress.
282 bool PendingActivationsShouldBeForced() const; 267 bool PendingActivationsShouldBeForced() const;
283 268
284 bool ShouldAnimate() const; 269 bool ShouldAnimate() const;
285 bool ShouldBeginOutputSurfaceCreation() const; 270 bool ShouldBeginOutputSurfaceCreation() const;
286 bool ShouldDraw() const; 271 bool ShouldDraw() const;
287 bool ShouldActivatePendingTree() const; 272 bool ShouldActivatePendingTree() const;
288 bool ShouldSendBeginMainFrame() const; 273 bool ShouldSendBeginMainFrame() const;
289 bool ShouldCommit() const; 274 bool ShouldCommit() const;
290 bool ShouldPrepareTiles() const; 275 bool ShouldPrepareTiles() const;
276 bool ShouldInvalidateOutputSurface() const;
291 277
292 void AdvanceCurrentFrameNumber(); 278 void AdvanceFrame();
293 bool HasAnimatedThisFrame() const; 279 bool HasAnimatedThisFrame() const;
294 bool HasSentBeginMainFrameThisFrame() const; 280 bool HasSentBeginMainFrameThisFrame() const;
295 bool HasRequestedSwapThisFrame() const; 281 bool HasRequestedSwapThisFrame() const;
296 bool HasSwappedThisFrame() const; 282 bool HasSwappedThisFrame() const;
283 bool HasInvalidatedOutputSurfaceThisFrame() const;
297 284
298 void UpdateStateOnCommit(bool commit_had_no_updates); 285 void UpdateStateOnCommit(bool commit_had_no_updates);
299 void UpdateStateOnActivation(); 286 void UpdateStateOnActivation();
300 void UpdateStateOnDraw(bool did_request_swap); 287 void UpdateStateOnDraw(bool did_request_swap);
301 void UpdateStateOnPrepareTiles(); 288 void UpdateStateOnPrepareTiles();
302 289
303 const SchedulerSettings settings_; 290 const SchedulerSettings settings_;
304 291
305 OutputSurfaceState output_surface_state_; 292 OutputSurfaceState output_surface_state_;
306 BeginImplFrameState begin_impl_frame_state_; 293 BeginImplFrameState begin_impl_frame_state_;
307 CommitState commit_state_; 294 CommitState commit_state_;
308 ForcedRedrawOnTimeoutState forced_redraw_state_; 295 ForcedRedrawOnTimeoutState forced_redraw_state_;
309 296
310 BeginFrameArgs begin_impl_frame_args_; 297 BeginFrameArgs begin_impl_frame_args_;
311 298
312 int commit_count_; 299 int commit_count_;
313 int current_frame_number_; 300 int current_frame_number_;
314 int last_frame_number_animate_performed_; 301 int last_frame_number_animate_performed_;
315 int last_frame_number_swap_performed_; 302 int last_frame_number_swap_performed_;
316 int last_frame_number_swap_requested_; 303 int last_frame_number_swap_requested_;
317 int last_frame_number_begin_main_frame_sent_; 304 int last_frame_number_begin_main_frame_sent_;
305 int last_frame_number_invalidate_output_surface_performed_;
318 306
319 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called 307 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called
320 // and "drained" on each BeginImplFrame. If the funnel gets too full, 308 // and "drained" on each BeginImplFrame. If the funnel gets too full,
321 // we start throttling ACTION_PREPARE_TILES such that we average one 309 // we start throttling ACTION_PREPARE_TILES such that we average one
322 // PrepareTiles per BeginImplFrame. 310 // PrepareTiles per BeginImplFrame.
323 int prepare_tiles_funnel_; 311 int prepare_tiles_funnel_;
324 int consecutive_checkerboard_animations_; 312 int consecutive_checkerboard_animations_;
325 int max_pending_swaps_; 313 int max_pending_swaps_;
326 int pending_swaps_; 314 int pending_swaps_;
327 bool needs_redraw_; 315 bool needs_redraw_;
328 bool needs_animate_; 316 bool needs_animate_;
329 bool needs_prepare_tiles_; 317 bool needs_prepare_tiles_;
330 bool needs_commit_; 318 bool needs_commit_;
331 bool inside_poll_for_anticipated_draw_triggers_;
332 bool visible_; 319 bool visible_;
333 bool can_start_; 320 bool can_start_;
334 bool can_draw_; 321 bool can_draw_;
335 bool has_pending_tree_; 322 bool has_pending_tree_;
336 bool pending_tree_is_ready_for_activation_; 323 bool pending_tree_is_ready_for_activation_;
337 bool active_tree_needs_first_draw_; 324 bool active_tree_needs_first_draw_;
338 bool did_commit_after_animating_; 325 bool did_commit_after_animating_;
339 bool did_create_and_initialize_first_output_surface_; 326 bool did_create_and_initialize_first_output_surface_;
340 bool impl_latency_takes_priority_; 327 bool impl_latency_takes_priority_;
341 bool skip_next_begin_main_frame_to_reduce_latency_; 328 bool skip_next_begin_main_frame_to_reduce_latency_;
342 bool skip_begin_main_frame_to_reduce_latency_; 329 bool skip_begin_main_frame_to_reduce_latency_;
343 bool continuous_painting_; 330 bool continuous_painting_;
344 bool impl_latency_takes_priority_on_battery_; 331 bool impl_latency_takes_priority_on_battery_;
345 bool children_need_begin_frames_; 332 bool children_need_begin_frames_;
346 bool defer_commits_; 333 bool defer_commits_;
347 334
348 private: 335 private:
349 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); 336 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine);
350 }; 337 };
351 338
352 } // namespace cc 339 } // namespace cc
353 340
354 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ 341 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698