Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Unified Diff: cc/scheduler/begin_frame_manager.h

Issue 423773002: Unified BeginFrame scheduling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WIP in mac and android Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..671588acc137920ce19a5ecd8d5e9a074019bde6
--- /dev/null
+++ b/cc/scheduler/begin_frame_manager.h
@@ -0,0 +1,86 @@
+// 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(Scheduler) should implement how to schedule next BeginFrame.
+ 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) = 0;
+
+ // When we want to use platform provided refresh rate instead of internal
+ // timer, compositor will deliver it by calling this function.
+ virtual void StartBeginFrame(const BeginFrameArgs& args) = 0;
+ };
+
+ BeginFrameManager();
+ ~BeginFrameManager();
+
+ void set_delegate(Delegate* delegate) {
+ DCHECK(!delegate_) <<
+ "BeginFrameManager::Delegate is allowed to set only once";
+ delegate_ = delegate;
+ }
+
+ // Send BeginFrame to observers.
+ 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 any new observers immediately.
+ BeginFrameArgs last_begin_frame_args_;
+
+ ObserverList<Observer> observer_list_;
+
+ DISALLOW_COPY_AND_ASSIGN(BeginFrameManager);
+};
+
+} // namespace cc
+
+#endif // CC_SCHEDULER_BEGIN_FRAME_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698