| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 base::TimeDelta prepare_tiles_duration_; | 206 base::TimeDelta prepare_tiles_duration_; |
| 207 base::TimeDelta activate_duration_; | 207 base::TimeDelta activate_duration_; |
| 208 base::TimeDelta draw_duration_; | 208 base::TimeDelta draw_duration_; |
| 209 | 209 |
| 210 private: | 210 private: |
| 211 DISALLOW_COPY_AND_ASSIGN(FakeCompositorTimingHistory); | 211 DISALLOW_COPY_AND_ASSIGN(FakeCompositorTimingHistory); |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 class TestScheduler : public Scheduler { | 214 class TestScheduler : public Scheduler { |
| 215 public: | 215 public: |
| 216 static scoped_ptr<TestScheduler> Create( | 216 TestScheduler(base::SimpleTestTickClock* now_src, |
| 217 base::SimpleTestTickClock* now_src, | 217 SchedulerClient* client, |
| 218 SchedulerClient* client, | 218 const SchedulerSettings& scheduler_settings, |
| 219 const SchedulerSettings& scheduler_settings, | 219 int layer_tree_host_id, |
| 220 int layer_tree_host_id, | 220 OrderedSimpleTaskRunner* task_runner, |
| 221 OrderedSimpleTaskRunner* task_runner, | 221 BeginFrameSource* begin_frame_source, |
| 222 BeginFrameSource* external_frame_source, | 222 scoped_ptr<CompositorTimingHistory> compositor_timing_history); |
| 223 scoped_ptr<CompositorTimingHistory> compositor_timing_history); | |
| 224 | 223 |
| 225 // Extra test helper functionality | 224 // Extra test helper functionality |
| 226 bool IsBeginRetroFrameArgsEmpty() const { | 225 bool IsBeginRetroFrameArgsEmpty() const { |
| 227 return begin_retro_frame_args_.empty(); | 226 return begin_retro_frame_args_.empty(); |
| 228 } | 227 } |
| 229 | 228 |
| 230 bool SwapThrottled() const { return state_machine_.SwapThrottled(); } | 229 bool SwapThrottled() const { return state_machine_.SwapThrottled(); } |
| 231 | 230 |
| 232 bool NeedsBeginMainFrame() const { | 231 bool NeedsBeginMainFrame() const { |
| 233 return state_machine_.needs_begin_main_frame(); | 232 return state_machine_.needs_begin_main_frame(); |
| 234 } | 233 } |
| 235 | 234 |
| 236 BeginFrameSource& frame_source() { return *frame_source_; } | 235 BeginFrameSource& frame_source() { return *begin_frame_source_; } |
| 237 bool FrameProductionThrottled() { | 236 bool FrameProductionThrottled() { |
| 238 return settings_.throttle_frame_production; | 237 return settings_.throttle_frame_production; |
| 239 } | 238 } |
| 240 | 239 |
| 241 bool MainThreadMissedLastDeadline() const { | 240 bool MainThreadMissedLastDeadline() const { |
| 242 return state_machine_.main_thread_missed_last_deadline(); | 241 return state_machine_.main_thread_missed_last_deadline(); |
| 243 } | 242 } |
| 244 | 243 |
| 245 bool begin_frames_expected() const { return observing_frame_source_; } | 244 bool begin_frames_expected() const { return observing_begin_frame_source_; } |
| 246 | 245 |
| 247 ~TestScheduler() override; | 246 ~TestScheduler() override; |
| 248 | 247 |
| 249 base::TimeDelta BeginImplFrameInterval() { | 248 base::TimeDelta BeginImplFrameInterval() { |
| 250 return begin_impl_frame_tracker_.Interval(); | 249 return begin_impl_frame_tracker_.Interval(); |
| 251 } | 250 } |
| 252 | 251 |
| 253 // Note: This setting will be overriden on the next BeginFrame in the | 252 // Note: This setting will be overriden on the next BeginFrame in the |
| 254 // scheduler. To control the value it gets on the next BeginFrame | 253 // scheduler. To control the value it gets on the next BeginFrame |
| 255 // Pass in a fake CompositorTimingHistory that indicates BeginMainFrame | 254 // Pass in a fake CompositorTimingHistory that indicates BeginMainFrame |
| 256 // to Activation is fast. | 255 // to Activation is fast. |
| 257 void SetCriticalBeginMainFrameToActivateIsFast(bool is_fast) { | 256 void SetCriticalBeginMainFrameToActivateIsFast(bool is_fast) { |
| 258 state_machine_.SetCriticalBeginMainFrameToActivateIsFast(is_fast); | 257 state_machine_.SetCriticalBeginMainFrameToActivateIsFast(is_fast); |
| 259 } | 258 } |
| 260 | 259 |
| 261 protected: | 260 protected: |
| 262 // Overridden from Scheduler. | 261 // Overridden from Scheduler. |
| 263 base::TimeTicks Now() const override; | 262 base::TimeTicks Now() const override; |
| 264 | 263 |
| 265 private: | 264 private: |
| 266 TestScheduler( | |
| 267 base::SimpleTestTickClock* now_src, | |
| 268 SchedulerClient* client, | |
| 269 const SchedulerSettings& scheduler_settings, | |
| 270 int layer_tree_host_id, | |
| 271 OrderedSimpleTaskRunner* task_runner, | |
| 272 BeginFrameSource* external_frame_source, | |
| 273 scoped_ptr<TestSyntheticBeginFrameSource> synthetic_frame_source, | |
| 274 scoped_ptr<TestBackToBackBeginFrameSource> unthrottled_frame_source, | |
| 275 scoped_ptr<CompositorTimingHistory> compositor_timing_history); | |
| 276 | |
| 277 base::SimpleTestTickClock* now_src_; | 265 base::SimpleTestTickClock* now_src_; |
| 278 | 266 |
| 279 DISALLOW_COPY_AND_ASSIGN(TestScheduler); | 267 DISALLOW_COPY_AND_ASSIGN(TestScheduler); |
| 280 }; | 268 }; |
| 281 | 269 |
| 282 } // namespace cc | 270 } // namespace cc |
| 283 | 271 |
| 284 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ | 272 #endif // CC_TEST_SCHEDULER_TEST_COMMON_H_ |
| OLD | NEW |