| 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/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 current_frame_number_; | 447 current_frame_number_; |
| 448 return; | 448 return; |
| 449 | 449 |
| 450 case ACTION_COMMIT: { | 450 case ACTION_COMMIT: { |
| 451 bool commit_was_aborted = false; | 451 bool commit_was_aborted = false; |
| 452 UpdateStateOnCommit(commit_was_aborted); | 452 UpdateStateOnCommit(commit_was_aborted); |
| 453 return; | 453 return; |
| 454 } | 454 } |
| 455 | 455 |
| 456 case ACTION_DRAW_FORCED: | 456 case ACTION_DRAW_FORCED: |
| 457 case ACTION_DRAW_IF_POSSIBLE: { | 457 case ACTION_DRAW_IF_POSSIBLE: |
| 458 bool did_swap = true; | 458 case ACTION_DRAW_AND_SWAP_ABORT: { |
| 459 UpdateStateOnDraw(did_swap); | 459 UpdateStateOnDraw(); |
| 460 return; | 460 return; |
| 461 } | 461 } |
| 462 | 462 |
| 463 case ACTION_DRAW_AND_SWAP_ABORT: { | |
| 464 bool did_swap = false; | |
| 465 UpdateStateOnDraw(did_swap); | |
| 466 return; | |
| 467 } | |
| 468 | |
| 469 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: | 463 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: |
| 470 DCHECK_EQ(commit_state_, COMMIT_STATE_IDLE); | 464 DCHECK_EQ(commit_state_, COMMIT_STATE_IDLE); |
| 471 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST); | 465 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST); |
| 472 output_surface_state_ = OUTPUT_SURFACE_CREATING; | 466 output_surface_state_ = OUTPUT_SURFACE_CREATING; |
| 473 return; | 467 return; |
| 474 | 468 |
| 475 case ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: | 469 case ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: |
| 476 texture_state_ = LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD; | 470 texture_state_ = LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD; |
| 477 main_thread_needs_layer_textures_ = false; | 471 main_thread_needs_layer_textures_ = false; |
| 478 return; | 472 return; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 void SchedulerStateMachine::UpdateStateOnActivation() { | 529 void SchedulerStateMachine::UpdateStateOnActivation() { |
| 536 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION) | 530 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION) |
| 537 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; | 531 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; |
| 538 | 532 |
| 539 has_pending_tree_ = false; | 533 has_pending_tree_ = false; |
| 540 pending_tree_is_ready_for_activation_ = false; | 534 pending_tree_is_ready_for_activation_ = false; |
| 541 active_tree_has_been_drawn_ = false; | 535 active_tree_has_been_drawn_ = false; |
| 542 needs_redraw_ = true; | 536 needs_redraw_ = true; |
| 543 } | 537 } |
| 544 | 538 |
| 545 void SchedulerStateMachine::UpdateStateOnDraw(bool did_swap) { | 539 void SchedulerStateMachine::UpdateStateOnDraw() { |
| 546 if (inside_begin_frame_) | 540 if (inside_begin_frame_) |
| 547 last_frame_number_where_draw_was_called_ = current_frame_number_; | 541 last_frame_number_where_draw_was_called_ = current_frame_number_; |
| 548 if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW) { | 542 if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW) { |
| 549 DCHECK(expect_immediate_begin_frame_for_main_thread_); | 543 DCHECK(expect_immediate_begin_frame_for_main_thread_); |
| 550 commit_state_ = COMMIT_STATE_FRAME_IN_PROGRESS; | 544 commit_state_ = COMMIT_STATE_FRAME_IN_PROGRESS; |
| 551 expect_immediate_begin_frame_for_main_thread_ = false; | 545 expect_immediate_begin_frame_for_main_thread_ = false; |
| 552 } else if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) { | 546 } else if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) { |
| 553 commit_state_ = COMMIT_STATE_IDLE; | 547 commit_state_ = COMMIT_STATE_IDLE; |
| 554 } | 548 } |
| 555 if (texture_state_ == LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD) | 549 if (texture_state_ == LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD) |
| 556 texture_state_ = LAYER_TEXTURE_STATE_UNLOCKED; | 550 texture_state_ = LAYER_TEXTURE_STATE_UNLOCKED; |
| 557 | 551 |
| 558 needs_redraw_ = false; | 552 needs_redraw_ = false; |
| 559 needs_forced_redraw_ = false; | 553 needs_forced_redraw_ = false; |
| 560 draw_if_possible_failed_ = false; | 554 draw_if_possible_failed_ = false; |
| 561 active_tree_has_been_drawn_ = true; | 555 active_tree_has_been_drawn_ = true; |
| 562 | |
| 563 if (did_swap) | |
| 564 swap_used_incomplete_tile_ = false; | |
| 565 } | 556 } |
| 566 | 557 |
| 567 void SchedulerStateMachine::SetMainThreadNeedsLayerTextures() { | 558 void SchedulerStateMachine::SetMainThreadNeedsLayerTextures() { |
| 568 DCHECK(!main_thread_needs_layer_textures_); | 559 DCHECK(!main_thread_needs_layer_textures_); |
| 569 DCHECK_NE(texture_state_, LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD); | 560 DCHECK_NE(texture_state_, LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD); |
| 570 main_thread_needs_layer_textures_ = true; | 561 main_thread_needs_layer_textures_ = true; |
| 571 } | 562 } |
| 572 | 563 |
| 573 bool SchedulerStateMachine::BeginFrameNeededToDrawByImplThread() const { | 564 bool SchedulerStateMachine::BeginFrameNeededToDrawByImplThread() const { |
| 574 // If we can't draw, don't tick until we are notified that we can draw again. | 565 // If we can't draw, don't tick until we are notified that we can draw again. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 } | 598 } |
| 608 | 599 |
| 609 void SchedulerStateMachine::DidLeaveBeginFrame() { | 600 void SchedulerStateMachine::DidLeaveBeginFrame() { |
| 610 inside_begin_frame_ = false; | 601 inside_begin_frame_ = false; |
| 611 } | 602 } |
| 612 | 603 |
| 613 void SchedulerStateMachine::SetVisible(bool visible) { visible_ = visible; } | 604 void SchedulerStateMachine::SetVisible(bool visible) { visible_ = visible; } |
| 614 | 605 |
| 615 void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; } | 606 void SchedulerStateMachine::SetNeedsRedraw() { needs_redraw_ = true; } |
| 616 | 607 |
| 617 void SchedulerStateMachine::DidSwapUseIncompleteTile() { | 608 void SchedulerStateMachine::SetSwapUsedIncompleteTile( |
| 618 swap_used_incomplete_tile_ = true; | 609 bool used_incomplete_tile) { |
| 610 swap_used_incomplete_tile_ = used_incomplete_tile; |
| 619 } | 611 } |
| 620 | 612 |
| 621 void SchedulerStateMachine::SetNeedsForcedRedraw() { | 613 void SchedulerStateMachine::SetNeedsForcedRedraw() { |
| 622 needs_forced_redraw_ = true; | 614 needs_forced_redraw_ = true; |
| 623 } | 615 } |
| 624 | 616 |
| 625 void SchedulerStateMachine::DidDrawIfPossibleCompleted(bool success) { | 617 void SchedulerStateMachine::DidDrawIfPossibleCompleted(bool success) { |
| 626 draw_if_possible_failed_ = !success; | 618 draw_if_possible_failed_ = !success; |
| 627 if (draw_if_possible_failed_) { | 619 if (draw_if_possible_failed_) { |
| 628 needs_redraw_ = true; | 620 needs_redraw_ = true; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 NOTREACHED(); | 702 NOTREACHED(); |
| 711 return false; | 703 return false; |
| 712 } | 704 } |
| 713 | 705 |
| 714 void SchedulerStateMachine::SetMaximumNumberOfFailedDrawsBeforeDrawIsForced( | 706 void SchedulerStateMachine::SetMaximumNumberOfFailedDrawsBeforeDrawIsForced( |
| 715 int num_draws) { | 707 int num_draws) { |
| 716 maximum_number_of_failed_draws_before_draw_is_forced_ = num_draws; | 708 maximum_number_of_failed_draws_before_draw_is_forced_ = num_draws; |
| 717 } | 709 } |
| 718 | 710 |
| 719 } // namespace cc | 711 } // namespace cc |
| OLD | NEW |