 Chromium Code Reviews
 Chromium Code Reviews Issue 2659123004:
  cc: Add scheduler support for invalidating content on impl thread.  (Closed)
    
  
    Issue 2659123004:
  cc: Add scheduler support for invalidating content on impl thread.  (Closed) 
  | 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/23 00:33:21
Please add a basic test for just invalidation in t
 
Khushal
2017/02/23 01:25:43
Done.
 | |
| 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 EXPECT_FALSE(scheduler_->needs_impl_side_invalidation()); | |
| 
sunnyps
2017/02/23 00:33:21
Can you run the deadline and check that no invalid
 
Khushal
2017/02/23 01:25:43
Done.
 | |
| 3209 } | |
| 3210 | |
| 3211 TEST_F(SchedulerTest, AbortedCommitsTriggerImplSideInvalidations) { | |
| 3212 SetUpScheduler(EXTERNAL_BFS); | |
| 3213 | |
| 3214 // Request a main frame and invalidation. | |
| 3215 scheduler_->SetNeedsBeginMainFrame(); | |
| 3216 scheduler_->SetNeedsImplSideInvalidation(); | |
| 3217 client_->Reset(); | |
| 3218 EXPECT_SCOPED(AdvanceFrame()); | |
| 3219 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | |
| 3220 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | |
| 3221 | |
| 3222 // Abort the main frame and request another one, the impl-side invalidations | |
| 3223 // should not be blocked on the main frame. | |
| 3224 client_->Reset(); | |
| 3225 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks::Now()); | |
| 3226 scheduler_->BeginMainFrameAborted(CommitEarlyOutReason::FINISHED_NO_UPDATES); | |
| 3227 scheduler_->SetNeedsBeginMainFrame(); | |
| 3228 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); | |
| 3229 EXPECT_SINGLE_ACTION("ScheduledActionPerformImplSideInvalidation", client_); | |
| 3230 | |
| 3231 // Activate the sync tree. | |
| 3232 client_->Reset(); | |
| 3233 scheduler_->NotifyReadyToActivate(); | |
| 3234 EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); | |
| 3235 | |
| 3236 // Second impl frame. | |
| 3237 client_->Reset(); | |
| 3238 EXPECT_SCOPED(AdvanceFrame()); | |
| 3239 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | |
| 3240 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | |
| 3241 | |
| 3242 // Deadline. | |
| 3243 client_->Reset(); | |
| 3244 task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true)); | |
| 3245 EXPECT_SINGLE_ACTION("ScheduledActionDrawIfPossible", client_); | |
| 3246 } | |
| 3247 | |
| 3186 // The three letters appeneded to each version of this test mean the following:s | 3248 // 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; | 3249 // tree_priority: B = both trees same priority; A = active tree priority; | 
| 3188 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll | 3250 // scroll_handler_state: H = affects scroll handler; N = does not affect scroll | 
| 3189 // handler; | 3251 // handler; | 
| 3190 // durations: F = fast durations; S = slow durations | 3252 // durations: F = fast durations; S = slow durations | 
| 3191 bool SchedulerTest::BeginMainFrameOnCriticalPath( | 3253 bool SchedulerTest::BeginMainFrameOnCriticalPath( | 
| 3192 TreePriority tree_priority, | 3254 TreePriority tree_priority, | 
| 3193 ScrollHandlerState scroll_handler_state, | 3255 ScrollHandlerState scroll_handler_state, | 
| 3194 base::TimeDelta durations) { | 3256 base::TimeDelta durations) { | 
| 3195 SetUpScheduler(EXTERNAL_BFS); | 3257 SetUpScheduler(EXTERNAL_BFS); | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3251 } | 3313 } | 
| 3252 | 3314 | 
| 3253 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 3315 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { | 
| 3254 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 3316 EXPECT_FALSE(BeginMainFrameOnCriticalPath( | 
| 3255 SMOOTHNESS_TAKES_PRIORITY, | 3317 SMOOTHNESS_TAKES_PRIORITY, | 
| 3256 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 3318 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); | 
| 3257 } | 3319 } | 
| 3258 | 3320 | 
| 3259 } // namespace | 3321 } // namespace | 
| 3260 } // namespace cc | 3322 } // namespace cc | 
| OLD | NEW |