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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 needs_begin_frame_ = enable; | 102 needs_begin_frame_ = enable; |
103 } | 103 } |
104 virtual void WillBeginImplFrame(const BeginFrameArgs& args) OVERRIDE { | 104 virtual void WillBeginImplFrame(const BeginFrameArgs& args) OVERRIDE { |
105 actions_.push_back("WillBeginImplFrame"); | 105 actions_.push_back("WillBeginImplFrame"); |
106 states_.push_back(scheduler_->StateAsValue().release()); | 106 states_.push_back(scheduler_->StateAsValue().release()); |
107 } | 107 } |
108 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE { | 108 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE { |
109 actions_.push_back("ScheduledActionSendBeginMainFrame"); | 109 actions_.push_back("ScheduledActionSendBeginMainFrame"); |
110 states_.push_back(scheduler_->StateAsValue().release()); | 110 states_.push_back(scheduler_->StateAsValue().release()); |
111 } | 111 } |
112 virtual void ScheduledActionAnimate() OVERRIDE { | |
113 actions_.push_back("ScheduledActionAnimate"); | |
114 states_.push_back(scheduler_->StateAsValue().release()); | |
115 } | |
116 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() | 112 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() |
117 OVERRIDE { | 113 OVERRIDE { |
118 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); | 114 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); |
119 states_.push_back(scheduler_->StateAsValue().release()); | 115 states_.push_back(scheduler_->StateAsValue().release()); |
120 num_draws_++; | 116 num_draws_++; |
121 bool did_readback = false; | 117 bool did_readback = false; |
122 DrawSwapReadbackResult::DrawResult result = | 118 DrawSwapReadbackResult::DrawResult result = |
123 draw_will_happen_ | 119 draw_will_happen_ |
124 ? DrawSwapReadbackResult::DRAW_SUCCESS | 120 ? DrawSwapReadbackResult::DRAW_SUCCESS |
125 : DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; | 121 : DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 279 |
284 // NotifyReadyToCommit should trigger the commit. | 280 // NotifyReadyToCommit should trigger the commit. |
285 scheduler->NotifyBeginMainFrameStarted(); | 281 scheduler->NotifyBeginMainFrameStarted(); |
286 scheduler->NotifyReadyToCommit(); | 282 scheduler->NotifyReadyToCommit(); |
287 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 283 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
288 EXPECT_TRUE(client.needs_begin_frame()); | 284 EXPECT_TRUE(client.needs_begin_frame()); |
289 client.Reset(); | 285 client.Reset(); |
290 | 286 |
291 // BeginImplFrame should prepare the draw. | 287 // BeginImplFrame should prepare the draw. |
292 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 288 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
293 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 289 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
294 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); | |
295 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 290 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
296 EXPECT_TRUE(client.needs_begin_frame()); | 291 EXPECT_TRUE(client.needs_begin_frame()); |
297 client.Reset(); | 292 client.Reset(); |
298 | 293 |
299 // BeginImplFrame deadline should draw. | 294 // BeginImplFrame deadline should draw. |
300 client.task_runner().RunPendingTasks(); // Run posted deadline. | 295 client.task_runner().RunPendingTasks(); // Run posted deadline. |
301 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); | 296 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
302 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 297 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
303 EXPECT_TRUE(client.needs_begin_frame()); | 298 EXPECT_TRUE(client.needs_begin_frame()); |
304 client.Reset(); | 299 client.Reset(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 EXPECT_EQ(client.num_actions_(), 0); | 341 EXPECT_EQ(client.num_actions_(), 0); |
347 client.Reset(); | 342 client.Reset(); |
348 | 343 |
349 // Finish the first commit. | 344 // Finish the first commit. |
350 scheduler->NotifyBeginMainFrameStarted(); | 345 scheduler->NotifyBeginMainFrameStarted(); |
351 scheduler->NotifyReadyToCommit(); | 346 scheduler->NotifyReadyToCommit(); |
352 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 347 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
353 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 348 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
354 client.Reset(); | 349 client.Reset(); |
355 client.task_runner().RunPendingTasks(); // Run posted deadline. | 350 client.task_runner().RunPendingTasks(); // Run posted deadline. |
356 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); | 351 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
357 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); | |
358 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 352 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
359 | 353 |
360 // Because we just swapped, the Scheduler should also request the next | 354 // Because we just swapped, the Scheduler should also request the next |
361 // BeginImplFrame from the OutputSurface. | 355 // BeginImplFrame from the OutputSurface. |
362 EXPECT_TRUE(client.needs_begin_frame()); | 356 EXPECT_TRUE(client.needs_begin_frame()); |
363 client.Reset(); | 357 client.Reset(); |
364 // Since another commit is needed, the next BeginImplFrame should initiate | 358 // Since another commit is needed, the next BeginImplFrame should initiate |
365 // the second commit. | 359 // the second commit. |
366 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 360 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
367 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 361 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); |
368 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); | 362 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); |
369 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 363 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
370 client.Reset(); | 364 client.Reset(); |
371 | 365 |
372 // Finishing the commit before the deadline should post a new deadline task | 366 // Finishing the commit before the deadline should post a new deadline task |
373 // to trigger the deadline early. | 367 // to trigger the deadline early. |
374 scheduler->NotifyBeginMainFrameStarted(); | 368 scheduler->NotifyBeginMainFrameStarted(); |
375 scheduler->NotifyReadyToCommit(); | 369 scheduler->NotifyReadyToCommit(); |
376 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 370 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
377 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 371 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
378 client.Reset(); | 372 client.Reset(); |
379 client.task_runner().RunPendingTasks(); // Run posted deadline. | 373 client.task_runner().RunPendingTasks(); // Run posted deadline. |
380 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); | 374 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
381 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); | |
382 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 375 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
383 EXPECT_TRUE(client.needs_begin_frame()); | 376 EXPECT_TRUE(client.needs_begin_frame()); |
384 client.Reset(); | 377 client.Reset(); |
385 | 378 |
386 // On the next BeginImplFrame, verify we go back to a quiescent state and | 379 // On the next BeginImplFrame, verify we go back to a quiescent state and |
387 // no longer request BeginImplFrames. | 380 // no longer request BeginImplFrames. |
388 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 381 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
389 client.task_runner().RunPendingTasks(); // Run posted deadline. | 382 client.task_runner().RunPendingTasks(); // Run posted deadline. |
390 EXPECT_FALSE(client.needs_begin_frame()); | 383 EXPECT_FALSE(client.needs_begin_frame()); |
391 client.Reset(); | 384 client.Reset(); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 EXPECT_TRUE(scheduler->ManageTilesPending()); | 731 EXPECT_TRUE(scheduler->ManageTilesPending()); |
739 EXPECT_TRUE(client.needs_begin_frame()); | 732 EXPECT_TRUE(client.needs_begin_frame()); |
740 EXPECT_EQ(0, client.num_draws()); | 733 EXPECT_EQ(0, client.num_draws()); |
741 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); | 734 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); |
742 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); | 735 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
743 | 736 |
744 // We have no immediate actions to perform, so the BeginImplFrame should post | 737 // We have no immediate actions to perform, so the BeginImplFrame should post |
745 // the deadline task. | 738 // the deadline task. |
746 client.Reset(); | 739 client.Reset(); |
747 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 740 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
748 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 741 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
749 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); | |
750 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 742 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
751 | 743 |
752 // On the deadline, he actions should have occured in the right order. | 744 // On the deadline, he actions should have occured in the right order. |
753 client.Reset(); | 745 client.Reset(); |
754 client.task_runner().RunPendingTasks(); // Run posted deadline. | 746 client.task_runner().RunPendingTasks(); // Run posted deadline. |
755 EXPECT_EQ(1, client.num_draws()); | 747 EXPECT_EQ(1, client.num_draws()); |
756 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); | 748 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
757 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); | 749 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); |
758 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), | 750 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), |
759 client.ActionIndex("ScheduledActionManageTiles")); | 751 client.ActionIndex("ScheduledActionManageTiles")); |
760 EXPECT_FALSE(scheduler->RedrawPending()); | 752 EXPECT_FALSE(scheduler->RedrawPending()); |
761 EXPECT_FALSE(scheduler->ManageTilesPending()); | 753 EXPECT_FALSE(scheduler->ManageTilesPending()); |
762 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 754 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
763 | 755 |
764 // Request a draw. We don't need a ManageTiles yet. | 756 // Request a draw. We don't need a ManageTiles yet. |
765 client.Reset(); | 757 client.Reset(); |
766 scheduler->SetNeedsRedraw(); | 758 scheduler->SetNeedsRedraw(); |
767 EXPECT_TRUE(scheduler->RedrawPending()); | 759 EXPECT_TRUE(scheduler->RedrawPending()); |
768 EXPECT_FALSE(scheduler->ManageTilesPending()); | 760 EXPECT_FALSE(scheduler->ManageTilesPending()); |
769 EXPECT_TRUE(client.needs_begin_frame()); | 761 EXPECT_TRUE(client.needs_begin_frame()); |
770 EXPECT_EQ(0, client.num_draws()); | 762 EXPECT_EQ(0, client.num_draws()); |
771 | 763 |
772 // We have no immediate actions to perform, so the BeginImplFrame should post | 764 // We have no immediate actions to perform, so the BeginImplFrame should post |
773 // the deadline task. | 765 // the deadline task. |
774 client.Reset(); | 766 client.Reset(); |
775 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 767 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
776 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 768 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
777 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); | |
778 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 769 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
779 | 770 |
780 // Draw. The draw will trigger SetNeedsManageTiles, and | 771 // Draw. The draw will trigger SetNeedsManageTiles, and |
781 // then the ManageTiles action will be triggered after the Draw. | 772 // then the ManageTiles action will be triggered after the Draw. |
782 // Afterwards, neither a draw nor ManageTiles are pending. | 773 // Afterwards, neither a draw nor ManageTiles are pending. |
783 client.Reset(); | 774 client.Reset(); |
784 client.task_runner().RunPendingTasks(); // Run posted deadline. | 775 client.task_runner().RunPendingTasks(); // Run posted deadline. |
785 EXPECT_EQ(1, client.num_draws()); | 776 EXPECT_EQ(1, client.num_draws()); |
786 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); | 777 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
787 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); | 778 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 scheduler->SetCanStart(); | 825 scheduler->SetCanStart(); |
835 scheduler->SetVisible(true); | 826 scheduler->SetVisible(true); |
836 scheduler->SetCanDraw(true); | 827 scheduler->SetCanDraw(true); |
837 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); | 828 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); |
838 | 829 |
839 // If DidManageTiles during a frame, then ManageTiles should not occur again. | 830 // If DidManageTiles during a frame, then ManageTiles should not occur again. |
840 scheduler->SetNeedsManageTiles(); | 831 scheduler->SetNeedsManageTiles(); |
841 scheduler->SetNeedsRedraw(); | 832 scheduler->SetNeedsRedraw(); |
842 client.Reset(); | 833 client.Reset(); |
843 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 834 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
844 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 835 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
845 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); | |
846 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 836 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
847 | 837 |
848 EXPECT_TRUE(scheduler->ManageTilesPending()); | 838 EXPECT_TRUE(scheduler->ManageTilesPending()); |
849 scheduler->DidManageTiles(); // An explicit ManageTiles. | 839 scheduler->DidManageTiles(); // An explicit ManageTiles. |
850 EXPECT_FALSE(scheduler->ManageTilesPending()); | 840 EXPECT_FALSE(scheduler->ManageTilesPending()); |
851 | 841 |
852 client.Reset(); | 842 client.Reset(); |
853 client.task_runner().RunPendingTasks(); // Run posted deadline. | 843 client.task_runner().RunPendingTasks(); // Run posted deadline. |
854 EXPECT_EQ(1, client.num_draws()); | 844 EXPECT_EQ(1, client.num_draws()); |
855 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); | 845 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
856 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); | 846 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); |
857 EXPECT_FALSE(scheduler->RedrawPending()); | 847 EXPECT_FALSE(scheduler->RedrawPending()); |
858 EXPECT_FALSE(scheduler->ManageTilesPending()); | 848 EXPECT_FALSE(scheduler->ManageTilesPending()); |
859 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 849 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
860 | 850 |
861 // Next frame without DidManageTiles should ManageTiles with draw. | 851 // Next frame without DidManageTiles should ManageTiles with draw. |
862 scheduler->SetNeedsManageTiles(); | 852 scheduler->SetNeedsManageTiles(); |
863 scheduler->SetNeedsRedraw(); | 853 scheduler->SetNeedsRedraw(); |
864 client.Reset(); | 854 client.Reset(); |
865 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 855 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
866 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 856 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
867 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); | |
868 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 857 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
869 | 858 |
870 client.Reset(); | 859 client.Reset(); |
871 client.task_runner().RunPendingTasks(); // Run posted deadline. | 860 client.task_runner().RunPendingTasks(); // Run posted deadline. |
872 EXPECT_EQ(1, client.num_draws()); | 861 EXPECT_EQ(1, client.num_draws()); |
873 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); | 862 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
874 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); | 863 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); |
875 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), | 864 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), |
876 client.ActionIndex("ScheduledActionManageTiles")); | 865 client.ActionIndex("ScheduledActionManageTiles")); |
877 EXPECT_FALSE(scheduler->RedrawPending()); | 866 EXPECT_FALSE(scheduler->RedrawPending()); |
878 EXPECT_FALSE(scheduler->ManageTilesPending()); | 867 EXPECT_FALSE(scheduler->ManageTilesPending()); |
879 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 868 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
880 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles | 869 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles |
881 | 870 |
882 // If we get another DidManageTiles within the same frame, we should | 871 // If we get another DidManageTiles within the same frame, we should |
883 // not ManageTiles on the next frame. | 872 // not ManageTiles on the next frame. |
884 scheduler->DidManageTiles(); // An explicit ManageTiles. | 873 scheduler->DidManageTiles(); // An explicit ManageTiles. |
885 scheduler->SetNeedsManageTiles(); | 874 scheduler->SetNeedsManageTiles(); |
886 scheduler->SetNeedsRedraw(); | 875 scheduler->SetNeedsRedraw(); |
887 client.Reset(); | 876 client.Reset(); |
888 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 877 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
889 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 878 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
890 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); | |
891 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 879 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
892 | 880 |
893 EXPECT_TRUE(scheduler->ManageTilesPending()); | 881 EXPECT_TRUE(scheduler->ManageTilesPending()); |
894 | 882 |
895 client.Reset(); | 883 client.Reset(); |
896 client.task_runner().RunPendingTasks(); // Run posted deadline. | 884 client.task_runner().RunPendingTasks(); // Run posted deadline. |
897 EXPECT_EQ(1, client.num_draws()); | 885 EXPECT_EQ(1, client.num_draws()); |
898 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); | 886 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
899 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); | 887 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); |
900 EXPECT_FALSE(scheduler->RedrawPending()); | 888 EXPECT_FALSE(scheduler->RedrawPending()); |
901 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 889 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
902 | 890 |
903 // If we get another DidManageTiles, we should not ManageTiles on the next | 891 // If we get another DidManageTiles, we should not ManageTiles on the next |
904 // frame. This verifies we don't alternate calling ManageTiles once and twice. | 892 // frame. This verifies we don't alternate calling ManageTiles once and twice. |
905 EXPECT_TRUE(scheduler->ManageTilesPending()); | 893 EXPECT_TRUE(scheduler->ManageTilesPending()); |
906 scheduler->DidManageTiles(); // An explicit ManageTiles. | 894 scheduler->DidManageTiles(); // An explicit ManageTiles. |
907 EXPECT_FALSE(scheduler->ManageTilesPending()); | 895 EXPECT_FALSE(scheduler->ManageTilesPending()); |
908 scheduler->SetNeedsManageTiles(); | 896 scheduler->SetNeedsManageTiles(); |
909 scheduler->SetNeedsRedraw(); | 897 scheduler->SetNeedsRedraw(); |
910 client.Reset(); | 898 client.Reset(); |
911 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 899 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
912 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 900 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
913 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); | |
914 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 901 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
915 | 902 |
916 EXPECT_TRUE(scheduler->ManageTilesPending()); | 903 EXPECT_TRUE(scheduler->ManageTilesPending()); |
917 | 904 |
918 client.Reset(); | 905 client.Reset(); |
919 client.task_runner().RunPendingTasks(); // Run posted deadline. | 906 client.task_runner().RunPendingTasks(); // Run posted deadline. |
920 EXPECT_EQ(1, client.num_draws()); | 907 EXPECT_EQ(1, client.num_draws()); |
921 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); | 908 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
922 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); | 909 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); |
923 EXPECT_FALSE(scheduler->RedrawPending()); | 910 EXPECT_FALSE(scheduler->RedrawPending()); |
924 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 911 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
925 | 912 |
926 // Next frame without DidManageTiles should ManageTiles with draw. | 913 // Next frame without DidManageTiles should ManageTiles with draw. |
927 scheduler->SetNeedsManageTiles(); | 914 scheduler->SetNeedsManageTiles(); |
928 scheduler->SetNeedsRedraw(); | 915 scheduler->SetNeedsRedraw(); |
929 client.Reset(); | 916 client.Reset(); |
930 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); | 917 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); |
931 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 918 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
932 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); | |
933 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 919 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
934 | 920 |
935 client.Reset(); | 921 client.Reset(); |
936 client.task_runner().RunPendingTasks(); // Run posted deadline. | 922 client.task_runner().RunPendingTasks(); // Run posted deadline. |
937 EXPECT_EQ(1, client.num_draws()); | 923 EXPECT_EQ(1, client.num_draws()); |
938 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); | 924 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); |
939 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); | 925 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); |
940 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), | 926 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), |
941 client.ActionIndex("ScheduledActionManageTiles")); | 927 client.ActionIndex("ScheduledActionManageTiles")); |
942 EXPECT_FALSE(scheduler->RedrawPending()); | 928 EXPECT_FALSE(scheduler->RedrawPending()); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 | 1164 |
1179 // NotifyReadyToCommit should trigger the commit. | 1165 // NotifyReadyToCommit should trigger the commit. |
1180 scheduler->NotifyBeginMainFrameStarted(); | 1166 scheduler->NotifyBeginMainFrameStarted(); |
1181 scheduler->NotifyReadyToCommit(); | 1167 scheduler->NotifyReadyToCommit(); |
1182 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 1168 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
1183 EXPECT_TRUE(client.needs_begin_frame()); | 1169 EXPECT_TRUE(client.needs_begin_frame()); |
1184 client.Reset(); | 1170 client.Reset(); |
1185 | 1171 |
1186 // BeginImplFrame should prepare the draw. | 1172 // BeginImplFrame should prepare the draw. |
1187 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. | 1173 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. |
1188 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 1174 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
1189 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); | |
1190 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1175 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
1191 EXPECT_TRUE(client.needs_begin_frame()); | 1176 EXPECT_TRUE(client.needs_begin_frame()); |
1192 client.Reset(); | 1177 client.Reset(); |
1193 | 1178 |
1194 // BeginImplFrame deadline should draw. | 1179 // BeginImplFrame deadline should draw. |
1195 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1180 client.task_runner().RunPendingTasks(); // Run posted deadline. |
1196 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); | 1181 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
1197 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1182 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
1198 EXPECT_TRUE(client.needs_begin_frame()); | 1183 EXPECT_TRUE(client.needs_begin_frame()); |
1199 client.Reset(); | 1184 client.Reset(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 | 1237 |
1253 // NotifyReadyToCommit should trigger the pending commit and draw. | 1238 // NotifyReadyToCommit should trigger the pending commit and draw. |
1254 scheduler->NotifyBeginMainFrameStarted(); | 1239 scheduler->NotifyBeginMainFrameStarted(); |
1255 scheduler->NotifyReadyToCommit(); | 1240 scheduler->NotifyReadyToCommit(); |
1256 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 1241 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
1257 EXPECT_TRUE(client.needs_begin_frame()); | 1242 EXPECT_TRUE(client.needs_begin_frame()); |
1258 client.Reset(); | 1243 client.Reset(); |
1259 | 1244 |
1260 // Swapping will put us into a swap throttled state. | 1245 // Swapping will put us into a swap throttled state. |
1261 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1246 client.task_runner().RunPendingTasks(); // Run posted deadline. |
1262 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); | 1247 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
1263 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); | |
1264 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1248 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
1265 EXPECT_TRUE(client.needs_begin_frame()); | 1249 EXPECT_TRUE(client.needs_begin_frame()); |
1266 client.Reset(); | 1250 client.Reset(); |
1267 | 1251 |
1268 // While swap throttled, BeginRetroFrames should trigger BeginImplFrames | 1252 // While swap throttled, BeginRetroFrames should trigger BeginImplFrames |
1269 // but not a BeginMainFrame or draw. | 1253 // but not a BeginMainFrame or draw. |
1270 scheduler->SetNeedsCommit(); | 1254 scheduler->SetNeedsCommit(); |
1271 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. | 1255 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. |
1272 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); | 1256 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); |
1273 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1257 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
(...skipping 11 matching lines...) Expand all Loading... |
1285 // Take us out of a swap throttled state. | 1269 // Take us out of a swap throttled state. |
1286 scheduler->DidSwapBuffersComplete(); | 1270 scheduler->DidSwapBuffersComplete(); |
1287 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); | 1271 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); |
1288 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1272 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
1289 EXPECT_TRUE(client.needs_begin_frame()); | 1273 EXPECT_TRUE(client.needs_begin_frame()); |
1290 client.Reset(); | 1274 client.Reset(); |
1291 | 1275 |
1292 // BeginImplFrame deadline should draw. | 1276 // BeginImplFrame deadline should draw. |
1293 scheduler->SetNeedsRedraw(); | 1277 scheduler->SetNeedsRedraw(); |
1294 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1278 client.task_runner().RunPendingTasks(); // Run posted deadline. |
1295 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); | 1279 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
1296 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); | |
1297 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1280 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
1298 EXPECT_TRUE(client.needs_begin_frame()); | 1281 EXPECT_TRUE(client.needs_begin_frame()); |
1299 client.Reset(); | 1282 client.Reset(); |
1300 } | 1283 } |
1301 | 1284 |
1302 void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled, | 1285 void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled, |
1303 bool throttle_frame_production) { | 1286 bool throttle_frame_production) { |
1304 FakeSchedulerClient client; | 1287 FakeSchedulerClient client; |
1305 SchedulerSettings scheduler_settings; | 1288 SchedulerSettings scheduler_settings; |
1306 scheduler_settings.begin_frame_scheduling_enabled = | 1289 scheduler_settings.begin_frame_scheduling_enabled = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 | 1321 |
1339 // NotifyReadyToCommit should trigger the commit. | 1322 // NotifyReadyToCommit should trigger the commit. |
1340 scheduler->NotifyBeginMainFrameStarted(); | 1323 scheduler->NotifyBeginMainFrameStarted(); |
1341 scheduler->NotifyReadyToCommit(); | 1324 scheduler->NotifyReadyToCommit(); |
1342 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 1325 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
1343 EXPECT_FALSE(client.needs_begin_frame()); | 1326 EXPECT_FALSE(client.needs_begin_frame()); |
1344 client.Reset(); | 1327 client.Reset(); |
1345 | 1328 |
1346 // BeginImplFrame should prepare the draw. | 1329 // BeginImplFrame should prepare the draw. |
1347 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. | 1330 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. |
1348 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 1331 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); |
1349 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2); | |
1350 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1332 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
1351 EXPECT_FALSE(client.needs_begin_frame()); | 1333 EXPECT_FALSE(client.needs_begin_frame()); |
1352 client.Reset(); | 1334 client.Reset(); |
1353 | 1335 |
1354 // BeginImplFrame deadline should draw. | 1336 // BeginImplFrame deadline should draw. |
1355 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1337 client.task_runner().RunPendingTasks(); // Run posted deadline. |
1356 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); | 1338 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
1357 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1339 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
1358 EXPECT_FALSE(client.needs_begin_frame()); | 1340 EXPECT_FALSE(client.needs_begin_frame()); |
1359 client.Reset(); | 1341 client.Reset(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 | 1410 |
1429 // NotifyReadyToCommit should trigger the pending commit and draw. | 1411 // NotifyReadyToCommit should trigger the pending commit and draw. |
1430 scheduler->NotifyBeginMainFrameStarted(); | 1412 scheduler->NotifyBeginMainFrameStarted(); |
1431 scheduler->NotifyReadyToCommit(); | 1413 scheduler->NotifyReadyToCommit(); |
1432 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); | 1414 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); |
1433 EXPECT_FALSE(client.needs_begin_frame()); | 1415 EXPECT_FALSE(client.needs_begin_frame()); |
1434 client.Reset(); | 1416 client.Reset(); |
1435 | 1417 |
1436 // Swapping will put us into a swap throttled state. | 1418 // Swapping will put us into a swap throttled state. |
1437 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1419 client.task_runner().RunPendingTasks(); // Run posted deadline. |
1438 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); | 1420 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
1439 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); | |
1440 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1421 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
1441 EXPECT_FALSE(client.needs_begin_frame()); | 1422 EXPECT_FALSE(client.needs_begin_frame()); |
1442 client.Reset(); | 1423 client.Reset(); |
1443 | 1424 |
1444 // While swap throttled, BeginFrames should trigger BeginImplFrames, | 1425 // While swap throttled, BeginFrames should trigger BeginImplFrames, |
1445 // but not a BeginMainFrame or draw. | 1426 // but not a BeginMainFrame or draw. |
1446 scheduler->SetNeedsCommit(); | 1427 scheduler->SetNeedsCommit(); |
1447 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. | 1428 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. |
1448 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); | 1429 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); |
1449 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1430 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
1450 EXPECT_FALSE(client.needs_begin_frame()); | 1431 EXPECT_FALSE(client.needs_begin_frame()); |
1451 client.Reset(); | 1432 client.Reset(); |
1452 | 1433 |
1453 // Take us out of a swap throttled state. | 1434 // Take us out of a swap throttled state. |
1454 scheduler->DidSwapBuffersComplete(); | 1435 scheduler->DidSwapBuffersComplete(); |
1455 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); | 1436 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); |
1456 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1437 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
1457 EXPECT_FALSE(client.needs_begin_frame()); | 1438 EXPECT_FALSE(client.needs_begin_frame()); |
1458 client.Reset(); | 1439 client.Reset(); |
1459 | 1440 |
1460 // BeginImplFrame deadline should draw. | 1441 // BeginImplFrame deadline should draw. |
1461 scheduler->SetNeedsRedraw(); | 1442 scheduler->SetNeedsRedraw(); |
1462 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1443 client.task_runner().RunPendingTasks(); // Run posted deadline. |
1463 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); | 1444 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); |
1464 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); | |
1465 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1445 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
1466 EXPECT_FALSE(client.needs_begin_frame()); | 1446 EXPECT_FALSE(client.needs_begin_frame()); |
1467 client.Reset(); | 1447 client.Reset(); |
1468 } | 1448 } |
1469 | 1449 |
1470 TEST(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { | 1450 TEST(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { |
1471 bool begin_frame_scheduling_enabled = false; | 1451 bool begin_frame_scheduling_enabled = false; |
1472 bool throttle_frame_production = true; | 1452 bool throttle_frame_production = true; |
1473 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, | 1453 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, |
1474 throttle_frame_production); | 1454 throttle_frame_production); |
1475 } | 1455 } |
1476 | 1456 |
1477 TEST(SchedulerTest, VSyncThrottlingDisabled_SwapThrottled) { | 1457 TEST(SchedulerTest, VSyncThrottlingDisabled_SwapThrottled) { |
1478 bool begin_frame_scheduling_enabled = true; | 1458 bool begin_frame_scheduling_enabled = true; |
1479 bool throttle_frame_production = false; | 1459 bool throttle_frame_production = false; |
1480 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, | 1460 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, |
1481 throttle_frame_production); | 1461 throttle_frame_production); |
1482 } | 1462 } |
1483 | 1463 |
1484 TEST(SchedulerTest, | 1464 TEST(SchedulerTest, |
1485 SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) { | 1465 SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) { |
1486 bool begin_frame_scheduling_enabled = false; | 1466 bool begin_frame_scheduling_enabled = false; |
1487 bool throttle_frame_production = false; | 1467 bool throttle_frame_production = false; |
1488 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, | 1468 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, |
1489 throttle_frame_production); | 1469 throttle_frame_production); |
1490 } | 1470 } |
1491 | 1471 |
1492 } // namespace | 1472 } // namespace |
1493 } // namespace cc | 1473 } // namespace cc |
OLD | NEW |