OLD | NEW |
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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // is pending at a time. | 110 // is pending at a time. |
111 virtual void DidFinishFrame(size_t remaining_frames) = 0; | 111 virtual void DidFinishFrame(size_t remaining_frames) = 0; |
112 | 112 |
113 // Add/Remove an observer from the source. | 113 // Add/Remove an observer from the source. |
114 // *At the moment* only a single observer can be added to the source, however | 114 // *At the moment* only a single observer can be added to the source, however |
115 // in the future this may be extended to allow multiple observers. | 115 // in the future this may be extended to allow multiple observers. |
116 // If making this change, please use base::ObserverList to do so. | 116 // If making this change, please use base::ObserverList to do so. |
117 virtual void AddObserver(BeginFrameObserver* obs) = 0; | 117 virtual void AddObserver(BeginFrameObserver* obs) = 0; |
118 virtual void RemoveObserver(BeginFrameObserver* obs) = 0; | 118 virtual void RemoveObserver(BeginFrameObserver* obs) = 0; |
119 | 119 |
| 120 // Tells the Source that client is ready to handle BeginFrames messages. |
| 121 virtual void SetClientReady() = 0; |
| 122 |
120 // Tracing support - Recommend (but not required) to call this implementation | 123 // Tracing support - Recommend (but not required) to call this implementation |
121 // in any override. | 124 // in any override. |
122 virtual void AsValueInto(base::debug::TracedValue* dict) const = 0; | 125 virtual void AsValueInto(base::debug::TracedValue* dict) const = 0; |
123 }; | 126 }; |
124 | 127 |
125 // Simple mix in which implements a BeginFrameSource. | 128 // Simple mix in which implements a BeginFrameSource. |
126 // Implementation classes should: | 129 // Implementation classes should: |
127 // - Implement the pure virtual (Set)NeedsBeginFrames methods from | 130 // - Implement the pure virtual (Set)NeedsBeginFrames methods from |
128 // BeginFrameSource. | 131 // BeginFrameSource. |
129 // - Use the CallOnBeginFrame method to call to the observer(s). | 132 // - Use the CallOnBeginFrame method to call to the observer(s). |
130 // - Recommended (but not required) to call BeginFrameSourceMixIn::AsValueInto | 133 // - Recommended (but not required) to call BeginFrameSourceMixIn::AsValueInto |
131 // in their own AsValueInto implementation. | 134 // in their own AsValueInto implementation. |
132 class CC_EXPORT BeginFrameSourceMixIn : public BeginFrameSource { | 135 class CC_EXPORT BeginFrameSourceMixIn : public BeginFrameSource { |
133 public: | 136 public: |
134 ~BeginFrameSourceMixIn() override {} | 137 ~BeginFrameSourceMixIn() override {} |
135 | 138 |
136 // BeginFrameSource | 139 // BeginFrameSource |
137 bool NeedsBeginFrames() const override; | 140 bool NeedsBeginFrames() const override; |
138 void SetNeedsBeginFrames(bool needs_begin_frames) override; | 141 void SetNeedsBeginFrames(bool needs_begin_frames) override; |
139 void DidFinishFrame(size_t remaining_frames) override {} | 142 void DidFinishFrame(size_t remaining_frames) override {} |
140 void AddObserver(BeginFrameObserver* obs) override; | 143 void AddObserver(BeginFrameObserver* obs) final; |
141 void RemoveObserver(BeginFrameObserver* obs) override; | 144 void RemoveObserver(BeginFrameObserver* obs) final; |
| 145 void SetClientReady() override {} |
142 | 146 |
143 // Tracing support - Recommend (but not required) to call this implementation | 147 // Tracing support - Recommend (but not required) to call this implementation |
144 // in any override. | 148 // in any override. |
145 void AsValueInto(base::debug::TracedValue* dict) const override; | 149 void AsValueInto(base::debug::TracedValue* dict) const override; |
146 | 150 |
147 protected: | 151 protected: |
148 BeginFrameSourceMixIn(); | 152 BeginFrameSourceMixIn(); |
149 | 153 |
150 // These methods should be used by subclasses to make the call to the | 154 // These methods should be used by subclasses to make the call to the |
151 // observers. | 155 // observers. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 274 |
271 base::TimeDelta minimum_interval_; | 275 base::TimeDelta minimum_interval_; |
272 | 276 |
273 BeginFrameSource* active_source_; | 277 BeginFrameSource* active_source_; |
274 std::set<BeginFrameSource*> source_list_; | 278 std::set<BeginFrameSource*> source_list_; |
275 }; | 279 }; |
276 | 280 |
277 } // namespace cc | 281 } // namespace cc |
278 | 282 |
279 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ | 283 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ |
OLD | NEW |