| 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 { | 130 void ScheduledActionCommit() override { PushAction("ScheduledActionCommit"); } |
| 131 PushAction("ScheduledActionCommit"); | |
| 132 scheduler_->DidCommit(); | |
| 133 } | |
| 134 void ScheduledActionActivateSyncTree() override { | 131 void ScheduledActionActivateSyncTree() override { |
| 135 PushAction("ScheduledActionActivateSyncTree"); | 132 PushAction("ScheduledActionActivateSyncTree"); |
| 136 } | 133 } |
| 137 void ScheduledActionBeginOutputSurfaceCreation() override { | 134 void ScheduledActionBeginOutputSurfaceCreation() override { |
| 138 PushAction("ScheduledActionBeginOutputSurfaceCreation"); | 135 PushAction("ScheduledActionBeginOutputSurfaceCreation"); |
| 139 } | 136 } |
| 140 void ScheduledActionPrepareTiles() override { | 137 void ScheduledActionPrepareTiles() override { |
| 141 PushAction("ScheduledActionPrepareTiles"); | 138 PushAction("ScheduledActionPrepareTiles"); |
| 142 scheduler_->WillPrepareTiles(); | |
| 143 scheduler_->DidPrepareTiles(); | |
| 144 } | 139 } |
| 145 void ScheduledActionInvalidateOutputSurface() override { | 140 void ScheduledActionInvalidateOutputSurface() override { |
| 146 actions_.push_back("ScheduledActionInvalidateOutputSurface"); | 141 actions_.push_back("ScheduledActionInvalidateOutputSurface"); |
| 147 states_.push_back(scheduler_->AsValue()); | 142 states_.push_back(scheduler_->AsValue()); |
| 148 } | 143 } |
| 149 | 144 |
| 150 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { | 145 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { |
| 151 begin_frame_args_sent_to_children_ = args; | 146 begin_frame_args_sent_to_children_ = args; |
| 152 } | 147 } |
| 153 | 148 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 443 |
| 449 client_->Reset(); | 444 client_->Reset(); |
| 450 EXPECT_SCOPED(AdvanceFrame()); | 445 EXPECT_SCOPED(AdvanceFrame()); |
| 451 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 446 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| 452 } | 447 } |
| 453 | 448 |
| 454 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) { | 449 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) { |
| 455 // Set up client with specified estimates. | 450 // Set up client with specified estimates. |
| 456 scheduler_settings_.use_external_begin_frame_source = true; | 451 scheduler_settings_.use_external_begin_frame_source = true; |
| 457 SetUpScheduler(true); | 452 SetUpScheduler(true); |
| 458 | 453 fake_compositor_timing_history_->SetDrawDurationEstimate( |
| 454 base::TimeDelta::FromMilliseconds(1)); |
| 459 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | 455 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( |
| 460 base::TimeDelta::FromMilliseconds(2)); | 456 base::TimeDelta::FromMilliseconds(2)); |
| 461 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | 457 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( |
| 462 base::TimeDelta::FromMilliseconds(4)); | 458 base::TimeDelta::FromMilliseconds(4)); |
| 463 fake_compositor_timing_history_->SetDrawDurationEstimate( | |
| 464 base::TimeDelta::FromMilliseconds(1)); | |
| 465 | 459 |
| 466 EXPECT_FALSE(client_->needs_begin_frames()); | 460 EXPECT_FALSE(client_->needs_begin_frames()); |
| 467 scheduler_->SetChildrenNeedBeginFrames(true); | 461 scheduler_->SetChildrenNeedBeginFrames(true); |
| 468 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 462 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 469 EXPECT_TRUE(client_->needs_begin_frames()); | 463 EXPECT_TRUE(client_->needs_begin_frames()); |
| 470 | 464 |
| 471 client_->Reset(); | 465 client_->Reset(); |
| 472 | 466 |
| 473 BeginFrameArgs frame_args = | 467 BeginFrameArgs frame_args = |
| 474 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 468 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 task_runner().RunPendingTasks(); // Run posted deadline. | 703 task_runner().RunPendingTasks(); // Run posted deadline. |
| 710 EXPECT_FALSE(client_->needs_begin_frames()); | 704 EXPECT_FALSE(client_->needs_begin_frames()); |
| 711 client_->Reset(); | 705 client_->Reset(); |
| 712 } | 706 } |
| 713 | 707 |
| 714 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient { | 708 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient { |
| 715 public: | 709 public: |
| 716 SchedulerClientThatsetNeedsDrawInsideDraw() | 710 SchedulerClientThatsetNeedsDrawInsideDraw() |
| 717 : FakeSchedulerClient(), request_redraws_(false) {} | 711 : FakeSchedulerClient(), request_redraws_(false) {} |
| 718 | 712 |
| 713 void ScheduledActionSendBeginMainFrame() override {} |
| 714 |
| 719 void SetRequestRedrawsInsideDraw(bool enable) { request_redraws_ = enable; } | 715 void SetRequestRedrawsInsideDraw(bool enable) { request_redraws_ = enable; } |
| 720 | 716 |
| 721 DrawResult ScheduledActionDrawAndSwapIfPossible() override { | 717 DrawResult ScheduledActionDrawAndSwapIfPossible() override { |
| 722 // Only SetNeedsRedraw the first time this is called | 718 // Only SetNeedsRedraw the first time this is called |
| 723 if (request_redraws_) { | 719 if (request_redraws_) { |
| 724 scheduler_->SetNeedsRedraw(); | 720 scheduler_->SetNeedsRedraw(); |
| 725 } | 721 } |
| 726 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 722 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
| 727 } | 723 } |
| 728 | 724 |
| 729 DrawResult ScheduledActionDrawAndSwapForced() override { | 725 DrawResult ScheduledActionDrawAndSwapForced() override { |
| 730 NOTREACHED(); | 726 NOTREACHED(); |
| 731 return DRAW_SUCCESS; | 727 return DRAW_SUCCESS; |
| 732 } | 728 } |
| 733 | 729 |
| 730 void ScheduledActionCommit() override {} |
| 731 |
| 734 private: | 732 private: |
| 735 bool request_redraws_; | 733 bool request_redraws_; |
| 736 }; | 734 }; |
| 737 | 735 |
| 738 // Tests for two different situations: | 736 // Tests for two different situations: |
| 739 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside | 737 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside |
| 740 // a ScheduledActionDrawAndSwap | 738 // a ScheduledActionDrawAndSwap |
| 741 // 2. the scheduler drawing twice inside a single tick | 739 // 2. the scheduler drawing twice inside a single tick |
| 742 TEST_F(SchedulerTest, RequestRedrawInsideDraw) { | 740 TEST_F(SchedulerTest, RequestRedrawInsideDraw) { |
| 743 SchedulerClientThatsetNeedsDrawInsideDraw* client = | 741 SchedulerClientThatsetNeedsDrawInsideDraw* client = |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 EXPECT_TRUE(scheduler_->CommitPending()); | 816 EXPECT_TRUE(scheduler_->CommitPending()); |
| 819 EXPECT_FALSE(scheduler_->RedrawPending()); | 817 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 820 EXPECT_TRUE(client->needs_begin_frames()); | 818 EXPECT_TRUE(client->needs_begin_frames()); |
| 821 } | 819 } |
| 822 | 820 |
| 823 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient { | 821 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient { |
| 824 public: | 822 public: |
| 825 SchedulerClientThatSetNeedsCommitInsideDraw() | 823 SchedulerClientThatSetNeedsCommitInsideDraw() |
| 826 : set_needs_commit_on_next_draw_(false) {} | 824 : set_needs_commit_on_next_draw_(false) {} |
| 827 | 825 |
| 826 void ScheduledActionSendBeginMainFrame() override {} |
| 828 DrawResult ScheduledActionDrawAndSwapIfPossible() override { | 827 DrawResult ScheduledActionDrawAndSwapIfPossible() override { |
| 829 // Only SetNeedsCommit the first time this is called | 828 // Only SetNeedsCommit the first time this is called |
| 830 if (set_needs_commit_on_next_draw_) { | 829 if (set_needs_commit_on_next_draw_) { |
| 831 scheduler_->SetNeedsCommit(); | 830 scheduler_->SetNeedsCommit(); |
| 832 set_needs_commit_on_next_draw_ = false; | 831 set_needs_commit_on_next_draw_ = false; |
| 833 } | 832 } |
| 834 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 833 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
| 835 } | 834 } |
| 836 | 835 |
| 837 DrawResult ScheduledActionDrawAndSwapForced() override { | 836 DrawResult ScheduledActionDrawAndSwapForced() override { |
| 838 NOTREACHED(); | 837 NOTREACHED(); |
| 839 return DRAW_SUCCESS; | 838 return DRAW_SUCCESS; |
| 840 } | 839 } |
| 841 | 840 |
| 841 void ScheduledActionCommit() override {} |
| 842 |
| 842 void SetNeedsCommitOnNextDraw() { set_needs_commit_on_next_draw_ = true; } | 843 void SetNeedsCommitOnNextDraw() { set_needs_commit_on_next_draw_ = true; } |
| 843 | 844 |
| 844 private: | 845 private: |
| 845 bool set_needs_commit_on_next_draw_; | 846 bool set_needs_commit_on_next_draw_; |
| 846 }; | 847 }; |
| 847 | 848 |
| 848 // Tests for the scheduler infinite-looping on SetNeedsCommit requests that | 849 // Tests for the scheduler infinite-looping on SetNeedsCommit requests that |
| 849 // happen inside a ScheduledActionDrawAndSwap | 850 // happen inside a ScheduledActionDrawAndSwap |
| 850 TEST_F(SchedulerTest, RequestCommitInsideDraw) { | 851 TEST_F(SchedulerTest, RequestCommitInsideDraw) { |
| 851 SchedulerClientThatSetNeedsCommitInsideDraw* client = | 852 SchedulerClientThatSetNeedsCommitInsideDraw* client = |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 // again. | 1084 // again. |
| 1084 scheduler_->SetNeedsPrepareTiles(); | 1085 scheduler_->SetNeedsPrepareTiles(); |
| 1085 scheduler_->SetNeedsRedraw(); | 1086 scheduler_->SetNeedsRedraw(); |
| 1086 client_->Reset(); | 1087 client_->Reset(); |
| 1087 EXPECT_SCOPED(AdvanceFrame()); | 1088 EXPECT_SCOPED(AdvanceFrame()); |
| 1088 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1089 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1089 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1090 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 1090 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1091 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1091 | 1092 |
| 1092 EXPECT_TRUE(scheduler_->PrepareTilesPending()); | 1093 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 |
| 1125 | 1126 |
| 1126 // If we get another DidPrepareTiles within the same frame, we should | 1127 // If we get another DidPrepareTiles within the same frame, we should |
| 1127 // not PrepareTiles on the next frame. | 1128 // 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(); | |
| 1153 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. | 1152 scheduler_->DidPrepareTiles(); // An explicit PrepareTiles. |
| 1154 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 1153 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 1155 scheduler_->SetNeedsPrepareTiles(); | 1154 scheduler_->SetNeedsPrepareTiles(); |
| 1156 scheduler_->SetNeedsRedraw(); | 1155 scheduler_->SetNeedsRedraw(); |
| 1157 client_->Reset(); | 1156 client_->Reset(); |
| 1158 EXPECT_SCOPED(AdvanceFrame()); | 1157 EXPECT_SCOPED(AdvanceFrame()); |
| 1159 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1158 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1160 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1159 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 1161 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1160 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1162 | 1161 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1182 client_->Reset(); | 1181 client_->Reset(); |
| 1183 task_runner().RunPendingTasks(); // Run posted deadline. | 1182 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1184 EXPECT_EQ(1, client_->num_draws()); | 1183 EXPECT_EQ(1, client_->num_draws()); |
| 1185 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); | 1184 EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| 1186 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles")); | 1185 EXPECT_TRUE(client_->HasAction("ScheduledActionPrepareTiles")); |
| 1187 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"), | 1186 EXPECT_LT(client_->ActionIndex("ScheduledActionDrawAndSwapIfPossible"), |
| 1188 client_->ActionIndex("ScheduledActionPrepareTiles")); | 1187 client_->ActionIndex("ScheduledActionPrepareTiles")); |
| 1189 EXPECT_FALSE(scheduler_->RedrawPending()); | 1188 EXPECT_FALSE(scheduler_->RedrawPending()); |
| 1190 EXPECT_FALSE(scheduler_->PrepareTilesPending()); | 1189 EXPECT_FALSE(scheduler_->PrepareTilesPending()); |
| 1191 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1190 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 Loading... |
| 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)); |
| 1300 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | 1302 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( |
| 1301 base::TimeDelta::FromMilliseconds( | 1303 base::TimeDelta::FromMilliseconds( |
| 1302 begin_main_frame_to_commit_estimate_in_ms)); | 1304 begin_main_frame_to_commit_estimate_in_ms)); |
| 1303 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | 1305 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( |
| 1304 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms)); | 1306 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 Loading... |
| 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_->SetDrawDurationEstimate( |
| 1374 base::TimeDelta::FromMilliseconds(1)); |
| 1373 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | 1375 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( |
| 1374 base::TimeDelta::FromMilliseconds(32)); | 1376 base::TimeDelta::FromMilliseconds(32)); |
| 1375 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | 1377 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( |
| 1376 base::TimeDelta::FromMilliseconds(32)); | 1378 base::TimeDelta::FromMilliseconds(32)); |
| 1377 fake_compositor_timing_history_->SetDrawDurationEstimate( | |
| 1378 base::TimeDelta::FromMilliseconds(1)); | |
| 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 Loading... |
| 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_->SetDrawDurationEstimate( |
| 1454 base::TimeDelta::FromMilliseconds(1)); |
| 1453 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | 1455 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( |
| 1454 base::TimeDelta::FromMilliseconds(32)); | 1456 base::TimeDelta::FromMilliseconds(32)); |
| 1455 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | 1457 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( |
| 1456 base::TimeDelta::FromMilliseconds(32)); | 1458 base::TimeDelta::FromMilliseconds(32)); |
| 1457 fake_compositor_timing_history_->SetDrawDurationEstimate( | |
| 1458 base::TimeDelta::FromMilliseconds(1)); | |
| 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 Loading... |
| 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_->SetDrawDurationEstimate( |
| 1542 base::TimeDelta::FromMilliseconds(1)); |
| 1541 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | 1543 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( |
| 1542 base::TimeDelta::FromMilliseconds(32)); | 1544 base::TimeDelta::FromMilliseconds(32)); |
| 1543 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | 1545 fake_compositor_timing_history_->SetCommitToActivateDurationEstimate( |
| 1544 base::TimeDelta::FromMilliseconds(32)); | 1546 base::TimeDelta::FromMilliseconds(32)); |
| 1545 fake_compositor_timing_history_->SetDrawDurationEstimate( | |
| 1546 base::TimeDelta::FromMilliseconds(1)); | |
| 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 Loading... |
| 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 } |
| 2855 }; | 2860 }; |
| 2856 | 2861 |
| 2857 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) { | 2862 TEST_F(SchedulerTest, SynchronousCompositorPrepareTilesOnDraw) { |
| 2858 scheduler_settings_.using_synchronous_renderer_compositor = true; | 2863 scheduler_settings_.using_synchronous_renderer_compositor = true; |
| 2859 scheduler_settings_.use_external_begin_frame_source = true; | 2864 scheduler_settings_.use_external_begin_frame_source = true; |
| 2860 | 2865 |
| 2861 scoped_ptr<FakeSchedulerClient> client = | 2866 scoped_ptr<FakeSchedulerClient> client = |
| 2862 make_scoped_ptr(new SchedulerClientSetNeedsPrepareTilesOnDraw); | 2867 make_scoped_ptr(new SchedulerClientSetNeedsPrepareTilesOnDraw); |
| 2863 SetUpScheduler(client.Pass(), true); | 2868 SetUpScheduler(client.Pass(), true); |
| 2864 | 2869 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2955 scheduler_->SetImplLatencyTakesPriority(true); | 2960 scheduler_->SetImplLatencyTakesPriority(true); |
| 2956 scheduler_->SetChildrenNeedBeginFrames(true); | 2961 scheduler_->SetChildrenNeedBeginFrames(true); |
| 2957 | 2962 |
| 2958 EXPECT_SCOPED(AdvanceFrame()); | 2963 EXPECT_SCOPED(AdvanceFrame()); |
| 2959 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 2964 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| 2960 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); | 2965 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); |
| 2961 } | 2966 } |
| 2962 | 2967 |
| 2963 } // namespace | 2968 } // namespace |
| 2964 } // namespace cc | 2969 } // namespace cc |
| OLD | NEW |