| 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 #include "cc/scheduler/scheduler_state_machine.h" | 5 #include "cc/scheduler/scheduler_state_machine.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 needs_commit_(false), | 25 needs_commit_(false), |
| 26 needs_forced_commit_(false), | 26 needs_forced_commit_(false), |
| 27 expect_immediate_begin_frame_(false), | 27 expect_immediate_begin_frame_(false), |
| 28 main_thread_needs_layer_textures_(false), | 28 main_thread_needs_layer_textures_(false), |
| 29 inside_vsync_(false), | 29 inside_vsync_(false), |
| 30 visible_(false), | 30 visible_(false), |
| 31 can_begin_frame_(false), | 31 can_begin_frame_(false), |
| 32 can_draw_(false), | 32 can_draw_(false), |
| 33 has_pending_tree_(false), | 33 has_pending_tree_(false), |
| 34 draw_if_possible_failed_(false), | 34 draw_if_possible_failed_(false), |
| 35 animate_requested_(false), |
| 35 texture_state_(LAYER_TEXTURE_STATE_UNLOCKED), | 36 texture_state_(LAYER_TEXTURE_STATE_UNLOCKED), |
| 36 output_surface_state_(OUTPUT_SURFACE_ACTIVE) {} | 37 output_surface_state_(OUTPUT_SURFACE_ACTIVE) {} |
| 37 | 38 |
| 38 std::string SchedulerStateMachine::ToString() { | 39 std::string SchedulerStateMachine::ToString() { |
| 39 std::string str; | 40 std::string str; |
| 40 base::StringAppendF(&str, | 41 base::StringAppendF(&str, |
| 41 "settings_.impl_side_painting = %d; ", | 42 "settings_.impl_side_painting = %d; ", |
| 42 settings_.impl_side_painting); | 43 settings_.impl_side_painting); |
| 43 base::StringAppendF(&str, "commit_state_ = %d; ", commit_state_); | 44 base::StringAppendF(&str, "commit_state_ = %d; ", commit_state_); |
| 44 base::StringAppendF( | 45 base::StringAppendF( |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 last_frame_number_where_tree_activation_attempted_ = | 258 last_frame_number_where_tree_activation_attempted_ = |
| 258 current_frame_number_; | 259 current_frame_number_; |
| 259 return; | 260 return; |
| 260 | 261 |
| 261 case ACTION_BEGIN_FRAME: | 262 case ACTION_BEGIN_FRAME: |
| 262 DCHECK(!has_pending_tree_); | 263 DCHECK(!has_pending_tree_); |
| 263 DCHECK(visible_ || needs_forced_commit_); | 264 DCHECK(visible_ || needs_forced_commit_); |
| 264 commit_state_ = COMMIT_STATE_FRAME_IN_PROGRESS; | 265 commit_state_ = COMMIT_STATE_FRAME_IN_PROGRESS; |
| 265 needs_commit_ = false; | 266 needs_commit_ = false; |
| 266 needs_forced_commit_ = false; | 267 needs_forced_commit_ = false; |
| 268 animate_requested_ = false; |
| 267 return; | 269 return; |
| 268 | 270 |
| 269 case ACTION_COMMIT: | 271 case ACTION_COMMIT: |
| 270 if (expect_immediate_begin_frame_) | 272 if (expect_immediate_begin_frame_) |
| 271 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW; | 273 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW; |
| 272 else | 274 else |
| 273 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; | 275 commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW; |
| 274 // When impl-side painting, we draw on activation instead of on commit. | 276 // When impl-side painting, we draw on activation instead of on commit. |
| 275 if (!settings_.impl_side_painting) | 277 if (!settings_.impl_side_painting) |
| 276 needs_redraw_ = true; | 278 needs_redraw_ = true; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 DCHECK_NE(texture_state_, LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD); | 326 DCHECK_NE(texture_state_, LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD); |
| 325 main_thread_needs_layer_textures_ = true; | 327 main_thread_needs_layer_textures_ = true; |
| 326 } | 328 } |
| 327 | 329 |
| 328 bool SchedulerStateMachine::VSyncCallbackNeeded() const { | 330 bool SchedulerStateMachine::VSyncCallbackNeeded() const { |
| 329 // If we have a pending tree, need to keep getting notifications until | 331 // If we have a pending tree, need to keep getting notifications until |
| 330 // the tree is ready to be swapped. | 332 // the tree is ready to be swapped. |
| 331 if (has_pending_tree_) | 333 if (has_pending_tree_) |
| 332 return true; | 334 return true; |
| 333 | 335 |
| 336 if (animate_requested_) |
| 337 return true; |
| 338 |
| 334 // If we can't draw, don't tick until we are notified that we can draw again. | 339 // If we can't draw, don't tick until we are notified that we can draw again. |
| 335 if (!can_draw_) | 340 if (!can_draw_) |
| 336 return false; | 341 return false; |
| 337 | 342 |
| 338 if (needs_forced_redraw_) | 343 if (needs_forced_redraw_) |
| 339 return true; | 344 return true; |
| 340 | 345 |
| 341 if (visible_ && swap_used_incomplete_tile_) | 346 if (visible_ && swap_used_incomplete_tile_) |
| 342 return true; | 347 return true; |
| 343 | 348 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // we've committed and have new textures. | 383 // we've committed and have new textures. |
| 379 needs_forced_redraw_after_next_commit_ = true; | 384 needs_forced_redraw_after_next_commit_ = true; |
| 380 } | 385 } |
| 381 } else { | 386 } else { |
| 382 consecutive_failed_draws_ = 0; | 387 consecutive_failed_draws_ = 0; |
| 383 } | 388 } |
| 384 } | 389 } |
| 385 | 390 |
| 386 void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; } | 391 void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; } |
| 387 | 392 |
| 393 void SchedulerStateMachine::SetAnimateRequested() { |
| 394 animate_requested_ = true; |
| 395 } |
| 396 |
| 388 void SchedulerStateMachine::SetNeedsForcedCommit() { | 397 void SchedulerStateMachine::SetNeedsForcedCommit() { |
| 389 needs_forced_commit_ = true; | 398 needs_forced_commit_ = true; |
| 390 expect_immediate_begin_frame_ = true; | 399 expect_immediate_begin_frame_ = true; |
| 391 } | 400 } |
| 392 | 401 |
| 393 void SchedulerStateMachine::BeginFrameComplete() { | 402 void SchedulerStateMachine::BeginFrameComplete() { |
| 394 DCHECK(commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS || | 403 DCHECK(commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS || |
| 395 (expect_immediate_begin_frame_ && commit_state_ != COMMIT_STATE_IDLE)) | 404 (expect_immediate_begin_frame_ && commit_state_ != COMMIT_STATE_IDLE)) |
| 396 << ToString(); | 405 << ToString(); |
| 397 commit_state_ = COMMIT_STATE_READY_TO_COMMIT; | 406 commit_state_ = COMMIT_STATE_READY_TO_COMMIT; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 425 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; | 434 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; |
| 426 SetNeedsCommit(); | 435 SetNeedsCommit(); |
| 427 } | 436 } |
| 428 | 437 |
| 429 void SchedulerStateMachine::SetMaximumNumberOfFailedDrawsBeforeDrawIsForced( | 438 void SchedulerStateMachine::SetMaximumNumberOfFailedDrawsBeforeDrawIsForced( |
| 430 int num_draws) { | 439 int num_draws) { |
| 431 maximum_number_of_failed_draws_before_draw_is_forced_ = num_draws; | 440 maximum_number_of_failed_draws_before_draw_is_forced_ = num_draws; |
| 432 } | 441 } |
| 433 | 442 |
| 434 } // namespace cc | 443 } // namespace cc |
| OLD | NEW |