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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED || | 94 commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED || |
95 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; | 95 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; |
96 } | 96 } |
97 CommitState commit_state() const { return commit_state_; } | 97 CommitState commit_state() const { return commit_state_; } |
98 | 98 |
99 bool RedrawPending() const { return needs_redraw_; } | 99 bool RedrawPending() const { return needs_redraw_; } |
100 bool ManageTilesPending() const { return needs_manage_tiles_; } | 100 bool ManageTilesPending() const { return needs_manage_tiles_; } |
101 | 101 |
102 enum Action { | 102 enum Action { |
103 ACTION_NONE, | 103 ACTION_NONE, |
104 ACTION_ANIMATE, | |
105 ACTION_SEND_BEGIN_MAIN_FRAME, | 104 ACTION_SEND_BEGIN_MAIN_FRAME, |
106 ACTION_COMMIT, | 105 ACTION_COMMIT, |
107 ACTION_UPDATE_VISIBLE_TILES, | 106 ACTION_UPDATE_VISIBLE_TILES, |
108 ACTION_ACTIVATE_PENDING_TREE, | 107 ACTION_ACTIVATE_PENDING_TREE, |
109 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, | 108 ACTION_DRAW_AND_SWAP_IF_POSSIBLE, |
110 ACTION_DRAW_AND_SWAP_FORCED, | 109 ACTION_DRAW_AND_SWAP_FORCED, |
111 ACTION_DRAW_AND_SWAP_ABORT, | 110 ACTION_DRAW_AND_SWAP_ABORT, |
112 ACTION_DRAW_AND_READBACK, | 111 ACTION_DRAW_AND_READBACK, |
113 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 112 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
114 ACTION_MANAGE_TILES, | 113 ACTION_MANAGE_TILES, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 157 } |
159 | 158 |
160 // Indicates whether the LayerTreeHostImpl is visible. | 159 // Indicates whether the LayerTreeHostImpl is visible. |
161 void SetVisible(bool visible); | 160 void SetVisible(bool visible); |
162 | 161 |
163 // Indicates that a redraw is required, either due to the impl tree changing | 162 // Indicates that a redraw is required, either due to the impl tree changing |
164 // or the screen being damaged and simply needing redisplay. | 163 // or the screen being damaged and simply needing redisplay. |
165 void SetNeedsRedraw(); | 164 void SetNeedsRedraw(); |
166 bool needs_redraw() const { return needs_redraw_; } | 165 bool needs_redraw() const { return needs_redraw_; } |
167 | 166 |
168 void SetNeedsAnimate(); | |
169 bool needs_animate() const { return needs_animate_; } | |
170 | |
171 // Indicates that manage-tiles is required. This guarantees another | 167 // Indicates that manage-tiles is required. This guarantees another |
172 // ManageTiles will occur shortly (even if no redraw is required). | 168 // ManageTiles will occur shortly (even if no redraw is required). |
173 void SetNeedsManageTiles(); | 169 void SetNeedsManageTiles(); |
174 | 170 |
175 // Sets how many swaps can be pending to the OutputSurface. | 171 // Sets how many swaps can be pending to the OutputSurface. |
176 void SetMaxSwapsPending(int max); | 172 void SetMaxSwapsPending(int max); |
177 | 173 |
178 // If the scheduler attempted to draw and swap, this provides feedback | 174 // If the scheduler attempted to draw and swap, this provides feedback |
179 // regarding whether or not the swap actually occured. We might skip the | 175 // regarding whether or not the swap actually occured. We might skip the |
180 // swap when there is not damage, for example. | 176 // swap when there is not damage, for example. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // True if we need to abort draws to make forward progress. | 241 // True if we need to abort draws to make forward progress. |
246 bool PendingDrawsShouldBeAborted() const; | 242 bool PendingDrawsShouldBeAborted() const; |
247 | 243 |
248 bool SupportsProactiveBeginFrame() const; | 244 bool SupportsProactiveBeginFrame() const; |
249 | 245 |
250 void SetContinuousPainting(bool continuous_painting) { | 246 void SetContinuousPainting(bool continuous_painting) { |
251 continuous_painting_ = continuous_painting; | 247 continuous_painting_ = continuous_painting; |
252 } | 248 } |
253 | 249 |
254 protected: | 250 protected: |
255 bool BeginFrameNeededToAnimateOrDraw() const; | 251 bool BeginFrameNeededToDraw() const; |
256 bool ProactiveBeginFrameWanted() const; | 252 bool ProactiveBeginFrameWanted() const; |
257 | 253 |
258 // True if we need to force activations to make forward progress. | 254 // True if we need to force activations to make forward progress. |
259 bool PendingActivationsShouldBeForced() const; | 255 bool PendingActivationsShouldBeForced() const; |
260 | 256 |
261 bool ShouldAnimate() const; | |
262 bool ShouldBeginOutputSurfaceCreation() const; | 257 bool ShouldBeginOutputSurfaceCreation() const; |
263 bool ShouldDrawForced() const; | 258 bool ShouldDrawForced() const; |
264 bool ShouldDraw() const; | 259 bool ShouldDraw() const; |
265 bool ShouldActivatePendingTree() const; | 260 bool ShouldActivatePendingTree() const; |
266 bool ShouldUpdateVisibleTiles() const; | 261 bool ShouldUpdateVisibleTiles() const; |
267 bool ShouldSendBeginMainFrame() const; | 262 bool ShouldSendBeginMainFrame() const; |
268 bool ShouldCommit() const; | 263 bool ShouldCommit() const; |
269 bool ShouldManageTiles() const; | 264 bool ShouldManageTiles() const; |
270 | 265 |
271 void AdvanceCurrentFrameNumber(); | 266 void AdvanceCurrentFrameNumber(); |
(...skipping 12 matching lines...) Expand all Loading... |
284 OutputSurfaceState output_surface_state_; | 279 OutputSurfaceState output_surface_state_; |
285 BeginImplFrameState begin_impl_frame_state_; | 280 BeginImplFrameState begin_impl_frame_state_; |
286 CommitState commit_state_; | 281 CommitState commit_state_; |
287 ForcedRedrawOnTimeoutState forced_redraw_state_; | 282 ForcedRedrawOnTimeoutState forced_redraw_state_; |
288 SynchronousReadbackState readback_state_; | 283 SynchronousReadbackState readback_state_; |
289 | 284 |
290 BeginFrameArgs begin_impl_frame_args_; | 285 BeginFrameArgs begin_impl_frame_args_; |
291 | 286 |
292 int commit_count_; | 287 int commit_count_; |
293 int current_frame_number_; | 288 int current_frame_number_; |
294 int last_frame_number_animate_performed_; | |
295 int last_frame_number_swap_performed_; | 289 int last_frame_number_swap_performed_; |
296 int last_frame_number_begin_main_frame_sent_; | 290 int last_frame_number_begin_main_frame_sent_; |
297 int last_frame_number_update_visible_tiles_was_called_; | 291 int last_frame_number_update_visible_tiles_was_called_; |
298 | 292 |
299 // manage_tiles_funnel_ is "filled" each time ManageTiles is called | 293 // manage_tiles_funnel_ is "filled" each time ManageTiles is called |
300 // and "drained" on each BeginImplFrame. If the funnel gets too full, | 294 // and "drained" on each BeginImplFrame. If the funnel gets too full, |
301 // we start throttling ACTION_MANAGE_TILES such that we average one | 295 // we start throttling ACTION_MANAGE_TILES such that we average one |
302 // ManageTile per BeginImplFrame. | 296 // ManageTile per BeginImplFrame. |
303 int manage_tiles_funnel_; | 297 int manage_tiles_funnel_; |
304 int consecutive_checkerboard_animations_; | 298 int consecutive_checkerboard_animations_; |
305 int max_pending_swaps_; | 299 int max_pending_swaps_; |
306 int pending_swaps_; | 300 int pending_swaps_; |
307 bool needs_redraw_; | 301 bool needs_redraw_; |
308 bool needs_animate_; | |
309 bool needs_manage_tiles_; | 302 bool needs_manage_tiles_; |
310 bool swap_used_incomplete_tile_; | 303 bool swap_used_incomplete_tile_; |
311 bool needs_commit_; | 304 bool needs_commit_; |
312 bool inside_poll_for_anticipated_draw_triggers_; | 305 bool inside_poll_for_anticipated_draw_triggers_; |
313 bool visible_; | 306 bool visible_; |
314 bool can_start_; | 307 bool can_start_; |
315 bool can_draw_; | 308 bool can_draw_; |
316 bool has_pending_tree_; | 309 bool has_pending_tree_; |
317 bool pending_tree_is_ready_for_activation_; | 310 bool pending_tree_is_ready_for_activation_; |
318 bool active_tree_needs_first_draw_; | 311 bool active_tree_needs_first_draw_; |
319 bool draw_if_possible_failed_; | 312 bool draw_if_possible_failed_; |
320 bool did_create_and_initialize_first_output_surface_; | 313 bool did_create_and_initialize_first_output_surface_; |
321 bool smoothness_takes_priority_; | 314 bool smoothness_takes_priority_; |
322 bool skip_next_begin_main_frame_to_reduce_latency_; | 315 bool skip_next_begin_main_frame_to_reduce_latency_; |
323 bool skip_begin_main_frame_to_reduce_latency_; | 316 bool skip_begin_main_frame_to_reduce_latency_; |
324 bool continuous_painting_; | 317 bool continuous_painting_; |
325 bool needs_back_to_back_readback_; | 318 bool needs_back_to_back_readback_; |
326 | 319 |
327 private: | 320 private: |
328 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 321 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
329 }; | 322 }; |
330 | 323 |
331 } // namespace cc | 324 } // namespace cc |
332 | 325 |
333 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 326 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
OLD | NEW |