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

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: Addressed comments and rebased. Created 6 years, 8 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 needs_begin_impl_frame_ = enable; 100 needs_begin_impl_frame_ = enable;
101 } 101 }
102 virtual void WillBeginImplFrame(const BeginFrameArgs& args) OVERRIDE { 102 virtual void WillBeginImplFrame(const BeginFrameArgs& args) OVERRIDE {
103 actions_.push_back("WillBeginImplFrame"); 103 actions_.push_back("WillBeginImplFrame");
104 states_.push_back(scheduler_->StateAsValue().release()); 104 states_.push_back(scheduler_->StateAsValue().release());
105 } 105 }
106 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE { 106 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE {
107 actions_.push_back("ScheduledActionSendBeginMainFrame"); 107 actions_.push_back("ScheduledActionSendBeginMainFrame");
108 states_.push_back(scheduler_->StateAsValue().release()); 108 states_.push_back(scheduler_->StateAsValue().release());
109 } 109 }
110 virtual void ScheduledActionAnimate() OVERRIDE {
111 actions_.push_back("ScheduledActionAnimate");
112 states_.push_back(scheduler_->StateAsValue().release());
113 }
110 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() 114 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible()
111 OVERRIDE { 115 OVERRIDE {
112 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); 116 actions_.push_back("ScheduledActionDrawAndSwapIfPossible");
113 states_.push_back(scheduler_->StateAsValue().release()); 117 states_.push_back(scheduler_->StateAsValue().release());
114 num_draws_++; 118 num_draws_++;
115 bool did_readback = false; 119 bool did_readback = false;
116 DrawSwapReadbackResult::DrawResult result = 120 DrawSwapReadbackResult::DrawResult result =
117 draw_will_happen_ 121 draw_will_happen_
118 ? DrawSwapReadbackResult::DRAW_SUCCESS 122 ? DrawSwapReadbackResult::DRAW_SUCCESS
119 : DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; 123 : DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 264
261 // NotifyReadyToCommit should trigger the commit. 265 // NotifyReadyToCommit should trigger the commit.
262 scheduler->NotifyBeginMainFrameStarted(); 266 scheduler->NotifyBeginMainFrameStarted();
263 scheduler->NotifyReadyToCommit(); 267 scheduler->NotifyReadyToCommit();
264 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 268 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
265 EXPECT_TRUE(client.needs_begin_impl_frame()); 269 EXPECT_TRUE(client.needs_begin_impl_frame());
266 client.Reset(); 270 client.Reset();
267 271
268 // BeginImplFrame should prepare the draw. 272 // BeginImplFrame should prepare the draw.
269 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 273 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
270 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 274 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
275 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
271 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 276 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
272 EXPECT_TRUE(client.needs_begin_impl_frame()); 277 EXPECT_TRUE(client.needs_begin_impl_frame());
273 client.Reset(); 278 client.Reset();
274 279
275 // BeginImplFrame deadline should draw. 280 // BeginImplFrame deadline should draw.
276 client.task_runner().RunPendingTasks(); // Run posted deadline. 281 client.task_runner().RunPendingTasks(); // Run posted deadline.
277 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 282 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
278 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); 283 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2);
279 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 284 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
280 EXPECT_TRUE(client.needs_begin_impl_frame()); 285 EXPECT_TRUE(client.needs_begin_impl_frame());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 EXPECT_EQ(client.num_actions_(), 0); 328 EXPECT_EQ(client.num_actions_(), 0);
324 client.Reset(); 329 client.Reset();
325 330
326 // Finish the first commit. 331 // Finish the first commit.
327 scheduler->NotifyBeginMainFrameStarted(); 332 scheduler->NotifyBeginMainFrameStarted();
328 scheduler->NotifyReadyToCommit(); 333 scheduler->NotifyReadyToCommit();
329 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 334 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
330 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 335 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
331 client.Reset(); 336 client.Reset();
332 client.task_runner().RunPendingTasks(); // Run posted deadline. 337 client.task_runner().RunPendingTasks(); // Run posted deadline.
333 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 338 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 3);
334 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); 339 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 3);
340 EXPECT_ACTION("SetNeedsBeginFrame", client, 2, 3);
335 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 341 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
336 342
337 // Because we just swapped, the Scheduler should also request the next 343 // Because we just swapped, the Scheduler should also request the next
338 // BeginImplFrame from the OutputSurface. 344 // BeginImplFrame from the OutputSurface.
339 EXPECT_TRUE(client.needs_begin_impl_frame()); 345 EXPECT_TRUE(client.needs_begin_impl_frame());
340 client.Reset(); 346 client.Reset();
341 // Since another commit is needed, the next BeginImplFrame should initiate 347 // Since another commit is needed, the next BeginImplFrame should initiate
342 // the second commit. 348 // the second commit.
343 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 349 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
344 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); 350 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
345 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); 351 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
346 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 352 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
347 client.Reset(); 353 client.Reset();
348 354
349 // Finishing the commit before the deadline should post a new deadline task 355 // Finishing the commit before the deadline should post a new deadline task
350 // to trigger the deadline early. 356 // to trigger the deadline early.
351 scheduler->NotifyBeginMainFrameStarted(); 357 scheduler->NotifyBeginMainFrameStarted();
352 scheduler->NotifyReadyToCommit(); 358 scheduler->NotifyReadyToCommit();
353 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 359 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
354 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 360 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
355 client.Reset(); 361 client.Reset();
356 client.task_runner().RunPendingTasks(); // Run posted deadline. 362 client.task_runner().RunPendingTasks(); // Run posted deadline.
357 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 363 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 3);
358 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); 364 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 3);
365 EXPECT_ACTION("SetNeedsBeginFrame", client, 2, 3);
359 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 366 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
360 EXPECT_TRUE(client.needs_begin_impl_frame()); 367 EXPECT_TRUE(client.needs_begin_impl_frame());
361 client.Reset(); 368 client.Reset();
362 369
363 // On the next BeginImplFrame, verify we go back to a quiescent state and 370 // On the next BeginImplFrame, verify we go back to a quiescent state and
364 // no longer request BeginImplFrames. 371 // no longer request BeginImplFrames.
365 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 372 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
366 client.task_runner().RunPendingTasks(); // Run posted deadline. 373 client.task_runner().RunPendingTasks(); // Run posted deadline.
367 EXPECT_FALSE(client.needs_begin_impl_frame()); 374 EXPECT_FALSE(client.needs_begin_impl_frame());
368 client.Reset(); 375 client.Reset();
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 EXPECT_TRUE(scheduler->ManageTilesPending()); 722 EXPECT_TRUE(scheduler->ManageTilesPending());
716 EXPECT_TRUE(client.needs_begin_impl_frame()); 723 EXPECT_TRUE(client.needs_begin_impl_frame());
717 EXPECT_EQ(0, client.num_draws()); 724 EXPECT_EQ(0, client.num_draws());
718 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 725 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
719 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 726 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
720 727
721 // We have no immediate actions to perform, so the BeginImplFrame should post 728 // We have no immediate actions to perform, so the BeginImplFrame should post
722 // the deadline task. 729 // the deadline task.
723 client.Reset(); 730 client.Reset();
724 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 731 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
725 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 732 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
733 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
726 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 734 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
727 735
728 // On the deadline, he actions should have occured in the right order. 736 // On the deadline, he actions should have occured in the right order.
729 client.Reset(); 737 client.Reset();
730 client.task_runner().RunPendingTasks(); // Run posted deadline. 738 client.task_runner().RunPendingTasks(); // Run posted deadline.
731 EXPECT_EQ(1, client.num_draws()); 739 EXPECT_EQ(1, client.num_draws());
732 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 740 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
733 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 741 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
734 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 742 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
735 client.ActionIndex("ScheduledActionManageTiles")); 743 client.ActionIndex("ScheduledActionManageTiles"));
736 EXPECT_FALSE(scheduler->RedrawPending()); 744 EXPECT_FALSE(scheduler->RedrawPending());
737 EXPECT_FALSE(scheduler->ManageTilesPending()); 745 EXPECT_FALSE(scheduler->ManageTilesPending());
738 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 746 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
739 747
740 // Request a draw. We don't need a ManageTiles yet. 748 // Request a draw. We don't need a ManageTiles yet.
741 client.Reset(); 749 client.Reset();
742 scheduler->SetNeedsRedraw(); 750 scheduler->SetNeedsRedraw();
743 EXPECT_TRUE(scheduler->RedrawPending()); 751 EXPECT_TRUE(scheduler->RedrawPending());
744 EXPECT_FALSE(scheduler->ManageTilesPending()); 752 EXPECT_FALSE(scheduler->ManageTilesPending());
745 EXPECT_TRUE(client.needs_begin_impl_frame()); 753 EXPECT_TRUE(client.needs_begin_impl_frame());
746 EXPECT_EQ(0, client.num_draws()); 754 EXPECT_EQ(0, client.num_draws());
747 755
748 // We have no immediate actions to perform, so the BeginImplFrame should post 756 // We have no immediate actions to perform, so the BeginImplFrame should post
749 // the deadline task. 757 // the deadline task.
750 client.Reset(); 758 client.Reset();
751 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 759 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
752 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 760 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
761 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
753 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 762 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
754 763
755 // Draw. The draw will trigger SetNeedsManageTiles, and 764 // Draw. The draw will trigger SetNeedsManageTiles, and
756 // then the ManageTiles action will be triggered after the Draw. 765 // then the ManageTiles action will be triggered after the Draw.
757 // Afterwards, neither a draw nor ManageTiles are pending. 766 // Afterwards, neither a draw nor ManageTiles are pending.
758 client.Reset(); 767 client.Reset();
759 client.task_runner().RunPendingTasks(); // Run posted deadline. 768 client.task_runner().RunPendingTasks(); // Run posted deadline.
760 EXPECT_EQ(1, client.num_draws()); 769 EXPECT_EQ(1, client.num_draws());
761 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 770 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
762 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 771 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 scheduler->SetCanStart(); 817 scheduler->SetCanStart();
809 scheduler->SetVisible(true); 818 scheduler->SetVisible(true);
810 scheduler->SetCanDraw(true); 819 scheduler->SetCanDraw(true);
811 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 820 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
812 821
813 // If DidManageTiles during a frame, then ManageTiles should not occur again. 822 // If DidManageTiles during a frame, then ManageTiles should not occur again.
814 scheduler->SetNeedsManageTiles(); 823 scheduler->SetNeedsManageTiles();
815 scheduler->SetNeedsRedraw(); 824 scheduler->SetNeedsRedraw();
816 client.Reset(); 825 client.Reset();
817 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 826 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
818 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 827 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
828 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
819 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 829 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
820 830
821 EXPECT_TRUE(scheduler->ManageTilesPending()); 831 EXPECT_TRUE(scheduler->ManageTilesPending());
822 scheduler->DidManageTiles(); // An explicit ManageTiles. 832 scheduler->DidManageTiles(); // An explicit ManageTiles.
823 EXPECT_FALSE(scheduler->ManageTilesPending()); 833 EXPECT_FALSE(scheduler->ManageTilesPending());
824 834
825 client.Reset(); 835 client.Reset();
826 client.task_runner().RunPendingTasks(); // Run posted deadline. 836 client.task_runner().RunPendingTasks(); // Run posted deadline.
827 EXPECT_EQ(1, client.num_draws()); 837 EXPECT_EQ(1, client.num_draws());
828 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 838 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
829 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 839 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
830 EXPECT_FALSE(scheduler->RedrawPending()); 840 EXPECT_FALSE(scheduler->RedrawPending());
831 EXPECT_FALSE(scheduler->ManageTilesPending()); 841 EXPECT_FALSE(scheduler->ManageTilesPending());
832 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 842 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
833 843
834 // Next frame without DidManageTiles should ManageTiles with draw. 844 // Next frame without DidManageTiles should ManageTiles with draw.
835 scheduler->SetNeedsManageTiles(); 845 scheduler->SetNeedsManageTiles();
836 scheduler->SetNeedsRedraw(); 846 scheduler->SetNeedsRedraw();
837 client.Reset(); 847 client.Reset();
838 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 848 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
839 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 849 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
850 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
840 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 851 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
841 852
842 client.Reset(); 853 client.Reset();
843 client.task_runner().RunPendingTasks(); // Run posted deadline. 854 client.task_runner().RunPendingTasks(); // Run posted deadline.
844 EXPECT_EQ(1, client.num_draws()); 855 EXPECT_EQ(1, client.num_draws());
845 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 856 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
846 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 857 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
847 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 858 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
848 client.ActionIndex("ScheduledActionManageTiles")); 859 client.ActionIndex("ScheduledActionManageTiles"));
849 EXPECT_FALSE(scheduler->RedrawPending()); 860 EXPECT_FALSE(scheduler->RedrawPending());
850 EXPECT_FALSE(scheduler->ManageTilesPending()); 861 EXPECT_FALSE(scheduler->ManageTilesPending());
851 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 862 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
852 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles 863 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles
853 864
854 // If we get another DidManageTiles within the same frame, we should 865 // If we get another DidManageTiles within the same frame, we should
855 // not ManageTiles on the next frame. 866 // not ManageTiles on the next frame.
856 scheduler->DidManageTiles(); // An explicit ManageTiles. 867 scheduler->DidManageTiles(); // An explicit ManageTiles.
857 scheduler->SetNeedsManageTiles(); 868 scheduler->SetNeedsManageTiles();
858 scheduler->SetNeedsRedraw(); 869 scheduler->SetNeedsRedraw();
859 client.Reset(); 870 client.Reset();
860 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 871 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
861 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 872 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
873 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
862 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 874 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
863 875
864 EXPECT_TRUE(scheduler->ManageTilesPending()); 876 EXPECT_TRUE(scheduler->ManageTilesPending());
865 877
866 client.Reset(); 878 client.Reset();
867 client.task_runner().RunPendingTasks(); // Run posted deadline. 879 client.task_runner().RunPendingTasks(); // Run posted deadline.
868 EXPECT_EQ(1, client.num_draws()); 880 EXPECT_EQ(1, client.num_draws());
869 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 881 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
870 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 882 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
871 EXPECT_FALSE(scheduler->RedrawPending()); 883 EXPECT_FALSE(scheduler->RedrawPending());
872 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 884 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
873 885
874 // If we get another DidManageTiles, we should not ManageTiles on the next 886 // If we get another DidManageTiles, we should not ManageTiles on the next
875 // frame. This verifies we don't alternate calling ManageTiles once and twice. 887 // frame. This verifies we don't alternate calling ManageTiles once and twice.
876 EXPECT_TRUE(scheduler->ManageTilesPending()); 888 EXPECT_TRUE(scheduler->ManageTilesPending());
877 scheduler->DidManageTiles(); // An explicit ManageTiles. 889 scheduler->DidManageTiles(); // An explicit ManageTiles.
878 EXPECT_FALSE(scheduler->ManageTilesPending()); 890 EXPECT_FALSE(scheduler->ManageTilesPending());
879 scheduler->SetNeedsManageTiles(); 891 scheduler->SetNeedsManageTiles();
880 scheduler->SetNeedsRedraw(); 892 scheduler->SetNeedsRedraw();
881 client.Reset(); 893 client.Reset();
882 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 894 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
883 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 895 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
896 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
884 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 897 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
885 898
886 EXPECT_TRUE(scheduler->ManageTilesPending()); 899 EXPECT_TRUE(scheduler->ManageTilesPending());
887 900
888 client.Reset(); 901 client.Reset();
889 client.task_runner().RunPendingTasks(); // Run posted deadline. 902 client.task_runner().RunPendingTasks(); // Run posted deadline.
890 EXPECT_EQ(1, client.num_draws()); 903 EXPECT_EQ(1, client.num_draws());
891 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 904 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
892 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 905 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
893 EXPECT_FALSE(scheduler->RedrawPending()); 906 EXPECT_FALSE(scheduler->RedrawPending());
894 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 907 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
895 908
896 // Next frame without DidManageTiles should ManageTiles with draw. 909 // Next frame without DidManageTiles should ManageTiles with draw.
897 scheduler->SetNeedsManageTiles(); 910 scheduler->SetNeedsManageTiles();
898 scheduler->SetNeedsRedraw(); 911 scheduler->SetNeedsRedraw();
899 client.Reset(); 912 client.Reset();
900 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 913 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
901 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 914 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
915 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
902 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 916 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
903 917
904 client.Reset(); 918 client.Reset();
905 client.task_runner().RunPendingTasks(); // Run posted deadline. 919 client.task_runner().RunPendingTasks(); // Run posted deadline.
906 EXPECT_EQ(1, client.num_draws()); 920 EXPECT_EQ(1, client.num_draws());
907 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 921 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
908 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 922 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
909 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 923 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
910 client.ActionIndex("ScheduledActionManageTiles")); 924 client.ActionIndex("ScheduledActionManageTiles"));
911 EXPECT_FALSE(scheduler->RedrawPending()); 925 EXPECT_FALSE(scheduler->RedrawPending());
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 scheduler->SetNeedsRedraw(); 1065 scheduler->SetNeedsRedraw();
1052 1066
1053 BeginFrameArgs frame_args = BeginFrameArgs::CreateForTesting(); 1067 BeginFrameArgs frame_args = BeginFrameArgs::CreateForTesting();
1054 frame_args.interval = base::TimeDelta::FromMilliseconds(1000); 1068 frame_args.interval = base::TimeDelta::FromMilliseconds(1000);
1055 scheduler->BeginFrame(frame_args); 1069 scheduler->BeginFrame(frame_args);
1056 1070
1057 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1071 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1058 client.task_runner().RunPendingTasks(); // Run posted deadline. 1072 client.task_runner().RunPendingTasks(); // Run posted deadline.
1059 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1073 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1060 1074
1061 // At this point, we've drawn a frame. Start another commit, but hold off on 1075 // At this point, we've drawn a frame. Start another commit, but hold off on
1062 // the NotifyReadyToCommit for now. 1076 // the NotifyReadyToCommit for now.
1063 EXPECT_FALSE(scheduler->CommitPending()); 1077 EXPECT_FALSE(scheduler->CommitPending());
1064 scheduler->SetNeedsCommit(); 1078 scheduler->SetNeedsCommit();
1065 scheduler->BeginFrame(frame_args); 1079 scheduler->BeginFrame(frame_args);
1066 EXPECT_TRUE(scheduler->CommitPending()); 1080 EXPECT_TRUE(scheduler->CommitPending());
1067 1081
1068 // Spin the event loop a few times and make sure we get more 1082 // Spin the event loop a few times and make sure we get more
1069 // DidAnticipateDrawTimeChange calls every time. 1083 // DidAnticipateDrawTimeChange calls every time.
1070 int actions_so_far = client.num_actions_(); 1084 int actions_so_far = client.num_actions_();
1071 1085
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 1153
1140 // NotifyReadyToCommit should trigger the commit. 1154 // NotifyReadyToCommit should trigger the commit.
1141 scheduler->NotifyBeginMainFrameStarted(); 1155 scheduler->NotifyBeginMainFrameStarted();
1142 scheduler->NotifyReadyToCommit(); 1156 scheduler->NotifyReadyToCommit();
1143 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 1157 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
1144 EXPECT_TRUE(client.needs_begin_impl_frame()); 1158 EXPECT_TRUE(client.needs_begin_impl_frame());
1145 client.Reset(); 1159 client.Reset();
1146 1160
1147 // BeginImplFrame should prepare the draw. 1161 // BeginImplFrame should prepare the draw.
1148 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. 1162 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame.
1149 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 1163 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2);
1164 EXPECT_ACTION("ScheduledActionAnimate", client, 1, 2);
1150 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1165 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1151 EXPECT_TRUE(client.needs_begin_impl_frame()); 1166 EXPECT_TRUE(client.needs_begin_impl_frame());
1152 client.Reset(); 1167 client.Reset();
1153 1168
1154 // BeginImplFrame deadline should draw. 1169 // BeginImplFrame deadline should draw.
1155 client.task_runner().RunPendingTasks(); // Run posted deadline. 1170 client.task_runner().RunPendingTasks(); // Run posted deadline.
1156 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 1171 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
1157 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2); 1172 EXPECT_ACTION("SetNeedsBeginFrame", client, 1, 2);
1158 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1173 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1159 EXPECT_TRUE(client.needs_begin_impl_frame()); 1174 EXPECT_TRUE(client.needs_begin_impl_frame());
1160 client.Reset(); 1175 client.Reset();
1161 1176
1162 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) 1177 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
1163 // to avoid excessive toggles. 1178 // to avoid excessive toggles.
1164 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. 1179 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame.
1165 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 1180 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
1166 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1181 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1167 client.Reset(); 1182 client.Reset();
1168 1183
1169 client.task_runner().RunPendingTasks(); // Run posted deadline. 1184 client.task_runner().RunPendingTasks(); // Run posted deadline.
1170 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client); 1185 EXPECT_SINGLE_ACTION("SetNeedsBeginFrame", client);
1171 EXPECT_FALSE(client.needs_begin_impl_frame()); 1186 EXPECT_FALSE(client.needs_begin_impl_frame());
1172 client.Reset(); 1187 client.Reset();
1173 } 1188 }
1174 1189
1175 } // namespace 1190 } // namespace
1176 } // namespace cc 1191 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698