Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: cc/scheduler/scheduler_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698