OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_SCHEDULER_STATE_MACHINE_H_ | 5 #ifndef CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
6 #define CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 6 #define CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 | 110 |
111 bool RedrawPending() const { return needs_redraw_; } | 111 bool RedrawPending() const { return needs_redraw_; } |
112 bool PrepareTilesPending() const { return needs_prepare_tiles_; } | 112 bool PrepareTilesPending() const { return needs_prepare_tiles_; } |
113 | 113 |
114 enum Action { | 114 enum Action { |
115 ACTION_NONE, | 115 ACTION_NONE, |
116 ACTION_SEND_BEGIN_MAIN_FRAME, | 116 ACTION_SEND_BEGIN_MAIN_FRAME, |
117 ACTION_COMMIT, | 117 ACTION_COMMIT, |
118 ACTION_ACTIVATE_SYNC_TREE, | 118 ACTION_ACTIVATE_SYNC_TREE, |
119 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, | 119 ACTION_DRAW_IF_POSSIBLE, |
120 ACTION_DRAW_AND_SWAP_FORCED, | 120 ACTION_DRAW_FORCED, |
121 ACTION_DRAW_AND_SWAP_ABORT, | 121 ACTION_DRAW_ABORT, |
122 ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION, | 122 ACTION_BEGIN_COMPOSITOR_FRAME_SINK_CREATION, |
123 ACTION_PREPARE_TILES, | 123 ACTION_PREPARE_TILES, |
124 ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK, | 124 ACTION_INVALIDATE_COMPOSITOR_FRAME_SINK, |
125 }; | 125 }; |
126 static const char* ActionToString(Action action); | 126 static const char* ActionToString(Action action); |
127 | 127 |
128 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; | 128 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValue() const; |
129 void AsValueInto(base::trace_event::TracedValue* dict) const; | 129 void AsValueInto(base::trace_event::TracedValue* dict) const; |
130 | 130 |
131 Action NextAction() const; | 131 Action NextAction() const; |
132 void WillSendBeginMainFrame(); | 132 void WillSendBeginMainFrame(); |
133 void WillCommit(bool commit_had_no_updates); | 133 void WillCommit(bool commit_had_no_updates); |
134 void WillActivate(); | 134 void WillActivate(); |
135 void WillDraw(); | 135 void WillDraw(); |
136 void WillBeginCompositorFrameSinkCreation(); | 136 void WillBeginCompositorFrameSinkCreation(); |
137 void WillPrepareTiles(); | 137 void WillPrepareTiles(); |
138 void WillInvalidateCompositorFrameSink(); | 138 void WillInvalidateCompositorFrameSink(); |
139 | 139 |
140 void DidDraw(DrawResult draw_result); | 140 void DidDraw(DrawResult draw_result); |
141 | 141 |
142 void AbortDrawAndSwap(); | 142 void AbortDraw(); |
143 | 143 |
144 // Indicates whether the impl thread needs a BeginImplFrame callback in order | 144 // Indicates whether the impl thread needs a BeginImplFrame callback in order |
145 // to make progress. | 145 // to make progress. |
146 bool BeginFrameNeeded() const; | 146 bool BeginFrameNeeded() const; |
147 | 147 |
148 // Indicates that the system has entered and left a BeginImplFrame callback. | 148 // Indicates that the system has entered and left a BeginImplFrame callback. |
149 // The scheduler will not draw more than once in a given BeginImplFrame | 149 // The scheduler will not draw more than once in a given BeginImplFrame |
150 // callback nor send more than one BeginMainFrame message. | 150 // callback nor send more than one BeginMainFrame message. |
151 void OnBeginImplFrame(); | 151 void OnBeginImplFrame(); |
152 // Indicates that the scheduler has entered the draw phase. The scheduler | 152 // Indicates that the scheduler has entered the draw phase. The scheduler |
153 // will not draw more than once in a single draw phase. | 153 // will not draw more than once in a single draw phase. |
154 // TODO(sunnyps): Rename OnBeginImplFrameDeadline to OnDraw or similar. | 154 // TODO(sunnyps): Rename OnBeginImplFrameDeadline to OnDraw or similar. |
155 void OnBeginImplFrameDeadline(); | 155 void OnBeginImplFrameDeadline(); |
156 void OnBeginImplFrameIdle(); | 156 void OnBeginImplFrameIdle(); |
157 | 157 |
158 int current_frame_number() const { return current_frame_number_; } | 158 int current_frame_number() const { return current_frame_number_; } |
159 | 159 |
160 BeginImplFrameState begin_impl_frame_state() const { | 160 BeginImplFrameState begin_impl_frame_state() const { |
161 return begin_impl_frame_state_; | 161 return begin_impl_frame_state_; |
162 } | 162 } |
163 BeginImplFrameDeadlineMode CurrentBeginImplFrameDeadlineMode() const; | 163 BeginImplFrameDeadlineMode CurrentBeginImplFrameDeadlineMode() const; |
164 | 164 |
165 // If the main thread didn't manage to produce a new frame in time for the | 165 // If the main thread didn't manage to produce a new frame in time for the |
166 // impl thread to draw, it is in a high latency mode. | 166 // impl thread to draw, it is in a high latency mode. |
167 bool main_thread_missed_last_deadline() const { | 167 bool main_thread_missed_last_deadline() const { |
168 return main_thread_missed_last_deadline_; | 168 return main_thread_missed_last_deadline_; |
169 } | 169 } |
170 | 170 |
171 bool SwapThrottled() const; | 171 bool IsDrawThrottled() const; |
172 | 172 |
173 // Indicates whether the LayerTreeHostImpl is visible. | 173 // Indicates whether the LayerTreeHostImpl is visible. |
174 void SetVisible(bool visible); | 174 void SetVisible(bool visible); |
175 bool visible() const { return visible_; } | 175 bool visible() const { return visible_; } |
176 | 176 |
177 void SetBeginFrameSourcePaused(bool paused); | 177 void SetBeginFrameSourcePaused(bool paused); |
178 bool begin_frame_source_paused() const { return begin_frame_source_paused_; } | 178 bool begin_frame_source_paused() const { return begin_frame_source_paused_; } |
179 | 179 |
180 // Indicates that a redraw is required, either due to the impl tree changing | 180 // Indicates that a redraw is required, either due to the impl tree changing |
181 // or the screen being damaged and simply needing redisplay. | 181 // or the screen being damaged and simply needing redisplay. |
182 void SetNeedsRedraw(); | 182 void SetNeedsRedraw(); |
183 bool needs_redraw() const { return needs_redraw_; } | 183 bool needs_redraw() const { return needs_redraw_; } |
184 | 184 |
185 bool OnlyImplSideUpdatesExpected() const; | 185 bool OnlyImplSideUpdatesExpected() const; |
186 | 186 |
187 // Indicates that prepare-tiles is required. This guarantees another | 187 // Indicates that prepare-tiles is required. This guarantees another |
188 // PrepareTiles will occur shortly (even if no redraw is required). | 188 // PrepareTiles will occur shortly (even if no redraw is required). |
189 void SetNeedsPrepareTiles(); | 189 void SetNeedsPrepareTiles(); |
190 | 190 |
191 // If the scheduler attempted to draw and swap, this provides feedback | 191 // If the scheduler attempted to draw, this provides feedback regarding |
192 // regarding whether or not the swap actually occured. We might skip the | 192 // whether or not a CompositorFrame was actually submitted. We might skip the |
193 // swap when there is not damage, for example. | 193 // submitting anything when there is not damage, for example. |
194 void DidSwapBuffers(); | 194 void DidSubmitCompositorFrame(); |
195 | 195 |
196 // Indicates whether a redraw is required because we are currently rendering | 196 // Notification from the CompositorFrameSink that a submitted frame has been |
197 // with a low resolution or checkerboarded tile. | 197 // consumed and it is ready for the next one. |
198 void SetSwapUsedIncompleteTile(bool used_incomplete_tile); | 198 void DidReceiveCompositorFrameAck(); |
199 | 199 |
200 // Notification from the CompositorFrameSink that a swap has been consumed. | 200 int pending_submit_frames() const { return pending_submit_frames_; } |
201 void DidSwapBuffersComplete(); | |
202 | |
203 int pending_swaps() const { return pending_swaps_; } | |
204 | 201 |
205 // Indicates whether to prioritize impl thread latency (i.e., animation | 202 // Indicates whether to prioritize impl thread latency (i.e., animation |
206 // smoothness) over new content activation. | 203 // smoothness) over new content activation. |
207 void SetTreePrioritiesAndScrollState(TreePriority tree_priority, | 204 void SetTreePrioritiesAndScrollState(TreePriority tree_priority, |
208 ScrollHandlerState scroll_handler_state); | 205 ScrollHandlerState scroll_handler_state); |
209 | 206 |
210 // Indicates if the main thread will likely respond within 1 vsync. | 207 // Indicates if the main thread will likely respond within 1 vsync. |
211 void SetCriticalBeginMainFrameToActivateIsFast(bool is_fast); | 208 void SetCriticalBeginMainFrameToActivateIsFast(bool is_fast); |
212 | 209 |
213 // A function of SetTreePrioritiesAndScrollState and | 210 // A function of SetTreePrioritiesAndScrollState and |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 const SchedulerSettings settings_; | 295 const SchedulerSettings settings_; |
299 | 296 |
300 CompositorFrameSinkState compositor_frame_sink_state_; | 297 CompositorFrameSinkState compositor_frame_sink_state_; |
301 BeginImplFrameState begin_impl_frame_state_; | 298 BeginImplFrameState begin_impl_frame_state_; |
302 BeginMainFrameState begin_main_frame_state_; | 299 BeginMainFrameState begin_main_frame_state_; |
303 ForcedRedrawOnTimeoutState forced_redraw_state_; | 300 ForcedRedrawOnTimeoutState forced_redraw_state_; |
304 | 301 |
305 // These are used for tracing only. | 302 // These are used for tracing only. |
306 int commit_count_; | 303 int commit_count_; |
307 int current_frame_number_; | 304 int current_frame_number_; |
308 int last_frame_number_swap_performed_; | 305 int last_frame_number_submit_performed_; |
309 int last_frame_number_draw_performed_; | 306 int last_frame_number_draw_performed_; |
310 int last_frame_number_begin_main_frame_sent_; | 307 int last_frame_number_begin_main_frame_sent_; |
311 int last_frame_number_invalidate_compositor_frame_sink_performed_; | 308 int last_frame_number_invalidate_compositor_frame_sink_performed_; |
312 | 309 |
313 // These are used to ensure that an action only happens once per frame, | 310 // These are used to ensure that an action only happens once per frame, |
314 // deadline, etc. | 311 // deadline, etc. |
315 bool draw_funnel_; | 312 bool draw_funnel_; |
316 bool send_begin_main_frame_funnel_; | 313 bool send_begin_main_frame_funnel_; |
317 bool invalidate_compositor_frame_sink_funnel_; | 314 bool invalidate_compositor_frame_sink_funnel_; |
318 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called | 315 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called |
319 // and "drained" on each BeginImplFrame. If the funnel gets too full, | 316 // and "drained" on each BeginImplFrame. If the funnel gets too full, |
320 // we start throttling ACTION_PREPARE_TILES such that we average one | 317 // we start throttling ACTION_PREPARE_TILES such that we average one |
321 // PrepareTiles per BeginImplFrame. | 318 // PrepareTiles per BeginImplFrame. |
322 int prepare_tiles_funnel_; | 319 int prepare_tiles_funnel_; |
323 | 320 |
324 int consecutive_checkerboard_animations_; | 321 int consecutive_checkerboard_animations_; |
325 int pending_swaps_; | 322 int pending_submit_frames_; |
326 int swaps_with_current_compositor_frame_sink_; | 323 int submit_frames_with_current_compositor_frame_sink_; |
327 bool needs_redraw_; | 324 bool needs_redraw_; |
328 bool needs_prepare_tiles_; | 325 bool needs_prepare_tiles_; |
329 bool needs_begin_main_frame_; | 326 bool needs_begin_main_frame_; |
330 bool needs_one_begin_impl_frame_; | 327 bool needs_one_begin_impl_frame_; |
331 bool visible_; | 328 bool visible_; |
332 bool begin_frame_source_paused_; | 329 bool begin_frame_source_paused_; |
333 bool resourceless_draw_; | 330 bool resourceless_draw_; |
334 bool can_draw_; | 331 bool can_draw_; |
335 bool has_pending_tree_; | 332 bool has_pending_tree_; |
336 bool pending_tree_is_ready_for_activation_; | 333 bool pending_tree_is_ready_for_activation_; |
337 bool active_tree_needs_first_draw_; | 334 bool active_tree_needs_first_draw_; |
338 bool did_create_and_initialize_first_compositor_frame_sink_; | 335 bool did_create_and_initialize_first_compositor_frame_sink_; |
339 TreePriority tree_priority_; | 336 TreePriority tree_priority_; |
340 ScrollHandlerState scroll_handler_state_; | 337 ScrollHandlerState scroll_handler_state_; |
341 bool critical_begin_main_frame_to_activate_is_fast_; | 338 bool critical_begin_main_frame_to_activate_is_fast_; |
342 bool main_thread_missed_last_deadline_; | 339 bool main_thread_missed_last_deadline_; |
343 bool skip_next_begin_main_frame_to_reduce_latency_; | 340 bool skip_next_begin_main_frame_to_reduce_latency_; |
344 bool defer_commits_; | 341 bool defer_commits_; |
345 bool video_needs_begin_frames_; | 342 bool video_needs_begin_frames_; |
346 bool last_commit_had_no_updates_; | 343 bool last_commit_had_no_updates_; |
347 bool wait_for_ready_to_draw_; | 344 bool wait_for_ready_to_draw_; |
348 bool did_draw_in_last_frame_; | 345 bool did_draw_in_last_frame_; |
349 bool did_swap_in_last_frame_; | 346 bool did_submit_in_last_frame_; |
350 | 347 |
351 private: | 348 private: |
352 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 349 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
353 }; | 350 }; |
354 | 351 |
355 } // namespace cc | 352 } // namespace cc |
356 | 353 |
357 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 354 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |