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_state_machine.h" | 5 #include "cc/scheduler/scheduler_state_machine.h" |
6 | 6 |
7 #include "cc/scheduler/scheduler.h" | 7 #include "cc/scheduler/scheduler.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 #define EXPECT_ACTION_UPDATE_STATE(action) \ | 10 #define EXPECT_ACTION_UPDATE_STATE(action) \ |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 // We're drawing now. | 192 // We're drawing now. |
193 EXPECT_ACTION_UPDATE_STATE( | 193 EXPECT_ACTION_UPDATE_STATE( |
194 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 194 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
195 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 195 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
196 | 196 |
197 EXPECT_FALSE(state.RedrawPending()); | 197 EXPECT_FALSE(state.RedrawPending()); |
198 EXPECT_FALSE(state.CommitPending()); | 198 EXPECT_FALSE(state.CommitPending()); |
199 | 199 |
200 // Failing the draw makes us require a commit. | 200 // Failing the draw makes us require a commit. |
201 state.DidDrawIfPossibleCompleted(false); | 201 state.DidDrawIfPossibleCompleted( |
| 202 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
202 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 203 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
203 EXPECT_ACTION_UPDATE_STATE( | 204 EXPECT_ACTION_UPDATE_STATE( |
204 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 205 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
205 EXPECT_TRUE(state.RedrawPending()); | 206 EXPECT_TRUE(state.RedrawPending()); |
206 EXPECT_TRUE(state.CommitPending()); | 207 EXPECT_TRUE(state.CommitPending()); |
207 } | 208 } |
208 | 209 |
209 TEST(SchedulerStateMachineTest, | 210 TEST(SchedulerStateMachineTest, |
210 TestsetNeedsRedrawDuringFailedDrawDoesNotRemoveNeedsRedraw) { | 211 TestsetNeedsRedrawDuringFailedDrawDoesNotRemoveNeedsRedraw) { |
211 SchedulerSettings default_scheduler_settings; | 212 SchedulerSettings default_scheduler_settings; |
(...skipping 16 matching lines...) Expand all Loading... |
228 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 229 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
229 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 230 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
230 EXPECT_FALSE(state.RedrawPending()); | 231 EXPECT_FALSE(state.RedrawPending()); |
231 EXPECT_FALSE(state.CommitPending()); | 232 EXPECT_FALSE(state.CommitPending()); |
232 | 233 |
233 // While still in the same BeginMainFrame callback on the main thread, | 234 // While still in the same BeginMainFrame callback on the main thread, |
234 // set needs redraw again. This should not redraw. | 235 // set needs redraw again. This should not redraw. |
235 state.SetNeedsRedraw(true); | 236 state.SetNeedsRedraw(true); |
236 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 237 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
237 | 238 |
238 // Failing the draw makes us require a commit. | 239 // Failing the draw for animation checkerboards makes us require a commit. |
239 state.DidDrawIfPossibleCompleted(false); | 240 state.DidDrawIfPossibleCompleted( |
| 241 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
240 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 242 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
241 EXPECT_ACTION_UPDATE_STATE( | 243 EXPECT_ACTION_UPDATE_STATE( |
242 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 244 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
243 EXPECT_TRUE(state.RedrawPending()); | 245 EXPECT_TRUE(state.RedrawPending()); |
244 } | 246 } |
245 | 247 |
246 void TestFailedDrawsWillEventuallyForceADrawAfterTheNextCommit( | 248 void TestFailedDrawsWillEventuallyForceADrawAfterTheNextCommit( |
247 bool deadline_scheduling_enabled) { | 249 bool deadline_scheduling_enabled) { |
248 SchedulerSettings scheduler_settings; | 250 SchedulerSettings scheduler_settings; |
249 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ = 1; | 251 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ = 1; |
(...skipping 20 matching lines...) Expand all Loading... |
270 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 272 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
271 EXPECT_TRUE(state.CommitPending()); | 273 EXPECT_TRUE(state.CommitPending()); |
272 | 274 |
273 // Then initiate a draw. | 275 // Then initiate a draw. |
274 state.SetNeedsRedraw(true); | 276 state.SetNeedsRedraw(true); |
275 state.OnBeginImplFrameDeadline(); | 277 state.OnBeginImplFrameDeadline(); |
276 EXPECT_ACTION_UPDATE_STATE( | 278 EXPECT_ACTION_UPDATE_STATE( |
277 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 279 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
278 | 280 |
279 // Fail the draw. | 281 // Fail the draw. |
280 state.DidDrawIfPossibleCompleted(false); | 282 state.DidDrawIfPossibleCompleted( |
| 283 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
281 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 284 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
282 EXPECT_TRUE(state.BeginImplFrameNeeded()); | 285 EXPECT_TRUE(state.BeginImplFrameNeeded()); |
283 EXPECT_TRUE(state.RedrawPending()); | 286 EXPECT_TRUE(state.RedrawPending()); |
284 // But the commit is ongoing. | 287 // But the commit is ongoing. |
285 EXPECT_TRUE(state.CommitPending()); | 288 EXPECT_TRUE(state.CommitPending()); |
286 | 289 |
287 // Finish the commit. Note, we should not yet be forcing a draw, but should | 290 // Finish the commit. Note, we should not yet be forcing a draw, but should |
288 // continue the commit as usual. | 291 // continue the commit as usual. |
289 state.FinishCommit(); | 292 state.FinishCommit(); |
290 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 293 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
(...skipping 18 matching lines...) Expand all Loading... |
309 TEST(SchedulerStateMachineTest, | 312 TEST(SchedulerStateMachineTest, |
310 TestFailedDrawsWillEventuallyForceADrawAfterTheNextCommit_Deadline) { | 313 TestFailedDrawsWillEventuallyForceADrawAfterTheNextCommit_Deadline) { |
311 bool deadline_scheduling_enabled = true; | 314 bool deadline_scheduling_enabled = true; |
312 TestFailedDrawsWillEventuallyForceADrawAfterTheNextCommit( | 315 TestFailedDrawsWillEventuallyForceADrawAfterTheNextCommit( |
313 deadline_scheduling_enabled); | 316 deadline_scheduling_enabled); |
314 } | 317 } |
315 | 318 |
316 void TestFailedDrawsDoNotRestartForcedDraw( | 319 void TestFailedDrawsDoNotRestartForcedDraw( |
317 bool deadline_scheduling_enabled) { | 320 bool deadline_scheduling_enabled) { |
318 SchedulerSettings scheduler_settings; | 321 SchedulerSettings scheduler_settings; |
319 int drawLimit = 1; | 322 int draw_limit = 1; |
320 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ = | 323 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ = |
321 drawLimit; | 324 draw_limit; |
322 scheduler_settings.deadline_scheduling_enabled = deadline_scheduling_enabled; | 325 scheduler_settings.deadline_scheduling_enabled = deadline_scheduling_enabled; |
323 scheduler_settings.impl_side_painting = true; | 326 scheduler_settings.impl_side_painting = true; |
324 StateMachine state(scheduler_settings); | 327 StateMachine state(scheduler_settings); |
325 state.SetCanStart(); | 328 state.SetCanStart(); |
326 state.UpdateState(state.NextAction()); | 329 state.UpdateState(state.NextAction()); |
327 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 330 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
328 state.SetVisible(true); | 331 state.SetVisible(true); |
329 state.SetCanDraw(true); | 332 state.SetCanDraw(true); |
330 | 333 |
331 // Start a commit. | 334 // Start a commit. |
(...skipping 12 matching lines...) Expand all Loading... |
344 EXPECT_TRUE(state.CommitPending()); | 347 EXPECT_TRUE(state.CommitPending()); |
345 | 348 |
346 // Then initiate a draw. | 349 // Then initiate a draw. |
347 state.SetNeedsRedraw(true); | 350 state.SetNeedsRedraw(true); |
348 state.OnBeginImplFrameDeadline(); | 351 state.OnBeginImplFrameDeadline(); |
349 EXPECT_ACTION_UPDATE_STATE( | 352 EXPECT_ACTION_UPDATE_STATE( |
350 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 353 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
351 | 354 |
352 // Fail the draw enough times to force a redraw, | 355 // Fail the draw enough times to force a redraw, |
353 // then once more for good measure. | 356 // then once more for good measure. |
354 for (int i = 0; i < drawLimit; ++i) | 357 for (int i = 0; i < draw_limit + 1; ++i) { |
355 state.DidDrawIfPossibleCompleted(false); | 358 state.DidDrawIfPossibleCompleted( |
356 state.DidDrawIfPossibleCompleted(false); | 359 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
| 360 } |
357 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 361 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
358 EXPECT_TRUE(state.BeginImplFrameNeeded()); | 362 EXPECT_TRUE(state.BeginImplFrameNeeded()); |
359 EXPECT_TRUE(state.RedrawPending()); | 363 EXPECT_TRUE(state.RedrawPending()); |
360 // But the commit is ongoing. | 364 // But the commit is ongoing. |
361 EXPECT_TRUE(state.CommitPending()); | 365 EXPECT_TRUE(state.CommitPending()); |
362 EXPECT_TRUE(state.ForcedRedrawState() == | 366 EXPECT_TRUE(state.ForcedRedrawState() == |
363 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_COMMIT); | 367 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_COMMIT); |
364 | 368 |
365 state.FinishCommit(); | 369 state.FinishCommit(); |
366 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 370 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
367 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 371 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
368 EXPECT_TRUE(state.RedrawPending()); | 372 EXPECT_TRUE(state.RedrawPending()); |
369 EXPECT_FALSE(state.CommitPending()); | 373 EXPECT_FALSE(state.CommitPending()); |
370 | 374 |
371 // Now force redraw should be in waiting for activation | 375 // Now force redraw should be in waiting for activation |
372 EXPECT_TRUE(state.ForcedRedrawState() == | 376 EXPECT_TRUE(state.ForcedRedrawState() == |
373 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION); | 377 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION); |
374 | 378 |
375 // After failing additional draws, we should still be in a forced | 379 // After failing additional draws, we should still be in a forced |
376 // redraw, but not back in WAITING_FOR_COMMIT. | 380 // redraw, but not back in WAITING_FOR_COMMIT. |
377 for (int i = 0; i < drawLimit; ++i) | 381 for (int i = 0; i < draw_limit + 1; ++i) { |
378 state.DidDrawIfPossibleCompleted(false); | 382 state.DidDrawIfPossibleCompleted( |
379 state.DidDrawIfPossibleCompleted(false); | 383 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
| 384 } |
380 EXPECT_TRUE(state.RedrawPending()); | 385 EXPECT_TRUE(state.RedrawPending()); |
381 EXPECT_TRUE(state.ForcedRedrawState() == | 386 EXPECT_TRUE(state.ForcedRedrawState() == |
382 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION); | 387 SchedulerStateMachine::FORCED_REDRAW_STATE_WAITING_FOR_ACTIVATION); |
383 } | 388 } |
384 | 389 |
385 TEST(SchedulerStateMachineTest, | 390 TEST(SchedulerStateMachineTest, |
386 TestFailedDrawsDoNotRestartForcedDraw) { | 391 TestFailedDrawsDoNotRestartForcedDraw) { |
387 bool deadline_scheduling_enabled = false; | 392 bool deadline_scheduling_enabled = false; |
388 TestFailedDrawsDoNotRestartForcedDraw( | 393 TestFailedDrawsDoNotRestartForcedDraw( |
389 deadline_scheduling_enabled); | 394 deadline_scheduling_enabled); |
(...skipping 18 matching lines...) Expand all Loading... |
408 // Start a draw. | 413 // Start a draw. |
409 state.SetNeedsRedraw(true); | 414 state.SetNeedsRedraw(true); |
410 EXPECT_TRUE(state.BeginImplFrameNeeded()); | 415 EXPECT_TRUE(state.BeginImplFrameNeeded()); |
411 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 416 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
412 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 417 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
413 state.OnBeginImplFrameDeadline(); | 418 state.OnBeginImplFrameDeadline(); |
414 EXPECT_TRUE(state.RedrawPending()); | 419 EXPECT_TRUE(state.RedrawPending()); |
415 EXPECT_ACTION_UPDATE_STATE( | 420 EXPECT_ACTION_UPDATE_STATE( |
416 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 421 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
417 | 422 |
418 // Fail the draw | 423 // Failing the draw for animation checkerboards makes us require a commit. |
419 state.DidDrawIfPossibleCompleted(false); | 424 state.DidDrawIfPossibleCompleted( |
| 425 DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS); |
420 EXPECT_ACTION_UPDATE_STATE( | 426 EXPECT_ACTION_UPDATE_STATE( |
421 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 427 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
422 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 428 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
423 EXPECT_TRUE(state.RedrawPending()); | 429 EXPECT_TRUE(state.RedrawPending()); |
424 | 430 |
425 // We should not be trying to draw again now, but we have a commit pending. | 431 // We should not be trying to draw again now, but we have a commit pending. |
426 EXPECT_TRUE(state.BeginImplFrameNeeded()); | 432 EXPECT_TRUE(state.BeginImplFrameNeeded()); |
427 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 433 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
428 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 434 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
429 | 435 |
(...skipping 16 matching lines...) Expand all Loading... |
446 state.SetNeedsRedraw(true); | 452 state.SetNeedsRedraw(true); |
447 | 453 |
448 // Draw the first frame. | 454 // Draw the first frame. |
449 EXPECT_TRUE(state.BeginImplFrameNeeded()); | 455 EXPECT_TRUE(state.BeginImplFrameNeeded()); |
450 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 456 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
451 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 457 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
452 | 458 |
453 state.OnBeginImplFrameDeadline(); | 459 state.OnBeginImplFrameDeadline(); |
454 EXPECT_ACTION_UPDATE_STATE( | 460 EXPECT_ACTION_UPDATE_STATE( |
455 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 461 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
456 state.DidDrawIfPossibleCompleted(true); | 462 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); |
457 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 463 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
458 | 464 |
459 // Before the next BeginImplFrame, set needs redraw again. | 465 // Before the next BeginImplFrame, set needs redraw again. |
460 // This should not redraw until the next BeginImplFrame. | 466 // This should not redraw until the next BeginImplFrame. |
461 state.SetNeedsRedraw(true); | 467 state.SetNeedsRedraw(true); |
462 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 468 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
463 | 469 |
464 // Move to another frame. This should now draw. | 470 // Move to another frame. This should now draw. |
465 EXPECT_TRUE(state.BeginImplFrameNeeded()); | 471 EXPECT_TRUE(state.BeginImplFrameNeeded()); |
466 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 472 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
467 | 473 |
468 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 474 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
469 | 475 |
470 state.OnBeginImplFrameDeadline(); | 476 state.OnBeginImplFrameDeadline(); |
471 EXPECT_ACTION_UPDATE_STATE( | 477 EXPECT_ACTION_UPDATE_STATE( |
472 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 478 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
473 state.DidDrawIfPossibleCompleted(true); | 479 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); |
474 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 480 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
475 | 481 |
476 // We just swapped, so we should proactively request another BeginImplFrame. | 482 // We just swapped, so we should proactively request another BeginImplFrame. |
477 EXPECT_TRUE(state.BeginImplFrameNeeded()); | 483 EXPECT_TRUE(state.BeginImplFrameNeeded()); |
478 } | 484 } |
479 | 485 |
480 TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) { | 486 TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginImplFrame) { |
481 SchedulerSettings default_scheduler_settings; | 487 SchedulerSettings default_scheduler_settings; |
482 | 488 |
483 // When not in BeginImplFrame deadline, or in BeginImplFrame deadline | 489 // When not in BeginImplFrame deadline, or in BeginImplFrame deadline |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); | 714 EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction()); |
709 | 715 |
710 // Commit and make sure we draw on next BeginImplFrame | 716 // Commit and make sure we draw on next BeginImplFrame |
711 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 717 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
712 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 718 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
713 state.OnBeginImplFrameDeadline(); | 719 state.OnBeginImplFrameDeadline(); |
714 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 720 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, |
715 state.CommitState()); | 721 state.CommitState()); |
716 EXPECT_ACTION_UPDATE_STATE( | 722 EXPECT_ACTION_UPDATE_STATE( |
717 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 723 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
718 state.DidDrawIfPossibleCompleted(true); | 724 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); |
719 | 725 |
720 // Verify that another commit will start immediately after draw. | 726 // Verify that another commit will start immediately after draw. |
721 EXPECT_ACTION_UPDATE_STATE( | 727 EXPECT_ACTION_UPDATE_STATE( |
722 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 728 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
723 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 729 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
724 } | 730 } |
725 | 731 |
726 TEST(SchedulerStateMachineTest, TestFullCycle) { | 732 TEST(SchedulerStateMachineTest, TestFullCycle) { |
727 SchedulerSettings default_scheduler_settings; | 733 SchedulerSettings default_scheduler_settings; |
728 StateMachine state(default_scheduler_settings); | 734 StateMachine state(default_scheduler_settings); |
(...skipping 26 matching lines...) Expand all Loading... |
755 state.CommitState()); | 761 state.CommitState()); |
756 EXPECT_TRUE(state.needs_redraw()); | 762 EXPECT_TRUE(state.needs_redraw()); |
757 | 763 |
758 // Expect to do nothing until BeginImplFrame deadline | 764 // Expect to do nothing until BeginImplFrame deadline |
759 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 765 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
760 | 766 |
761 // At BeginImplFrame deadline, draw. | 767 // At BeginImplFrame deadline, draw. |
762 state.OnBeginImplFrameDeadline(); | 768 state.OnBeginImplFrameDeadline(); |
763 EXPECT_ACTION_UPDATE_STATE( | 769 EXPECT_ACTION_UPDATE_STATE( |
764 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 770 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
765 state.DidDrawIfPossibleCompleted(true); | 771 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); |
766 | 772 |
767 // Should be synchronized, no draw needed, no action needed. | 773 // Should be synchronized, no draw needed, no action needed. |
768 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 774 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
769 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); | 775 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); |
770 EXPECT_FALSE(state.needs_redraw()); | 776 EXPECT_FALSE(state.needs_redraw()); |
771 } | 777 } |
772 | 778 |
773 TEST(SchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) { | 779 TEST(SchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) { |
774 SchedulerSettings default_scheduler_settings; | 780 SchedulerSettings default_scheduler_settings; |
775 StateMachine state(default_scheduler_settings); | 781 StateMachine state(default_scheduler_settings); |
(...skipping 30 matching lines...) Expand all Loading... |
806 state.CommitState()); | 812 state.CommitState()); |
807 EXPECT_TRUE(state.needs_redraw()); | 813 EXPECT_TRUE(state.needs_redraw()); |
808 | 814 |
809 // Expect to do nothing until BeginImplFrame deadline. | 815 // Expect to do nothing until BeginImplFrame deadline. |
810 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 816 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
811 | 817 |
812 // At BeginImplFrame deadline, draw. | 818 // At BeginImplFrame deadline, draw. |
813 state.OnBeginImplFrameDeadline(); | 819 state.OnBeginImplFrameDeadline(); |
814 EXPECT_ACTION_UPDATE_STATE( | 820 EXPECT_ACTION_UPDATE_STATE( |
815 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); | 821 SchedulerStateMachine::ACTION_DRAW_AND_SWAP_IF_POSSIBLE); |
816 state.DidDrawIfPossibleCompleted(true); | 822 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); |
817 | 823 |
818 // Should be synchronized, no draw needed, no action needed. | 824 // Should be synchronized, no draw needed, no action needed. |
819 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 825 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
820 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); | 826 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState()); |
821 EXPECT_FALSE(state.needs_redraw()); | 827 EXPECT_FALSE(state.needs_redraw()); |
822 | 828 |
823 // Next BeginImplFrame should initiate second commit. | 829 // Next BeginImplFrame should initiate second commit. |
824 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); | 830 state.OnBeginImplFrame(BeginFrameArgs::CreateForTesting()); |
825 EXPECT_ACTION_UPDATE_STATE( | 831 EXPECT_ACTION_UPDATE_STATE( |
826 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); | 832 SchedulerStateMachine::ACTION_SEND_BEGIN_MAIN_FRAME); |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 state.FinishCommit(); | 1448 state.FinishCommit(); |
1443 | 1449 |
1444 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1450 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
1445 state.CommitState()); | 1451 state.CommitState()); |
1446 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1452 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1447 | 1453 |
1448 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 1454 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, |
1449 state.CommitState()); | 1455 state.CommitState()); |
1450 | 1456 |
1451 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1457 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
1452 state.DidDrawIfPossibleCompleted(true); | 1458 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); |
1453 | 1459 |
1454 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1460 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1455 | 1461 |
1456 // Should be waiting for the normal BeginMainFrame. | 1462 // Should be waiting for the normal BeginMainFrame. |
1457 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 1463 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
1458 state.CommitState()); | 1464 state.CommitState()); |
1459 } | 1465 } |
1460 | 1466 |
1461 void TestImmediateFinishCommitDuringCommit(bool deadline_scheduling_enabled) { | 1467 void TestImmediateFinishCommitDuringCommit(bool deadline_scheduling_enabled) { |
1462 SchedulerSettings scheduler_settings; | 1468 SchedulerSettings scheduler_settings; |
(...skipping 22 matching lines...) Expand all Loading... |
1485 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1491 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1486 state.FinishCommit(); | 1492 state.FinishCommit(); |
1487 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1493 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
1488 state.CommitState()); | 1494 state.CommitState()); |
1489 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1495 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1490 | 1496 |
1491 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 1497 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, |
1492 state.CommitState()); | 1498 state.CommitState()); |
1493 | 1499 |
1494 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1500 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
1495 state.DidDrawIfPossibleCompleted(true); | 1501 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); |
1496 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1502 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1497 | 1503 |
1498 // Should be waiting for the normal BeginMainFrame. | 1504 // Should be waiting for the normal BeginMainFrame. |
1499 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 1505 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
1500 state.CommitState()) | 1506 state.CommitState()) |
1501 << *state.AsValue(); | 1507 << *state.AsValue(); |
1502 } | 1508 } |
1503 | 1509 |
1504 TEST(SchedulerStateMachineTest, TestImmediateFinishCommitDuringCommit) { | 1510 TEST(SchedulerStateMachineTest, TestImmediateFinishCommitDuringCommit) { |
1505 bool deadline_scheduling_enabled = false; | 1511 bool deadline_scheduling_enabled = false; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 state.FinishCommit(); | 1545 state.FinishCommit(); |
1540 | 1546 |
1541 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1547 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
1542 state.CommitState()); | 1548 state.CommitState()); |
1543 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1549 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1544 | 1550 |
1545 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 1551 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, |
1546 state.CommitState()); | 1552 state.CommitState()); |
1547 | 1553 |
1548 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1554 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
1549 state.DidDrawIfPossibleCompleted(true); | 1555 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); |
1550 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1556 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1551 | 1557 |
1552 // Should be waiting for BeginMainFrame. | 1558 // Should be waiting for BeginMainFrame. |
1553 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, | 1559 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS, |
1554 state.CommitState()) | 1560 state.CommitState()) |
1555 << *state.AsValue(); | 1561 << *state.AsValue(); |
1556 | 1562 |
1557 // Become invisible and abort BeginMainFrame. | 1563 // Become invisible and abort BeginMainFrame. |
1558 state.SetVisible(false); | 1564 state.SetVisible(false); |
1559 state.BeginMainFrameAborted(false); | 1565 state.BeginMainFrameAborted(false); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 state.FinishCommit(); | 1601 state.FinishCommit(); |
1596 | 1602 |
1597 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, | 1603 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT, |
1598 state.CommitState()); | 1604 state.CommitState()); |
1599 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); | 1605 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_COMMIT); |
1600 | 1606 |
1601 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, | 1607 EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW, |
1602 state.CommitState()); | 1608 state.CommitState()); |
1603 | 1609 |
1604 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); | 1610 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_DRAW_AND_READBACK); |
1605 state.DidDrawIfPossibleCompleted(true); | 1611 state.DidDrawIfPossibleCompleted(DrawSwapReadbackResult::DRAW_SUCCESS); |
1606 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1612 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1607 } | 1613 } |
1608 | 1614 |
1609 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) { | 1615 TEST(SchedulerStateMachineTest, ReportIfNotDrawing) { |
1610 SchedulerSettings default_scheduler_settings; | 1616 SchedulerSettings default_scheduler_settings; |
1611 StateMachine state(default_scheduler_settings); | 1617 StateMachine state(default_scheduler_settings); |
1612 state.SetCanStart(); | 1618 state.SetCanStart(); |
1613 state.UpdateState(state.NextAction()); | 1619 state.UpdateState(state.NextAction()); |
1614 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); | 1620 state.CreateAndInitializeOutputSurfaceWithActivatedCommit(); |
1615 | 1621 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); | 1762 EXPECT_ACTION_UPDATE_STATE(SchedulerStateMachine::ACTION_NONE); |
1757 | 1763 |
1758 // The deadline is not triggered early until we enter prefer smoothness mode. | 1764 // The deadline is not triggered early until we enter prefer smoothness mode. |
1759 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1765 EXPECT_FALSE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
1760 state.SetSmoothnessTakesPriority(true); | 1766 state.SetSmoothnessTakesPriority(true); |
1761 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); | 1767 EXPECT_TRUE(state.ShouldTriggerBeginImplFrameDeadlineEarly()); |
1762 } | 1768 } |
1763 | 1769 |
1764 } // namespace | 1770 } // namespace |
1765 } // namespace cc | 1771 } // namespace cc |
OLD | NEW |