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

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

Issue 2888043004: [cc] Add and plumb CFS::DidNotProduceFrame. (Closed)
Patch Set: address nits, rename to DidNotProduceFrame. Created 3 years, 7 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
« no previous file with comments | « cc/output/compositor_frame_sink_unittest.cc ('k') | cc/scheduler/begin_frame_source.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_BEGIN_FRAME_SOURCE_H_ 5 #ifndef CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_
6 #define CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ 6 #define CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 std::unique_ptr<DelayBasedTimeSource> time_source_; 240 std::unique_ptr<DelayBasedTimeSource> time_source_;
241 std::unordered_set<BeginFrameObserver*> observers_; 241 std::unordered_set<BeginFrameObserver*> observers_;
242 base::TimeTicks last_timebase_; 242 base::TimeTicks last_timebase_;
243 base::TimeDelta authoritative_interval_; 243 base::TimeDelta authoritative_interval_;
244 BeginFrameArgs current_begin_frame_args_; 244 BeginFrameArgs current_begin_frame_args_;
245 uint64_t next_sequence_number_; 245 uint64_t next_sequence_number_;
246 246
247 DISALLOW_COPY_AND_ASSIGN(DelayBasedBeginFrameSource); 247 DISALLOW_COPY_AND_ASSIGN(DelayBasedBeginFrameSource);
248 }; 248 };
249 249
250 // Helper class that tracks outstanding acknowledgments from
251 // BeginFrameObservers.
252 class CC_EXPORT BeginFrameObserverAckTracker {
253 public:
254 BeginFrameObserverAckTracker();
255 ~BeginFrameObserverAckTracker();
256
257 // The BeginFrameSource uses these methods to notify us when a BeginFrame was
258 // started, an observer finished a frame, or an observer was added/removed.
259 void OnBeginFrame(const BeginFrameArgs& args);
260 void OnObserverFinishedFrame(BeginFrameObserver* obs,
261 const BeginFrameAck& ack);
262 void OnObserverAdded(BeginFrameObserver* obs);
263 void OnObserverRemoved(BeginFrameObserver* obs);
264
265 // Returns |true| if all the source's observers completed the current frame.
266 bool AllObserversFinishedFrame() const;
267
268 // Returns |true| if any observer had damage during the current frame.
269 bool AnyObserversHadDamage() const;
270
271 // Return the sequence number of the latest frame that all active observers
272 // have confirmed.
273 uint64_t LatestConfirmedSequenceNumber() const;
274
275 void AsValueInto(base::trace_event::TracedValue* state) const;
276
277 private:
278 void SourceChanged(const BeginFrameArgs& args);
279
280 uint32_t current_source_id_ = 0;
281 uint64_t current_sequence_number_ = BeginFrameArgs::kStartingFrameNumber;
282 // Small sets, but order matters for intersection computation.
283 base::flat_set<BeginFrameObserver*> observers_;
284 base::flat_set<BeginFrameObserver*> finished_observers_;
285 bool observers_had_damage_ = false;
286 base::flat_map<BeginFrameObserver*, uint64_t>
287 latest_confirmed_sequence_numbers_;
288
289 DISALLOW_COPY_AND_ASSIGN(BeginFrameObserverAckTracker);
290 };
291
292 class CC_EXPORT ExternalBeginFrameSourceClient { 250 class CC_EXPORT ExternalBeginFrameSourceClient {
293 public: 251 public:
294 // Only called when changed. Assumed false by default. 252 // Only called when changed. Assumed false by default.
295 virtual void OnNeedsBeginFrames(bool needs_begin_frames) = 0; 253 virtual void OnNeedsBeginFrames(bool needs_begin_frames) = 0;
296 // Called when all observers have completed a frame.
297 virtual void OnDidFinishFrame(const BeginFrameAck& ack) = 0;
298 }; 254 };
299 255
300 // A BeginFrameSource that is only ticked manually. Usually the endpoint 256 // A BeginFrameSource that is only ticked manually. Usually the endpoint
301 // of messages from some other thread/process that send OnBeginFrame and 257 // of messages from some other thread/process that send OnBeginFrame and
302 // receive SetNeedsBeginFrame messages. This turns such messages back into 258 // receive SetNeedsBeginFrame messages. This turns such messages back into
303 // an observable BeginFrameSource. 259 // an observable BeginFrameSource.
304 class CC_EXPORT ExternalBeginFrameSource : public BeginFrameSource { 260 class CC_EXPORT ExternalBeginFrameSource : public BeginFrameSource {
305 public: 261 public:
306 // Client lifetime must be preserved by owner past the lifetime of this class. 262 // Client lifetime must be preserved by owner past the lifetime of this class.
307 explicit ExternalBeginFrameSource(ExternalBeginFrameSourceClient* client); 263 explicit ExternalBeginFrameSource(ExternalBeginFrameSourceClient* client);
308 ~ExternalBeginFrameSource() override; 264 ~ExternalBeginFrameSource() override;
309 265
310 // BeginFrameSource implementation. 266 // BeginFrameSource implementation.
311 void AddObserver(BeginFrameObserver* obs) override; 267 void AddObserver(BeginFrameObserver* obs) override;
312 void RemoveObserver(BeginFrameObserver* obs) override; 268 void RemoveObserver(BeginFrameObserver* obs) override;
313 void DidFinishFrame(BeginFrameObserver* obs, 269 void DidFinishFrame(BeginFrameObserver* obs,
314 const BeginFrameAck& ack) override; 270 const BeginFrameAck& ack) override;
315 bool IsThrottled() const override; 271 bool IsThrottled() const override;
316 void AsValueInto(base::trace_event::TracedValue* state) const override; 272 void AsValueInto(base::trace_event::TracedValue* state) const override;
317 273
318 void OnSetBeginFrameSourcePaused(bool paused); 274 void OnSetBeginFrameSourcePaused(bool paused);
319 void OnBeginFrame(const BeginFrameArgs& args); 275 void OnBeginFrame(const BeginFrameArgs& args);
320 276
321 protected: 277 protected:
322 void MaybeFinishFrame();
323 void FinishFrame();
324
325 BeginFrameArgs last_begin_frame_args_; 278 BeginFrameArgs last_begin_frame_args_;
326 std::unordered_set<BeginFrameObserver*> observers_; 279 std::unordered_set<BeginFrameObserver*> observers_;
327 ExternalBeginFrameSourceClient* client_; 280 ExternalBeginFrameSourceClient* client_;
328 bool paused_ = false; 281 bool paused_ = false;
329 bool frame_active_ = false;
330 BeginFrameObserverAckTracker ack_tracker_;
331 282
332 private: 283 private:
333 DISALLOW_COPY_AND_ASSIGN(ExternalBeginFrameSource); 284 DISALLOW_COPY_AND_ASSIGN(ExternalBeginFrameSource);
334 }; 285 };
335 286
336 } // namespace cc 287 } // namespace cc
337 288
338 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ 289 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_
OLDNEW
« no previous file with comments | « cc/output/compositor_frame_sink_unittest.cc ('k') | cc/scheduler/begin_frame_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698