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

Side by Side Diff: cc/surfaces/display_begin_frame_source.h

Issue 2527283003: cc: Introduce BeginFrame sequence numbers and acknowledgements.
Patch Set: . 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
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 target BeginFrameSource and keeps track of observers that have
27 // finished a BeginFrame. Supports swapping the target source underneath it.
28 class CC_SURFACES_EXPORT DisplayBeginFrameSource : public BeginFrameSource,
29 public BeginFrameObserver {
30 public:
31 explicit DisplayBeginFrameSource(
32 std::unique_ptr<BeginFrameSource> target_source);
Sami 2016/12/06 12:41:07 Sorry for the bikeshed but "target source" is brea
Eric Seckler 2016/12/06 17:34:00 Done.
33 ~DisplayBeginFrameSource() override;
34
35 BeginFrameSource* GetTargetSource() { return target_source_.get(); }
36 void SetClient(DisplayBeginFrameSourceClient* client) { client_ = client; }
37
38 void SetClientNeedsBeginFrames(bool needs_begin_frames);
39
40 // Returns |true| if all the source's observers completed the current frame.
41 bool ObserversFinishedFrame();
Sami 2016/12/06 12:41:07 ditto: AllObservers...?
Eric Seckler 2016/12/06 17:34:00 Done.
42
43 // Completes the currently active frame. The client calls this to signal
44 // that it has executed the deadline for the BeginFrame. |had_updates|
45 // indicates whether the client produced an update (draw) as a result of the
46 // frame, and |has_pending_updates| whether it still has updates pending that
47 // it could not produce during this frame.
48 void FinishFrame(bool had_updates, bool has_pending_updates);
Sami 2016/12/06 12:41:07 Should we call this FinishClientFrame()? I'd like
Eric Seckler 2016/12/06 17:34:00 Done.
49
50 // Swaps the current target source with the one pointed to by
51 // |begin_frame_source|. The old source is returned through the provided
52 // pointer, transferring its ownership to the caller.
53 void SwapTargetSource(std::unique_ptr<BeginFrameSource>* begin_frame_source);
54
55 // BeginFrameSource implementation.
56 void DidFinishFrame(BeginFrameObserver* obs,
57 const BeginFrameAck& ack) override;
58 void AddObserver(BeginFrameObserver* obs) override;
59 void RemoveObserver(BeginFrameObserver* obs) override;
60 bool IsThrottled() const override;
61
62 // BeginFrameObserver implementation.
63 void OnBeginFrame(const BeginFrameArgs& args) override;
64 const BeginFrameArgs& LastUsedBeginFrameArgs() const override;
65 void OnBeginFrameSourcePausedChanged(bool paused) override;
66
67 private:
68 void ObserverStatusChanged();
69
70 std::unique_ptr<BeginFrameSource> target_source_;
71 std::set<BeginFrameObserver*> observers_;
72 BeginFrameObserverAckTracker ack_tracker_;
73 BeginFrameArgs current_begin_frame_args_;
74 bool observing_begin_frames_;
75 bool frame_active_;
76 uint64_t current_source_id_;
77 uint64_t oldest_incorporated_frame_;
78
79 DisplayBeginFrameSourceClient* client_; // Not owned.
80 bool client_needs_begin_frames_;
81
82 DISALLOW_COPY_AND_ASSIGN(DisplayBeginFrameSource);
83 };
84
85 } // namespace cc
86
87 #endif // CC_SURFACES_DISPLAY_BEGIN_FRAME_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698