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

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

Issue 2527283003: cc: Introduce BeginFrame sequence numbers and acknowledgements.
Patch Set: Address Brian's comments. Created 4 years 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
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | cc/scheduler/scheduler_state_machine.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdint.h>
9
8 #include <memory> 10 #include <memory>
9 #include <string> 11 #include <string>
10 12
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "cc/base/cc_export.h" 14 #include "cc/base/cc_export.h"
13 #include "cc/output/begin_frame_args.h"
14 #include "cc/scheduler/commit_earlyout_reason.h" 15 #include "cc/scheduler/commit_earlyout_reason.h"
15 #include "cc/scheduler/draw_result.h" 16 #include "cc/scheduler/draw_result.h"
16 #include "cc/scheduler/scheduler_settings.h" 17 #include "cc/scheduler/scheduler_settings.h"
17 #include "cc/tiles/tile_priority.h" 18 #include "cc/tiles/tile_priority.h"
18 19
19 namespace base { 20 namespace base {
20 namespace trace_event { 21 namespace trace_event {
21 class ConvertableToTraceFormat; 22 class ConvertableToTraceFormat;
22 class TracedValue; 23 class TracedValue;
23 } 24 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 141
141 void AbortDraw(); 142 void AbortDraw();
142 143
143 // Indicates whether the impl thread needs a BeginImplFrame callback in order 144 // Indicates whether the impl thread needs a BeginImplFrame callback in order
144 // to make progress. 145 // to make progress.
145 bool BeginFrameNeeded() const; 146 bool BeginFrameNeeded() const;
146 147
147 // Indicates that the system has entered and left a BeginImplFrame callback. 148 // Indicates that the system has entered and left a BeginImplFrame callback.
148 // The scheduler will not draw more than once in a given BeginImplFrame 149 // The scheduler will not draw more than once in a given BeginImplFrame
149 // callback nor send more than one BeginMainFrame message. 150 // callback nor send more than one BeginMainFrame message.
150 void OnBeginImplFrame(); 151 void OnBeginImplFrame(uint64_t source_id, uint64_t sequence_number);
151 // Indicates that the scheduler has entered the draw phase. The scheduler 152 // Indicates that the scheduler has entered the draw phase. The scheduler
152 // will not draw more than once in a single draw phase. 153 // will not draw more than once in a single draw phase.
153 // TODO(sunnyps): Rename OnBeginImplFrameDeadline to OnDraw or similar. 154 // TODO(sunnyps): Rename OnBeginImplFrameDeadline to OnDraw or similar.
154 void OnBeginImplFrameDeadline(); 155 void OnBeginImplFrameDeadline();
155 void OnBeginImplFrameIdle(); 156 void OnBeginImplFrameIdle();
156 157
157 int current_frame_number() const { return current_frame_number_; } 158 int current_frame_number() const { return current_frame_number_; }
158 159
159 BeginImplFrameState begin_impl_frame_state() const { 160 BeginImplFrameState begin_impl_frame_state() const {
160 return begin_impl_frame_state_; 161 return begin_impl_frame_state_;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // True if we need to abort draws to make forward progress. 263 // True if we need to abort draws to make forward progress.
263 bool PendingDrawsShouldBeAborted() const; 264 bool PendingDrawsShouldBeAborted() const;
264 265
265 bool CouldSendBeginMainFrame() const; 266 bool CouldSendBeginMainFrame() const;
266 267
267 void SetDeferCommits(bool defer_commits); 268 void SetDeferCommits(bool defer_commits);
268 269
269 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames); 270 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames);
270 bool video_needs_begin_frames() const { return video_needs_begin_frames_; } 271 bool video_needs_begin_frames() const { return video_needs_begin_frames_; }
271 272
273 bool did_submit_in_last_frame() const { return did_submit_in_last_frame_; }
274 uint64_t last_frame_number_compositor_frame_was_fresh() const {
275 return last_frame_number_compositor_frame_was_fresh_;
276 }
277 uint64_t last_frame_number_active_tree_was_fresh() const {
278 return last_frame_number_active_tree_was_fresh_;
279 }
280
272 protected: 281 protected:
273 bool BeginFrameRequiredForAction() const; 282 bool BeginFrameRequiredForAction() const;
274 bool BeginFrameNeededForVideo() const; 283 bool BeginFrameNeededForVideo() const;
275 bool ProactiveBeginFrameWanted() const; 284 bool ProactiveBeginFrameWanted() const;
276 285
277 bool ShouldTriggerBeginImplFrameDeadlineImmediately() const; 286 bool ShouldTriggerBeginImplFrameDeadlineImmediately() const;
278 287
279 // True if we need to force activations to make forward progress. 288 // True if we need to force activations to make forward progress.
280 // TODO(sunnyps): Rename this to ShouldAbortCurrentFrame or similar. 289 // TODO(sunnyps): Rename this to ShouldAbortCurrentFrame or similar.
281 bool PendingActivationsShouldBeForced() const; 290 bool PendingActivationsShouldBeForced() const;
282 291
283 bool ShouldBeginCompositorFrameSinkCreation() const; 292 bool ShouldBeginCompositorFrameSinkCreation() const;
284 bool ShouldDraw() const; 293 bool ShouldDraw() const;
285 bool ShouldActivatePendingTree() const; 294 bool ShouldActivatePendingTree() const;
286 bool ShouldSendBeginMainFrame() const; 295 bool ShouldSendBeginMainFrame() const;
287 bool ShouldCommit() const; 296 bool ShouldCommit() const;
288 bool ShouldPrepareTiles() const; 297 bool ShouldPrepareTiles() const;
289 bool ShouldInvalidateCompositorFrameSink() const; 298 bool ShouldInvalidateCompositorFrameSink() const;
290 299
291 void WillDrawInternal(); 300 void WillDrawInternal();
292 void DidDrawInternal(DrawResult draw_result); 301 void DidDrawInternal(DrawResult draw_result);
293 302
294 const SchedulerSettings settings_; 303 const SchedulerSettings settings_;
295 304
296 CompositorFrameSinkState compositor_frame_sink_state_; 305 CompositorFrameSinkState compositor_frame_sink_state_;
297 BeginImplFrameState begin_impl_frame_state_; 306 BeginImplFrameState begin_impl_frame_state_;
298 BeginMainFrameState begin_main_frame_state_; 307 BeginMainFrameState begin_main_frame_state_;
299 ForcedRedrawOnTimeoutState forced_redraw_state_; 308 ForcedRedrawOnTimeoutState forced_redraw_state_;
300 309
301 // These are used for tracing only. 310 // These are used for tracing and BeginFrame acknowledgments.
302 int commit_count_; 311 int commit_count_;
303 int current_frame_number_; 312 uint64_t begin_frame_source_id_;
304 int last_frame_number_submit_performed_; 313 uint64_t current_frame_number_;
305 int last_frame_number_draw_performed_; 314 uint64_t last_frame_number_submit_performed_;
306 int last_frame_number_begin_main_frame_sent_; 315 uint64_t last_frame_number_draw_performed_;
307 int last_frame_number_invalidate_compositor_frame_sink_performed_; 316 uint64_t last_frame_number_begin_main_frame_sent_;
317 uint64_t last_frame_number_invalidate_compositor_frame_sink_performed_;
318 uint64_t last_frame_number_pending_tree_was_fresh_;
319 uint64_t last_frame_number_active_tree_was_fresh_;
320 uint64_t last_frame_number_compositor_frame_was_fresh_;
308 321
309 // These are used to ensure that an action only happens once per frame, 322 // These are used to ensure that an action only happens once per frame,
310 // deadline, etc. 323 // deadline, etc.
311 bool draw_funnel_; 324 bool draw_funnel_;
312 bool send_begin_main_frame_funnel_; 325 bool send_begin_main_frame_funnel_;
313 bool invalidate_compositor_frame_sink_funnel_; 326 bool invalidate_compositor_frame_sink_funnel_;
314 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called 327 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called
315 // and "drained" on each BeginImplFrame. If the funnel gets too full, 328 // and "drained" on each BeginImplFrame. If the funnel gets too full,
316 // we start throttling ACTION_PREPARE_TILES such that we average one 329 // we start throttling ACTION_PREPARE_TILES such that we average one
317 // PrepareTiles per BeginImplFrame. 330 // PrepareTiles per BeginImplFrame.
(...skipping 26 matching lines...) Expand all
344 bool did_draw_in_last_frame_; 357 bool did_draw_in_last_frame_;
345 bool did_submit_in_last_frame_; 358 bool did_submit_in_last_frame_;
346 359
347 private: 360 private:
348 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); 361 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine);
349 }; 362 };
350 363
351 } // namespace cc 364 } // namespace cc
352 365
353 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ 366 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | cc/scheduler/scheduler_state_machine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698