Chromium Code Reviews| 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, ImplSideInvalidationsMergedWithCommit) { | |
|
sunnyps
2017/02/20 23:19:22
I don't understand what this is testing. If SetNee
Khushal
2017/02/21 09:43:45
Its testing that if there is a main frame request,
| |
| 3190 SetUpScheduler(EXTERNAL_BFS); | |
| 3191 | |
| 3192 // Request a main frame and invalidation, the only action run should be | |
| 3193 // sending the main frame. | |
| 3194 scheduler_->SetNeedsBeginMainFrame(); | |
| 3195 scheduler_->SetNeedsImplSideInvalidation(); | |
| 3196 client_->Reset(); | |
| 3197 EXPECT_SCOPED(AdvanceFrame()); | |
| 3198 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | |
| 3199 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | |
| 3200 | |
| 3201 // Respond with a commit. The scheduler should only perform the commit | |
| 3202 // actions since the impl-side invalidation request will be merged with the | |
| 3203 // commit. | |
| 3204 client_->Reset(); | |
| 3205 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now()); | |
| 3206 scheduler_->NotifyReadyToCommit(); | |
| 3207 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | |
| 3208 } | |
| 3209 | |
| 3210 TEST_F(SchedulerTest, AbortedCommitsTriggerImplSideInvalidations) { | |
| 3211 SetUpScheduler(EXTERNAL_BFS); | |
| 3212 | |
| 3213 // Request a main frame and invalidation. | |
| 3214 scheduler_->SetNeedsBeginMainFrame(); | |
| 3215 scheduler_->SetNeedsImplSideInvalidation(); | |
| 3216 client_->Reset(); | |
| 3217 EXPECT_SCOPED(AdvanceFrame()); | |
| 3218 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | |
| 3219 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | |
| 3220 | |
| 3221 // Abort the main frame and request another one, the impl-side invalidations | |
| 3222 // should not be blocked on the main frame. | |
| 3223 client_->Reset(); | |
| 3224 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now()); | |
| 3225 scheduler_->BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); | |
| 3226 scheduler_->SetNeedsBeginMainFrame(); | |
| 3227 EXPECT_SINGLE_ACTION("ScheduledActionPerformImplSideInvalidation", client_); | |
| 3228 } | |
| 3229 | |
| 3186 // The three letters appeneded to each version of this test mean the following:s | 3230 // 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; | 3231 // tree_priority: B = both trees same priority; A = active tree priority; |
| 3188 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll | 3232 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll |
| 3189 // handler; | 3233 // handler; |
| 3190 // durations: F = fast durations; S = slow durations | 3234 // durations: F = fast durations; S = slow durations |
| 3191 bool SchedulerTest::BeginMainFrameOnCriticalPath( | 3235 bool SchedulerTest::BeginMainFrameOnCriticalPath( |
| 3192 TreePriority tree_priority, | 3236 TreePriority tree_priority, |
| 3193 ScrollHandlerState scroll_handler_state, | 3237 ScrollHandlerState scroll_handler_state, |
| 3194 base::TimeDelta durations) { | 3238 base::TimeDelta durations) { |
| 3195 SetUpScheduler(EXTERNAL_BFS); | 3239 SetUpScheduler(EXTERNAL_BFS); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3251 } | 3295 } |
| 3252 | 3296 |
| 3253 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3297 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { |
| 3254 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3298 EXPECT_FALSE(BeginMainFrameOnCriticalPath( |
| 3255 SMOOTHNESS_TAKES_PRIORITY, | 3299 SMOOTHNESS_TAKES_PRIORITY, |
| 3256 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3300 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); |
| 3257 } | 3301 } |
| 3258 | 3302 |
| 3259 } // namespace | 3303 } // namespace |
| 3260 } // namespace cc | 3304 } // namespace cc |
| OLD | NEW |