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

Side by Side Diff: cc/scheduler/begin_frame_source.h

Issue 2323123002: Make disable vsync run the renderer independently (Closed)
Patch Set: Rebase Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | cc/scheduler/begin_frame_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // processing (rather than toggling SetNeedsBeginFrames every frame). It is 105 // processing (rather than toggling SetNeedsBeginFrames every frame). It is
106 // used by systems like the BackToBackFrameSource to make sure only one frame 106 // used by systems like the BackToBackFrameSource to make sure only one frame
107 // is pending at a time. 107 // is pending at a time.
108 virtual void DidFinishFrame(BeginFrameObserver* obs, 108 virtual void DidFinishFrame(BeginFrameObserver* obs,
109 size_t remaining_frames) = 0; 109 size_t remaining_frames) = 0;
110 110
111 // Add/Remove an observer from the source. When no observers are added the BFS 111 // Add/Remove an observer from the source. When no observers are added the BFS
112 // should shut down its timers, disable vsync, etc. 112 // should shut down its timers, disable vsync, etc.
113 virtual void AddObserver(BeginFrameObserver* obs) = 0; 113 virtual void AddObserver(BeginFrameObserver* obs) = 0;
114 virtual void RemoveObserver(BeginFrameObserver* obs) = 0; 114 virtual void RemoveObserver(BeginFrameObserver* obs) = 0;
115
116 // Returns false if the begin frame source will just continue to produce
117 // begin frames without waiting.
118 virtual bool IsThrottled() const = 0;
115 }; 119 };
116 120
117 // A BeginFrameSource that does nothing. 121 // A BeginFrameSource that does nothing.
118 class StubBeginFrameSource : public BeginFrameSource { 122 class CC_EXPORT StubBeginFrameSource : public BeginFrameSource {
119 public: 123 public:
120 void DidFinishFrame(BeginFrameObserver* obs, 124 void DidFinishFrame(BeginFrameObserver* obs,
121 size_t remaining_frames) override {} 125 size_t remaining_frames) override {}
122 void AddObserver(BeginFrameObserver* obs) override {} 126 void AddObserver(BeginFrameObserver* obs) override {}
123 void RemoveObserver(BeginFrameObserver* obs) override {} 127 void RemoveObserver(BeginFrameObserver* obs) override {}
128 bool IsThrottled() const override;
124 }; 129 };
125 130
126 // A frame source which ticks itself independently. 131 // A frame source which ticks itself independently.
127 class CC_EXPORT SyntheticBeginFrameSource : public BeginFrameSource { 132 class CC_EXPORT SyntheticBeginFrameSource : public BeginFrameSource {
128 public: 133 public:
129 ~SyntheticBeginFrameSource() override; 134 ~SyntheticBeginFrameSource() override;
130 135
131 virtual void OnUpdateVSyncParameters(base::TimeTicks timebase, 136 virtual void OnUpdateVSyncParameters(base::TimeTicks timebase,
132 base::TimeDelta interval) = 0; 137 base::TimeDelta interval) = 0;
133 // This overrides any past or future interval from updating vsync parameters. 138 // This overrides any past or future interval from updating vsync parameters.
134 virtual void SetAuthoritativeVSyncInterval(base::TimeDelta interval) = 0; 139 virtual void SetAuthoritativeVSyncInterval(base::TimeDelta interval) = 0;
135 }; 140 };
136 141
137 // A frame source which calls BeginFrame (at the next possible time) as soon as 142 // A frame source which calls BeginFrame (at the next possible time) as soon as
138 // remaining frames reaches zero. 143 // remaining frames reaches zero.
139 class CC_EXPORT BackToBackBeginFrameSource : public SyntheticBeginFrameSource, 144 class CC_EXPORT BackToBackBeginFrameSource : public SyntheticBeginFrameSource,
140 public DelayBasedTimeSourceClient { 145 public DelayBasedTimeSourceClient {
141 public: 146 public:
142 explicit BackToBackBeginFrameSource( 147 explicit BackToBackBeginFrameSource(
143 std::unique_ptr<DelayBasedTimeSource> time_source); 148 std::unique_ptr<DelayBasedTimeSource> time_source);
144 ~BackToBackBeginFrameSource() override; 149 ~BackToBackBeginFrameSource() override;
145 150
146 // BeginFrameSource implementation. 151 // BeginFrameSource implementation.
147 void AddObserver(BeginFrameObserver* obs) override; 152 void AddObserver(BeginFrameObserver* obs) override;
148 void RemoveObserver(BeginFrameObserver* obs) override; 153 void RemoveObserver(BeginFrameObserver* obs) override;
149 void DidFinishFrame(BeginFrameObserver* obs, 154 void DidFinishFrame(BeginFrameObserver* obs,
150 size_t remaining_frames) override; 155 size_t remaining_frames) override;
156 bool IsThrottled() const override;
151 157
152 // SyntheticBeginFrameSource implementation. 158 // SyntheticBeginFrameSource implementation.
153 void OnUpdateVSyncParameters(base::TimeTicks timebase, 159 void OnUpdateVSyncParameters(base::TimeTicks timebase,
154 base::TimeDelta interval) override {} 160 base::TimeDelta interval) override {}
155 void SetAuthoritativeVSyncInterval(base::TimeDelta interval) override {} 161 void SetAuthoritativeVSyncInterval(base::TimeDelta interval) override {}
156 162
157 // DelayBasedTimeSourceClient implementation. 163 // DelayBasedTimeSourceClient implementation.
158 void OnTimerTick() override; 164 void OnTimerTick() override;
159 165
160 private: 166 private:
(...skipping 12 matching lines...) Expand all
173 public: 179 public:
174 explicit DelayBasedBeginFrameSource( 180 explicit DelayBasedBeginFrameSource(
175 std::unique_ptr<DelayBasedTimeSource> time_source); 181 std::unique_ptr<DelayBasedTimeSource> time_source);
176 ~DelayBasedBeginFrameSource() override; 182 ~DelayBasedBeginFrameSource() override;
177 183
178 // BeginFrameSource implementation. 184 // BeginFrameSource implementation.
179 void AddObserver(BeginFrameObserver* obs) override; 185 void AddObserver(BeginFrameObserver* obs) override;
180 void RemoveObserver(BeginFrameObserver* obs) override; 186 void RemoveObserver(BeginFrameObserver* obs) override;
181 void DidFinishFrame(BeginFrameObserver* obs, 187 void DidFinishFrame(BeginFrameObserver* obs,
182 size_t remaining_frames) override {} 188 size_t remaining_frames) override {}
189 bool IsThrottled() const override;
183 190
184 // SyntheticBeginFrameSource implementation. 191 // SyntheticBeginFrameSource implementation.
185 void OnUpdateVSyncParameters(base::TimeTicks timebase, 192 void OnUpdateVSyncParameters(base::TimeTicks timebase,
186 base::TimeDelta interval) override; 193 base::TimeDelta interval) override;
187 void SetAuthoritativeVSyncInterval(base::TimeDelta interval) override; 194 void SetAuthoritativeVSyncInterval(base::TimeDelta interval) override;
188 195
189 // DelayBasedTimeSourceClient implementation. 196 // DelayBasedTimeSourceClient implementation.
190 void OnTimerTick() override; 197 void OnTimerTick() override;
191 198
192 private: 199 private:
(...skipping 22 matching lines...) Expand all
215 public: 222 public:
216 // Client lifetime must be preserved by owner past the lifetime of this class. 223 // Client lifetime must be preserved by owner past the lifetime of this class.
217 explicit ExternalBeginFrameSource(ExternalBeginFrameSourceClient* client); 224 explicit ExternalBeginFrameSource(ExternalBeginFrameSourceClient* client);
218 ~ExternalBeginFrameSource() override; 225 ~ExternalBeginFrameSource() override;
219 226
220 // BeginFrameSource implementation. 227 // BeginFrameSource implementation.
221 void AddObserver(BeginFrameObserver* obs) override; 228 void AddObserver(BeginFrameObserver* obs) override;
222 void RemoveObserver(BeginFrameObserver* obs) override; 229 void RemoveObserver(BeginFrameObserver* obs) override;
223 void DidFinishFrame(BeginFrameObserver* obs, 230 void DidFinishFrame(BeginFrameObserver* obs,
224 size_t remaining_frames) override {} 231 size_t remaining_frames) override {}
232 bool IsThrottled() const override;
225 233
226 void OnSetBeginFrameSourcePaused(bool paused); 234 void OnSetBeginFrameSourcePaused(bool paused);
227 void OnBeginFrame(const BeginFrameArgs& args); 235 void OnBeginFrame(const BeginFrameArgs& args);
228 236
229 protected: 237 protected:
230 BeginFrameArgs missed_begin_frame_args_; 238 BeginFrameArgs missed_begin_frame_args_;
231 std::unordered_set<BeginFrameObserver*> observers_; 239 std::unordered_set<BeginFrameObserver*> observers_;
232 ExternalBeginFrameSourceClient* client_; 240 ExternalBeginFrameSourceClient* client_;
233 bool paused_ = false; 241 bool paused_ = false;
234 242
235 private: 243 private:
236 DISALLOW_COPY_AND_ASSIGN(ExternalBeginFrameSource); 244 DISALLOW_COPY_AND_ASSIGN(ExternalBeginFrameSource);
237 }; 245 };
238 246
239 } // namespace cc 247 } // namespace cc
240 248
241 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ 249 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_
OLDNEW
« 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