OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_SCHEDULER_BEGIN_FRAME_MANAGER_H_ | |
6 #define CC_SCHEDULER_BEGIN_FRAME_MANAGER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/observer_list.h" | |
10 #include "base/threading/non_thread_safe.h" | |
11 #include "base/time/time.h" | |
12 #include "cc/base/cc_export.h" | |
13 #include "cc/output/begin_frame_args.h" | |
14 | |
15 namespace cc { | |
16 | |
17 struct BeginFrameArgs; | |
18 | |
19 // This class delivers a BeginFrame request from the Compositor to its | |
20 // observers. It also handles next BeginFrame scheduling via its delegate. | |
21 // Browser compositor will own this. | |
22 // This class will be run only on main thread. | |
23 class CC_EXPORT BeginFrameManager : public base::NonThreadSafe { | |
24 public: | |
25 // Subclass should deliver BeginFrame to its client. | |
26 class Observer { | |
27 public: | |
28 virtual void OnSendBeginFrame(const BeginFrameArgs& args) = 0; | |
29 }; | |
30 | |
31 // Subclass should implement howto schedule next BeginFrame. | |
brianderson
2014/08/27 01:34:08
howto -> how to
simonhong
2014/08/27 07:56:12
Done.
| |
32 class Delegate { | |
33 public: | |
34 virtual void SetChildrenNeedBeginFrames(bool need_begin_frame) = 0; | |
35 | |
36 // The "authoritative" vsync interval, if provided, will override interval | |
37 // reported from 3D context. This is typically the value reported by a more | |
38 // reliable source, e.g, the platform display configuration. | |
39 // In the particular case of ChromeOS -- this is the value queried through | |
40 // XRandR, which is more reliable than the value queried through the 3D | |
41 // context. | |
42 virtual void SetAuthoritativeVSyncInterval(base::TimeDelta interval) {} | |
43 }; | |
44 | |
45 BeginFrameManager(); | |
46 ~BeginFrameManager(); | |
47 | |
48 void set_delegate(Delegate* delegate) { | |
49 DCHECK(!delegate_); | |
50 delegate_ = delegate; | |
51 } | |
52 | |
53 // Request BeginFrame to observers. | |
brianderson
2014/08/27 01:34:08
Request -> Send
simonhong
2014/08/27 07:56:12
Done.
| |
54 void SendBeginFrameToChildren(const BeginFrameArgs& args); | |
55 | |
56 // See the comment of Delegate::SetAuthritativeVSyncInterval. | |
57 void SetAuthoritativeVSyncInterval(base::TimeDelta interval) const; | |
58 | |
59 void AddObserver( | |
60 Observer* observer, | |
61 const BeginFrameArgs& last_begin_frame_args_sent_to_observer); | |
62 void RemoveObserver(Observer* observer); | |
63 | |
64 private: | |
65 // Not owned by this class. | |
66 Delegate* delegate_; | |
67 | |
68 // Number of BeginFrameManager's observer. | |
69 int num_of_observers_; | |
70 | |
71 // Used to send to the new observer immediately. | |
brianderson
2014/08/27 01:34:08
"the new observer" -> "any new observers"
simonhong
2014/08/27 07:56:12
Done.
| |
72 BeginFrameArgs last_begin_frame_args_; | |
73 | |
74 ObserverList<BeginFrameManager::Observer> observer_list_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(BeginFrameManager); | |
77 }; | |
78 | |
79 } // namespace cc | |
80 | |
81 #endif // CC_SCHEDULER_BEGIN_FRAME_MANAGER_H_ | |
OLD | NEW |