| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 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 Loading... |
| 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_ |
| 458 base::TimeDelta::FromMilliseconds(4)); | 463 ->SetPrepareTilesBeginToReadyToActivateDurationEstimate( |
| 464 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( | 1300 fake_compositor_timing_history_->SetDrawDurationEstimate( |
| 1301 base::TimeDelta::FromMilliseconds(1)); | 1301 base::TimeDelta::FromMilliseconds(1)); |
| 1302 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | 1302 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( |
| 1303 base::TimeDelta::FromMilliseconds( | 1303 base::TimeDelta::FromMilliseconds( |
| 1304 begin_main_frame_to_commit_estimate_in_ms)); | 1304 begin_main_frame_to_commit_estimate_in_ms)); |
| 1305 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( | 1305 fake_compositor_timing_history_ |
| 1306 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms)); | 1306 ->SetPrepareTilesBeginToReadyToActivateDurationEstimate( |
| 1307 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms)); |
| 1307 | 1308 |
| 1308 scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority); | 1309 scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority); |
| 1309 | 1310 |
| 1310 // Impl thread hits deadline before commit finishes. | 1311 // Impl thread hits deadline before commit finishes. |
| 1311 scheduler_->SetNeedsCommit(); | 1312 scheduler_->SetNeedsCommit(); |
| 1312 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1313 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1313 EXPECT_SCOPED(AdvanceFrame()); | 1314 EXPECT_SCOPED(AdvanceFrame()); |
| 1314 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1315 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1315 task_runner().RunPendingTasks(); // Run posted deadline. | 1316 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1316 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1317 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 // Since we are simulating a long commit, set up a client with draw duration | 1368 // 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. | 1369 // estimates that prevent skipping main frames to get to low latency mode. |
| 1369 scheduler_settings_.use_external_begin_frame_source = true; | 1370 scheduler_settings_.use_external_begin_frame_source = true; |
| 1370 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1371 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| 1371 SetUpScheduler(true); | 1372 SetUpScheduler(true); |
| 1372 | 1373 |
| 1373 fake_compositor_timing_history_->SetDrawDurationEstimate( | 1374 fake_compositor_timing_history_->SetDrawDurationEstimate( |
| 1374 base::TimeDelta::FromMilliseconds(1)); | 1375 base::TimeDelta::FromMilliseconds(1)); |
| 1375 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | 1376 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( |
| 1376 base::TimeDelta::FromMilliseconds(32)); | 1377 base::TimeDelta::FromMilliseconds(32)); |
| 1377 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( | 1378 fake_compositor_timing_history_ |
| 1378 base::TimeDelta::FromMilliseconds(32)); | 1379 ->SetPrepareTilesBeginToReadyToActivateDurationEstimate( |
| 1380 base::TimeDelta::FromMilliseconds(32)); |
| 1379 | 1381 |
| 1380 // Disables automatic swap acks so this test can force swap ack throttling | 1382 // Disables automatic swap acks so this test can force swap ack throttling |
| 1381 // to simulate a blocked Browser ui thread. | 1383 // to simulate a blocked Browser ui thread. |
| 1382 scheduler_->SetMaxSwapsPending(1); | 1384 scheduler_->SetMaxSwapsPending(1); |
| 1383 client_->SetAutomaticSwapAck(false); | 1385 client_->SetAutomaticSwapAck(false); |
| 1384 | 1386 |
| 1385 // Get a new active tree in main-thread high latency mode and put us | 1387 // Get a new active tree in main-thread high latency mode and put us |
| 1386 // in a swap throttled state. | 1388 // in a swap throttled state. |
| 1387 client_->Reset(); | 1389 client_->Reset(); |
| 1388 EXPECT_FALSE(scheduler_->CommitPending()); | 1390 EXPECT_FALSE(scheduler_->CommitPending()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1447 // estimates that prevent skipping main frames to get to low latency mode. | 1449 // estimates that prevent skipping main frames to get to low latency mode. |
| 1448 scheduler_settings_.use_external_begin_frame_source = true; | 1450 scheduler_settings_.use_external_begin_frame_source = true; |
| 1449 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1451 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| 1450 scheduler_settings_.main_frame_before_activation_enabled = true; | 1452 scheduler_settings_.main_frame_before_activation_enabled = true; |
| 1451 SetUpScheduler(true); | 1453 SetUpScheduler(true); |
| 1452 | 1454 |
| 1453 fake_compositor_timing_history_->SetDrawDurationEstimate( | 1455 fake_compositor_timing_history_->SetDrawDurationEstimate( |
| 1454 base::TimeDelta::FromMilliseconds(1)); | 1456 base::TimeDelta::FromMilliseconds(1)); |
| 1455 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | 1457 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( |
| 1456 base::TimeDelta::FromMilliseconds(32)); | 1458 base::TimeDelta::FromMilliseconds(32)); |
| 1457 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( | 1459 fake_compositor_timing_history_ |
| 1458 base::TimeDelta::FromMilliseconds(32)); | 1460 ->SetPrepareTilesBeginToReadyToActivateDurationEstimate( |
| 1461 base::TimeDelta::FromMilliseconds(32)); |
| 1459 | 1462 |
| 1460 // Disables automatic swap acks so this test can force swap ack throttling | 1463 // Disables automatic swap acks so this test can force swap ack throttling |
| 1461 // to simulate a blocked Browser ui thread. | 1464 // to simulate a blocked Browser ui thread. |
| 1462 scheduler_->SetMaxSwapsPending(1); | 1465 scheduler_->SetMaxSwapsPending(1); |
| 1463 client_->SetAutomaticSwapAck(false); | 1466 client_->SetAutomaticSwapAck(false); |
| 1464 | 1467 |
| 1465 // Start a new commit in main-thread high latency mode and hold off on | 1468 // Start a new commit in main-thread high latency mode and hold off on |
| 1466 // activation. | 1469 // activation. |
| 1467 client_->Reset(); | 1470 client_->Reset(); |
| 1468 EXPECT_FALSE(scheduler_->CommitPending()); | 1471 EXPECT_FALSE(scheduler_->CommitPending()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 // estimates that prevent skipping main frames to get to low latency mode. | 1538 // estimates that prevent skipping main frames to get to low latency mode. |
| 1536 scheduler_settings_.use_external_begin_frame_source = true; | 1539 scheduler_settings_.use_external_begin_frame_source = true; |
| 1537 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1540 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| 1538 scheduler_settings_.main_frame_before_activation_enabled = true; | 1541 scheduler_settings_.main_frame_before_activation_enabled = true; |
| 1539 SetUpScheduler(true); | 1542 SetUpScheduler(true); |
| 1540 | 1543 |
| 1541 fake_compositor_timing_history_->SetDrawDurationEstimate( | 1544 fake_compositor_timing_history_->SetDrawDurationEstimate( |
| 1542 base::TimeDelta::FromMilliseconds(1)); | 1545 base::TimeDelta::FromMilliseconds(1)); |
| 1543 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | 1546 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( |
| 1544 base::TimeDelta::FromMilliseconds(32)); | 1547 base::TimeDelta::FromMilliseconds(32)); |
| 1545 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( | 1548 fake_compositor_timing_history_ |
| 1546 base::TimeDelta::FromMilliseconds(32)); | 1549 ->SetPrepareTilesBeginToReadyToActivateDurationEstimate( |
| 1550 base::TimeDelta::FromMilliseconds(32)); |
| 1547 | 1551 |
| 1548 // Disables automatic swap acks so this test can force swap ack throttling | 1552 // Disables automatic swap acks so this test can force swap ack throttling |
| 1549 // to simulate a blocked Browser ui thread. | 1553 // to simulate a blocked Browser ui thread. |
| 1550 scheduler_->SetMaxSwapsPending(1); | 1554 scheduler_->SetMaxSwapsPending(1); |
| 1551 client_->SetAutomaticSwapAck(false); | 1555 client_->SetAutomaticSwapAck(false); |
| 1552 | 1556 |
| 1553 // Start a new commit in main-thread high latency mode and hold off on | 1557 // Start a new commit in main-thread high latency mode and hold off on |
| 1554 // activation. | 1558 // activation. |
| 1555 client_->Reset(); | 1559 client_->Reset(); |
| 1556 EXPECT_FALSE(scheduler_->CommitPending()); | 1560 EXPECT_FALSE(scheduler_->CommitPending()); |
| (...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2845 | 2849 |
| 2846 class SchedulerClientSetNeedsPrepareTilesOnDraw : public FakeSchedulerClient { | 2850 class SchedulerClientSetNeedsPrepareTilesOnDraw : public FakeSchedulerClient { |
| 2847 public: | 2851 public: |
| 2848 SchedulerClientSetNeedsPrepareTilesOnDraw() : FakeSchedulerClient() {} | 2852 SchedulerClientSetNeedsPrepareTilesOnDraw() : FakeSchedulerClient() {} |
| 2849 | 2853 |
| 2850 protected: | 2854 protected: |
| 2851 DrawResult ScheduledActionDrawAndSwapIfPossible() override { | 2855 DrawResult ScheduledActionDrawAndSwapIfPossible() override { |
| 2852 scheduler_->SetNeedsPrepareTiles(); | 2856 scheduler_->SetNeedsPrepareTiles(); |
| 2853 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 2857 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
| 2854 } | 2858 } |
| 2855 | |
| 2856 void ScheduledActionPrepareTiles() override { | |
| 2857 FakeSchedulerClient::ScheduledActionPrepareTiles(); | |
| 2858 scheduler_->DidPrepareTiles(); | |
| 2859 } | |
| 2860 }; | 2859 }; |
| 2861 | 2860 |
| 2862 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) { | 2861 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) { |
| 2863 scheduler_settings_.using_synchronous_renderer_compositor = true; | 2862 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 2864 scheduler_settings_.use_external_begin_frame_source = true; | 2863 scheduler_settings_.use_external_begin_frame_source = true; |
| 2865 | 2864 |
| 2866 scoped_ptr<FakeSchedulerClient> client = | 2865 scoped_ptr<FakeSchedulerClient> client = |
| 2867 make_scoped_ptr(new SchedulerClientSetNeedsPrepareTilesOnDraw); | 2866 make_scoped_ptr(new SchedulerClientSetNeedsPrepareTilesOnDraw); |
| 2868 SetUpScheduler(client.Pass(), true); | 2867 SetUpScheduler(client.Pass(), true); |
| 2869 | 2868 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2960 scheduler_->SetImplLatencyTakesPriority(true); | 2959 scheduler_->SetImplLatencyTakesPriority(true); |
| 2961 scheduler_->SetChildrenNeedBeginFrames(true); | 2960 scheduler_->SetChildrenNeedBeginFrames(true); |
| 2962 | 2961 |
| 2963 EXPECT_SCOPED(AdvanceFrame()); | 2962 EXPECT_SCOPED(AdvanceFrame()); |
| 2964 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 2963 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| 2965 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); | 2964 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); |
| 2966 } | 2965 } |
| 2967 | 2966 |
| 2968 } // namespace | 2967 } // namespace |
| 2969 } // namespace cc | 2968 } // namespace cc |
| OLD | NEW |