| 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 #include "cc/scheduler/scheduler.h" | 4 #include "cc/scheduler/scheduler.h" |
| 5 | 5 |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); | 258 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| 259 client.Reset(); | 259 client.Reset(); |
| 260 | 260 |
| 261 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 261 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 262 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 262 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| 263 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); | 263 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| 264 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 264 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 265 EXPECT_TRUE(client.needs_begin_impl_frame()); | 265 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 266 client.Reset(); | 266 client.Reset(); |
| 267 | 267 |
| 268 // If we don't swap on the deadline, we need to request another | 268 // If we don't swap on the deadline, we wait for the next BeginFrame. |
| 269 // BeginImplFrame. | |
| 270 client.task_runner().RunPendingTasks(); // Run posted deadline. | 269 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 271 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); | 270 EXPECT_EQ(0, client.num_actions_()); |
| 272 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 271 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 273 EXPECT_TRUE(client.needs_begin_impl_frame()); | 272 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 274 client.Reset(); | 273 client.Reset(); |
| 275 | 274 |
| 276 // NotifyReadyToCommit should trigger the commit. | 275 // NotifyReadyToCommit should trigger the commit. |
| 277 scheduler->NotifyBeginMainFrameStarted(); | 276 scheduler->NotifyBeginMainFrameStarted(); |
| 278 scheduler->NotifyReadyToCommit(); | 277 scheduler->NotifyReadyToCommit(); |
| 279 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 278 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
| 280 EXPECT_TRUE(client.needs_begin_impl_frame()); | 279 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 281 client.Reset(); | 280 client.Reset(); |
| 282 | 281 |
| 283 // BeginImplFrame should prepare the draw. | 282 // BeginImplFrame should prepare the draw. |
| 284 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 283 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 285 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 284 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 286 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 285 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 287 EXPECT_TRUE(client.needs_begin_impl_frame()); | 286 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 288 client.Reset(); | 287 client.Reset(); |
| 289 | 288 |
| 290 // BeginImplFrame deadline should draw. | 289 // BeginImplFrame deadline should draw. |
| 291 client.task_runner().RunPendingTasks(); // Run posted deadline. | 290 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 292 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); | 291 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
| 293 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); | |
| 294 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 292 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 295 EXPECT_TRUE(client.needs_begin_impl_frame()); | 293 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 296 client.Reset(); | 294 client.Reset(); |
| 297 | 295 |
| 298 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) | 296 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) |
| 299 // to avoid excessive toggles. | 297 // to avoid excessive toggles. |
| 300 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 298 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 301 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 299 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 302 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 300 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 303 client.Reset(); | 301 client.Reset(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 EXPECT_EQ(client.num_actions_(), 0); | 336 EXPECT_EQ(client.num_actions_(), 0); |
| 339 client.Reset(); | 337 client.Reset(); |
| 340 | 338 |
| 341 // Finish the first commit. | 339 // Finish the first commit. |
| 342 scheduler->NotifyBeginMainFrameStarted(); | 340 scheduler->NotifyBeginMainFrameStarted(); |
| 343 scheduler->NotifyReadyToCommit(); | 341 scheduler->NotifyReadyToCommit(); |
| 344 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 342 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
| 345 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 343 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 346 client.Reset(); | 344 client.Reset(); |
| 347 client.task_runner().RunPendingTasks(); // Run posted deadline. | 345 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 348 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); | 346 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
| 349 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); | |
| 350 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 347 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 351 | 348 |
| 352 // Because we just swapped, the Scheduler should also request the next | 349 // Because we just swapped, the Scheduler should also request the next |
| 353 // BeginImplFrame from the OutputSurface. | 350 // BeginImplFrame from the OutputSurface. |
| 354 EXPECT_TRUE(client.needs_begin_impl_frame()); | 351 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 355 client.Reset(); | 352 client.Reset(); |
| 356 // Since another commit is needed, the next BeginImplFrame should initiate | 353 // Since another commit is needed, the next BeginImplFrame should initiate |
| 357 // the second commit. | 354 // the second commit. |
| 358 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 355 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 359 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 356 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| 360 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); | 357 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| 361 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 358 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 362 client.Reset(); | 359 client.Reset(); |
| 363 | 360 |
| 364 // Finishing the commit before the deadline should post a new deadline task | 361 // Finishing the commit before the deadline should post a new deadline task |
| 365 // to trigger the deadline early. | 362 // to trigger the deadline early. |
| 366 scheduler->NotifyBeginMainFrameStarted(); | 363 scheduler->NotifyBeginMainFrameStarted(); |
| 367 scheduler->NotifyReadyToCommit(); | 364 scheduler->NotifyReadyToCommit(); |
| 368 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 365 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
| 369 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 366 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 370 client.Reset(); | 367 client.Reset(); |
| 371 client.task_runner().RunPendingTasks(); // Run posted deadline. | 368 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 372 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); | 369 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
| 373 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); | |
| 374 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 370 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 375 EXPECT_TRUE(client.needs_begin_impl_frame()); | 371 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 376 client.Reset(); | 372 client.Reset(); |
| 377 | 373 |
| 378 // On the next BeginImplFrame, verify we go back to a quiescent state and | 374 // On the next BeginImplFrame, verify we go back to a quiescent state and |
| 379 // no longer request BeginImplFrames. | 375 // no longer request BeginImplFrames. |
| 380 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 376 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 381 client.task_runner().RunPendingTasks(); // Run posted deadline. | 377 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 382 EXPECT_FALSE(client.needs_begin_impl_frame()); | 378 EXPECT_FALSE(client.needs_begin_impl_frame()); |
| 383 client.Reset(); | 379 client.Reset(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 398 EXPECT_TRUE(scheduler->RedrawPending()); | 394 EXPECT_TRUE(scheduler->RedrawPending()); |
| 399 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); | 395 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| 400 EXPECT_TRUE(client.needs_begin_impl_frame()); | 396 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 401 | 397 |
| 402 client.Reset(); | 398 client.Reset(); |
| 403 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 399 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 404 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 400 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 405 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 401 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 406 client.Reset(); | 402 client.Reset(); |
| 407 client.task_runner().RunPendingTasks(); // Run posted deadline. | 403 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 408 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); | 404 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
| 409 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); | |
| 410 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 405 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 411 EXPECT_FALSE(scheduler->RedrawPending()); | 406 EXPECT_FALSE(scheduler->RedrawPending()); |
| 412 EXPECT_TRUE(client.needs_begin_impl_frame()); | 407 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 413 | 408 |
| 414 client.Reset(); | 409 client.Reset(); |
| 415 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 410 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 416 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 411 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 417 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 412 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 418 client.Reset(); | 413 client.Reset(); |
| 419 client.task_runner().RunPendingTasks(); // Run posted deadline. | 414 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 434 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); | 429 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| 435 EXPECT_TRUE(client.needs_begin_impl_frame()); | 430 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 436 | 431 |
| 437 // No draw happens since the textures are acquired by the main thread. | 432 // No draw happens since the textures are acquired by the main thread. |
| 438 client.Reset(); | 433 client.Reset(); |
| 439 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 434 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 440 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 435 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 441 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 436 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 442 client.Reset(); | 437 client.Reset(); |
| 443 client.task_runner().RunPendingTasks(); // Run posted deadline. | 438 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 444 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); | 439 EXPECT_EQ(0, client.num_actions_()); |
| 445 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 440 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 446 EXPECT_TRUE(scheduler->RedrawPending()); | 441 EXPECT_TRUE(scheduler->RedrawPending()); |
| 447 EXPECT_TRUE(client.needs_begin_impl_frame()); | 442 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 448 | 443 |
| 449 client.Reset(); | 444 client.Reset(); |
| 450 scheduler->SetNeedsCommit(); | 445 scheduler->SetNeedsCommit(); |
| 451 EXPECT_EQ(0, client.num_actions_()); | 446 EXPECT_EQ(0, client.num_actions_()); |
| 452 | 447 |
| 453 client.Reset(); | 448 client.Reset(); |
| 454 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 449 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 455 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 450 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| 456 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); | 451 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| 457 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 452 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 458 | 453 |
| 459 // Commit will release the texture. | 454 // Commit will release the texture. |
| 460 client.Reset(); | 455 client.Reset(); |
| 461 scheduler->NotifyBeginMainFrameStarted(); | 456 scheduler->NotifyBeginMainFrameStarted(); |
| 462 scheduler->NotifyReadyToCommit(); | 457 scheduler->NotifyReadyToCommit(); |
| 463 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 458 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
| 464 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 459 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 465 EXPECT_TRUE(scheduler->RedrawPending()); | 460 EXPECT_TRUE(scheduler->RedrawPending()); |
| 466 | 461 |
| 467 // Now we can draw again after the commit happens. | 462 // Now we can draw again after the commit happens. |
| 468 client.Reset(); | 463 client.Reset(); |
| 469 client.task_runner().RunPendingTasks(); // Run posted deadline. | 464 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 470 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); | 465 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
| 471 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); | |
| 472 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 466 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 473 EXPECT_FALSE(scheduler->RedrawPending()); | 467 EXPECT_FALSE(scheduler->RedrawPending()); |
| 474 EXPECT_TRUE(client.needs_begin_impl_frame()); | 468 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 475 | 469 |
| 476 // Make sure we stop requesting BeginImplFrames if we don't swap. | 470 // Make sure we stop requesting BeginImplFrames if we don't swap. |
| 477 client.Reset(); | 471 client.Reset(); |
| 478 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 472 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 479 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 473 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 480 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 474 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 481 client.Reset(); | 475 client.Reset(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 505 "ScheduledActionAcquireLayerTexturesForMainThread", client); | 499 "ScheduledActionAcquireLayerTexturesForMainThread", client); |
| 506 | 500 |
| 507 client.Reset(); | 501 client.Reset(); |
| 508 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 502 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 509 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 503 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
| 510 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); | 504 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
| 511 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 505 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 512 | 506 |
| 513 client.Reset(); | 507 client.Reset(); |
| 514 client.task_runner().RunPendingTasks(); // Run posted deadline. | 508 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 515 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); | 509 EXPECT_EQ(0, client.num_actions_()); |
| 516 | 510 |
| 517 // Although the compositor cannot draw because textures are locked by main | 511 // Although the compositor cannot draw because textures are locked by main |
| 518 // thread, we continue requesting SetNeedsBeginFrame in anticipation of | 512 // thread, we continue requesting SetNeedsBeginFrame in anticipation of |
| 519 // the unlock. | 513 // the unlock. |
| 520 EXPECT_TRUE(client.needs_begin_impl_frame()); | 514 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 521 | 515 |
| 522 // Trigger the commit. | 516 // Trigger the commit. |
| 523 scheduler->NotifyBeginMainFrameStarted(); | 517 scheduler->NotifyBeginMainFrameStarted(); |
| 524 scheduler->NotifyReadyToCommit(); | 518 scheduler->NotifyReadyToCommit(); |
| 525 EXPECT_TRUE(client.needs_begin_impl_frame()); | 519 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 526 | 520 |
| 527 // Between commit and draw, texture acquisition for main thread delayed, | 521 // Between commit and draw, texture acquisition for main thread delayed, |
| 528 // and main thread blocks. | 522 // and main thread blocks. |
| 529 client.Reset(); | 523 client.Reset(); |
| 530 scheduler->SetMainThreadNeedsLayerTextures(); | 524 scheduler->SetMainThreadNeedsLayerTextures(); |
| 531 EXPECT_EQ(0, client.num_actions_()); | 525 EXPECT_EQ(0, client.num_actions_()); |
| 532 | 526 |
| 533 // No implicit commit is expected. | 527 // No implicit commit is expected. |
| 534 client.Reset(); | 528 client.Reset(); |
| 535 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 529 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 536 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 530 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 537 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 531 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 538 | 532 |
| 539 client.Reset(); | 533 client.Reset(); |
| 540 client.task_runner().RunPendingTasks(); // Run posted deadline. | 534 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 541 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3); | 535 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); |
| 542 EXPECT_ACTION( | 536 EXPECT_ACTION( |
| 543 "ScheduledActionAcquireLayerTexturesForMainThread", client, 1, 3); | 537 "ScheduledActionAcquireLayerTexturesForMainThread", client, 1, 2); |
| 544 EXPECT_ACTION("SetNeedsBeginFrame", client, 2, 3); | |
| 545 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 538 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 546 EXPECT_TRUE(client.needs_begin_impl_frame()); | 539 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 547 | 540 |
| 548 // The compositor should not draw because textures are locked by main | 541 // The compositor should not draw because textures are locked by main |
| 549 // thread. | 542 // thread. |
| 550 client.Reset(); | 543 client.Reset(); |
| 551 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 544 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 552 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 545 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 553 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 546 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 554 client.Reset(); | 547 client.Reset(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 574 // Trigger the commit, which will trigger the deadline task early. | 567 // Trigger the commit, which will trigger the deadline task early. |
| 575 scheduler->NotifyBeginMainFrameStarted(); | 568 scheduler->NotifyBeginMainFrameStarted(); |
| 576 scheduler->NotifyReadyToCommit(); | 569 scheduler->NotifyReadyToCommit(); |
| 577 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 570 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
| 578 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 571 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 579 EXPECT_TRUE(client.needs_begin_impl_frame()); | 572 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 580 client.Reset(); | 573 client.Reset(); |
| 581 | 574 |
| 582 // Verify we draw on the next BeginImplFrame deadline | 575 // Verify we draw on the next BeginImplFrame deadline |
| 583 client.task_runner().RunPendingTasks(); // Run posted deadline. | 576 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 584 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); | 577 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
| 585 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); | |
| 586 EXPECT_TRUE(client.needs_begin_impl_frame()); | 578 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 587 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 579 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 588 client.Reset(); | 580 client.Reset(); |
| 589 } | 581 } |
| 590 | 582 |
| 591 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { | 583 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { |
| 592 FakeSchedulerClient client; | 584 FakeSchedulerClient client; |
| 593 SchedulerSettings scheduler_settings; | 585 SchedulerSettings scheduler_settings; |
| 594 Scheduler* scheduler = client.CreateScheduler(scheduler_settings); | 586 Scheduler* scheduler = client.CreateScheduler(scheduler_settings); |
| 595 scheduler->SetCanStart(); | 587 scheduler->SetCanStart(); |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1020 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 1029 | 1021 |
| 1030 // We need a BeginImplFrame where we don't swap to go idle. | 1022 // We need a BeginImplFrame where we don't swap to go idle. |
| 1031 client.Reset(); | 1023 client.Reset(); |
| 1032 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 1024 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
| 1033 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 1025 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 1034 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1026 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 1035 client.Reset(); | 1027 client.Reset(); |
| 1036 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1028 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 1037 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); | 1029 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); |
| 1030 EXPECT_FALSE(client.needs_begin_impl_frame()); |
| 1038 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1031 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 1039 EXPECT_EQ(0, client.num_draws()); | 1032 EXPECT_EQ(0, client.num_draws()); |
| 1040 | 1033 |
| 1041 // Now trigger a ManageTiles outside of a draw. We will then need | 1034 // Now trigger a ManageTiles outside of a draw. We will then need |
| 1042 // a begin-frame for the ManageTiles, but we don't need a draw. | 1035 // a begin-frame for the ManageTiles, but we don't need a draw. |
| 1043 client.Reset(); | 1036 client.Reset(); |
| 1044 EXPECT_FALSE(client.needs_begin_impl_frame()); | 1037 EXPECT_FALSE(client.needs_begin_impl_frame()); |
| 1045 scheduler->SetNeedsManageTiles(); | 1038 scheduler->SetNeedsManageTiles(); |
| 1046 EXPECT_TRUE(client.needs_begin_impl_frame()); | 1039 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 1047 EXPECT_TRUE(scheduler->ManageTilesPending()); | 1040 EXPECT_TRUE(scheduler->ManageTilesPending()); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1385 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 1393 EXPECT_TRUE(client.needs_begin_impl_frame()); | 1386 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 1394 client.Reset(); | 1387 client.Reset(); |
| 1395 | 1388 |
| 1396 // Queue BeginFrames while we are still handling the previous BeginFrame. | 1389 // Queue BeginFrames while we are still handling the previous BeginFrame. |
| 1397 args.frame_time += base::TimeDelta::FromSeconds(1); | 1390 args.frame_time += base::TimeDelta::FromSeconds(1); |
| 1398 scheduler->BeginFrame(args); | 1391 scheduler->BeginFrame(args); |
| 1399 args.frame_time += base::TimeDelta::FromSeconds(1); | 1392 args.frame_time += base::TimeDelta::FromSeconds(1); |
| 1400 scheduler->BeginFrame(args); | 1393 scheduler->BeginFrame(args); |
| 1401 | 1394 |
| 1402 // If we don't swap on the deadline, we need to request another | 1395 // If we don't swap on the deadline, we wait for the next BeginImplFrame. |
| 1403 // BeginImplFrame. | |
| 1404 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1396 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 1405 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); | 1397 EXPECT_EQ(0, client.num_actions_()); |
| 1406 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1398 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 1407 EXPECT_TRUE(client.needs_begin_impl_frame()); | 1399 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 1408 client.Reset(); | 1400 client.Reset(); |
| 1409 | 1401 |
| 1410 // NotifyReadyToCommit should trigger the commit. | 1402 // NotifyReadyToCommit should trigger the commit. |
| 1411 scheduler->NotifyBeginMainFrameStarted(); | 1403 scheduler->NotifyBeginMainFrameStarted(); |
| 1412 scheduler->NotifyReadyToCommit(); | 1404 scheduler->NotifyReadyToCommit(); |
| 1413 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 1405 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
| 1414 EXPECT_TRUE(client.needs_begin_impl_frame()); | 1406 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 1415 client.Reset(); | 1407 client.Reset(); |
| 1416 | 1408 |
| 1417 // BeginImplFrame should prepare the draw. | 1409 // BeginImplFrame should prepare the draw. |
| 1418 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. | 1410 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. |
| 1419 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 1411 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 1420 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1412 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 1421 EXPECT_TRUE(client.needs_begin_impl_frame()); | 1413 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 1422 client.Reset(); | 1414 client.Reset(); |
| 1423 | 1415 |
| 1424 // BeginImplFrame deadline should draw. | 1416 // BeginImplFrame deadline should draw. |
| 1425 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1417 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 1426 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); | 1418 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
| 1427 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); | |
| 1428 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1419 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 1429 EXPECT_TRUE(client.needs_begin_impl_frame()); | 1420 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 1430 client.Reset(); | 1421 client.Reset(); |
| 1431 | 1422 |
| 1432 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) | 1423 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) |
| 1433 // to avoid excessive toggles. | 1424 // to avoid excessive toggles. |
| 1434 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. | 1425 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. |
| 1435 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); | 1426 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
| 1436 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1427 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 1437 client.Reset(); | 1428 client.Reset(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 | 1474 |
| 1484 // NotifyReadyToCommit should trigger the pending commit and draw. | 1475 // NotifyReadyToCommit should trigger the pending commit and draw. |
| 1485 scheduler->NotifyBeginMainFrameStarted(); | 1476 scheduler->NotifyBeginMainFrameStarted(); |
| 1486 scheduler->NotifyReadyToCommit(); | 1477 scheduler->NotifyReadyToCommit(); |
| 1487 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 1478 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
| 1488 EXPECT_TRUE(client.needs_begin_impl_frame()); | 1479 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 1489 client.Reset(); | 1480 client.Reset(); |
| 1490 | 1481 |
| 1491 // Swapping will put us into a swap throttled state. | 1482 // Swapping will put us into a swap throttled state. |
| 1492 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1483 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 1493 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); | 1484 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
| 1494 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); | |
| 1495 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1485 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 1496 EXPECT_TRUE(client.needs_begin_impl_frame()); | 1486 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 1497 client.Reset(); | 1487 client.Reset(); |
| 1498 | 1488 |
| 1499 // While swap throttled, BeginRetroFrames should trigger BeginImplFrames | 1489 // While swap throttled, BeginRetroFrames should trigger BeginImplFrames |
| 1500 // but not a BeginMainFrame or draw. | 1490 // but not a BeginMainFrame or draw. |
| 1501 scheduler->SetNeedsCommit(); | 1491 scheduler->SetNeedsCommit(); |
| 1502 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. | 1492 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. |
| 1503 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); | 1493 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); |
| 1504 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1494 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1516 // Take us out of a swap throttled state. | 1506 // Take us out of a swap throttled state. |
| 1517 scheduler->OnSwapBuffersComplete(); | 1507 scheduler->OnSwapBuffersComplete(); |
| 1518 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); | 1508 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); |
| 1519 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1509 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 1520 EXPECT_TRUE(client.needs_begin_impl_frame()); | 1510 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 1521 client.Reset(); | 1511 client.Reset(); |
| 1522 | 1512 |
| 1523 // BeginImplFrame deadline should draw. | 1513 // BeginImplFrame deadline should draw. |
| 1524 scheduler->SetNeedsRedraw(); | 1514 scheduler->SetNeedsRedraw(); |
| 1525 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1515 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 1526 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); | 1516 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
| 1527 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); | |
| 1528 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1517 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 1529 EXPECT_TRUE(client.needs_begin_impl_frame()); | 1518 EXPECT_TRUE(client.needs_begin_impl_frame()); |
| 1530 client.Reset(); | 1519 client.Reset(); |
| 1531 } | 1520 } |
| 1532 | 1521 |
| 1533 } // namespace | 1522 } // namespace |
| 1534 } // namespace cc | 1523 } // namespace cc |
| OLD | NEW |