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" |
| 11 #include "base/memory/ptr_util.h" |
11 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
13 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
14 #include "base/trace_event/trace_event_argument.h" | 15 #include "base/trace_event/trace_event_argument.h" |
15 #include "cc/debug/devtools_instrumentation.h" | 16 #include "cc/debug/devtools_instrumentation.h" |
16 #include "cc/debug/traced_value.h" | 17 #include "cc/debug/traced_value.h" |
17 #include "cc/scheduler/compositor_timing_history.h" | 18 #include "cc/scheduler/compositor_timing_history.h" |
18 #include "cc/scheduler/delay_based_time_source.h" | 19 #include "cc/scheduler/delay_based_time_source.h" |
19 | 20 |
20 namespace cc { | 21 namespace cc { |
21 | 22 |
22 namespace { | 23 namespace { |
23 // This is a fudge factor we subtract from the deadline to account | 24 // This is a fudge factor we subtract from the deadline to account |
24 // for message latency and kernel scheduling variability. | 25 // for message latency and kernel scheduling variability. |
25 const base::TimeDelta kDeadlineFudgeFactor = | 26 const base::TimeDelta kDeadlineFudgeFactor = |
26 base::TimeDelta::FromMicroseconds(1000); | 27 base::TimeDelta::FromMicroseconds(1000); |
27 } | 28 } |
28 | 29 |
29 scoped_ptr<Scheduler> Scheduler::Create( | 30 std::unique_ptr<Scheduler> Scheduler::Create( |
30 SchedulerClient* client, | 31 SchedulerClient* client, |
31 const SchedulerSettings& settings, | 32 const SchedulerSettings& settings, |
32 int layer_tree_host_id, | 33 int layer_tree_host_id, |
33 base::SingleThreadTaskRunner* task_runner, | 34 base::SingleThreadTaskRunner* task_runner, |
34 BeginFrameSource* begin_frame_source, | 35 BeginFrameSource* begin_frame_source, |
35 scoped_ptr<CompositorTimingHistory> compositor_timing_history) { | 36 std::unique_ptr<CompositorTimingHistory> compositor_timing_history) { |
36 return make_scoped_ptr(new Scheduler(client, settings, layer_tree_host_id, | 37 return base::WrapUnique(new Scheduler(client, settings, layer_tree_host_id, |
37 task_runner, begin_frame_source, | 38 task_runner, begin_frame_source, |
38 std::move(compositor_timing_history))); | 39 std::move(compositor_timing_history))); |
39 } | 40 } |
40 | 41 |
41 Scheduler::Scheduler( | 42 Scheduler::Scheduler( |
42 SchedulerClient* client, | 43 SchedulerClient* client, |
43 const SchedulerSettings& settings, | 44 const SchedulerSettings& settings, |
44 int layer_tree_host_id, | 45 int layer_tree_host_id, |
45 base::SingleThreadTaskRunner* task_runner, | 46 base::SingleThreadTaskRunner* task_runner, |
46 BeginFrameSource* begin_frame_source, | 47 BeginFrameSource* begin_frame_source, |
47 scoped_ptr<CompositorTimingHistory> compositor_timing_history) | 48 std::unique_ptr<CompositorTimingHistory> compositor_timing_history) |
48 : settings_(settings), | 49 : settings_(settings), |
49 client_(client), | 50 client_(client), |
50 layer_tree_host_id_(layer_tree_host_id), | 51 layer_tree_host_id_(layer_tree_host_id), |
51 task_runner_(task_runner), | 52 task_runner_(task_runner), |
52 begin_frame_source_(nullptr), | 53 begin_frame_source_(nullptr), |
53 observing_begin_frame_source_(false), | 54 observing_begin_frame_source_(false), |
54 compositor_timing_history_(std::move(compositor_timing_history)), | 55 compositor_timing_history_(std::move(compositor_timing_history)), |
55 begin_impl_frame_deadline_mode_( | 56 begin_impl_frame_deadline_mode_( |
56 SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE), | 57 SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE), |
57 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), | 58 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 client_->ScheduledActionInvalidateOutputSurface(); | 735 client_->ScheduledActionInvalidateOutputSurface(); |
735 break; | 736 break; |
736 } | 737 } |
737 } | 738 } |
738 } while (action != SchedulerStateMachine::ACTION_NONE); | 739 } while (action != SchedulerStateMachine::ACTION_NONE); |
739 | 740 |
740 ScheduleBeginImplFrameDeadlineIfNeeded(); | 741 ScheduleBeginImplFrameDeadlineIfNeeded(); |
741 SetupNextBeginFrameIfNeeded(); | 742 SetupNextBeginFrameIfNeeded(); |
742 } | 743 } |
743 | 744 |
744 scoped_ptr<base::trace_event::ConvertableToTraceFormat> Scheduler::AsValue() | 745 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
745 const { | 746 Scheduler::AsValue() const { |
746 scoped_ptr<base::trace_event::TracedValue> state( | 747 std::unique_ptr<base::trace_event::TracedValue> state( |
747 new base::trace_event::TracedValue()); | 748 new base::trace_event::TracedValue()); |
748 AsValueInto(state.get()); | 749 AsValueInto(state.get()); |
749 return std::move(state); | 750 return std::move(state); |
750 } | 751 } |
751 | 752 |
752 void Scheduler::AsValueInto(base::trace_event::TracedValue* state) const { | 753 void Scheduler::AsValueInto(base::trace_event::TracedValue* state) const { |
753 base::TimeTicks now = Now(); | 754 base::TimeTicks now = Now(); |
754 | 755 |
755 state->BeginDictionary("state_machine"); | 756 state->BeginDictionary("state_machine"); |
756 state_machine_.AsValueInto(state); | 757 state_machine_.AsValueInto(state); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 } | 869 } |
869 | 870 |
870 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 871 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
871 return (state_machine_.begin_main_frame_state() == | 872 return (state_machine_.begin_main_frame_state() == |
872 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || | 873 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || |
873 state_machine_.begin_main_frame_state() == | 874 state_machine_.begin_main_frame_state() == |
874 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); | 875 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); |
875 } | 876 } |
876 | 877 |
877 } // namespace cc | 878 } // namespace cc |
OLD | NEW |