| 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.h" | 5 #include "cc/scheduler/scheduler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 state_machine_.SetVisible(visible); | 82 state_machine_.SetVisible(visible); |
| 83 UpdateCompositorTimingHistoryRecordingEnabled(); | 83 UpdateCompositorTimingHistoryRecordingEnabled(); |
| 84 ProcessScheduledActions(); | 84 ProcessScheduledActions(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void Scheduler::SetCanDraw(bool can_draw) { | 87 void Scheduler::SetCanDraw(bool can_draw) { |
| 88 state_machine_.SetCanDraw(can_draw); | 88 state_machine_.SetCanDraw(can_draw); |
| 89 ProcessScheduledActions(); | 89 ProcessScheduledActions(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void Scheduler::NotifyReadyToActivate() { | 92 void Scheduler::NotifyReadyToActivate(int source_frame_number) { |
| 93 compositor_timing_history_->ReadyToActivate(); | 93 compositor_timing_history_->ReadyToActivate(); |
| 94 state_machine_.NotifyReadyToActivate(); | 94 state_machine_.NotifyReadyToActivate(); |
| 95 // Note the activate source-frame and timestamp |
| 96 if (source_frame_number != 0) { |
| 97 ready_to_activate_time_.emplace_back(source_frame_number, |
| 98 base::TimeTicks::Now()); |
| 99 } |
| 95 ProcessScheduledActions(); | 100 ProcessScheduledActions(); |
| 96 } | 101 } |
| 97 | 102 |
| 98 void Scheduler::NotifyReadyToDraw() { | 103 void Scheduler::NotifyReadyToDraw() { |
| 99 // Future work might still needed for crbug.com/352894. | 104 // Future work might still needed for crbug.com/352894. |
| 100 state_machine_.NotifyReadyToDraw(); | 105 state_machine_.NotifyReadyToDraw(); |
| 101 ProcessScheduledActions(); | 106 ProcessScheduledActions(); |
| 102 } | 107 } |
| 103 | 108 |
| 104 void Scheduler::SetBeginFrameSource(BeginFrameSource* source) { | 109 void Scheduler::SetBeginFrameSource(BeginFrameSource* source) { |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 | 606 |
| 602 void Scheduler::ProcessScheduledActions() { | 607 void Scheduler::ProcessScheduledActions() { |
| 603 // Do not perform actions during compositor shutdown. | 608 // Do not perform actions during compositor shutdown. |
| 604 if (stopped_) | 609 if (stopped_) |
| 605 return; | 610 return; |
| 606 | 611 |
| 607 // We do not allow ProcessScheduledActions to be recursive. | 612 // We do not allow ProcessScheduledActions to be recursive. |
| 608 // The top-level call will iteratively execute the next action for us anyway. | 613 // The top-level call will iteratively execute the next action for us anyway. |
| 609 if (inside_process_scheduled_actions_) | 614 if (inside_process_scheduled_actions_) |
| 610 return; | 615 return; |
| 611 | |
| 612 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); | 616 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); |
| 613 | 617 |
| 614 SchedulerStateMachine::Action action; | 618 SchedulerStateMachine::Action action; |
| 615 do { | 619 do { |
| 616 action = state_machine_.NextAction(); | 620 action = state_machine_.NextAction(); |
| 617 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 621 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
| 618 "SchedulerStateMachine", "state", AsValue()); | 622 "SchedulerStateMachine", "state", AsValue()); |
| 619 base::AutoReset<SchedulerStateMachine::Action> mark_inside_action( | 623 base::AutoReset<SchedulerStateMachine::Action> mark_inside_action( |
| 620 &inside_action_, action); | 624 &inside_action_, action); |
| 621 switch (action) { | 625 switch (action) { |
| 622 case SchedulerStateMachine::ACTION_NONE: | 626 case SchedulerStateMachine::ACTION_NONE: |
| 623 break; | 627 break; |
| 624 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: | 628 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: |
| 625 compositor_timing_history_->WillBeginMainFrame( | 629 compositor_timing_history_->WillBeginMainFrame( |
| 626 begin_main_frame_args_.on_critical_path, | 630 begin_main_frame_args_.on_critical_path, |
| 627 begin_main_frame_args_.frame_time); | 631 begin_main_frame_args_.frame_time); |
| 628 state_machine_.WillSendBeginMainFrame(); | 632 state_machine_.WillSendBeginMainFrame(); |
| 629 // TODO(brianderson): Pass begin_main_frame_args_ directly to client. | 633 // TODO(brianderson): Pass begin_main_frame_args_ directly to client. |
| 634 begin_main_frame_args_.ready_to_activate_time = |
| 635 std::move(ready_to_activate_time_); |
| 636 ready_to_activate_time_.clear(); |
| 630 client_->ScheduledActionSendBeginMainFrame(begin_main_frame_args_); | 637 client_->ScheduledActionSendBeginMainFrame(begin_main_frame_args_); |
| 631 break; | 638 break; |
| 632 case SchedulerStateMachine::ACTION_COMMIT: { | 639 case SchedulerStateMachine::ACTION_COMMIT: { |
| 633 bool commit_has_no_updates = false; | 640 bool commit_has_no_updates = false; |
| 634 state_machine_.WillCommit(commit_has_no_updates); | 641 state_machine_.WillCommit(commit_has_no_updates); |
| 635 client_->ScheduledActionCommit(); | 642 client_->ScheduledActionCommit(); |
| 636 break; | 643 break; |
| 637 } | 644 } |
| 638 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: | 645 case SchedulerStateMachine::ACTION_ACTIVATE_SYNC_TREE: |
| 639 compositor_timing_history_->WillActivate(); | 646 compositor_timing_history_->WillActivate(); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 } | 806 } |
| 800 | 807 |
| 801 BeginFrameAck Scheduler::CurrentBeginFrameAckForActiveTree() const { | 808 BeginFrameAck Scheduler::CurrentBeginFrameAckForActiveTree() const { |
| 802 return BeginFrameAck( | 809 return BeginFrameAck( |
| 803 begin_main_frame_args_.source_id, begin_main_frame_args_.sequence_number, | 810 begin_main_frame_args_.source_id, begin_main_frame_args_.sequence_number, |
| 804 state_machine_.last_begin_frame_sequence_number_active_tree_was_fresh(), | 811 state_machine_.last_begin_frame_sequence_number_active_tree_was_fresh(), |
| 805 true); | 812 true); |
| 806 } | 813 } |
| 807 | 814 |
| 808 } // namespace cc | 815 } // namespace cc |
| OLD | NEW |