| 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/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 needs_begin_main_frame_ = false; | 556 needs_begin_main_frame_ = false; |
| 557 send_begin_main_frame_funnel_ = true; | 557 send_begin_main_frame_funnel_ = true; |
| 558 last_frame_number_begin_main_frame_sent_ = current_frame_number_; | 558 last_frame_number_begin_main_frame_sent_ = current_frame_number_; |
| 559 } | 559 } |
| 560 | 560 |
| 561 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { | 561 void SchedulerStateMachine::WillCommit(bool commit_has_no_updates) { |
| 562 DCHECK(!has_pending_tree_ || | 562 DCHECK(!has_pending_tree_ || |
| 563 (settings_.main_frame_before_activation_enabled && | 563 (settings_.main_frame_before_activation_enabled && |
| 564 commit_has_no_updates)); | 564 commit_has_no_updates)); |
| 565 commit_count_++; | 565 commit_count_++; |
| 566 last_commit_had_no_updates_ = commit_has_no_updates; |
| 566 | 567 |
| 567 if (commit_has_no_updates || settings_.main_frame_before_activation_enabled) { | 568 if (commit_has_no_updates || settings_.main_frame_before_activation_enabled) { |
| 568 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; | 569 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_IDLE; |
| 569 } else { | 570 } else { |
| 570 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION; | 571 begin_main_frame_state_ = BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION; |
| 571 } | 572 } |
| 572 | 573 |
| 573 // Pending tree only exists if commit had updates. | 574 if (!commit_has_no_updates) { |
| 574 if (!commit_has_no_updates) | 575 // Pending tree only exists if commit had updates. |
| 575 has_pending_tree_ = true; | 576 has_pending_tree_ = true; |
| 576 | 577 pending_tree_is_ready_for_activation_ = false; |
| 577 wait_for_ready_to_draw_ = | 578 wait_for_ready_to_draw_ = settings_.commit_to_active_tree; |
| 578 !commit_has_no_updates && settings_.commit_to_active_tree; | 579 } |
| 579 | 580 |
| 580 // Update state related to forced draws. | 581 // Update state related to forced draws. |
| 581 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { | 582 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_COMMIT) { |
| 582 forced_redraw_state_ = has_pending_tree_ | 583 forced_redraw_state_ = has_pending_tree_ |
| 583 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION | 584 ? FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION |
| 584 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; | 585 : FORCED_REDRAW_STATE_WAITING_FOR_DRAW; |
| 585 } | 586 } |
| 586 | 587 |
| 587 // Update the output surface state. | 588 // Update the output surface state. |
| 588 DCHECK_NE(output_surface_state_, OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION); | |
| 589 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) { | 589 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) { |
| 590 if (has_pending_tree_) { | 590 output_surface_state_ = has_pending_tree_ |
| 591 output_surface_state_ = OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION; | 591 ? OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION |
| 592 } else { | 592 : OUTPUT_SURFACE_ACTIVE; |
| 593 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; | |
| 594 } | |
| 595 } | 593 } |
| 596 | |
| 597 // Update state if there's no updates heading for the active tree, but we need | |
| 598 // to do a forced draw. | |
| 599 if (commit_has_no_updates && | |
| 600 forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) { | |
| 601 DCHECK(!has_pending_tree_); | |
| 602 needs_redraw_ = true; | |
| 603 } | |
| 604 | |
| 605 // This post-commit work is common to both completed and aborted commits. | |
| 606 pending_tree_is_ready_for_activation_ = false; | |
| 607 | |
| 608 last_commit_had_no_updates_ = commit_has_no_updates; | |
| 609 } | 594 } |
| 610 | 595 |
| 611 void SchedulerStateMachine::WillActivate() { | 596 void SchedulerStateMachine::WillActivate() { |
| 612 if (begin_main_frame_state_ == | 597 if (begin_main_frame_state_ == |
| 613 BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION) { | 598 BEGIN_MAIN_FRAME_STATE_WAITING_FOR_ACTIVATION) { |
| 614 begin_main_frame_state_ = settings_.commit_to_active_tree | 599 begin_main_frame_state_ = settings_.commit_to_active_tree |
| 615 ? BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW | 600 ? BEGIN_MAIN_FRAME_STATE_WAITING_FOR_DRAW |
| 616 : BEGIN_MAIN_FRAME_STATE_IDLE; | 601 : BEGIN_MAIN_FRAME_STATE_IDLE; |
| 617 } | 602 } |
| 618 | 603 |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 case OUTPUT_SURFACE_ACTIVE: | 1105 case OUTPUT_SURFACE_ACTIVE: |
| 1121 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: | 1106 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: |
| 1122 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: | 1107 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: |
| 1123 return true; | 1108 return true; |
| 1124 } | 1109 } |
| 1125 NOTREACHED(); | 1110 NOTREACHED(); |
| 1126 return false; | 1111 return false; |
| 1127 } | 1112 } |
| 1128 | 1113 |
| 1129 } // namespace cc | 1114 } // namespace cc |
| OLD | NEW |