Chromium Code Reviews| 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_SUBMIT_COMPOSITOR_FRAME_IF_POSSIBLE, |
| 120 ACTION_DRAW_AND_SWAP_FORCED, | 120 ACTION_SUBMIT_COMPOSITOR_FRAME_FORCED, |
| 121 ACTION_DRAW_AND_SWAP_ABORT, | 121 ACTION_SUBMIT_COMPOSITOR_FRAME_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 AbortSubmitCompositorFrame(); |
| 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 SubmitThrottled() const; |
|
enne (OOO)
2016/10/11 17:26:00
bikeshedding: IsSubmitThrottled?
danakj
2016/10/13 23:50:22
Went to IsDrawThrottled.
| |
| 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 and swap, this provides feedback |
| 192 // regarding whether or not the swap actually occured. We might skip the | 192 // regarding whether or not the swap actually occured. We might skip the |
| 193 // swap when there is not damage, for example. | 193 // swap when there is not damage, for example. |
| 194 void DidSwapBuffers(); | 194 void DidSubmitCompositorFrame(); |
| 195 | |
| 196 // Indicates whether a redraw is required because we are currently rendering | |
| 197 // with a low resolution or checkerboarded tile. | |
| 198 void SetSwapUsedIncompleteTile(bool used_incomplete_tile); | |
|
sunnyps
2016/10/11 18:32:48
Can you clarify why this method was removed?
danakj
2016/10/13 23:50:22
The method doesn't exist only the definition does.
| |
| 199 | 195 |
| 200 // Notification from the CompositorFrameSink that a swap has been consumed. | 196 // Notification from the CompositorFrameSink that a swap has been consumed. |
| 201 void DidSwapBuffersComplete(); | 197 void DidReceiveCompositorFrameAck(); |
| 202 | 198 |
| 203 int pending_swaps() const { return pending_swaps_; } | 199 int pending_submit_frames() const { return pending_submit_frames_; } |
| 204 | 200 |
| 205 // Indicates whether to prioritize impl thread latency (i.e., animation | 201 // Indicates whether to prioritize impl thread latency (i.e., animation |
| 206 // smoothness) over new content activation. | 202 // smoothness) over new content activation. |
| 207 void SetTreePrioritiesAndScrollState(TreePriority tree_priority, | 203 void SetTreePrioritiesAndScrollState(TreePriority tree_priority, |
| 208 ScrollHandlerState scroll_handler_state); | 204 ScrollHandlerState scroll_handler_state); |
| 209 | 205 |
| 210 // Indicates if the main thread will likely respond within 1 vsync. | 206 // Indicates if the main thread will likely respond within 1 vsync. |
| 211 void SetCriticalBeginMainFrameToActivateIsFast(bool is_fast); | 207 void SetCriticalBeginMainFrameToActivateIsFast(bool is_fast); |
| 212 | 208 |
| 213 // A function of SetTreePrioritiesAndScrollState and | 209 // A function of SetTreePrioritiesAndScrollState and |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 const SchedulerSettings settings_; | 294 const SchedulerSettings settings_; |
| 299 | 295 |
| 300 CompositorFrameSinkState compositor_frame_sink_state_; | 296 CompositorFrameSinkState compositor_frame_sink_state_; |
| 301 BeginImplFrameState begin_impl_frame_state_; | 297 BeginImplFrameState begin_impl_frame_state_; |
| 302 BeginMainFrameState begin_main_frame_state_; | 298 BeginMainFrameState begin_main_frame_state_; |
| 303 ForcedRedrawOnTimeoutState forced_redraw_state_; | 299 ForcedRedrawOnTimeoutState forced_redraw_state_; |
| 304 | 300 |
| 305 // These are used for tracing only. | 301 // These are used for tracing only. |
| 306 int commit_count_; | 302 int commit_count_; |
| 307 int current_frame_number_; | 303 int current_frame_number_; |
| 308 int last_frame_number_swap_performed_; | 304 int last_frame_number_submit_performed_; |
| 309 int last_frame_number_draw_performed_; | 305 int last_frame_number_draw_performed_; |
| 310 int last_frame_number_begin_main_frame_sent_; | 306 int last_frame_number_begin_main_frame_sent_; |
| 311 int last_frame_number_invalidate_compositor_frame_sink_performed_; | 307 int last_frame_number_invalidate_compositor_frame_sink_performed_; |
| 312 | 308 |
| 313 // These are used to ensure that an action only happens once per frame, | 309 // These are used to ensure that an action only happens once per frame, |
| 314 // deadline, etc. | 310 // deadline, etc. |
| 315 bool draw_funnel_; | 311 bool draw_funnel_; |
| 316 bool send_begin_main_frame_funnel_; | 312 bool send_begin_main_frame_funnel_; |
| 317 bool invalidate_compositor_frame_sink_funnel_; | 313 bool invalidate_compositor_frame_sink_funnel_; |
| 318 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called | 314 // prepare_tiles_funnel_ is "filled" each time PrepareTiles is called |
| 319 // and "drained" on each BeginImplFrame. If the funnel gets too full, | 315 // and "drained" on each BeginImplFrame. If the funnel gets too full, |
| 320 // we start throttling ACTION_PREPARE_TILES such that we average one | 316 // we start throttling ACTION_PREPARE_TILES such that we average one |
| 321 // PrepareTiles per BeginImplFrame. | 317 // PrepareTiles per BeginImplFrame. |
| 322 int prepare_tiles_funnel_; | 318 int prepare_tiles_funnel_; |
| 323 | 319 |
| 324 int consecutive_checkerboard_animations_; | 320 int consecutive_checkerboard_animations_; |
| 325 int max_pending_swaps_; | 321 int max_pending_submit_frames_; |
| 326 int pending_swaps_; | 322 int pending_submit_frames_; |
| 327 int swaps_with_current_compositor_frame_sink_; | 323 int submit_frames_with_current_compositor_frame_sink_; |
| 328 bool needs_redraw_; | 324 bool needs_redraw_; |
| 329 bool needs_prepare_tiles_; | 325 bool needs_prepare_tiles_; |
| 330 bool needs_begin_main_frame_; | 326 bool needs_begin_main_frame_; |
| 331 bool needs_one_begin_impl_frame_; | 327 bool needs_one_begin_impl_frame_; |
| 332 bool visible_; | 328 bool visible_; |
| 333 bool begin_frame_source_paused_; | 329 bool begin_frame_source_paused_; |
| 334 bool resourceless_draw_; | 330 bool resourceless_draw_; |
| 335 bool can_draw_; | 331 bool can_draw_; |
| 336 bool has_pending_tree_; | 332 bool has_pending_tree_; |
| 337 bool pending_tree_is_ready_for_activation_; | 333 bool pending_tree_is_ready_for_activation_; |
| 338 bool active_tree_needs_first_draw_; | 334 bool active_tree_needs_first_draw_; |
| 339 bool did_create_and_initialize_first_compositor_frame_sink_; | 335 bool did_create_and_initialize_first_compositor_frame_sink_; |
| 340 TreePriority tree_priority_; | 336 TreePriority tree_priority_; |
| 341 ScrollHandlerState scroll_handler_state_; | 337 ScrollHandlerState scroll_handler_state_; |
| 342 bool critical_begin_main_frame_to_activate_is_fast_; | 338 bool critical_begin_main_frame_to_activate_is_fast_; |
| 343 bool main_thread_missed_last_deadline_; | 339 bool main_thread_missed_last_deadline_; |
| 344 bool skip_next_begin_main_frame_to_reduce_latency_; | 340 bool skip_next_begin_main_frame_to_reduce_latency_; |
| 345 bool defer_commits_; | 341 bool defer_commits_; |
| 346 bool video_needs_begin_frames_; | 342 bool video_needs_begin_frames_; |
| 347 bool last_commit_had_no_updates_; | 343 bool last_commit_had_no_updates_; |
| 348 bool wait_for_ready_to_draw_; | 344 bool wait_for_ready_to_draw_; |
| 349 bool did_draw_in_last_frame_; | 345 bool did_draw_in_last_frame_; |
| 350 bool did_swap_in_last_frame_; | 346 bool did_submit_in_last_frame_; |
| 351 | 347 |
| 352 private: | 348 private: |
| 353 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 349 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
| 354 }; | 350 }; |
| 355 | 351 |
| 356 } // namespace cc | 352 } // namespace cc |
| 357 | 353 |
| 358 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 354 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| OLD | NEW |