| 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 virtual ~BeginFrameSourceMixIn() {} | 137 virtual ~BeginFrameSourceMixIn() {} |
| 135 | 138 |
| 136 // BeginFrameSource | 139 // BeginFrameSource |
| 137 virtual bool NeedsBeginFrames() const override; | 140 virtual bool NeedsBeginFrames() const override; |
| 138 virtual void SetNeedsBeginFrames(bool needs_begin_frames) override; | 141 virtual void SetNeedsBeginFrames(bool needs_begin_frames) override; |
| 139 virtual void DidFinishFrame(size_t remaining_frames) override {} | 142 virtual void DidFinishFrame(size_t remaining_frames) override {} |
| 140 virtual void AddObserver(BeginFrameObserver* obs) override; | 143 virtual void AddObserver(BeginFrameObserver* obs) override; |
| 141 virtual void RemoveObserver(BeginFrameObserver* obs) override; | 144 virtual void RemoveObserver(BeginFrameObserver* obs) override; |
| 145 virtual 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 virtual void AsValueInto(base::debug::TracedValue* dict) const override; | 149 virtual 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 275 |
| 272 base::TimeDelta minimum_interval_; | 276 base::TimeDelta minimum_interval_; |
| 273 | 277 |
| 274 BeginFrameSource* active_source_; | 278 BeginFrameSource* active_source_; |
| 275 std::set<BeginFrameSource*> source_list_; | 279 std::set<BeginFrameSource*> source_list_; |
| 276 }; | 280 }; |
| 277 | 281 |
| 278 } // namespace cc | 282 } // namespace cc |
| 279 | 283 |
| 280 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ | 284 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ |
| OLD | NEW |