| 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 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/debug/traced_value.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "cc/debug/devtools_instrumentation.h" | 12 #include "cc/debug/devtools_instrumentation.h" |
| 12 #include "cc/debug/traced_value.h" | |
| 13 #include "cc/scheduler/delay_based_time_source.h" | 13 #include "cc/scheduler/delay_based_time_source.h" |
| 14 #include "ui/gfx/frame_time.h" | 14 #include "ui/gfx/frame_time.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 class SyntheticBeginFrameSource : public TimeSourceClient { | 18 class SyntheticBeginFrameSource : public TimeSourceClient { |
| 19 public: | 19 public: |
| 20 SyntheticBeginFrameSource(Scheduler* scheduler, | 20 SyntheticBeginFrameSource(Scheduler* scheduler, |
| 21 base::SingleThreadTaskRunner* task_runner) | 21 base::SingleThreadTaskRunner* task_runner) |
| 22 : scheduler_(scheduler) { | 22 : scheduler_(scheduler) { |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 | 623 |
| 624 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); | 624 base::AutoReset<bool> mark_inside(&inside_process_scheduled_actions_, true); |
| 625 | 625 |
| 626 SchedulerStateMachine::Action action; | 626 SchedulerStateMachine::Action action; |
| 627 do { | 627 do { |
| 628 state_machine_.CheckInvariants(); | 628 state_machine_.CheckInvariants(); |
| 629 action = state_machine_.NextAction(); | 629 action = state_machine_.NextAction(); |
| 630 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 630 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
| 631 "SchedulerStateMachine", | 631 "SchedulerStateMachine", |
| 632 "state", | 632 "state", |
| 633 TracedValue::FromValue(StateAsValue().release())); | 633 base::debug::TracedValue::FromValue(StateAsValue().release())); |
| 634 state_machine_.UpdateState(action); | 634 state_machine_.UpdateState(action); |
| 635 base::AutoReset<SchedulerStateMachine::Action> | 635 base::AutoReset<SchedulerStateMachine::Action> |
| 636 mark_inside_action(&inside_action_, action); | 636 mark_inside_action(&inside_action_, action); |
| 637 switch (action) { | 637 switch (action) { |
| 638 case SchedulerStateMachine::ACTION_NONE: | 638 case SchedulerStateMachine::ACTION_NONE: |
| 639 break; | 639 break; |
| 640 case SchedulerStateMachine::ACTION_ANIMATE: | 640 case SchedulerStateMachine::ACTION_ANIMATE: |
| 641 client_->ScheduledActionAnimate(); | 641 client_->ScheduledActionAnimate(); |
| 642 break; | 642 break; |
| 643 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: | 643 case SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 begin_impl_frame_args_.frame_time + | 735 begin_impl_frame_args_.frame_time + |
| 736 client_->BeginMainFrameToCommitDurationEstimate() + | 736 client_->BeginMainFrameToCommitDurationEstimate() + |
| 737 client_->CommitToActivateDurationEstimate(); | 737 client_->CommitToActivateDurationEstimate(); |
| 738 | 738 |
| 739 TRACE_EVENT2( | 739 TRACE_EVENT2( |
| 740 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), | 740 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"), |
| 741 "CanCommitAndActivateBeforeDeadline", | 741 "CanCommitAndActivateBeforeDeadline", |
| 742 "time_left_after_drawing_ms", | 742 "time_left_after_drawing_ms", |
| 743 (begin_impl_frame_args_.deadline - estimated_draw_time).InMillisecondsF(), | 743 (begin_impl_frame_args_.deadline - estimated_draw_time).InMillisecondsF(), |
| 744 "state", | 744 "state", |
| 745 TracedValue::FromValue(StateAsValue().release())); | 745 base::debug::TracedValue::FromValue(StateAsValue().release())); |
| 746 | 746 |
| 747 return estimated_draw_time < begin_impl_frame_args_.deadline; | 747 return estimated_draw_time < begin_impl_frame_args_.deadline; |
| 748 } | 748 } |
| 749 | 749 |
| 750 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 750 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 751 return (state_machine_.commit_state() == | 751 return (state_machine_.commit_state() == |
| 752 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 752 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || |
| 753 state_machine_.commit_state() == | 753 state_machine_.commit_state() == |
| 754 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); | 754 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); |
| 755 } | 755 } |
| 756 | 756 |
| 757 } // namespace cc | 757 } // namespace cc |
| OLD | NEW |