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

Unified Diff: cc/scheduler/begin_frame_source.h

Issue 2281143002: Refactor external begin frame source into a base class (Closed)
Patch Set: danakj review Created 4 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
« no previous file with comments | « no previous file | cc/scheduler/begin_frame_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/begin_frame_source.h
diff --git a/cc/scheduler/begin_frame_source.h b/cc/scheduler/begin_frame_source.h
index 0a8a51f08d7c911d6c1594b1623ae74ad5a9fe43..4a0668cd9fb4534deea2cb214e39c917ea70ee12 100644
--- a/cc/scheduler/begin_frame_source.h
+++ b/cc/scheduler/begin_frame_source.h
@@ -201,6 +201,41 @@ class CC_EXPORT DelayBasedBeginFrameSource : public SyntheticBeginFrameSource,
DISALLOW_COPY_AND_ASSIGN(DelayBasedBeginFrameSource);
};
+class CC_EXPORT ExternalBeginFrameSourceClient {
+ public:
+ // Only called when changed. Assumed false by default.
+ virtual void OnNeedsBeginFrames(bool needs_begin_frames) = 0;
+};
+
+// A BeginFrameSource that is only ticked manually. Usually the endpoint
+// of messages from some other thread/process that send OnBeginFrame and
+// receive SetNeedsBeginFrame messages. This turns such messages back into
+// an observable BeginFrameSource.
+class CC_EXPORT ExternalBeginFrameSource : public BeginFrameSource {
+ public:
+ // Client lifetime must be preserved by owner past the lifetime of this class.
+ explicit ExternalBeginFrameSource(ExternalBeginFrameSourceClient* client);
+ ~ExternalBeginFrameSource() override;
+
+ // BeginFrameSource implementation.
+ void AddObserver(BeginFrameObserver* obs) override;
+ void RemoveObserver(BeginFrameObserver* obs) override;
+ void DidFinishFrame(BeginFrameObserver* obs,
+ size_t remaining_frames) override {}
+
+ void OnSetBeginFrameSourcePaused(bool paused);
+ void OnBeginFrame(const BeginFrameArgs& args);
+
+ protected:
+ BeginFrameArgs missed_begin_frame_args_;
+ std::unordered_set<BeginFrameObserver*> observers_;
+ ExternalBeginFrameSourceClient* client_;
+ bool paused_ = false;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ExternalBeginFrameSource);
+};
+
} // namespace cc
#endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_
« no previous file with comments | « no previous file | cc/scheduler/begin_frame_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698