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

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

Issue 1192663005: cc: Measure compositor timing with finer granularity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@modeTimingHistory3
Patch Set: don't reset timing history Created 5 years, 5 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
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | cc/test/fake_layer_tree_host_impl_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4
5 #include "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 if (automatic_swap_ack_) 121 if (automatic_swap_ack_)
122 scheduler_->DidSwapBuffersComplete(); 122 scheduler_->DidSwapBuffersComplete();
123 } 123 }
124 return result; 124 return result;
125 } 125 }
126 DrawResult ScheduledActionDrawAndSwapForced() override { 126 DrawResult ScheduledActionDrawAndSwapForced() override {
127 PushAction("ScheduledActionDrawAndSwapForced"); 127 PushAction("ScheduledActionDrawAndSwapForced");
128 return DRAW_SUCCESS; 128 return DRAW_SUCCESS;
129 } 129 }
130 void ScheduledActionCommit() override { PushAction("ScheduledActionCommit"); } 130 void ScheduledActionCommit() override {
131 PushAction("ScheduledActionCommit");
132 scheduler_->DidCommit();
133 }
131 void ScheduledActionActivateSyncTree() override { 134 void ScheduledActionActivateSyncTree() override {
132 PushAction("ScheduledActionActivateSyncTree"); 135 PushAction("ScheduledActionActivateSyncTree");
133 } 136 }
134 void ScheduledActionBeginOutputSurfaceCreation() override { 137 void ScheduledActionBeginOutputSurfaceCreation() override {
135 PushAction("ScheduledActionBeginOutputSurfaceCreation"); 138 PushAction("ScheduledActionBeginOutputSurfaceCreation");
136 } 139 }
137 void ScheduledActionPrepareTiles() override { 140 void ScheduledActionPrepareTiles() override {
138 PushAction("ScheduledActionPrepareTiles"); 141 PushAction("ScheduledActionPrepareTiles");
142 scheduler_->WillPrepareTiles();
143 scheduler_->DidPrepareTiles();
139 } 144 }
140 void ScheduledActionInvalidateOutputSurface() override { 145 void ScheduledActionInvalidateOutputSurface() override {
141 actions_.push_back("ScheduledActionInvalidateOutputSurface"); 146 actions_.push_back("ScheduledActionInvalidateOutputSurface");
142 states_.push_back(scheduler_->AsValue()); 147 states_.push_back(scheduler_->AsValue());
143 } 148 }
144 149
145 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { 150 void SendBeginFramesToChildren(const BeginFrameArgs& args) override {
146 begin_frame_args_sent_to_children_ = args; 151 begin_frame_args_sent_to_children_ = args;
147 } 152 }
148 153
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 448
444 client_->Reset(); 449 client_->Reset();
445 EXPECT_SCOPED(AdvanceFrame()); 450 EXPECT_SCOPED(AdvanceFrame());
446 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); 451 EXPECT_TRUE(client_->begin_frame_is_sent_to_children());
447 } 452 }
448 453
449 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) { 454 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) {
450 // Set up client with specified estimates. 455 // Set up client with specified estimates.
451 scheduler_settings_.use_external_begin_frame_source = true; 456 scheduler_settings_.use_external_begin_frame_source = true;
452 SetUpScheduler(true); 457 SetUpScheduler(true);
458
459 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
460 base::TimeDelta::FromMilliseconds(2));
461 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
462 base::TimeDelta::FromMilliseconds(4));
453 fake_compositor_timing_history_->SetDrawDurationEstimate( 463 fake_compositor_timing_history_->SetDrawDurationEstimate(
454 base::TimeDelta::FromMilliseconds(1)); 464 base::TimeDelta::FromMilliseconds(1));
455 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
456 base::TimeDelta::FromMilliseconds(2));
457 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate(
458 base::TimeDelta::FromMilliseconds(4));
459 465
460 EXPECT_FALSE(client_->needs_begin_frames()); 466 EXPECT_FALSE(client_->needs_begin_frames());
461 scheduler_->SetChildrenNeedBeginFrames(true); 467 scheduler_->SetChildrenNeedBeginFrames(true);
462 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); 468 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_);
463 EXPECT_TRUE(client_->needs_begin_frames()); 469 EXPECT_TRUE(client_->needs_begin_frames());
464 470
465 client_->Reset(); 471 client_->Reset();
466 472
467 BeginFrameArgs frame_args = 473 BeginFrameArgs frame_args =
468 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); 474 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 task_runner().RunPendingTasks(); // Run posted deadline. 709 task_runner().RunPendingTasks(); // Run posted deadline.
704 EXPECT_FALSE(client_->needs_begin_frames()); 710 EXPECT_FALSE(client_->needs_begin_frames());
705 client_->Reset(); 711 client_->Reset();
706 } 712 }
707 713
708 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient { 714 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient {
709 public: 715 public:
710 SchedulerClientThatsetNeedsDrawInsideDraw() 716 SchedulerClientThatsetNeedsDrawInsideDraw()
711 : FakeSchedulerClient(), request_redraws_(false) {} 717 : FakeSchedulerClient(), request_redraws_(false) {}
712 718
713 void ScheduledActionSendBeginMainFrame() override {}
714
715 void SetRequestRedrawsInsideDraw(bool enable) { request_redraws_ = enable; } 719 void SetRequestRedrawsInsideDraw(bool enable) { request_redraws_ = enable; }
716 720
717 DrawResult ScheduledActionDrawAndSwapIfPossible() override { 721 DrawResult ScheduledActionDrawAndSwapIfPossible() override {
718 // Only SetNeedsRedraw the first time this is called 722 // Only SetNeedsRedraw the first time this is called
719 if (request_redraws_) { 723 if (request_redraws_) {
720 scheduler_->SetNeedsRedraw(); 724 scheduler_->SetNeedsRedraw();
721 } 725 }
722 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 726 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
723 } 727 }
724 728
725 DrawResult ScheduledActionDrawAndSwapForced() override { 729 DrawResult ScheduledActionDrawAndSwapForced() override {
726 NOTREACHED(); 730 NOTREACHED();
727 return DRAW_SUCCESS; 731 return DRAW_SUCCESS;
728 } 732 }
729 733
730 void ScheduledActionCommit() override {}
731
732 private: 734 private:
733 bool request_redraws_; 735 bool request_redraws_;
734 }; 736 };
735 737
736 // Tests for two different situations: 738 // Tests for two different situations:
737 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside 739 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside
738 // a ScheduledActionDrawAndSwap 740 // a ScheduledActionDrawAndSwap
739 // 2. the scheduler drawing twice inside a single tick 741 // 2. the scheduler drawing twice inside a single tick
740 TEST_F(SchedulerTest, RequestRedrawInsideDraw) { 742 TEST_F(SchedulerTest, RequestRedrawInsideDraw) {
741 SchedulerClientThatsetNeedsDrawInsideDraw* client = 743 SchedulerClientThatsetNeedsDrawInsideDraw* client =
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 EXPECT_TRUE(scheduler_->CommitPending()); 818 EXPECT_TRUE(scheduler_->CommitPending());
817 EXPECT_FALSE(scheduler_->RedrawPending()); 819 EXPECT_FALSE(scheduler_->RedrawPending());
818 EXPECT_TRUE(client->needs_begin_frames()); 820 EXPECT_TRUE(client->needs_begin_frames());
819 } 821 }
820 822
821 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient { 823 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient {
822 public: 824 public:
823 SchedulerClientThatSetNeedsCommitInsideDraw() 825 SchedulerClientThatSetNeedsCommitInsideDraw()
824 : set_needs_commit_on_next_draw_(false) {} 826 : set_needs_commit_on_next_draw_(false) {}
825 827
826 void ScheduledActionSendBeginMainFrame() override {}
827 DrawResult ScheduledActionDrawAndSwapIfPossible() override { 828 DrawResult ScheduledActionDrawAndSwapIfPossible() override {
828 // Only SetNeedsCommit the first time this is called 829 // Only SetNeedsCommit the first time this is called
829 if (set_needs_commit_on_next_draw_) { 830 if (set_needs_commit_on_next_draw_) {
830 scheduler_->SetNeedsCommit(); 831 scheduler_->SetNeedsCommit();
831 set_needs_commit_on_next_draw_ = false; 832 set_needs_commit_on_next_draw_ = false;
832 } 833 }
833 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 834 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
834 } 835 }
835 836
836 DrawResult ScheduledActionDrawAndSwapForced() override { 837 DrawResult ScheduledActionDrawAndSwapForced() override {
837 NOTREACHED(); 838 NOTREACHED();
838 return DRAW_SUCCESS; 839 return DRAW_SUCCESS;
839 } 840 }
840 841
841 void ScheduledActionCommit() override {}
842
843 void SetNeedsCommitOnNextDraw() { set_needs_commit_on_next_draw_ = true; } 842 void SetNeedsCommitOnNextDraw() { set_needs_commit_on_next_draw_ = true; }
844 843
845 private: 844 private:
846 bool set_needs_commit_on_next_draw_; 845 bool set_needs_commit_on_next_draw_;
847 }; 846 };
848 847
849 // Tests for the scheduler infinite-looping on SetNeedsCommit requests that 848 // Tests for the scheduler infinite-looping on SetNeedsCommit requests that
850 // happen inside a ScheduledActionDrawAndSwap 849 // happen inside a ScheduledActionDrawAndSwap
851 TEST_F(SchedulerTest, RequestCommitInsideDraw) { 850 TEST_F(SchedulerTest, RequestCommitInsideDraw) {
852 SchedulerClientThatSetNeedsCommitInsideDraw* client = 851 SchedulerClientThatSetNeedsCommitInsideDraw* client =
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 // again. 1083 // again.
1085 scheduler_->SetNeedsPrepareTiles(); 1084 scheduler_->SetNeedsPrepareTiles();
1086 scheduler_->SetNeedsRedraw(); 1085 scheduler_->SetNeedsRedraw();
1087 client_->Reset(); 1086 client_->Reset();
1088 EXPECT_SCOPED(AdvanceFrame()); 1087 EXPECT_SCOPED(AdvanceFrame());
1089 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 1088 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
1090 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); 1089 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2);
1091 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1090 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1092 1091
1093 EXPECT_TRUE(scheduler_->PrepareTilesPending()); 1092 EXPECT_TRUE(scheduler_->PrepareTilesPending());
1093 scheduler_->WillPrepareTiles();
1094 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. 1094 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles.
1095 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 1095 EXPECT_FALSE(scheduler_->PrepareTilesPending());
1096 1096
1097 client_->Reset(); 1097 client_->Reset();
1098 task_runner().RunPendingTasks(); // Run posted deadline. 1098 task_runner().RunPendingTasks(); // Run posted deadline.
1099 EXPECT_EQ(1, client_->num_draws()); 1099 EXPECT_EQ(1, client_->num_draws());
1100 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); 1100 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible"));
1101 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles")); 1101 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles"));
1102 EXPECT_FALSE(scheduler_->RedrawPending()); 1102 EXPECT_FALSE(scheduler_->RedrawPending());
1103 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 1103 EXPECT_FALSE(scheduler_->PrepareTilesPending());
(...skipping 11 matching lines...) Expand all
1115 client_->Reset(); 1115 client_->Reset();
1116 task_runner().RunPendingTasks(); // Run posted deadline. 1116 task_runner().RunPendingTasks(); // Run posted deadline.
1117 EXPECT_EQ(1, client_->num_draws()); 1117 EXPECT_EQ(1, client_->num_draws());
1118 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); 1118 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible"));
1119 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles")); 1119 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles"));
1120 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 1120 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
1121 client_->ActionIndex("ScheduledActionPrepareTiles")); 1121 client_->ActionIndex("ScheduledActionPrepareTiles"));
1122 EXPECT_FALSE(scheduler_->RedrawPending()); 1122 EXPECT_FALSE(scheduler_->RedrawPending());
1123 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 1123 EXPECT_FALSE(scheduler_->PrepareTilesPending());
1124 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); 1124 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending());
1125 scheduler_->DidPrepareTiles(); // Corresponds to ScheduledActionPrepareTiles
1126 1125
1127 // If we get another DidPrepareTiles within the same frame, we should 1126 // If we get another DidPrepareTiles within the same frame, we should
1128 // not PrepareTiles on the next frame. 1127 // not PrepareTiles on the next frame.
1128 scheduler_->WillPrepareTiles();
1129 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. 1129 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles.
1130 scheduler_->SetNeedsPrepareTiles(); 1130 scheduler_->SetNeedsPrepareTiles();
1131 scheduler_->SetNeedsRedraw(); 1131 scheduler_->SetNeedsRedraw();
1132 client_->Reset(); 1132 client_->Reset();
1133 EXPECT_SCOPED(AdvanceFrame()); 1133 EXPECT_SCOPED(AdvanceFrame());
1134 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 1134 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
1135 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); 1135 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2);
1136 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1136 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1137 1137
1138 EXPECT_TRUE(scheduler_->PrepareTilesPending()); 1138 EXPECT_TRUE(scheduler_->PrepareTilesPending());
1139 1139
1140 client_->Reset(); 1140 client_->Reset();
1141 task_runner().RunPendingTasks(); // Run posted deadline. 1141 task_runner().RunPendingTasks(); // Run posted deadline.
1142 EXPECT_EQ(1, client_->num_draws()); 1142 EXPECT_EQ(1, client_->num_draws());
1143 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); 1143 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible"));
1144 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles")); 1144 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles"));
1145 EXPECT_FALSE(scheduler_->RedrawPending()); 1145 EXPECT_FALSE(scheduler_->RedrawPending());
1146 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); 1146 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending());
1147 1147
1148 // If we get another DidPrepareTiles, we should not PrepareTiles on the next 1148 // If we get another DidPrepareTiles, we should not PrepareTiles on the next
1149 // frame. This verifies we don't alternate calling PrepareTiles once and 1149 // frame. This verifies we don't alternate calling PrepareTiles once and
1150 // twice. 1150 // twice.
1151 EXPECT_TRUE(scheduler_->PrepareTilesPending()); 1151 EXPECT_TRUE(scheduler_->PrepareTilesPending());
1152 scheduler_->WillPrepareTiles();
1152 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. 1153 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles.
1153 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 1154 EXPECT_FALSE(scheduler_->PrepareTilesPending());
1154 scheduler_->SetNeedsPrepareTiles(); 1155 scheduler_->SetNeedsPrepareTiles();
1155 scheduler_->SetNeedsRedraw(); 1156 scheduler_->SetNeedsRedraw();
1156 client_->Reset(); 1157 client_->Reset();
1157 EXPECT_SCOPED(AdvanceFrame()); 1158 EXPECT_SCOPED(AdvanceFrame());
1158 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 1159 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
1159 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); 1160 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2);
1160 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1161 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1161 1162
(...skipping 19 matching lines...) Expand all
1181 client_->Reset(); 1182 client_->Reset();
1182 task_runner().RunPendingTasks(); // Run posted deadline. 1183 task_runner().RunPendingTasks(); // Run posted deadline.
1183 EXPECT_EQ(1, client_->num_draws()); 1184 EXPECT_EQ(1, client_->num_draws());
1184 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); 1185 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible"));
1185 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles")); 1186 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles"));
1186 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 1187 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
1187 client_->ActionIndex("ScheduledActionPrepareTiles")); 1188 client_->ActionIndex("ScheduledActionPrepareTiles"));
1188 EXPECT_FALSE(scheduler_->RedrawPending()); 1189 EXPECT_FALSE(scheduler_->RedrawPending());
1189 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 1190 EXPECT_FALSE(scheduler_->PrepareTilesPending());
1190 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); 1191 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending());
1191 scheduler_->DidPrepareTiles(); // Corresponds to ScheduledActionPrepareTiles
1192 } 1192 }
1193 1193
1194 TEST_F(SchedulerTest, TriggerBeginFrameDeadlineEarly) { 1194 TEST_F(SchedulerTest, TriggerBeginFrameDeadlineEarly) {
1195 SchedulerClientNeedsPrepareTilesInDraw* client = 1195 SchedulerClientNeedsPrepareTilesInDraw* client =
1196 new SchedulerClientNeedsPrepareTilesInDraw; 1196 new SchedulerClientNeedsPrepareTilesInDraw;
1197 scheduler_settings_.use_external_begin_frame_source = true; 1197 scheduler_settings_.use_external_begin_frame_source = true;
1198 SetUpScheduler(make_scoped_ptr(client).Pass(), true); 1198 SetUpScheduler(make_scoped_ptr(client).Pass(), true);
1199 1199
1200 scheduler_->SetNeedsRedraw(); 1200 scheduler_->SetNeedsRedraw();
1201 EXPECT_SCOPED(AdvanceFrame()); 1201 EXPECT_SCOPED(AdvanceFrame());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 } 1290 }
1291 1291
1292 void SchedulerTest::MainFrameInHighLatencyMode( 1292 void SchedulerTest::MainFrameInHighLatencyMode(
1293 int64 begin_main_frame_to_commit_estimate_in_ms, 1293 int64 begin_main_frame_to_commit_estimate_in_ms,
1294 int64 commit_to_activate_estimate_in_ms, 1294 int64 commit_to_activate_estimate_in_ms,
1295 bool impl_latency_takes_priority, 1295 bool impl_latency_takes_priority,
1296 bool should_send_begin_main_frame) { 1296 bool should_send_begin_main_frame) {
1297 scheduler_settings_.use_external_begin_frame_source = true; 1297 scheduler_settings_.use_external_begin_frame_source = true;
1298 SetUpScheduler(true); 1298 SetUpScheduler(true);
1299 1299
1300 fake_compositor_timing_history_->SetDrawDurationEstimate(
1301 base::TimeDelta::FromMilliseconds(1));
1302 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( 1300 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1303 base::TimeDelta::FromMilliseconds( 1301 base::TimeDelta::FromMilliseconds(
1304 begin_main_frame_to_commit_estimate_in_ms)); 1302 begin_main_frame_to_commit_estimate_in_ms));
1305 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( 1303 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
1306 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms)); 1304 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms));
1305 fake_compositor_timing_history_->SetDrawDurationEstimate(
1306 base::TimeDelta::FromMilliseconds(1));
1307 1307
1308 scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority); 1308 scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority);
1309 1309
1310 // Impl thread hits deadline before commit finishes. 1310 // Impl thread hits deadline before commit finishes.
1311 scheduler_->SetNeedsCommit(); 1311 scheduler_->SetNeedsCommit();
1312 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); 1312 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode());
1313 EXPECT_SCOPED(AdvanceFrame()); 1313 EXPECT_SCOPED(AdvanceFrame());
1314 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); 1314 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode());
1315 task_runner().RunPendingTasks(); // Run posted deadline. 1315 task_runner().RunPendingTasks(); // Run posted deadline.
1316 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); 1316 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) { 1363 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) {
1364 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main 1364 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main
1365 // thread. This prevents the scheduler from receiving any pending swap acks. 1365 // thread. This prevents the scheduler from receiving any pending swap acks.
1366 1366
1367 // Since we are simulating a long commit, set up a client with draw duration 1367 // Since we are simulating a long commit, set up a client with draw duration
1368 // estimates that prevent skipping main frames to get to low latency mode. 1368 // estimates that prevent skipping main frames to get to low latency mode.
1369 scheduler_settings_.use_external_begin_frame_source = true; 1369 scheduler_settings_.use_external_begin_frame_source = true;
1370 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; 1370 scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
1371 SetUpScheduler(true); 1371 SetUpScheduler(true);
1372 1372
1373 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1374 base::TimeDelta::FromMilliseconds(32));
1375 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
1376 base::TimeDelta::FromMilliseconds(32));
1373 fake_compositor_timing_history_->SetDrawDurationEstimate( 1377 fake_compositor_timing_history_->SetDrawDurationEstimate(
1374 base::TimeDelta::FromMilliseconds(1)); 1378 base::TimeDelta::FromMilliseconds(1));
1375 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1376 base::TimeDelta::FromMilliseconds(32));
1377 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate(
1378 base::TimeDelta::FromMilliseconds(32));
1379 1379
1380 // Disables automatic swap acks so this test can force swap ack throttling 1380 // Disables automatic swap acks so this test can force swap ack throttling
1381 // to simulate a blocked Browser ui thread. 1381 // to simulate a blocked Browser ui thread.
1382 scheduler_->SetMaxSwapsPending(1); 1382 scheduler_->SetMaxSwapsPending(1);
1383 client_->SetAutomaticSwapAck(false); 1383 client_->SetAutomaticSwapAck(false);
1384 1384
1385 // Get a new active tree in main-thread high latency mode and put us 1385 // Get a new active tree in main-thread high latency mode and put us
1386 // in a swap throttled state. 1386 // in a swap throttled state.
1387 client_->Reset(); 1387 client_->Reset();
1388 EXPECT_FALSE(scheduler_->CommitPending()); 1388 EXPECT_FALSE(scheduler_->CommitPending());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 // swap trottled and we have a pending tree and active tree that 1443 // swap trottled and we have a pending tree and active tree that
1444 // still needs to be drawn for the first time. 1444 // still needs to be drawn for the first time.
1445 1445
1446 // Since we are simulating a long commit, set up a client with draw duration 1446 // Since we are simulating a long commit, set up a client with draw duration
1447 // estimates that prevent skipping main frames to get to low latency mode. 1447 // estimates that prevent skipping main frames to get to low latency mode.
1448 scheduler_settings_.use_external_begin_frame_source = true; 1448 scheduler_settings_.use_external_begin_frame_source = true;
1449 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; 1449 scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
1450 scheduler_settings_.main_frame_before_activation_enabled = true; 1450 scheduler_settings_.main_frame_before_activation_enabled = true;
1451 SetUpScheduler(true); 1451 SetUpScheduler(true);
1452 1452
1453 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1454 base::TimeDelta::FromMilliseconds(32));
1455 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
1456 base::TimeDelta::FromMilliseconds(32));
1453 fake_compositor_timing_history_->SetDrawDurationEstimate( 1457 fake_compositor_timing_history_->SetDrawDurationEstimate(
1454 base::TimeDelta::FromMilliseconds(1)); 1458 base::TimeDelta::FromMilliseconds(1));
1455 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1456 base::TimeDelta::FromMilliseconds(32));
1457 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate(
1458 base::TimeDelta::FromMilliseconds(32));
1459 1459
1460 // Disables automatic swap acks so this test can force swap ack throttling 1460 // Disables automatic swap acks so this test can force swap ack throttling
1461 // to simulate a blocked Browser ui thread. 1461 // to simulate a blocked Browser ui thread.
1462 scheduler_->SetMaxSwapsPending(1); 1462 scheduler_->SetMaxSwapsPending(1);
1463 client_->SetAutomaticSwapAck(false); 1463 client_->SetAutomaticSwapAck(false);
1464 1464
1465 // Start a new commit in main-thread high latency mode and hold off on 1465 // Start a new commit in main-thread high latency mode and hold off on
1466 // activation. 1466 // activation.
1467 client_->Reset(); 1467 client_->Reset();
1468 EXPECT_FALSE(scheduler_->CommitPending()); 1468 EXPECT_FALSE(scheduler_->CommitPending());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 // This verifies we don't block commits longer than we need to 1531 // This verifies we don't block commits longer than we need to
1532 // for performance reasons - not deadlock reasons. 1532 // for performance reasons - not deadlock reasons.
1533 1533
1534 // Since we are simulating a long commit, set up a client with draw duration 1534 // Since we are simulating a long commit, set up a client with draw duration
1535 // estimates that prevent skipping main frames to get to low latency mode. 1535 // estimates that prevent skipping main frames to get to low latency mode.
1536 scheduler_settings_.use_external_begin_frame_source = true; 1536 scheduler_settings_.use_external_begin_frame_source = true;
1537 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; 1537 scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
1538 scheduler_settings_.main_frame_before_activation_enabled = true; 1538 scheduler_settings_.main_frame_before_activation_enabled = true;
1539 SetUpScheduler(true); 1539 SetUpScheduler(true);
1540 1540
1541 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1542 base::TimeDelta::FromMilliseconds(32));
1543 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
1544 base::TimeDelta::FromMilliseconds(32));
1541 fake_compositor_timing_history_->SetDrawDurationEstimate( 1545 fake_compositor_timing_history_->SetDrawDurationEstimate(
1542 base::TimeDelta::FromMilliseconds(1)); 1546 base::TimeDelta::FromMilliseconds(1));
1543 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1544 base::TimeDelta::FromMilliseconds(32));
1545 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate(
1546 base::TimeDelta::FromMilliseconds(32));
1547 1547
1548 // Disables automatic swap acks so this test can force swap ack throttling 1548 // Disables automatic swap acks so this test can force swap ack throttling
1549 // to simulate a blocked Browser ui thread. 1549 // to simulate a blocked Browser ui thread.
1550 scheduler_->SetMaxSwapsPending(1); 1550 scheduler_->SetMaxSwapsPending(1);
1551 client_->SetAutomaticSwapAck(false); 1551 client_->SetAutomaticSwapAck(false);
1552 1552
1553 // Start a new commit in main-thread high latency mode and hold off on 1553 // Start a new commit in main-thread high latency mode and hold off on
1554 // activation. 1554 // activation.
1555 client_->Reset(); 1555 client_->Reset();
1556 EXPECT_FALSE(scheduler_->CommitPending()); 1556 EXPECT_FALSE(scheduler_->CommitPending());
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 2845
2846 class SchedulerClientSetNeedsPrepareTilesOnDraw : public FakeSchedulerClient { 2846 class SchedulerClientSetNeedsPrepareTilesOnDraw : public FakeSchedulerClient {
2847 public: 2847 public:
2848 SchedulerClientSetNeedsPrepareTilesOnDraw() : FakeSchedulerClient() {} 2848 SchedulerClientSetNeedsPrepareTilesOnDraw() : FakeSchedulerClient() {}
2849 2849
2850 protected: 2850 protected:
2851 DrawResult ScheduledActionDrawAndSwapIfPossible() override { 2851 DrawResult ScheduledActionDrawAndSwapIfPossible() override {
2852 scheduler_->SetNeedsPrepareTiles(); 2852 scheduler_->SetNeedsPrepareTiles();
2853 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 2853 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
2854 } 2854 }
2855
2856 void ScheduledActionPrepareTiles() override {
2857 FakeSchedulerClient::ScheduledActionPrepareTiles();
2858 scheduler_->DidPrepareTiles();
2859 }
2860 }; 2855 };
2861 2856
2862 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) { 2857 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) {
2863 scheduler_settings_.using_synchronous_renderer_compositor = true; 2858 scheduler_settings_.using_synchronous_renderer_compositor = true;
2864 scheduler_settings_.use_external_begin_frame_source = true; 2859 scheduler_settings_.use_external_begin_frame_source = true;
2865 2860
2866 scoped_ptr<FakeSchedulerClient> client = 2861 scoped_ptr<FakeSchedulerClient> client =
2867 make_scoped_ptr(new SchedulerClientSetNeedsPrepareTilesOnDraw); 2862 make_scoped_ptr(new SchedulerClientSetNeedsPrepareTilesOnDraw);
2868 SetUpScheduler(client.Pass(), true); 2863 SetUpScheduler(client.Pass(), true);
2869 2864
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 scheduler_->SetImplLatencyTakesPriority(true); 2955 scheduler_->SetImplLatencyTakesPriority(true);
2961 scheduler_->SetChildrenNeedBeginFrames(true); 2956 scheduler_->SetChildrenNeedBeginFrames(true);
2962 2957
2963 EXPECT_SCOPED(AdvanceFrame()); 2958 EXPECT_SCOPED(AdvanceFrame());
2964 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); 2959 EXPECT_TRUE(client_->begin_frame_is_sent_to_children());
2965 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); 2960 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path);
2966 } 2961 }
2967 2962
2968 } // namespace 2963 } // namespace
2969 } // namespace cc 2964 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.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