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 #ifndef CC_TEST_SCHEDULER_TEST_COMMON_H_ | 5 #ifndef CC_TEST_SCHEDULER_TEST_COMMON_H_ |
6 #define CC_TEST_SCHEDULER_TEST_COMMON_H_ | 6 #define CC_TEST_SCHEDULER_TEST_COMMON_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "cc/scheduler/delay_based_time_source.h" | 13 #include "cc/scheduler/delay_based_time_source.h" |
14 #include "cc/scheduler/scheduler.h" | 14 #include "cc/scheduler/scheduler.h" |
15 #include "cc/test/ordered_simple_task_runner.h" | 15 #include "cc/test/ordered_simple_task_runner.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 namespace cc { | 18 namespace cc { |
19 | 19 |
| 20 class RenderingStatsInstrumentation; |
| 21 |
20 class FakeTimeSourceClient : public TimeSourceClient { | 22 class FakeTimeSourceClient : public TimeSourceClient { |
21 public: | 23 public: |
22 FakeTimeSourceClient() : tick_called_(false) {} | 24 FakeTimeSourceClient() : tick_called_(false) {} |
23 void Reset() { tick_called_ = false; } | 25 void Reset() { tick_called_ = false; } |
24 bool TickCalled() const { return tick_called_; } | 26 bool TickCalled() const { return tick_called_; } |
25 | 27 |
26 // TimeSourceClient implementation. | 28 // TimeSourceClient implementation. |
27 void OnTimerTick() override; | 29 void OnTimerTick() override; |
28 | 30 |
29 protected: | 31 protected: |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 }; | 158 }; |
157 | 159 |
158 class TestScheduler : public Scheduler { | 160 class TestScheduler : public Scheduler { |
159 public: | 161 public: |
160 static scoped_ptr<TestScheduler> Create( | 162 static scoped_ptr<TestScheduler> Create( |
161 base::SimpleTestTickClock* now_src, | 163 base::SimpleTestTickClock* now_src, |
162 SchedulerClient* client, | 164 SchedulerClient* client, |
163 const SchedulerSettings& scheduler_settings, | 165 const SchedulerSettings& scheduler_settings, |
164 int layer_tree_host_id, | 166 int layer_tree_host_id, |
165 const scoped_refptr<OrderedSimpleTaskRunner>& task_runner, | 167 const scoped_refptr<OrderedSimpleTaskRunner>& task_runner, |
166 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | 168 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
| 169 RenderingStatsInstrumentation* rendering_stats_instrumentation) { |
167 TestSchedulerFrameSourcesConstructor frame_sources_constructor( | 170 TestSchedulerFrameSourcesConstructor frame_sources_constructor( |
168 task_runner.get(), now_src); | 171 task_runner.get(), now_src); |
169 return make_scoped_ptr(new TestScheduler( | 172 return make_scoped_ptr(new TestScheduler( |
170 now_src, | 173 now_src, client, scheduler_settings, layer_tree_host_id, task_runner, |
171 client, | 174 &frame_sources_constructor, external_begin_frame_source.Pass(), |
172 scheduler_settings, | 175 rendering_stats_instrumentation)); |
173 layer_tree_host_id, | |
174 task_runner, | |
175 &frame_sources_constructor, | |
176 external_begin_frame_source.Pass())); | |
177 } | 176 } |
178 | 177 |
179 // Extra test helper functionality | 178 // Extra test helper functionality |
180 bool IsBeginRetroFrameArgsEmpty() const { | 179 bool IsBeginRetroFrameArgsEmpty() const { |
181 return begin_retro_frame_args_.empty(); | 180 return begin_retro_frame_args_.empty(); |
182 } | 181 } |
183 | 182 |
184 bool CanStart() const { return state_machine_.CanStartForTesting(); } | 183 bool CanStart() const { return state_machine_.CanStartForTesting(); } |
185 | 184 |
186 BeginFrameSource& frame_source() { return *frame_source_; } | 185 BeginFrameSource& frame_source() { return *frame_source_; } |
187 bool FrameProductionThrottled() { return throttle_frame_production_; } | 186 bool FrameProductionThrottled() { return throttle_frame_production_; } |
188 | 187 |
189 ~TestScheduler() override; | 188 ~TestScheduler() override; |
190 | 189 |
191 void NotifyReadyToCommitThenActivateIfNeeded() { | |
192 NotifyReadyToCommit(); | |
193 if (settings_.impl_side_painting) { | |
194 NotifyReadyToActivate(); | |
195 } | |
196 } | |
197 | |
198 base::TimeDelta BeginImplFrameInterval() { | 190 base::TimeDelta BeginImplFrameInterval() { |
199 return begin_impl_frame_tracker_.Interval(); | 191 return begin_impl_frame_tracker_.Interval(); |
200 } | 192 } |
201 | 193 |
| 194 void SetDrawDurationEstimate(base::TimeDelta duration); |
| 195 void SetBeginMainFrameToCommitDurationEstimate(base::TimeDelta duration); |
| 196 void SetPrepareTilesToReadyToActivateDurationEstimate( |
| 197 base::TimeDelta duration); |
| 198 |
| 199 base::TimeDelta BeginMainFrameToCommitDurationEstimate() const override; |
| 200 base::TimeDelta PrepareTilesToReadyToActivateDurationEstimate() |
| 201 const override; |
| 202 base::TimeDelta ActivateDurationEstimate() const override; |
| 203 base::TimeDelta DrawDurationEstimate() const override; |
| 204 |
202 protected: | 205 protected: |
203 // Overridden from Scheduler. | 206 // Overridden from Scheduler. |
204 base::TimeTicks Now() const override; | 207 base::TimeTicks Now() const override; |
205 | 208 |
206 private: | 209 private: |
207 TestScheduler(base::SimpleTestTickClock* now_src, | 210 TestScheduler(base::SimpleTestTickClock* now_src, |
208 SchedulerClient* client, | 211 SchedulerClient* client, |
209 const SchedulerSettings& scheduler_settings, | 212 const SchedulerSettings& scheduler_settings, |
210 int layer_tree_host_id, | 213 int layer_tree_host_id, |
211 const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner, | 214 const scoped_refptr<OrderedSimpleTaskRunner>& test_task_runner, |
212 TestSchedulerFrameSourcesConstructor* frame_sources_constructor, | 215 TestSchedulerFrameSourcesConstructor* frame_sources_constructor, |
213 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 216 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
| 217 RenderingStatsInstrumentation* rendering_stats_instrumentation); |
214 | 218 |
215 // Not owned. | 219 // Not owned. |
216 base::SimpleTestTickClock* now_src_; | 220 base::SimpleTestTickClock* now_src_; |
| 221 |
| 222 base::TimeDelta draw_duration_; |
| 223 base::TimeDelta begin_main_frame_to_commit_duration_; |
| 224 base::TimeDelta commit_to_activate_duration_; |
217 }; | 225 }; |
218 | 226 |
219 } // namespace cc | 227 } // namespace cc |
220 | 228 |
221 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ | 229 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ |
OLD | NEW |