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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 new FakeExternalBeginFrameSource(client_.get())); | 264 new FakeExternalBeginFrameSource(client_.get())); |
265 } | 265 } |
266 | 266 |
267 scoped_ptr<FakeCompositorTimingHistory> fake_compositor_timing_history = | 267 scoped_ptr<FakeCompositorTimingHistory> fake_compositor_timing_history = |
268 FakeCompositorTimingHistory::Create(); | 268 FakeCompositorTimingHistory::Create(); |
269 fake_compositor_timing_history_ = fake_compositor_timing_history.get(); | 269 fake_compositor_timing_history_ = fake_compositor_timing_history.get(); |
270 | 270 |
271 scheduler_ = TestScheduler::Create( | 271 scheduler_ = TestScheduler::Create( |
272 now_src_.get(), client_.get(), scheduler_settings_, 0, | 272 now_src_.get(), client_.get(), scheduler_settings_, 0, |
273 task_runner_.get(), fake_external_begin_frame_source_.get(), | 273 task_runner_.get(), fake_external_begin_frame_source_.get(), |
274 fake_compositor_timing_history.Pass()); | 274 std::move(fake_compositor_timing_history)); |
275 DCHECK(scheduler_); | 275 DCHECK(scheduler_); |
276 client_->set_scheduler(scheduler_.get()); | 276 client_->set_scheduler(scheduler_.get()); |
277 | 277 |
278 // Use large estimates by default to avoid latency recovery in most tests. | 278 // Use large estimates by default to avoid latency recovery in most tests. |
279 base::TimeDelta slow_duration = base::TimeDelta::FromSeconds(1); | 279 base::TimeDelta slow_duration = base::TimeDelta::FromSeconds(1); |
280 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | 280 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); |
281 | 281 |
282 return scheduler_.get(); | 282 return scheduler_.get(); |
283 } | 283 } |
284 | 284 |
285 void CreateSchedulerAndInitSurface() { | 285 void CreateSchedulerAndInitSurface() { |
286 CreateScheduler(); | 286 CreateScheduler(); |
287 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); | 287 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); |
288 } | 288 } |
289 | 289 |
290 void SetUpScheduler(bool initSurface) { | 290 void SetUpScheduler(bool initSurface) { |
291 SetUpScheduler(make_scoped_ptr(new FakeSchedulerClient), initSurface); | 291 SetUpScheduler(make_scoped_ptr(new FakeSchedulerClient), initSurface); |
292 } | 292 } |
293 | 293 |
294 void SetUpScheduler(scoped_ptr<FakeSchedulerClient> client, | 294 void SetUpScheduler(scoped_ptr<FakeSchedulerClient> client, |
295 bool initSurface) { | 295 bool initSurface) { |
296 client_ = client.Pass(); | 296 client_ = std::move(client); |
297 if (initSurface) | 297 if (initSurface) |
298 CreateSchedulerAndInitSurface(); | 298 CreateSchedulerAndInitSurface(); |
299 else | 299 else |
300 CreateScheduler(); | 300 CreateScheduler(); |
301 } | 301 } |
302 | 302 |
303 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } | 303 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } |
304 base::SimpleTestTickClock* now_src() { return now_src_.get(); } | 304 base::SimpleTestTickClock* now_src() { return now_src_.get(); } |
305 | 305 |
306 // As this function contains EXPECT macros, to allow debugging it should be | 306 // As this function contains EXPECT macros, to allow debugging it should be |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 client_->ActionIndex("ScheduledActionPrepareTiles")); | 1221 client_->ActionIndex("ScheduledActionPrepareTiles")); |
1222 EXPECT_FALSE(scheduler_->RedrawPending()); | 1222 EXPECT_FALSE(scheduler_->RedrawPending()); |
1223 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 1223 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
1224 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1224 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
1225 } | 1225 } |
1226 | 1226 |
1227 TEST_F(SchedulerTest, PrepareTilesFunnelResetOnVisibilityChange) { | 1227 TEST_F(SchedulerTest, PrepareTilesFunnelResetOnVisibilityChange) { |
1228 scoped_ptr<SchedulerClientNeedsPrepareTilesInDraw> client = | 1228 scoped_ptr<SchedulerClientNeedsPrepareTilesInDraw> client = |
1229 make_scoped_ptr(new SchedulerClientNeedsPrepareTilesInDraw); | 1229 make_scoped_ptr(new SchedulerClientNeedsPrepareTilesInDraw); |
1230 scheduler_settings_.use_external_begin_frame_source = true; | 1230 scheduler_settings_.use_external_begin_frame_source = true; |
1231 SetUpScheduler(client.Pass(), true); | 1231 SetUpScheduler(std::move(client), true); |
1232 | 1232 |
1233 // Simulate a few visibility changes and associated PrepareTiles. | 1233 // Simulate a few visibility changes and associated PrepareTiles. |
1234 for (int i = 0; i < 10; i++) { | 1234 for (int i = 0; i < 10; i++) { |
1235 scheduler_->SetVisible(false); | 1235 scheduler_->SetVisible(false); |
1236 scheduler_->WillPrepareTiles(); | 1236 scheduler_->WillPrepareTiles(); |
1237 scheduler_->DidPrepareTiles(); | 1237 scheduler_->DidPrepareTiles(); |
1238 | 1238 |
1239 scheduler_->SetVisible(true); | 1239 scheduler_->SetVisible(true); |
1240 scheduler_->WillPrepareTiles(); | 1240 scheduler_->WillPrepareTiles(); |
1241 scheduler_->DidPrepareTiles(); | 1241 scheduler_->DidPrepareTiles(); |
(...skipping 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3324 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 3324 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
3325 } | 3325 } |
3326 }; | 3326 }; |
3327 | 3327 |
3328 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) { | 3328 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) { |
3329 scheduler_settings_.using_synchronous_renderer_compositor = true; | 3329 scheduler_settings_.using_synchronous_renderer_compositor = true; |
3330 scheduler_settings_.use_external_begin_frame_source = true; | 3330 scheduler_settings_.use_external_begin_frame_source = true; |
3331 | 3331 |
3332 scoped_ptr<FakeSchedulerClient> client = | 3332 scoped_ptr<FakeSchedulerClient> client = |
3333 make_scoped_ptr(new SchedulerClientSetNeedsPrepareTilesOnDraw); | 3333 make_scoped_ptr(new SchedulerClientSetNeedsPrepareTilesOnDraw); |
3334 SetUpScheduler(client.Pass(), true); | 3334 SetUpScheduler(std::move(client), true); |
3335 | 3335 |
3336 scheduler_->SetNeedsRedraw(); | 3336 scheduler_->SetNeedsRedraw(); |
3337 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 3337 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
3338 client_->Reset(); | 3338 client_->Reset(); |
3339 | 3339 |
3340 // Next vsync. | 3340 // Next vsync. |
3341 EXPECT_SCOPED(AdvanceFrame()); | 3341 EXPECT_SCOPED(AdvanceFrame()); |
3342 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 3342 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
3343 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); | 3343 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); |
3344 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 2, 3); | 3344 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client_, 2, 3); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3508 | 3508 |
3509 client_->Reset(); | 3509 client_->Reset(); |
3510 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); | 3510 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); |
3511 EXPECT_SCOPED(AdvanceFrame()); | 3511 EXPECT_SCOPED(AdvanceFrame()); |
3512 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); | 3512 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); |
3513 EXPECT_FALSE(client_->last_begin_main_frame_args().on_critical_path); | 3513 EXPECT_FALSE(client_->last_begin_main_frame_args().on_critical_path); |
3514 } | 3514 } |
3515 | 3515 |
3516 } // namespace | 3516 } // namespace |
3517 } // namespace cc | 3517 } // namespace cc |
OLD | NEW |