OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/test/scheduler_test_common.h" | 5 #include "cc/test/scheduler_test_common.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "cc/debug/rendering_stats_instrumentation.h" |
10 | 11 |
11 namespace cc { | 12 namespace cc { |
12 | 13 |
13 void FakeTimeSourceClient::OnTimerTick() { | 14 void FakeTimeSourceClient::OnTimerTick() { |
14 tick_called_ = true; | 15 tick_called_ = true; |
15 } | 16 } |
16 | 17 |
17 base::TimeTicks FakeDelayBasedTimeSource::Now() const { return now_; } | 18 base::TimeTicks FakeDelayBasedTimeSource::Now() const { return now_; } |
18 | 19 |
19 TestDelayBasedTimeSource::TestDelayBasedTimeSource( | 20 TestDelayBasedTimeSource::TestDelayBasedTimeSource( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 59 } |
59 | 60 |
60 TestSyntheticBeginFrameSource::TestSyntheticBeginFrameSource( | 61 TestSyntheticBeginFrameSource::TestSyntheticBeginFrameSource( |
61 scoped_ptr<DelayBasedTimeSource> time_source) | 62 scoped_ptr<DelayBasedTimeSource> time_source) |
62 : SyntheticBeginFrameSource(time_source.Pass()) { | 63 : SyntheticBeginFrameSource(time_source.Pass()) { |
63 } | 64 } |
64 | 65 |
65 TestSyntheticBeginFrameSource::~TestSyntheticBeginFrameSource() { | 66 TestSyntheticBeginFrameSource::~TestSyntheticBeginFrameSource() { |
66 } | 67 } |
67 | 68 |
| 69 scoped_ptr<FakeCompositorTimingHistory> FakeCompositorTimingHistory::Create() { |
| 70 scoped_ptr<RenderingStatsInstrumentation> rendering_stats_instrumentation = |
| 71 RenderingStatsInstrumentation::Create(); |
| 72 return make_scoped_ptr( |
| 73 new FakeCompositorTimingHistory(rendering_stats_instrumentation.Pass())); |
| 74 } |
| 75 |
| 76 FakeCompositorTimingHistory::FakeCompositorTimingHistory( |
| 77 scoped_ptr<RenderingStatsInstrumentation> rendering_stats_instrumentation) |
| 78 : CompositorTimingHistory(rendering_stats_instrumentation.get()), |
| 79 rendering_stats_instrumentation_owned_( |
| 80 rendering_stats_instrumentation.Pass()) { |
| 81 } |
| 82 |
| 83 FakeCompositorTimingHistory::~FakeCompositorTimingHistory() { |
| 84 } |
| 85 |
| 86 void FakeCompositorTimingHistory::SetDrawDurationEstimate( |
| 87 base::TimeDelta duration) { |
| 88 draw_duration_ = duration; |
| 89 } |
| 90 |
| 91 void FakeCompositorTimingHistory::SetBeginMainFrameToCommitDurationEstimate( |
| 92 base::TimeDelta duration) { |
| 93 begin_main_frame_to_commit_duration_ = duration; |
| 94 } |
| 95 |
| 96 void FakeCompositorTimingHistory::SetCommitToActivateDurationEstimate( |
| 97 base::TimeDelta duration) { |
| 98 commit_to_activate_duration_ = duration; |
| 99 } |
| 100 |
| 101 base::TimeDelta FakeCompositorTimingHistory::DrawDurationEstimate() const { |
| 102 return draw_duration_; |
| 103 } |
| 104 |
| 105 base::TimeDelta |
| 106 FakeCompositorTimingHistory::BeginMainFrameToCommitDurationEstimate() const { |
| 107 return begin_main_frame_to_commit_duration_; |
| 108 } |
| 109 |
| 110 base::TimeDelta FakeCompositorTimingHistory::CommitToActivateDurationEstimate() |
| 111 const { |
| 112 return commit_to_activate_duration_; |
| 113 } |
| 114 |
68 scoped_ptr<TestScheduler> TestScheduler::Create( | 115 scoped_ptr<TestScheduler> TestScheduler::Create( |
69 base::SimpleTestTickClock* now_src, | 116 base::SimpleTestTickClock* now_src, |
70 SchedulerClient* client, | 117 SchedulerClient* client, |
71 const SchedulerSettings& settings, | 118 const SchedulerSettings& settings, |
72 int layer_tree_host_id, | 119 int layer_tree_host_id, |
73 OrderedSimpleTaskRunner* task_runner, | 120 OrderedSimpleTaskRunner* task_runner, |
74 BeginFrameSource* external_frame_source) { | 121 BeginFrameSource* external_frame_source, |
| 122 scoped_ptr<CompositorTimingHistory> compositor_timing_history) { |
75 scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source; | 123 scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source; |
76 if (!settings.use_external_begin_frame_source) { | 124 if (!settings.use_external_begin_frame_source) { |
77 synthetic_frame_source = TestSyntheticBeginFrameSource::Create( | 125 synthetic_frame_source = TestSyntheticBeginFrameSource::Create( |
78 now_src, task_runner, BeginFrameArgs::DefaultInterval()); | 126 now_src, task_runner, BeginFrameArgs::DefaultInterval()); |
79 } | 127 } |
80 scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source = | 128 scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source = |
81 TestBackToBackBeginFrameSource::Create(now_src, task_runner); | 129 TestBackToBackBeginFrameSource::Create(now_src, task_runner); |
82 return make_scoped_ptr(new TestScheduler( | 130 return make_scoped_ptr(new TestScheduler( |
83 now_src, client, settings, layer_tree_host_id, task_runner, | 131 now_src, client, settings, layer_tree_host_id, task_runner, |
84 external_frame_source, synthetic_frame_source.Pass(), | 132 external_frame_source, synthetic_frame_source.Pass(), |
85 unthrottled_frame_source.Pass())); | 133 unthrottled_frame_source.Pass(), compositor_timing_history.Pass())); |
86 } | 134 } |
87 | 135 |
88 TestScheduler::TestScheduler( | 136 TestScheduler::TestScheduler( |
89 base::SimpleTestTickClock* now_src, | 137 base::SimpleTestTickClock* now_src, |
90 SchedulerClient* client, | 138 SchedulerClient* client, |
91 const SchedulerSettings& scheduler_settings, | 139 const SchedulerSettings& scheduler_settings, |
92 int layer_tree_host_id, | 140 int layer_tree_host_id, |
93 OrderedSimpleTaskRunner* task_runner, | 141 OrderedSimpleTaskRunner* task_runner, |
94 BeginFrameSource* external_frame_source, | 142 BeginFrameSource* external_frame_source, |
95 scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source, | 143 scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source, |
96 scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source) | 144 scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source, |
| 145 scoped_ptr<CompositorTimingHistory> compositor_timing_history) |
97 : Scheduler(client, | 146 : Scheduler(client, |
98 scheduler_settings, | 147 scheduler_settings, |
99 layer_tree_host_id, | 148 layer_tree_host_id, |
100 task_runner, | 149 task_runner, |
101 external_frame_source, | 150 external_frame_source, |
102 synthetic_frame_source.Pass(), | 151 synthetic_frame_source.Pass(), |
103 unthrottled_frame_source.Pass()), | 152 unthrottled_frame_source.Pass(), |
| 153 compositor_timing_history.Pass()), |
104 now_src_(now_src) { | 154 now_src_(now_src) { |
105 } | 155 } |
106 | 156 |
107 base::TimeTicks TestScheduler::Now() const { | 157 base::TimeTicks TestScheduler::Now() const { |
108 return now_src_->NowTicks(); | 158 return now_src_->NowTicks(); |
109 } | 159 } |
110 | 160 |
111 TestScheduler::~TestScheduler() { | 161 TestScheduler::~TestScheduler() { |
112 } | 162 } |
113 | 163 |
114 } // namespace cc | 164 } // namespace cc |
OLD | NEW |