| 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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 states_.push_back(scheduler_->AsValue()); | 260 states_.push_back(scheduler_->AsValue()); |
| 261 } | 261 } |
| 262 void ScheduledActionBeginOutputSurfaceCreation() override { | 262 void ScheduledActionBeginOutputSurfaceCreation() override { |
| 263 actions_.push_back("ScheduledActionBeginOutputSurfaceCreation"); | 263 actions_.push_back("ScheduledActionBeginOutputSurfaceCreation"); |
| 264 states_.push_back(scheduler_->AsValue()); | 264 states_.push_back(scheduler_->AsValue()); |
| 265 } | 265 } |
| 266 void ScheduledActionPrepareTiles() override { | 266 void ScheduledActionPrepareTiles() override { |
| 267 actions_.push_back("ScheduledActionPrepareTiles"); | 267 actions_.push_back("ScheduledActionPrepareTiles"); |
| 268 states_.push_back(scheduler_->AsValue()); | 268 states_.push_back(scheduler_->AsValue()); |
| 269 } | 269 } |
| 270 void ScheduledActionInvalidateOutputSurface() override { |
| 271 actions_.push_back("ScheduledActionInvalidateOutputSurface"); |
| 272 states_.push_back(scheduler_->AsValue()); |
| 273 } |
| 270 void DidAnticipatedDrawTimeChange(base::TimeTicks) override { | 274 void DidAnticipatedDrawTimeChange(base::TimeTicks) override { |
| 271 if (log_anticipated_draw_time_change_) | 275 if (log_anticipated_draw_time_change_) |
| 272 actions_.push_back("DidAnticipatedDrawTimeChange"); | 276 actions_.push_back("DidAnticipatedDrawTimeChange"); |
| 273 } | 277 } |
| 274 base::TimeDelta DrawDurationEstimate() override { return base::TimeDelta(); } | 278 base::TimeDelta DrawDurationEstimate() override { return base::TimeDelta(); } |
| 275 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override { | 279 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override { |
| 276 return base::TimeDelta(); | 280 return base::TimeDelta(); |
| 277 } | 281 } |
| 278 base::TimeDelta CommitToActivateDurationEstimate() override { | 282 base::TimeDelta CommitToActivateDurationEstimate() override { |
| 279 return base::TimeDelta(); | 283 return base::TimeDelta(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 scheduler->NotifyBeginMainFrameStarted(); | 331 scheduler->NotifyBeginMainFrameStarted(); |
| 328 scheduler->NotifyReadyToCommit(); | 332 scheduler->NotifyReadyToCommit(); |
| 329 if (scheduler->settings().impl_side_painting) | 333 if (scheduler->settings().impl_side_painting) |
| 330 scheduler->NotifyReadyToActivate(); | 334 scheduler->NotifyReadyToActivate(); |
| 331 | 335 |
| 332 { | 336 { |
| 333 SCOPED_TRACE("Go through the motions to draw the commit"); | 337 SCOPED_TRACE("Go through the motions to draw the commit"); |
| 334 client->AdvanceFrame(); | 338 client->AdvanceFrame(); |
| 335 } | 339 } |
| 336 | 340 |
| 337 // Run the posted deadline task. | |
| 338 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 341 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 339 client->task_runner().RunTasksWhile(client->ImplFrameDeadlinePending(true)); | 342 if (scheduler->settings().using_synchronous_renderer_compositor) { |
| 343 // Trigger deadline synchronously. |
| 344 scheduler->OutputSurfaceDidRequestDraw(); |
| 345 } else { |
| 346 // Run the posted deadline task. |
| 347 client->task_runner().RunTasksWhile(client->ImplFrameDeadlinePending(true)); |
| 348 } |
| 340 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 349 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 341 | 350 |
| 342 { | 351 { |
| 343 SCOPED_TRACE( | 352 SCOPED_TRACE( |
| 344 "We need another BeginImplFrame so Scheduler calls " | 353 "We need another BeginImplFrame so Scheduler calls " |
| 345 "SetNeedsBeginFrame(false)."); | 354 "SetNeedsBeginFrame(false)."); |
| 346 client->AdvanceFrame(); | 355 client->AdvanceFrame(); |
| 347 } | 356 } |
| 348 | 357 |
| 349 // Run the posted deadline task. | 358 // Run the posted deadline task. |
| (...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2277 // Disable auto-advancing of now_src | 2286 // Disable auto-advancing of now_src |
| 2278 client.task_runner().SetAutoAdvanceNowToPendingTasks(false); | 2287 client.task_runner().SetAutoAdvanceNowToPendingTasks(false); |
| 2279 | 2288 |
| 2280 // Deadline task is pending | 2289 // Deadline task is pending |
| 2281 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 2290 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 2282 client.task_runner().RunPendingTasks(); | 2291 client.task_runner().RunPendingTasks(); |
| 2283 // Deadline task runs immediately | 2292 // Deadline task runs immediately |
| 2284 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 2293 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 2285 } | 2294 } |
| 2286 | 2295 |
| 2296 TEST(SchedulerTest, UsingSynchronousCompositor) { |
| 2297 FakeSchedulerClient client; |
| 2298 SchedulerSettings settings; |
| 2299 settings.using_synchronous_renderer_compositor = true; |
| 2300 settings.use_external_begin_frame_source = true; |
| 2301 TestScheduler* scheduler = client.CreateScheduler(settings); |
| 2302 |
| 2303 scheduler->SetCanStart(); |
| 2304 scheduler->SetVisible(true); |
| 2305 scheduler->SetCanDraw(true); |
| 2306 |
| 2307 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); |
| 2308 client.Reset(); |
| 2309 |
| 2310 // Static page. Scrolling initiated by webview. OnDraw comes in time. |
| 2311 scheduler->SetNeedsRedraw(); |
| 2312 // Ask for BeginFrames. |
| 2313 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); |
| 2314 client.Reset(); |
| 2315 |
| 2316 client.SendNextBeginFrame(); |
| 2317 EXPECT_ACTION("WillBeginImplFrame", client, 0, 3); |
| 2318 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 3); |
| 2319 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client, 2, 3); |
| 2320 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 2321 client.Reset(); |
| 2322 |
| 2323 // Android onDraw. |
| 2324 scheduler->SetNeedsRedraw(); |
| 2325 scheduler->OutputSurfaceDidRequestDraw(); |
| 2326 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client); |
| 2327 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 2328 client.Reset(); |
| 2329 |
| 2330 // It takes one more frame to call SetNeedsBeginFrames(false). |
| 2331 client.AdvanceFrame(); |
| 2332 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 2333 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 2334 client.Reset(); |
| 2335 |
| 2336 client.task_runner().RunTasksWhile(client.ImplFrameDeadlinePending(true)); |
| 2337 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client); |
| 2338 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 2339 client.Reset(); |
| 2340 |
| 2341 // Static page. Scrolling initiated by webview. OnDraw does not come in time. |
| 2342 scheduler->SetNeedsRedraw(); |
| 2343 // Ask for BeginFrames. |
| 2344 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client); |
| 2345 client.Reset(); |
| 2346 |
| 2347 client.SendNextBeginFrame(); |
| 2348 EXPECT_ACTION("WillBeginImplFrame", client, 0, 3); |
| 2349 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 3); |
| 2350 EXPECT_ACTION("ScheduledActionInvalidateOutputSurface", client, 2, 3); |
| 2351 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 2352 client.Reset(); |
| 2353 |
| 2354 // No onDraw => no draw action by the scheduler. |
| 2355 client.task_runner().RunUntilTime(client.now_src()->Now()); |
| 2356 EXPECT_NO_ACTION(client); |
| 2357 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 2358 } |
| 2359 |
| 2287 } // namespace | 2360 } // namespace |
| 2288 } // namespace cc | 2361 } // namespace cc |
| OLD | NEW |