Chromium Code Reviews| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 | 79 |
| 80 protected: | 80 protected: |
| 81 // Subclasses should override this method! | 81 // Subclasses should override this method! |
| 82 // Return true if the given argument is (or will be) used. | 82 // Return true if the given argument is (or will be) used. |
| 83 virtual bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) = 0; | 83 virtual bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) = 0; |
| 84 | 84 |
| 85 BeginFrameArgs last_begin_frame_args_; | 85 BeginFrameArgs last_begin_frame_args_; |
| 86 int64_t dropped_begin_frame_args_; | 86 int64_t dropped_begin_frame_args_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 // A "virtual" frame observer which forwards any received BeginFrame messages | |
| 90 // to all registered observers. Also provides a callback allowing detection of | |
| 91 // observers existing. | |
| 92 class CC_EXPORT BeginFrameObserverMultiplexer : public BeginFrameObserverMixIn { | |
|
simonhong
2015/03/25 02:03:22
As dana said, how about subclassing BeginFrameObse
mithro-old
2015/03/25 02:34:47
Implementing BeginFrameObserver means duplicating
| |
| 93 public: | |
| 94 using HasObserversCallback = base::Callback<void(bool has_observers)>; | |
| 95 | |
| 96 static scoped_ptr<BeginFrameObserverMultiplexer> Create(); | |
| 97 ~BeginFrameObserverMultiplexer() override; | |
| 98 | |
| 99 void AddObserver(BeginFrameObserver* obs); | |
| 100 void RemoveObserver(BeginFrameObserver* obs); | |
| 101 bool HasObservers(); | |
| 102 void SetHasObserverCallback(const HasObserversCallback& cb); | |
| 103 | |
| 104 void AsValueInto(base::trace_event::TracedValue* dict) const override; | |
| 105 | |
| 106 protected: | |
| 107 BeginFrameObserverMultiplexer(); | |
| 108 | |
| 109 bool last_callback_state_; | |
| 110 HasObserversCallback has_observers_callback_; | |
| 111 void CallCallbackOnChange(); | |
| 112 void CallCallback(bool has_observers); | |
| 113 | |
| 114 // BeginFrameObserverMixIn | |
| 115 bool OnBeginFrameMixInDelegate(const BeginFrameArgs& args) override; | |
| 116 | |
| 117 ObserverList<BeginFrameObserver> observer_list_; | |
| 118 }; | |
| 119 | |
| 89 // Interface for a class which produces BeginFrame calls to a | 120 // Interface for a class which produces BeginFrame calls to a |
| 90 // BeginFrameObserver. | 121 // BeginFrameObserver. |
| 91 // | 122 // |
| 92 // BeginFrame calls *normally* occur just after a vsync interrupt when input | 123 // BeginFrame calls *normally* occur just after a vsync interrupt when input |
| 93 // processing has been finished and provide information about the time values | 124 // processing has been finished and provide information about the time values |
| 94 // of the vsync times. *However*, these values can be heavily modified or even | 125 // of the vsync times. *However*, these values can be heavily modified or even |
| 95 // plain made up (when no vsync signal is available or vsync throttling is | 126 // plain made up (when no vsync signal is available or vsync throttling is |
| 96 // turned off). See the BeginFrameObserver for information about the guarantees | 127 // turned off). See the BeginFrameObserver for information about the guarantees |
| 97 // all BeginFrameSources *must* provide. | 128 // all BeginFrameSources *must* provide. |
| 98 class CC_EXPORT BeginFrameSource { | 129 class CC_EXPORT BeginFrameSource { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 | 305 |
| 275 base::TimeDelta minimum_interval_; | 306 base::TimeDelta minimum_interval_; |
| 276 | 307 |
| 277 BeginFrameSource* active_source_; | 308 BeginFrameSource* active_source_; |
| 278 std::set<BeginFrameSource*> source_list_; | 309 std::set<BeginFrameSource*> source_list_; |
| 279 }; | 310 }; |
| 280 | 311 |
| 281 } // namespace cc | 312 } // namespace cc |
| 282 | 313 |
| 283 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ | 314 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ |
| OLD | NEW |