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

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: rebase 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
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 {
mithro-old 2015/06/30 07:55:49 Why didn't any tests previously depend on this hap
brianderson 2015/06/30 17:35:15 I added Scheduler::DidCommit as part of this patch
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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
453 fake_compositor_timing_history_->SetDrawDurationEstimate( 458 fake_compositor_timing_history_->SetDrawDurationEstimate(
454 base::TimeDelta::FromMilliseconds(1)); 459 base::TimeDelta::FromMilliseconds(1));
455 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( 460 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
456 base::TimeDelta::FromMilliseconds(2)); 461 base::TimeDelta::FromMilliseconds(2));
457 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( 462 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
458 base::TimeDelta::FromMilliseconds(4)); 463 base::TimeDelta::FromMilliseconds(4));
459 464
460 EXPECT_FALSE(client_->needs_begin_frames()); 465 EXPECT_FALSE(client_->needs_begin_frames());
461 scheduler_->SetChildrenNeedBeginFrames(true); 466 scheduler_->SetChildrenNeedBeginFrames(true);
462 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); 467 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_);
463 EXPECT_TRUE(client_->needs_begin_frames()); 468 EXPECT_TRUE(client_->needs_begin_frames());
464 469
465 client_->Reset(); 470 client_->Reset();
466 471
467 BeginFrameArgs frame_args = 472 BeginFrameArgs frame_args =
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 task_runner().RunPendingTasks(); // Run posted deadline. 708 task_runner().RunPendingTasks(); // Run posted deadline.
704 EXPECT_FALSE(client_->needs_begin_frames()); 709 EXPECT_FALSE(client_->needs_begin_frames());
705 client_->Reset(); 710 client_->Reset();
706 } 711 }
707 712
708 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient { 713 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient {
709 public: 714 public:
710 SchedulerClientThatsetNeedsDrawInsideDraw() 715 SchedulerClientThatsetNeedsDrawInsideDraw()
711 : FakeSchedulerClient(), request_redraws_(false) {} 716 : FakeSchedulerClient(), request_redraws_(false) {}
712 717
713 void ScheduledActionSendBeginMainFrame() override {}
714
715 void SetRequestRedrawsInsideDraw(bool enable) { request_redraws_ = enable; } 718 void SetRequestRedrawsInsideDraw(bool enable) { request_redraws_ = enable; }
716 719
717 DrawResult ScheduledActionDrawAndSwapIfPossible() override { 720 DrawResult ScheduledActionDrawAndSwapIfPossible() override {
718 // Only SetNeedsRedraw the first time this is called 721 // Only SetNeedsRedraw the first time this is called
719 if (request_redraws_) { 722 if (request_redraws_) {
720 scheduler_->SetNeedsRedraw(); 723 scheduler_->SetNeedsRedraw();
721 } 724 }
722 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 725 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
723 } 726 }
724 727
725 DrawResult ScheduledActionDrawAndSwapForced() override { 728 DrawResult ScheduledActionDrawAndSwapForced() override {
726 NOTREACHED(); 729 NOTREACHED();
727 return DRAW_SUCCESS; 730 return DRAW_SUCCESS;
728 } 731 }
729 732
730 void ScheduledActionCommit() override {}
731
732 private: 733 private:
733 bool request_redraws_; 734 bool request_redraws_;
734 }; 735 };
735 736
736 // Tests for two different situations: 737 // Tests for two different situations:
737 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside 738 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside
738 // a ScheduledActionDrawAndSwap 739 // a ScheduledActionDrawAndSwap
739 // 2. the scheduler drawing twice inside a single tick 740 // 2. the scheduler drawing twice inside a single tick
740 TEST_F(SchedulerTest, RequestRedrawInsideDraw) { 741 TEST_F(SchedulerTest, RequestRedrawInsideDraw) {
741 SchedulerClientThatsetNeedsDrawInsideDraw* client = 742 SchedulerClientThatsetNeedsDrawInsideDraw* client =
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 EXPECT_TRUE(scheduler_->CommitPending()); 817 EXPECT_TRUE(scheduler_->CommitPending());
817 EXPECT_FALSE(scheduler_->RedrawPending()); 818 EXPECT_FALSE(scheduler_->RedrawPending());
818 EXPECT_TRUE(client->needs_begin_frames()); 819 EXPECT_TRUE(client->needs_begin_frames());
819 } 820 }
820 821
821 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient { 822 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient {
822 public: 823 public:
823 SchedulerClientThatSetNeedsCommitInsideDraw() 824 SchedulerClientThatSetNeedsCommitInsideDraw()
824 : set_needs_commit_on_next_draw_(false) {} 825 : set_needs_commit_on_next_draw_(false) {}
825 826
826 void ScheduledActionSendBeginMainFrame() override {}
827 DrawResult ScheduledActionDrawAndSwapIfPossible() override { 827 DrawResult ScheduledActionDrawAndSwapIfPossible() override {
828 // Only SetNeedsCommit the first time this is called 828 // Only SetNeedsCommit the first time this is called
829 if (set_needs_commit_on_next_draw_) { 829 if (set_needs_commit_on_next_draw_) {
830 scheduler_->SetNeedsCommit(); 830 scheduler_->SetNeedsCommit();
831 set_needs_commit_on_next_draw_ = false; 831 set_needs_commit_on_next_draw_ = false;
832 } 832 }
833 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 833 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
834 } 834 }
835 835
836 DrawResult ScheduledActionDrawAndSwapForced() override { 836 DrawResult ScheduledActionDrawAndSwapForced() override {
837 NOTREACHED(); 837 NOTREACHED();
838 return DRAW_SUCCESS; 838 return DRAW_SUCCESS;
839 } 839 }
840 840
841 void ScheduledActionCommit() override {}
842
843 void SetNeedsCommitOnNextDraw() { set_needs_commit_on_next_draw_ = true; } 841 void SetNeedsCommitOnNextDraw() { set_needs_commit_on_next_draw_ = true; }
844 842
845 private: 843 private:
846 bool set_needs_commit_on_next_draw_; 844 bool set_needs_commit_on_next_draw_;
847 }; 845 };
848 846
849 // Tests for the scheduler infinite-looping on SetNeedsCommit requests that 847 // Tests for the scheduler infinite-looping on SetNeedsCommit requests that
850 // happen inside a ScheduledActionDrawAndSwap 848 // happen inside a ScheduledActionDrawAndSwap
851 TEST_F(SchedulerTest, RequestCommitInsideDraw) { 849 TEST_F(SchedulerTest, RequestCommitInsideDraw) {
852 SchedulerClientThatSetNeedsCommitInsideDraw* client = 850 SchedulerClientThatSetNeedsCommitInsideDraw* client =
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 // again. 1082 // again.
1085 scheduler_->SetNeedsPrepareTiles(); 1083 scheduler_->SetNeedsPrepareTiles();
1086 scheduler_->SetNeedsRedraw(); 1084 scheduler_->SetNeedsRedraw();
1087 client_->Reset(); 1085 client_->Reset();
1088 EXPECT_SCOPED(AdvanceFrame()); 1086 EXPECT_SCOPED(AdvanceFrame());
1089 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 1087 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
1090 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); 1088 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2);
1091 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1089 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1092 1090
1093 EXPECT_TRUE(scheduler_->PrepareTilesPending()); 1091 EXPECT_TRUE(scheduler_->PrepareTilesPending());
1092 scheduler_->WillPrepareTiles();
1094 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. 1093 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles.
1095 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 1094 EXPECT_FALSE(scheduler_->PrepareTilesPending());
1096 1095
1097 client_->Reset(); 1096 client_->Reset();
1098 task_runner().RunPendingTasks(); // Run posted deadline. 1097 task_runner().RunPendingTasks(); // Run posted deadline.
1099 EXPECT_EQ(1, client_->num_draws()); 1098 EXPECT_EQ(1, client_->num_draws());
1100 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); 1099 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible"));
1101 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles")); 1100 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles"));
1102 EXPECT_FALSE(scheduler_->RedrawPending()); 1101 EXPECT_FALSE(scheduler_->RedrawPending());
1103 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 1102 EXPECT_FALSE(scheduler_->PrepareTilesPending());
(...skipping 11 matching lines...) Expand all
1115 client_->Reset(); 1114 client_->Reset();
1116 task_runner().RunPendingTasks(); // Run posted deadline. 1115 task_runner().RunPendingTasks(); // Run posted deadline.
1117 EXPECT_EQ(1, client_->num_draws()); 1116 EXPECT_EQ(1, client_->num_draws());
1118 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); 1117 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible"));
1119 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles")); 1118 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles"));
1120 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 1119 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
1121 client_->ActionIndex("ScheduledActionPrepareTiles")); 1120 client_->ActionIndex("ScheduledActionPrepareTiles"));
1122 EXPECT_FALSE(scheduler_->RedrawPending()); 1121 EXPECT_FALSE(scheduler_->RedrawPending());
1123 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 1122 EXPECT_FALSE(scheduler_->PrepareTilesPending());
1124 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); 1123 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending());
1125 scheduler_->DidPrepareTiles(); // Corresponds to ScheduledActionPrepareTiles
1126 1124
1127 // If we get another DidPrepareTiles within the same frame, we should 1125 // If we get another DidPrepareTiles within the same frame, we should
1128 // not PrepareTiles on the next frame. 1126 // not PrepareTiles on the next frame.
1127 scheduler_->WillPrepareTiles();
1129 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. 1128 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles.
1130 scheduler_->SetNeedsPrepareTiles(); 1129 scheduler_->SetNeedsPrepareTiles();
1131 scheduler_->SetNeedsRedraw(); 1130 scheduler_->SetNeedsRedraw();
1132 client_->Reset(); 1131 client_->Reset();
1133 EXPECT_SCOPED(AdvanceFrame()); 1132 EXPECT_SCOPED(AdvanceFrame());
1134 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 1133 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
1135 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); 1134 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2);
1136 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1135 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1137 1136
1138 EXPECT_TRUE(scheduler_->PrepareTilesPending()); 1137 EXPECT_TRUE(scheduler_->PrepareTilesPending());
1139 1138
1140 client_->Reset(); 1139 client_->Reset();
1141 task_runner().RunPendingTasks(); // Run posted deadline. 1140 task_runner().RunPendingTasks(); // Run posted deadline.
1142 EXPECT_EQ(1, client_->num_draws()); 1141 EXPECT_EQ(1, client_->num_draws());
1143 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); 1142 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible"));
1144 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles")); 1143 EXPECT_FALSE(client_->HasAction("ScheduledActionPrepareTiles"));
1145 EXPECT_FALSE(scheduler_->RedrawPending()); 1144 EXPECT_FALSE(scheduler_->RedrawPending());
1146 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); 1145 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending());
1147 1146
1148 // If we get another DidPrepareTiles, we should not PrepareTiles on the next 1147 // If we get another DidPrepareTiles, we should not PrepareTiles on the next
1149 // frame. This verifies we don't alternate calling PrepareTiles once and 1148 // frame. This verifies we don't alternate calling PrepareTiles once and
1150 // twice. 1149 // twice.
1151 EXPECT_TRUE(scheduler_->PrepareTilesPending()); 1150 EXPECT_TRUE(scheduler_->PrepareTilesPending());
1151 scheduler_->WillPrepareTiles();
1152 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. 1152 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles.
1153 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 1153 EXPECT_FALSE(scheduler_->PrepareTilesPending());
1154 scheduler_->SetNeedsPrepareTiles(); 1154 scheduler_->SetNeedsPrepareTiles();
1155 scheduler_->SetNeedsRedraw(); 1155 scheduler_->SetNeedsRedraw();
1156 client_->Reset(); 1156 client_->Reset();
1157 EXPECT_SCOPED(AdvanceFrame()); 1157 EXPECT_SCOPED(AdvanceFrame());
1158 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 1158 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
1159 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); 1159 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2);
1160 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1160 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1161 1161
(...skipping 19 matching lines...) Expand all
1181 client_->Reset(); 1181 client_->Reset();
1182 task_runner().RunPendingTasks(); // Run posted deadline. 1182 task_runner().RunPendingTasks(); // Run posted deadline.
1183 EXPECT_EQ(1, client_->num_draws()); 1183 EXPECT_EQ(1, client_->num_draws());
1184 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); 1184 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible"));
1185 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles")); 1185 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles"));
1186 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 1186 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
1187 client_->ActionIndex("ScheduledActionPrepareTiles")); 1187 client_->ActionIndex("ScheduledActionPrepareTiles"));
1188 EXPECT_FALSE(scheduler_->RedrawPending()); 1188 EXPECT_FALSE(scheduler_->RedrawPending());
1189 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 1189 EXPECT_FALSE(scheduler_->PrepareTilesPending());
1190 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); 1190 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending());
1191 scheduler_->DidPrepareTiles(); // Corresponds to ScheduledActionPrepareTiles
1192 } 1191 }
1193 1192
1194 TEST_F(SchedulerTest, TriggerBeginFrameDeadlineEarly) { 1193 TEST_F(SchedulerTest, TriggerBeginFrameDeadlineEarly) {
1195 SchedulerClientNeedsPrepareTilesInDraw* client = 1194 SchedulerClientNeedsPrepareTilesInDraw* client =
1196 new SchedulerClientNeedsPrepareTilesInDraw; 1195 new SchedulerClientNeedsPrepareTilesInDraw;
1197 scheduler_settings_.use_external_begin_frame_source = true; 1196 scheduler_settings_.use_external_begin_frame_source = true;
1198 SetUpScheduler(make_scoped_ptr(client).Pass(), true); 1197 SetUpScheduler(make_scoped_ptr(client).Pass(), true);
1199 1198
1200 scheduler_->SetNeedsRedraw(); 1199 scheduler_->SetNeedsRedraw();
1201 EXPECT_SCOPED(AdvanceFrame()); 1200 EXPECT_SCOPED(AdvanceFrame());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 bool impl_latency_takes_priority, 1294 bool impl_latency_takes_priority,
1296 bool should_send_begin_main_frame) { 1295 bool should_send_begin_main_frame) {
1297 scheduler_settings_.use_external_begin_frame_source = true; 1296 scheduler_settings_.use_external_begin_frame_source = true;
1298 SetUpScheduler(true); 1297 SetUpScheduler(true);
1299 1298
1300 fake_compositor_timing_history_->SetDrawDurationEstimate( 1299 fake_compositor_timing_history_->SetDrawDurationEstimate(
1301 base::TimeDelta::FromMilliseconds(1)); 1300 base::TimeDelta::FromMilliseconds(1));
1302 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( 1301 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1303 base::TimeDelta::FromMilliseconds( 1302 base::TimeDelta::FromMilliseconds(
1304 begin_main_frame_to_commit_estimate_in_ms)); 1303 begin_main_frame_to_commit_estimate_in_ms));
1305 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( 1304 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
1306 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms)); 1305 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms));
1307 1306
1308 scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority); 1307 scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority);
1309 1308
1310 // Impl thread hits deadline before commit finishes. 1309 // Impl thread hits deadline before commit finishes.
1311 scheduler_->SetNeedsCommit(); 1310 scheduler_->SetNeedsCommit();
1312 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); 1311 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode());
1313 EXPECT_SCOPED(AdvanceFrame()); 1312 EXPECT_SCOPED(AdvanceFrame());
1314 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); 1313 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode());
1315 task_runner().RunPendingTasks(); // Run posted deadline. 1314 task_runner().RunPendingTasks(); // Run posted deadline.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 // Since we are simulating a long commit, set up a client with draw duration 1366 // 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. 1367 // estimates that prevent skipping main frames to get to low latency mode.
1369 scheduler_settings_.use_external_begin_frame_source = true; 1368 scheduler_settings_.use_external_begin_frame_source = true;
1370 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; 1369 scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
1371 SetUpScheduler(true); 1370 SetUpScheduler(true);
1372 1371
1373 fake_compositor_timing_history_->SetDrawDurationEstimate( 1372 fake_compositor_timing_history_->SetDrawDurationEstimate(
1374 base::TimeDelta::FromMilliseconds(1)); 1373 base::TimeDelta::FromMilliseconds(1));
1375 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( 1374 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1376 base::TimeDelta::FromMilliseconds(32)); 1375 base::TimeDelta::FromMilliseconds(32));
1377 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( 1376 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
1378 base::TimeDelta::FromMilliseconds(32)); 1377 base::TimeDelta::FromMilliseconds(32));
1379 1378
1380 // Disables automatic swap acks so this test can force swap ack throttling 1379 // Disables automatic swap acks so this test can force swap ack throttling
1381 // to simulate a blocked Browser ui thread. 1380 // to simulate a blocked Browser ui thread.
1382 scheduler_->SetMaxSwapsPending(1); 1381 scheduler_->SetMaxSwapsPending(1);
1383 client_->SetAutomaticSwapAck(false); 1382 client_->SetAutomaticSwapAck(false);
1384 1383
1385 // Get a new active tree in main-thread high latency mode and put us 1384 // Get a new active tree in main-thread high latency mode and put us
1386 // in a swap throttled state. 1385 // in a swap throttled state.
1387 client_->Reset(); 1386 client_->Reset();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 // estimates that prevent skipping main frames to get to low latency mode. 1446 // estimates that prevent skipping main frames to get to low latency mode.
1448 scheduler_settings_.use_external_begin_frame_source = true; 1447 scheduler_settings_.use_external_begin_frame_source = true;
1449 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; 1448 scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
1450 scheduler_settings_.main_frame_before_activation_enabled = true; 1449 scheduler_settings_.main_frame_before_activation_enabled = true;
1451 SetUpScheduler(true); 1450 SetUpScheduler(true);
1452 1451
1453 fake_compositor_timing_history_->SetDrawDurationEstimate( 1452 fake_compositor_timing_history_->SetDrawDurationEstimate(
1454 base::TimeDelta::FromMilliseconds(1)); 1453 base::TimeDelta::FromMilliseconds(1));
1455 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( 1454 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1456 base::TimeDelta::FromMilliseconds(32)); 1455 base::TimeDelta::FromMilliseconds(32));
1457 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( 1456 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
1458 base::TimeDelta::FromMilliseconds(32)); 1457 base::TimeDelta::FromMilliseconds(32));
1459 1458
1460 // Disables automatic swap acks so this test can force swap ack throttling 1459 // Disables automatic swap acks so this test can force swap ack throttling
1461 // to simulate a blocked Browser ui thread. 1460 // to simulate a blocked Browser ui thread.
1462 scheduler_->SetMaxSwapsPending(1); 1461 scheduler_->SetMaxSwapsPending(1);
1463 client_->SetAutomaticSwapAck(false); 1462 client_->SetAutomaticSwapAck(false);
1464 1463
1465 // Start a new commit in main-thread high latency mode and hold off on 1464 // Start a new commit in main-thread high latency mode and hold off on
1466 // activation. 1465 // activation.
1467 client_->Reset(); 1466 client_->Reset();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 // estimates that prevent skipping main frames to get to low latency mode. 1534 // estimates that prevent skipping main frames to get to low latency mode.
1536 scheduler_settings_.use_external_begin_frame_source = true; 1535 scheduler_settings_.use_external_begin_frame_source = true;
1537 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; 1536 scheduler_settings_.main_frame_while_swap_throttled_enabled = true;
1538 scheduler_settings_.main_frame_before_activation_enabled = true; 1537 scheduler_settings_.main_frame_before_activation_enabled = true;
1539 SetUpScheduler(true); 1538 SetUpScheduler(true);
1540 1539
1541 fake_compositor_timing_history_->SetDrawDurationEstimate( 1540 fake_compositor_timing_history_->SetDrawDurationEstimate(
1542 base::TimeDelta::FromMilliseconds(1)); 1541 base::TimeDelta::FromMilliseconds(1));
1543 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( 1542 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate(
1544 base::TimeDelta::FromMilliseconds(32)); 1543 base::TimeDelta::FromMilliseconds(32));
1545 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( 1544 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
1546 base::TimeDelta::FromMilliseconds(32)); 1545 base::TimeDelta::FromMilliseconds(32));
1547 1546
1548 // Disables automatic swap acks so this test can force swap ack throttling 1547 // Disables automatic swap acks so this test can force swap ack throttling
1549 // to simulate a blocked Browser ui thread. 1548 // to simulate a blocked Browser ui thread.
1550 scheduler_->SetMaxSwapsPending(1); 1549 scheduler_->SetMaxSwapsPending(1);
1551 client_->SetAutomaticSwapAck(false); 1550 client_->SetAutomaticSwapAck(false);
1552 1551
1553 // Start a new commit in main-thread high latency mode and hold off on 1552 // Start a new commit in main-thread high latency mode and hold off on
1554 // activation. 1553 // activation.
1555 client_->Reset(); 1554 client_->Reset();
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 2844
2846 class SchedulerClientSetNeedsPrepareTilesOnDraw : public FakeSchedulerClient { 2845 class SchedulerClientSetNeedsPrepareTilesOnDraw : public FakeSchedulerClient {
2847 public: 2846 public:
2848 SchedulerClientSetNeedsPrepareTilesOnDraw() : FakeSchedulerClient() {} 2847 SchedulerClientSetNeedsPrepareTilesOnDraw() : FakeSchedulerClient() {}
2849 2848
2850 protected: 2849 protected:
2851 DrawResult ScheduledActionDrawAndSwapIfPossible() override { 2850 DrawResult ScheduledActionDrawAndSwapIfPossible() override {
2852 scheduler_->SetNeedsPrepareTiles(); 2851 scheduler_->SetNeedsPrepareTiles();
2853 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 2852 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
2854 } 2853 }
2855
2856 void ScheduledActionPrepareTiles() override {
2857 FakeSchedulerClient::ScheduledActionPrepareTiles();
2858 scheduler_->DidPrepareTiles();
2859 }
2860 }; 2854 };
2861 2855
2862 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) { 2856 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) {
2863 scheduler_settings_.using_synchronous_renderer_compositor = true; 2857 scheduler_settings_.using_synchronous_renderer_compositor = true;
2864 scheduler_settings_.use_external_begin_frame_source = true; 2858 scheduler_settings_.use_external_begin_frame_source = true;
2865 2859
2866 scoped_ptr<FakeSchedulerClient> client = 2860 scoped_ptr<FakeSchedulerClient> client =
2867 make_scoped_ptr(new SchedulerClientSetNeedsPrepareTilesOnDraw); 2861 make_scoped_ptr(new SchedulerClientSetNeedsPrepareTilesOnDraw);
2868 SetUpScheduler(client.Pass(), true); 2862 SetUpScheduler(client.Pass(), true);
2869 2863
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 scheduler_->SetImplLatencyTakesPriority(true); 2954 scheduler_->SetImplLatencyTakesPriority(true);
2961 scheduler_->SetChildrenNeedBeginFrames(true); 2955 scheduler_->SetChildrenNeedBeginFrames(true);
2962 2956
2963 EXPECT_SCOPED(AdvanceFrame()); 2957 EXPECT_SCOPED(AdvanceFrame());
2964 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); 2958 EXPECT_TRUE(client_->begin_frame_is_sent_to_children());
2965 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); 2959 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path);
2966 } 2960 }
2967 2961
2968 } // namespace 2962 } // namespace
2969 } // namespace cc 2963 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698