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

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

Issue 2411793008: Adds BeginFrameControl via DevTools.
Patch Set: BFC prototype v2 with allow_latency_opts and waiting for BFOs. 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
11 #include "base/macros.h"
12 #include "cc/scheduler/begin_frame_source.h"
13
14 namespace cc {
15
16 class DisplayBeginFrameSourceClient {
17 public:
18 virtual void ObserverStatusChanged() = 0;
19 virtual void BeginFrameSourceSwapping(BeginFrameSource* new_source) = 0;
20 };
21
22 // Wraps a target BeginFrameSource and keeps track of observers that have
23 // finished a BeginFrame. Supports swapping the target source underneath it.
24 class DisplayBeginFrameSource : public BeginFrameSource,
25 public BeginFrameObserver {
26 public:
27 explicit DisplayBeginFrameSource(
28 std::unique_ptr<BeginFrameSource> target_source);
29 ~DisplayBeginFrameSource() override;
30
31 BeginFrameSource* GetTargetSource() { return target_source_.get(); }
32 void SetClient(DisplayBeginFrameSourceClient* client) { client_ = client; }
33
34 bool AllObserversFinishedFrame();
35
36 void SwapTargetSource(std::unique_ptr<BeginFrameSource>* begin_frame_source);
37
38 // BeginFrameSource implementation.
39 void DidFinishFrame(BeginFrameObserver* obs,
40 size_t remaining_frames) override;
41 void AddObserver(BeginFrameObserver* obs) override;
42 void RemoveObserver(BeginFrameObserver* obs) override;
43 bool IsThrottled() const override;
44
45 // BeginFrameObserver implementation.
46 void OnBeginFrame(const BeginFrameArgs& args) override;
47 const BeginFrameArgs& LastUsedBeginFrameArgs() const override;
48 void OnBeginFrameSourcePausedChanged(bool paused) override;
49
50 private:
51 void ObserverStatusChanged();
52 void MaybeFinishFrame();
53
54 std::unique_ptr<BeginFrameSource> target_source_;
55 std::set<BeginFrameObserver*> observers_;
56 std::set<BeginFrameObserver*> finished_observers_;
57 BeginFrameArgs last_begin_frame_args_;
58 bool observing_begin_frames_;
59 bool frame_active_;
60
61 DisplayBeginFrameSourceClient* client_; // Not owned.
62
63 DISALLOW_COPY_AND_ASSIGN(DisplayBeginFrameSource);
64 };
65
66 } // namespace cc
67
68 #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