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

Side by Side Diff: cc/surfaces/display_begin_frame_source.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/surfaces/display.cc ('k') | cc/surfaces/display_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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CC_SURFACES_DISPLAY_BEGIN_FRAME_SOURCE_H_
6 #define CC_SURFACES_DISPLAY_BEGIN_FRAME_SOURCE_H_
7
8 #include <memory>
9 #include <set>
10 #include <unordered_map>
11
12 #include "base/macros.h"
13 #include "cc/output/begin_frame_args.h"
14 #include "cc/scheduler/begin_frame_source.h"
15 #include "cc/surfaces/surfaces_export.h"
16
17 namespace cc {
18
19 class CC_SURFACES_EXPORT DisplayBeginFrameSourceClient {
20 public:
21 virtual void BeginFrameObserverStatusChanged() = 0;
22 virtual void OnBeginFrame(const BeginFrameArgs& args) = 0;
23 virtual const BeginFrameArgs& LastUsedBeginFrameArgs() const = 0;
24 };
25
26 // Wraps a BeginFrameSource and keeps track of observers that have finished a
27 // BeginFrame. Supports swapping the wrapped source underneath it.
28 class CC_SURFACES_EXPORT DisplayBeginFrameSource : public BeginFrameSource,
29 public BeginFrameObserver {
30 public:
31 explicit DisplayBeginFrameSource(
32 std::unique_ptr<BeginFrameSource> wrapped_source);
33 ~DisplayBeginFrameSource() override;
34
35 BeginFrameSource* GetWrappedSource() { return wrapped_source_.get(); }
36
37 void SetClient(DisplayBeginFrameSourceClient* client);
38 void SetClientNeedsBeginFrames(bool needs_begin_frames);
39
40 // Returns |true| if it the source has any active observers.
41 bool HasObservers() const;
42
43 // Returns |true| if all the source's observers completed the current frame.
44 bool AllObserversFinishedFrame() const;
45
46 // Completes the currently active frame. The client calls this to signal
47 // that it has executed the deadline for the BeginFrame. |had_updates|
48 // indicates whether the client produced an update (draw) as a result of the
49 // frame, and |has_pending_updates| whether it still has updates pending that
50 // it could not produce during this frame.
51 void FinishClientFrame(bool had_updates, bool has_pending_updates);
52
53 // Swaps the current wrapped source with the one pointed to by
54 // |begin_frame_source|. The old source is returned through the provided
55 // pointer, transferring its ownership to the caller.
56 void SwapWrappedSource(std::unique_ptr<BeginFrameSource>* begin_frame_source);
57
58 // Returns the source ID of the current BeginFrame.
59 uint64_t CurrentSourceId();
60
61 // Returns the sequence number of the current BeginFrame.
62 uint64_t CurrentFrameNumber();
63
64 // Returns the latest confirmed frame number for the current BeginFrame.
65 uint64_t LatestConfirmedFrame();
66
67 // BeginFrameSource implementation.
68 void DidFinishFrame(BeginFrameObserver* obs,
69 const BeginFrameAck& ack) override;
70 void AddObserver(BeginFrameObserver* obs) override;
71 void RemoveObserver(BeginFrameObserver* obs) override;
72 bool IsThrottled() const override;
73
74 // BeginFrameObserver implementation.
75 void OnBeginFrame(const BeginFrameArgs& args) override;
76 const BeginFrameArgs& LastUsedBeginFrameArgs() const override;
77 void OnBeginFrameSourcePausedChanged(bool paused) override;
78
79 private:
80 void UpdateObservingBeginFrames();
81 BeginFrameArgs GetMissedArgs(const BeginFrameArgs& last_args) const;
82 void ObserverStatusChanged();
83
84 std::unique_ptr<BeginFrameSource> wrapped_source_;
85 std::set<BeginFrameObserver*> observers_;
86 BeginFrameObserverAckTracker ack_tracker_;
87 BeginFrameArgs current_begin_frame_args_;
88 bool observing_begin_frames_;
89 bool frame_active_;
90 uint64_t latest_confirmed_frame_;
91
92 DisplayBeginFrameSourceClient* client_; // Not owned.
93 bool client_needs_begin_frames_;
94
95 DISALLOW_COPY_AND_ASSIGN(DisplayBeginFrameSource);
96 };
97
98 } // namespace cc
99
100 #endif // CC_SURFACES_DISPLAY_BEGIN_FRAME_SOURCE_H_
OLDNEW
« no previous file with comments | « cc/surfaces/display.cc ('k') | cc/surfaces/display_begin_frame_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698