Chromium Code Reviews| Index: cc/scheduler/begin_frame_manager.h |
| diff --git a/cc/scheduler/begin_frame_manager.h b/cc/scheduler/begin_frame_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e6dc28395c78fd801fb721897179af8ba3060089 |
| --- /dev/null |
| +++ b/cc/scheduler/begin_frame_manager.h |
| @@ -0,0 +1,81 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CC_SCHEDULER_BEGIN_FRAME_MANAGER_H_ |
| +#define CC_SCHEDULER_BEGIN_FRAME_MANAGER_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/observer_list.h" |
| +#include "base/threading/non_thread_safe.h" |
| +#include "base/time/time.h" |
| +#include "cc/base/cc_export.h" |
| +#include "cc/output/begin_frame_args.h" |
| + |
| +namespace cc { |
| + |
| +struct BeginFrameArgs; |
| + |
| +// This class delivers a BeginFrame request from the Compositor to its |
| +// observers. It also handles next BeginFrame scheduling via its delegate. |
| +// Browser compositor will own this. |
| +// This class will be run only on main thread. |
| +class CC_EXPORT BeginFrameManager : public base::NonThreadSafe { |
| + public: |
| + // Subclass should deliver BeginFrame to its client. |
| + class Observer { |
| + public: |
| + virtual void OnSendBeginFrame(const BeginFrameArgs& args) = 0; |
| + }; |
| + |
| + // 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.
|
| + class Delegate { |
| + public: |
| + virtual void SetChildrenNeedBeginFrames(bool need_begin_frame) = 0; |
| + |
| + // The "authoritative" vsync interval, if provided, will override interval |
| + // reported from 3D context. This is typically the value reported by a more |
| + // reliable source, e.g, the platform display configuration. |
| + // In the particular case of ChromeOS -- this is the value queried through |
| + // XRandR, which is more reliable than the value queried through the 3D |
| + // context. |
| + virtual void SetAuthoritativeVSyncInterval(base::TimeDelta interval) {} |
| + }; |
| + |
| + BeginFrameManager(); |
| + ~BeginFrameManager(); |
| + |
| + void set_delegate(Delegate* delegate) { |
| + DCHECK(!delegate_); |
| + delegate_ = delegate; |
| + } |
| + |
| + // Request BeginFrame to observers. |
|
brianderson
2014/08/27 01:34:08
Request -> Send
simonhong
2014/08/27 07:56:12
Done.
|
| + void SendBeginFrameToChildren(const BeginFrameArgs& args); |
| + |
| + // See the comment of Delegate::SetAuthritativeVSyncInterval. |
| + void SetAuthoritativeVSyncInterval(base::TimeDelta interval) const; |
| + |
| + void AddObserver( |
| + Observer* observer, |
| + const BeginFrameArgs& last_begin_frame_args_sent_to_observer); |
| + void RemoveObserver(Observer* observer); |
| + |
| + private: |
| + // Not owned by this class. |
| + Delegate* delegate_; |
| + |
| + // Number of BeginFrameManager's observer. |
| + int num_of_observers_; |
| + |
| + // 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.
|
| + BeginFrameArgs last_begin_frame_args_; |
| + |
| + ObserverList<BeginFrameManager::Observer> observer_list_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BeginFrameManager); |
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_SCHEDULER_BEGIN_FRAME_MANAGER_H_ |