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

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

Issue 2591013004: [cc] Add and use BeginFrameAck for DidFinishFrame. (Closed)
Patch Set: remove ipc struct traits for BeginFrameAck. Created 3 years, 11 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 | « cc/output/begin_frame_args.cc ('k') | 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // processing has been finished and provide information about the time values 97 // processing has been finished and provide information about the time values
98 // of the vsync times. *However*, these values can be heavily modified or even 98 // of the vsync times. *However*, these values can be heavily modified or even
99 // plain made up (when no vsync signal is available or vsync throttling is 99 // plain made up (when no vsync signal is available or vsync throttling is
100 // turned off). See the BeginFrameObserver for information about the guarantees 100 // turned off). See the BeginFrameObserver for information about the guarantees
101 // all BeginFrameSources *must* provide. 101 // all BeginFrameSources *must* provide.
102 class CC_EXPORT BeginFrameSource { 102 class CC_EXPORT BeginFrameSource {
103 public: 103 public:
104 BeginFrameSource(); 104 BeginFrameSource();
105 virtual ~BeginFrameSource() {} 105 virtual ~BeginFrameSource() {}
106 106
107 // DidFinishFrame provides back pressure to a frame source about frame 107 // BeginFrameObservers use DidFinishFrame to acknowledge that they have
108 // processing (rather than toggling SetNeedsBeginFrames every frame). It is 108 // completed handling a BeginFrame.
109 // used by systems like the BackToBackFrameSource to make sure only one frame 109 //
110 // is pending at a time. 110 // The DisplayScheduler uses these acknowledgments to trigger an early
111 // deadline once all BeginFrameObservers have completed a frame.
112 //
113 // They also provide back pressure to a frame source about frame processing
114 // (rather than toggling SetNeedsBeginFrames every frame). For example, the
115 // BackToBackFrameSource uses them to make sure only one frame is pending at a
116 // time.
117 // TODO(eseckler): Use BeginFrameAcks in DisplayScheduler as described above.
111 virtual void DidFinishFrame(BeginFrameObserver* obs, 118 virtual void DidFinishFrame(BeginFrameObserver* obs,
112 size_t remaining_frames) = 0; 119 const BeginFrameAck& ack) = 0;
113 120
114 // Add/Remove an observer from the source. When no observers are added the BFS 121 // Add/Remove an observer from the source. When no observers are added the BFS
115 // should shut down its timers, disable vsync, etc. 122 // should shut down its timers, disable vsync, etc.
116 virtual void AddObserver(BeginFrameObserver* obs) = 0; 123 virtual void AddObserver(BeginFrameObserver* obs) = 0;
117 virtual void RemoveObserver(BeginFrameObserver* obs) = 0; 124 virtual void RemoveObserver(BeginFrameObserver* obs) = 0;
118 125
119 // Returns false if the begin frame source will just continue to produce 126 // Returns false if the begin frame source will just continue to produce
120 // begin frames without waiting. 127 // begin frames without waiting.
121 virtual bool IsThrottled() const = 0; 128 virtual bool IsThrottled() const = 0;
122 129
123 // Returns an identifier for this BeginFrameSource. Guaranteed unique within a 130 // Returns an identifier for this BeginFrameSource. Guaranteed unique within a
124 // process, but not across processes. This is used to create BeginFrames that 131 // process, but not across processes. This is used to create BeginFrames that
125 // originate at this source. Note that BeginFrameSources may pass on 132 // originate at this source. Note that BeginFrameSources may pass on
126 // BeginFrames created by other sources, with different IDs. 133 // BeginFrames created by other sources, with different IDs.
127 uint32_t source_id() const; 134 uint32_t source_id() const;
128 135
129 private: 136 private:
130 uint32_t source_id_; 137 uint32_t source_id_;
131 }; 138 };
132 139
133 // A BeginFrameSource that does nothing. 140 // A BeginFrameSource that does nothing.
134 class CC_EXPORT StubBeginFrameSource : public BeginFrameSource { 141 class CC_EXPORT StubBeginFrameSource : public BeginFrameSource {
135 public: 142 public:
136 void DidFinishFrame(BeginFrameObserver* obs, 143 void DidFinishFrame(BeginFrameObserver* obs,
137 size_t remaining_frames) override {} 144 const BeginFrameAck& ack) override {}
138 void AddObserver(BeginFrameObserver* obs) override {} 145 void AddObserver(BeginFrameObserver* obs) override {}
139 void RemoveObserver(BeginFrameObserver* obs) override {} 146 void RemoveObserver(BeginFrameObserver* obs) override {}
140 bool IsThrottled() const override; 147 bool IsThrottled() const override;
141 }; 148 };
142 149
143 // A frame source which ticks itself independently. 150 // A frame source which ticks itself independently.
144 class CC_EXPORT SyntheticBeginFrameSource : public BeginFrameSource { 151 class CC_EXPORT SyntheticBeginFrameSource : public BeginFrameSource {
145 public: 152 public:
146 ~SyntheticBeginFrameSource() override; 153 ~SyntheticBeginFrameSource() override;
147 154
148 virtual void OnUpdateVSyncParameters(base::TimeTicks timebase, 155 virtual void OnUpdateVSyncParameters(base::TimeTicks timebase,
149 base::TimeDelta interval) = 0; 156 base::TimeDelta interval) = 0;
150 // This overrides any past or future interval from updating vsync parameters. 157 // This overrides any past or future interval from updating vsync parameters.
151 virtual void SetAuthoritativeVSyncInterval(base::TimeDelta interval) = 0; 158 virtual void SetAuthoritativeVSyncInterval(base::TimeDelta interval) = 0;
152 }; 159 };
153 160
154 // A frame source which calls BeginFrame (at the next possible time) as soon as 161 // A frame source which calls BeginFrame (at the next possible time) as soon as
155 // remaining frames reaches zero. 162 // remaining frames reaches zero.
156 class CC_EXPORT BackToBackBeginFrameSource : public SyntheticBeginFrameSource, 163 class CC_EXPORT BackToBackBeginFrameSource : public SyntheticBeginFrameSource,
157 public DelayBasedTimeSourceClient { 164 public DelayBasedTimeSourceClient {
158 public: 165 public:
159 explicit BackToBackBeginFrameSource( 166 explicit BackToBackBeginFrameSource(
160 std::unique_ptr<DelayBasedTimeSource> time_source); 167 std::unique_ptr<DelayBasedTimeSource> time_source);
161 ~BackToBackBeginFrameSource() override; 168 ~BackToBackBeginFrameSource() override;
162 169
163 // BeginFrameSource implementation. 170 // BeginFrameSource implementation.
164 void AddObserver(BeginFrameObserver* obs) override; 171 void AddObserver(BeginFrameObserver* obs) override;
165 void RemoveObserver(BeginFrameObserver* obs) override; 172 void RemoveObserver(BeginFrameObserver* obs) override;
166 void DidFinishFrame(BeginFrameObserver* obs, 173 void DidFinishFrame(BeginFrameObserver* obs,
167 size_t remaining_frames) override; 174 const BeginFrameAck& ack) override;
168 bool IsThrottled() const override; 175 bool IsThrottled() const override;
169 176
170 // SyntheticBeginFrameSource implementation. 177 // SyntheticBeginFrameSource implementation.
171 void OnUpdateVSyncParameters(base::TimeTicks timebase, 178 void OnUpdateVSyncParameters(base::TimeTicks timebase,
172 base::TimeDelta interval) override {} 179 base::TimeDelta interval) override {}
173 void SetAuthoritativeVSyncInterval(base::TimeDelta interval) override {} 180 void SetAuthoritativeVSyncInterval(base::TimeDelta interval) override {}
174 181
175 // DelayBasedTimeSourceClient implementation. 182 // DelayBasedTimeSourceClient implementation.
176 void OnTimerTick() override; 183 void OnTimerTick() override;
177 184
(...skipping 13 matching lines...) Expand all
191 public DelayBasedTimeSourceClient { 198 public DelayBasedTimeSourceClient {
192 public: 199 public:
193 explicit DelayBasedBeginFrameSource( 200 explicit DelayBasedBeginFrameSource(
194 std::unique_ptr<DelayBasedTimeSource> time_source); 201 std::unique_ptr<DelayBasedTimeSource> time_source);
195 ~DelayBasedBeginFrameSource() override; 202 ~DelayBasedBeginFrameSource() override;
196 203
197 // BeginFrameSource implementation. 204 // BeginFrameSource implementation.
198 void AddObserver(BeginFrameObserver* obs) override; 205 void AddObserver(BeginFrameObserver* obs) override;
199 void RemoveObserver(BeginFrameObserver* obs) override; 206 void RemoveObserver(BeginFrameObserver* obs) override;
200 void DidFinishFrame(BeginFrameObserver* obs, 207 void DidFinishFrame(BeginFrameObserver* obs,
201 size_t remaining_frames) override {} 208 const BeginFrameAck& ack) override {}
202 bool IsThrottled() const override; 209 bool IsThrottled() const override;
203 210
204 // SyntheticBeginFrameSource implementation. 211 // SyntheticBeginFrameSource implementation.
205 void OnUpdateVSyncParameters(base::TimeTicks timebase, 212 void OnUpdateVSyncParameters(base::TimeTicks timebase,
206 base::TimeDelta interval) override; 213 base::TimeDelta interval) override;
207 void SetAuthoritativeVSyncInterval(base::TimeDelta interval) override; 214 void SetAuthoritativeVSyncInterval(base::TimeDelta interval) override;
208 215
209 // DelayBasedTimeSourceClient implementation. 216 // DelayBasedTimeSourceClient implementation.
210 void OnTimerTick() override; 217 void OnTimerTick() override;
211 218
(...skipping 24 matching lines...) Expand all
236 class CC_EXPORT ExternalBeginFrameSource : public BeginFrameSource { 243 class CC_EXPORT ExternalBeginFrameSource : public BeginFrameSource {
237 public: 244 public:
238 // Client lifetime must be preserved by owner past the lifetime of this class. 245 // Client lifetime must be preserved by owner past the lifetime of this class.
239 explicit ExternalBeginFrameSource(ExternalBeginFrameSourceClient* client); 246 explicit ExternalBeginFrameSource(ExternalBeginFrameSourceClient* client);
240 ~ExternalBeginFrameSource() override; 247 ~ExternalBeginFrameSource() override;
241 248
242 // BeginFrameSource implementation. 249 // BeginFrameSource implementation.
243 void AddObserver(BeginFrameObserver* obs) override; 250 void AddObserver(BeginFrameObserver* obs) override;
244 void RemoveObserver(BeginFrameObserver* obs) override; 251 void RemoveObserver(BeginFrameObserver* obs) override;
245 void DidFinishFrame(BeginFrameObserver* obs, 252 void DidFinishFrame(BeginFrameObserver* obs,
246 size_t remaining_frames) override {} 253 const BeginFrameAck& ack) override {}
247 bool IsThrottled() const override; 254 bool IsThrottled() const override;
248 255
249 void OnSetBeginFrameSourcePaused(bool paused); 256 void OnSetBeginFrameSourcePaused(bool paused);
250 void OnBeginFrame(const BeginFrameArgs& args); 257 void OnBeginFrame(const BeginFrameArgs& args);
251 258
252 protected: 259 protected:
253 BeginFrameArgs missed_begin_frame_args_; 260 BeginFrameArgs missed_begin_frame_args_;
254 std::unordered_set<BeginFrameObserver*> observers_; 261 std::unordered_set<BeginFrameObserver*> observers_;
255 ExternalBeginFrameSourceClient* client_; 262 ExternalBeginFrameSourceClient* client_;
256 bool paused_ = false; 263 bool paused_ = false;
257 264
258 private: 265 private:
259 DISALLOW_COPY_AND_ASSIGN(ExternalBeginFrameSource); 266 DISALLOW_COPY_AND_ASSIGN(ExternalBeginFrameSource);
260 }; 267 };
261 268
262 } // namespace cc 269 } // namespace cc
263 270
264 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_ 271 #endif // CC_SCHEDULER_BEGIN_FRAME_SOURCE_H_
OLDNEW
« no previous file with comments | « cc/output/begin_frame_args.cc ('k') | cc/scheduler/begin_frame_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698