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

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

Issue 2632563003: [cc] Calculate the correct latest_confirmed_sequence_number in cc::Scheduler. (Closed)
Patch Set: Fix handling of source_id changes and add some Scheduler tests. Created 3 years, 11 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 <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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void WillInvalidateCompositorFrameSink(); 138 void WillInvalidateCompositorFrameSink();
138 139
139 void DidDraw(DrawResult draw_result); 140 void DidDraw(DrawResult draw_result);
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
148 // Indicates that the Scheduler has received a BeginFrame that did not require
149 // a BeginImplFrame, because the Scheduler stopped observing BeginFrames.
150 // Updates the sequence and freshness numbers for the dropped BeginFrame.
151 void OnBeginFrameDroppedNotObserving(uint32_t source_id,
152 uint64_t sequence_number);
153
147 // Indicates that the system has entered and left a BeginImplFrame callback. 154 // Indicates that the system has entered and left a BeginImplFrame callback.
148 // The scheduler will not draw more than once in a given BeginImplFrame 155 // The scheduler will not draw more than once in a given BeginImplFrame
149 // callback nor send more than one BeginMainFrame message. 156 // callback nor send more than one BeginMainFrame message.
150 void OnBeginImplFrame(); 157 void OnBeginImplFrame(uint32_t source_id, uint64_t sequence_number);
151 // Indicates that the scheduler has entered the draw phase. The scheduler 158 // Indicates that the scheduler has entered the draw phase. The scheduler
152 // will not draw more than once in a single draw phase. 159 // will not draw more than once in a single draw phase.
153 // TODO(sunnyps): Rename OnBeginImplFrameDeadline to OnDraw or similar. 160 // TODO(sunnyps): Rename OnBeginImplFrameDeadline to OnDraw or similar.
154 void OnBeginImplFrameDeadline(); 161 void OnBeginImplFrameDeadline();
155 void OnBeginImplFrameIdle(); 162 void OnBeginImplFrameIdle();
156 163
157 int current_frame_number() const { return current_frame_number_; } 164 int current_frame_number() const { return current_frame_number_; }
158 165
159 BeginImplFrameState begin_impl_frame_state() const { 166 BeginImplFrameState begin_impl_frame_state() const {
160 return begin_impl_frame_state_; 167 return begin_impl_frame_state_;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 271
265 bool CouldSendBeginMainFrame() const; 272 bool CouldSendBeginMainFrame() const;
266 273
267 void SetDeferCommits(bool defer_commits); 274 void SetDeferCommits(bool defer_commits);
268 275
269 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames); 276 void SetVideoNeedsBeginFrames(bool video_needs_begin_frames);
270 bool video_needs_begin_frames() const { return video_needs_begin_frames_; } 277 bool video_needs_begin_frames() const { return video_needs_begin_frames_; }
271 278
272 bool did_submit_in_last_frame() const { return did_submit_in_last_frame_; } 279 bool did_submit_in_last_frame() const { return did_submit_in_last_frame_; }
273 280
281 uint32_t begin_frame_source_id() const { return begin_frame_source_id_; }
282 uint64_t last_begin_frame_sequence_number_compositor_frame_was_fresh() const {
283 return last_begin_frame_sequence_number_compositor_frame_was_fresh_;
284 }
285
274 protected: 286 protected:
275 bool BeginFrameRequiredForAction() const; 287 bool BeginFrameRequiredForAction() const;
276 bool BeginFrameNeededForVideo() const; 288 bool BeginFrameNeededForVideo() const;
277 bool ProactiveBeginFrameWanted() const; 289 bool ProactiveBeginFrameWanted() const;
278 290
279 bool ShouldTriggerBeginImplFrameDeadlineImmediately() const; 291 bool ShouldTriggerBeginImplFrameDeadlineImmediately() const;
280 292
281 // True if we need to force activations to make forward progress. 293 // True if we need to force activations to make forward progress.
282 // TODO(sunnyps): Rename this to ShouldAbortCurrentFrame or similar. 294 // TODO(sunnyps): Rename this to ShouldAbortCurrentFrame or similar.
283 bool PendingActivationsShouldBeForced() const; 295 bool PendingActivationsShouldBeForced() const;
284 296
285 bool ShouldBeginCompositorFrameSinkCreation() const; 297 bool ShouldBeginCompositorFrameSinkCreation() const;
286 bool ShouldDraw() const; 298 bool ShouldDraw() const;
287 bool ShouldActivatePendingTree() const; 299 bool ShouldActivatePendingTree() const;
288 bool ShouldSendBeginMainFrame() const; 300 bool ShouldSendBeginMainFrame() const;
289 bool ShouldCommit() const; 301 bool ShouldCommit() const;
290 bool ShouldPrepareTiles() const; 302 bool ShouldPrepareTiles() const;
291 bool ShouldInvalidateCompositorFrameSink() const; 303 bool ShouldInvalidateCompositorFrameSink() const;
292 304
293 void WillDrawInternal(); 305 void WillDrawInternal();
294 void DidDrawInternal(DrawResult draw_result); 306 void DidDrawInternal(DrawResult draw_result);
295 307
308 void UpdateBeginFrameSequenceNumbersForBeginFrame(uint32_t source_id,
309 uint64_t sequence_number);
310 void UpdateBeginFrameSequenceNumbersForBeginFrameDeadline();
311
296 const SchedulerSettings settings_; 312 const SchedulerSettings settings_;
297 313
298 CompositorFrameSinkState compositor_frame_sink_state_; 314 CompositorFrameSinkState compositor_frame_sink_state_;
299 BeginImplFrameState begin_impl_frame_state_; 315 BeginImplFrameState begin_impl_frame_state_;
300 BeginMainFrameState begin_main_frame_state_; 316 BeginMainFrameState begin_main_frame_state_;
301 ForcedRedrawOnTimeoutState forced_redraw_state_; 317 ForcedRedrawOnTimeoutState forced_redraw_state_;
302 318
319 // These fields are used to track the freshness of pending updates in the
320 // commit/activate/draw pipeline. The Scheduler uses the CompositorFrame's
321 // freshness to fill the |latest_confirmed_frame| field in BeginFrameAcks.
322 uint32_t begin_frame_source_id_;
323 uint64_t begin_frame_sequence_number_;
324 uint64_t last_begin_frame_sequence_number_begin_main_frame_sent_;
325 uint64_t last_begin_frame_sequence_number_pending_tree_was_fresh_;
326 uint64_t last_begin_frame_sequence_number_active_tree_was_fresh_;
327 uint64_t last_begin_frame_sequence_number_compositor_frame_was_fresh_;
328
303 // These are used for tracing only. 329 // These are used for tracing only.
304 int commit_count_; 330 int commit_count_;
305 int current_frame_number_; 331 int current_frame_number_;
306 int last_frame_number_submit_performed_; 332 int last_frame_number_submit_performed_;
307 int last_frame_number_draw_performed_; 333 int last_frame_number_draw_performed_;
308 int last_frame_number_begin_main_frame_sent_; 334 int last_frame_number_begin_main_frame_sent_;
309 int last_frame_number_invalidate_compositor_frame_sink_performed_; 335 int last_frame_number_invalidate_compositor_frame_sink_performed_;
310 336
311 // These are used to ensure that an action only happens once per frame, 337 // These are used to ensure that an action only happens once per frame,
312 // deadline, etc. 338 // deadline, etc.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 bool did_draw_in_last_frame_; 372 bool did_draw_in_last_frame_;
347 bool did_submit_in_last_frame_; 373 bool did_submit_in_last_frame_;
348 374
349 private: 375 private:
350 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); 376 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine);
351 }; 377 };
352 378
353 } // namespace cc 379 } // namespace cc
354 380
355 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ 381 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698