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

Unified Diff: cc/surfaces/display_begin_frame_source.h

Issue 2411793008: Adds BeginFrameControl via DevTools.
Patch Set: BFC prototype v2 with allow_latency_opts and waiting for BFOs. Created 4 years, 1 month 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
« no previous file with comments | « cc/surfaces/display.cc ('k') | cc/surfaces/display_begin_frame_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/display_begin_frame_source.h
diff --git a/cc/surfaces/display_begin_frame_source.h b/cc/surfaces/display_begin_frame_source.h
new file mode 100644
index 0000000000000000000000000000000000000000..055137ec74d1b5ebc520e919936e2cac3c6231e3
--- /dev/null
+++ b/cc/surfaces/display_begin_frame_source.h
@@ -0,0 +1,68 @@
+// Copyright 2016 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_SURFACES_DISPLAY_BEGIN_FRAME_SOURCE_H_
+#define CC_SURFACES_DISPLAY_BEGIN_FRAME_SOURCE_H_
+
+#include <memory>
+#include <set>
+
+#include "base/macros.h"
+#include "cc/scheduler/begin_frame_source.h"
+
+namespace cc {
+
+class DisplayBeginFrameSourceClient {
+ public:
+ virtual void ObserverStatusChanged() = 0;
+ virtual void BeginFrameSourceSwapping(BeginFrameSource* new_source) = 0;
+};
+
+// Wraps a target BeginFrameSource and keeps track of observers that have
+// finished a BeginFrame. Supports swapping the target source underneath it.
+class DisplayBeginFrameSource : public BeginFrameSource,
+ public BeginFrameObserver {
+ public:
+ explicit DisplayBeginFrameSource(
+ std::unique_ptr<BeginFrameSource> target_source);
+ ~DisplayBeginFrameSource() override;
+
+ BeginFrameSource* GetTargetSource() { return target_source_.get(); }
+ void SetClient(DisplayBeginFrameSourceClient* client) { client_ = client; }
+
+ bool AllObserversFinishedFrame();
+
+ void SwapTargetSource(std::unique_ptr<BeginFrameSource>* begin_frame_source);
+
+ // BeginFrameSource implementation.
+ void DidFinishFrame(BeginFrameObserver* obs,
+ size_t remaining_frames) override;
+ void AddObserver(BeginFrameObserver* obs) override;
+ void RemoveObserver(BeginFrameObserver* obs) override;
+ bool IsThrottled() const override;
+
+ // BeginFrameObserver implementation.
+ void OnBeginFrame(const BeginFrameArgs& args) override;
+ const BeginFrameArgs& LastUsedBeginFrameArgs() const override;
+ void OnBeginFrameSourcePausedChanged(bool paused) override;
+
+ private:
+ void ObserverStatusChanged();
+ void MaybeFinishFrame();
+
+ std::unique_ptr<BeginFrameSource> target_source_;
+ std::set<BeginFrameObserver*> observers_;
+ std::set<BeginFrameObserver*> finished_observers_;
+ BeginFrameArgs last_begin_frame_args_;
+ bool observing_begin_frames_;
+ bool frame_active_;
+
+ DisplayBeginFrameSourceClient* client_; // Not owned.
+
+ DISALLOW_COPY_AND_ASSIGN(DisplayBeginFrameSource);
+};
+
+} // namespace cc
+
+#endif // CC_SURFACES_DISPLAY_BEGIN_FRAME_SOURCE_H_
« no previous file with comments | « cc/surfaces/display.cc ('k') | cc/surfaces/display_begin_frame_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698