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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 164 } |
165 void ScheduledActionPrepareTiles() override { | 165 void ScheduledActionPrepareTiles() override { |
166 PushAction("ScheduledActionPrepareTiles"); | 166 PushAction("ScheduledActionPrepareTiles"); |
167 scheduler_->WillPrepareTiles(); | 167 scheduler_->WillPrepareTiles(); |
168 scheduler_->DidPrepareTiles(); | 168 scheduler_->DidPrepareTiles(); |
169 } | 169 } |
170 void ScheduledActionInvalidateCompositorFrameSink() override { | 170 void ScheduledActionInvalidateCompositorFrameSink() override { |
171 actions_.push_back("ScheduledActionInvalidateCompositorFrameSink"); | 171 actions_.push_back("ScheduledActionInvalidateCompositorFrameSink"); |
172 states_.push_back(scheduler_->AsValue()); | 172 states_.push_back(scheduler_->AsValue()); |
173 } | 173 } |
| 174 void ScheduledActionPerformImplSideInvalidation() override { |
| 175 PushAction("ScheduledActionPerformImplSideInvalidation"); |
| 176 } |
174 | 177 |
175 void SendBeginMainFrameNotExpectedSoon() override { | 178 void SendBeginMainFrameNotExpectedSoon() override { |
176 PushAction("SendBeginMainFrameNotExpectedSoon"); | 179 PushAction("SendBeginMainFrameNotExpectedSoon"); |
177 } | 180 } |
178 | 181 |
179 bool IsInsideBeginImplFrame() const { return inside_begin_impl_frame_; } | 182 bool IsInsideBeginImplFrame() const { return inside_begin_impl_frame_; } |
180 | 183 |
181 base::Callback<bool(void)> InsideBeginImplFrame(bool state) { | 184 base::Callback<bool(void)> InsideBeginImplFrame(bool state) { |
182 return base::Bind(&FakeSchedulerClient::InsideBeginImplFrameCallback, | 185 return base::Bind(&FakeSchedulerClient::InsideBeginImplFrameCallback, |
183 base::Unretained(this), state); | 186 base::Unretained(this), state); |
(...skipping 2992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3176 | 3179 |
3177 // Abort the commit. | 3180 // Abort the commit. |
3178 client_->Reset(); | 3181 client_->Reset(); |
3179 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now()); | 3182 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now()); |
3180 scheduler_->BeginMainFrameAborted( | 3183 scheduler_->BeginMainFrameAborted( |
3181 CommitEarlyOutReason::ABORTED_COMPOSITOR_FRAME_SINK_LOST); | 3184 CommitEarlyOutReason::ABORTED_COMPOSITOR_FRAME_SINK_LOST); |
3182 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", | 3185 EXPECT_SINGLE_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", |
3183 client_); | 3186 client_); |
3184 } | 3187 } |
3185 | 3188 |
| 3189 TEST_F(SchedulerTest, ImplSideInvalidationsInDeadline) { |
| 3190 SetUpScheduler(EXTERNAL_BFS); |
| 3191 |
| 3192 // Request an impl-side invalidation and trigger the deadline. Ensure that the |
| 3193 // invalidation runs inside the deadline. |
| 3194 scheduler_->SetNeedsImplSideInvalidation(); |
| 3195 client_->Reset(); |
| 3196 EXPECT_SCOPED(AdvanceFrame()); |
| 3197 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 3198 |
| 3199 // Deadline. |
| 3200 client_->Reset(); |
| 3201 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 3202 EXPECT_SINGLE_ACTION("ScheduledActionPerformImplSideInvalidation", client_); |
| 3203 } |
| 3204 |
| 3205 TEST_F(SchedulerTest, ImplSideInvalidationsMergedWithCommit) { |
| 3206 SetUpScheduler(EXTERNAL_BFS); |
| 3207 |
| 3208 // Request a main frame and invalidation, the only action run should be |
| 3209 // sending the main frame. |
| 3210 scheduler_->SetNeedsBeginMainFrame(); |
| 3211 scheduler_->SetNeedsImplSideInvalidation(); |
| 3212 client_->Reset(); |
| 3213 EXPECT_SCOPED(AdvanceFrame()); |
| 3214 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3215 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 3216 |
| 3217 // Respond with a commit. The scheduler should only perform the commit |
| 3218 // actions since the impl-side invalidation request will be merged with the |
| 3219 // commit. |
| 3220 client_->Reset(); |
| 3221 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now()); |
| 3222 scheduler_->NotifyReadyToCommit(); |
| 3223 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); |
| 3224 EXPECT_FALSE(scheduler_->needs_impl_side_invalidation()); |
| 3225 |
| 3226 // Deadline. |
| 3227 client_->Reset(); |
| 3228 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 3229 EXPECT_NO_ACTION(client_); |
| 3230 } |
| 3231 |
| 3232 TEST_F(SchedulerTest, AbortedCommitsTriggerImplSideInvalidations) { |
| 3233 SetUpScheduler(EXTERNAL_BFS); |
| 3234 |
| 3235 // Request a main frame and invalidation. |
| 3236 scheduler_->SetNeedsBeginMainFrame(); |
| 3237 scheduler_->SetNeedsImplSideInvalidation(); |
| 3238 client_->Reset(); |
| 3239 EXPECT_SCOPED(AdvanceFrame()); |
| 3240 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3241 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 3242 |
| 3243 // Abort the main frame and request another one, the impl-side invalidations |
| 3244 // should not be blocked on the main frame. |
| 3245 client_->Reset(); |
| 3246 scheduler_->SetNeedsBeginMainFrame(); |
| 3247 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now()); |
| 3248 scheduler_->BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); |
| 3249 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 3250 EXPECT_SINGLE_ACTION("ScheduledActionPerformImplSideInvalidation", client_); |
| 3251 |
| 3252 // Activate the sync tree. |
| 3253 client_->Reset(); |
| 3254 scheduler_->NotifyReadyToActivate(); |
| 3255 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); |
| 3256 |
| 3257 // Second impl frame. |
| 3258 client_->Reset(); |
| 3259 EXPECT_SCOPED(AdvanceFrame()); |
| 3260 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 3261 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
| 3262 |
| 3263 // Deadline. |
| 3264 client_->Reset(); |
| 3265 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); |
| 3266 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); |
| 3267 } |
| 3268 |
3186 // The three letters appeneded to each version of this test mean the following:s | 3269 // The three letters appeneded to each version of this test mean the following:s |
3187 // tree_priority: B = both trees same priority; A = active tree priority; | 3270 // tree_priority: B = both trees same priority; A = active tree priority; |
3188 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll | 3271 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll |
3189 // handler; | 3272 // handler; |
3190 // durations: F = fast durations; S = slow durations | 3273 // durations: F = fast durations; S = slow durations |
3191 bool SchedulerTest::BeginMainFrameOnCriticalPath( | 3274 bool SchedulerTest::BeginMainFrameOnCriticalPath( |
3192 TreePriority tree_priority, | 3275 TreePriority tree_priority, |
3193 ScrollHandlerState scroll_handler_state, | 3276 ScrollHandlerState scroll_handler_state, |
3194 base::TimeDelta durations) { | 3277 base::TimeDelta durations) { |
3195 SetUpScheduler(EXTERNAL_BFS); | 3278 SetUpScheduler(EXTERNAL_BFS); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3251 } | 3334 } |
3252 | 3335 |
3253 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3336 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
3254 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3337 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
3255 SMOOTHNESS_TAKES_PRIORITY, | 3338 SMOOTHNESS_TAKES_PRIORITY, |
3256 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3339 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
3257 } | 3340 } |
3258 | 3341 |
3259 } // namespace | 3342 } // namespace |
3260 } // namespace cc | 3343 } // namespace cc |
OLD | NEW |