Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: cc/scheduler/scheduler_unittest.cc

Issue 191293004: cc: Rename FinishCommit to NotifyReadyToCommit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/trees/thread_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "cc/scheduler/scheduler.h" 4 #include "cc/scheduler/scheduler.h"
5 5
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 17 matching lines...) Expand all
28 #define EXPECT_SINGLE_ACTION(action, client) \ 28 #define EXPECT_SINGLE_ACTION(action, client) \
29 EXPECT_ACTION(action, client, 0, 1) 29 EXPECT_ACTION(action, client, 0, 1)
30 30
31 namespace cc { 31 namespace cc {
32 namespace { 32 namespace {
33 33
34 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler) { 34 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler) {
35 scheduler->DidCreateAndInitializeOutputSurface(); 35 scheduler->DidCreateAndInitializeOutputSurface();
36 scheduler->SetNeedsCommit(); 36 scheduler->SetNeedsCommit();
37 scheduler->NotifyBeginMainFrameStarted(); 37 scheduler->NotifyBeginMainFrameStarted();
38 scheduler->FinishCommit(); 38 scheduler->NotifyReadyToCommit();
39 // Go through the motions to draw the commit. 39 // Go through the motions to draw the commit.
40 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 40 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
41 scheduler->OnBeginImplFrameDeadline(); 41 scheduler->OnBeginImplFrameDeadline();
42 // We need another BeginImplFrame so Scheduler calls 42 // We need another BeginImplFrame so Scheduler calls
43 // SetNeedsBeginImplFrame(false). 43 // SetNeedsBeginImplFrame(false).
44 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 44 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
45 scheduler->OnBeginImplFrameDeadline(); 45 scheduler->OnBeginImplFrameDeadline();
46 } 46 }
47 47
48 class FakeSchedulerClient : public SchedulerClient { 48 class FakeSchedulerClient : public SchedulerClient {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 EXPECT_TRUE(client.needs_begin_impl_frame()); 231 EXPECT_TRUE(client.needs_begin_impl_frame());
232 client.Reset(); 232 client.Reset();
233 233
234 // If we don't swap on the deadline, we need to request another 234 // If we don't swap on the deadline, we need to request another
235 // BeginImplFrame. 235 // BeginImplFrame.
236 scheduler->OnBeginImplFrameDeadline(); 236 scheduler->OnBeginImplFrameDeadline();
237 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); 237 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
238 EXPECT_TRUE(client.needs_begin_impl_frame()); 238 EXPECT_TRUE(client.needs_begin_impl_frame());
239 client.Reset(); 239 client.Reset();
240 240
241 // FinishCommit should commit 241 // NotifyReadyToCommit should trigger the commit.
242 scheduler->NotifyBeginMainFrameStarted(); 242 scheduler->NotifyBeginMainFrameStarted();
243 scheduler->FinishCommit(); 243 scheduler->NotifyReadyToCommit();
244 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 244 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
245 EXPECT_TRUE(client.needs_begin_impl_frame()); 245 EXPECT_TRUE(client.needs_begin_impl_frame());
246 client.Reset(); 246 client.Reset();
247 247
248 // BeginImplFrame should prepare the draw. 248 // BeginImplFrame should prepare the draw.
249 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 249 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
250 EXPECT_SINGLE_ACTION("PostBeginImplFrameDeadlineTask", client); 250 EXPECT_SINGLE_ACTION("PostBeginImplFrameDeadlineTask", client);
251 EXPECT_TRUE(client.needs_begin_impl_frame()); 251 EXPECT_TRUE(client.needs_begin_impl_frame());
252 client.Reset(); 252 client.Reset();
253 253
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 EXPECT_TRUE(client.needs_begin_impl_frame()); 295 EXPECT_TRUE(client.needs_begin_impl_frame());
296 client.Reset(); 296 client.Reset();
297 297
298 // Now SetNeedsCommit again. Calling here means we need a second commit. 298 // Now SetNeedsCommit again. Calling here means we need a second commit.
299 scheduler->SetNeedsCommit(); 299 scheduler->SetNeedsCommit();
300 EXPECT_EQ(client.num_actions_(), 0); 300 EXPECT_EQ(client.num_actions_(), 0);
301 client.Reset(); 301 client.Reset();
302 302
303 // Finish the first commit. 303 // Finish the first commit.
304 scheduler->NotifyBeginMainFrameStarted(); 304 scheduler->NotifyBeginMainFrameStarted();
305 scheduler->FinishCommit(); 305 scheduler->NotifyReadyToCommit();
306 EXPECT_ACTION("ScheduledActionCommit", client, 0, 2); 306 EXPECT_ACTION("ScheduledActionCommit", client, 0, 2);
307 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2); 307 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2);
308 client.Reset(); 308 client.Reset();
309 scheduler->OnBeginImplFrameDeadline(); 309 scheduler->OnBeginImplFrameDeadline();
310 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 310 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
311 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); 311 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2);
312 312
313 // Because we just swapped, the Scheduler should also request the next 313 // Because we just swapped, the Scheduler should also request the next
314 // BeginImplFrame from the OutputSurface. 314 // BeginImplFrame from the OutputSurface.
315 EXPECT_TRUE(client.needs_begin_impl_frame()); 315 EXPECT_TRUE(client.needs_begin_impl_frame());
316 client.Reset(); 316 client.Reset();
317 317
318 // Since another commit is needed, the next BeginImplFrame should initiate 318 // Since another commit is needed, the next BeginImplFrame should initiate
319 // the second commit. 319 // the second commit.
320 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 320 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
321 EXPECT_EQ(client.num_actions_(), 2); 321 EXPECT_EQ(client.num_actions_(), 2);
322 EXPECT_TRUE(client.HasAction("ScheduledActionSendBeginMainFrame")); 322 EXPECT_TRUE(client.HasAction("ScheduledActionSendBeginMainFrame"));
323 EXPECT_TRUE(client.HasAction("PostBeginImplFrameDeadlineTask")); 323 EXPECT_TRUE(client.HasAction("PostBeginImplFrameDeadlineTask"));
324 client.Reset(); 324 client.Reset();
325 325
326 // Finishing the commit before the deadline should post a new deadline task 326 // Finishing the commit before the deadline should post a new deadline task
327 // to trigger the deadline early. 327 // to trigger the deadline early.
328 scheduler->NotifyBeginMainFrameStarted(); 328 scheduler->NotifyBeginMainFrameStarted();
329 scheduler->FinishCommit(); 329 scheduler->NotifyReadyToCommit();
330 EXPECT_ACTION("ScheduledActionCommit", client, 0, 2); 330 EXPECT_ACTION("ScheduledActionCommit", client, 0, 2);
331 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2); 331 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2);
332 client.Reset(); 332 client.Reset();
333 scheduler->OnBeginImplFrameDeadline(); 333 scheduler->OnBeginImplFrameDeadline();
334 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 334 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
335 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); 335 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2);
336 EXPECT_TRUE(client.needs_begin_impl_frame()); 336 EXPECT_TRUE(client.needs_begin_impl_frame());
337 client.Reset(); 337 client.Reset();
338 338
339 // On the next BeginImplFrame, verify we go back to a quiescent state and 339 // On the next BeginImplFrame, verify we go back to a quiescent state and
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 EXPECT_EQ(0, client.num_actions_()); 406 EXPECT_EQ(0, client.num_actions_());
407 407
408 client.Reset(); 408 client.Reset();
409 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 409 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
410 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 2); 410 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 2);
411 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2); 411 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2);
412 412
413 // Commit will release the texture. 413 // Commit will release the texture.
414 client.Reset(); 414 client.Reset();
415 scheduler->NotifyBeginMainFrameStarted(); 415 scheduler->NotifyBeginMainFrameStarted();
416 scheduler->FinishCommit(); 416 scheduler->NotifyReadyToCommit();
417 EXPECT_ACTION("ScheduledActionCommit", client, 0, 2); 417 EXPECT_ACTION("ScheduledActionCommit", client, 0, 2);
418 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2); 418 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2);
419 EXPECT_TRUE(scheduler->RedrawPending()); 419 EXPECT_TRUE(scheduler->RedrawPending());
420 420
421 // Now we can draw again after the commit happens. 421 // Now we can draw again after the commit happens.
422 client.Reset(); 422 client.Reset();
423 scheduler->OnBeginImplFrameDeadline(); 423 scheduler->OnBeginImplFrameDeadline();
424 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 424 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
425 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); 425 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2);
426 EXPECT_FALSE(scheduler->RedrawPending()); 426 EXPECT_FALSE(scheduler->RedrawPending());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 463
464 client.Reset(); 464 client.Reset();
465 scheduler->OnBeginImplFrameDeadline(); 465 scheduler->OnBeginImplFrameDeadline();
466 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); 466 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
467 467
468 // Although the compositor cannot draw because textures are locked by main 468 // Although the compositor cannot draw because textures are locked by main
469 // thread, we continue requesting SetNeedsBeginImplFrame in anticipation of 469 // thread, we continue requesting SetNeedsBeginImplFrame in anticipation of
470 // the unlock. 470 // the unlock.
471 EXPECT_TRUE(client.needs_begin_impl_frame()); 471 EXPECT_TRUE(client.needs_begin_impl_frame());
472 472
473 // Trigger the commit 473 // Trigger the commit.
474 scheduler->NotifyBeginMainFrameStarted(); 474 scheduler->NotifyBeginMainFrameStarted();
475 scheduler->FinishCommit(); 475 scheduler->NotifyReadyToCommit();
476 EXPECT_TRUE(client.needs_begin_impl_frame()); 476 EXPECT_TRUE(client.needs_begin_impl_frame());
477 477
478 // Between commit and draw, texture acquisition for main thread delayed, 478 // Between commit and draw, texture acquisition for main thread delayed,
479 // and main thread blocks. 479 // and main thread blocks.
480 client.Reset(); 480 client.Reset();
481 scheduler->SetMainThreadNeedsLayerTextures(); 481 scheduler->SetMainThreadNeedsLayerTextures();
482 EXPECT_EQ(0, client.num_actions_()); 482 EXPECT_EQ(0, client.num_actions_());
483 483
484 // No implicit commit is expected. 484 // No implicit commit is expected.
485 client.Reset(); 485 client.Reset();
(...skipping 26 matching lines...) Expand all
512 EXPECT_TRUE(client.needs_begin_impl_frame()); 512 EXPECT_TRUE(client.needs_begin_impl_frame());
513 513
514 client.Reset(); 514 client.Reset();
515 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 515 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
516 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 2); 516 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 2);
517 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2); 517 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2);
518 client.Reset(); 518 client.Reset();
519 519
520 // Trigger the commit, which will trigger the deadline task early. 520 // Trigger the commit, which will trigger the deadline task early.
521 scheduler->NotifyBeginMainFrameStarted(); 521 scheduler->NotifyBeginMainFrameStarted();
522 scheduler->FinishCommit(); 522 scheduler->NotifyReadyToCommit();
523 EXPECT_ACTION("ScheduledActionCommit", client, 0, 2); 523 EXPECT_ACTION("ScheduledActionCommit", client, 0, 2);
524 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2); 524 EXPECT_ACTION("PostBeginImplFrameDeadlineTask", client, 1, 2);
525 EXPECT_TRUE(client.needs_begin_impl_frame()); 525 EXPECT_TRUE(client.needs_begin_impl_frame());
526 client.Reset(); 526 client.Reset();
527 527
528 // Verify we draw on the next BeginImplFrame deadline 528 // Verify we draw on the next BeginImplFrame deadline
529 scheduler->OnBeginImplFrameDeadline(); 529 scheduler->OnBeginImplFrameDeadline();
530 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 530 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
531 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); 531 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2);
532 EXPECT_TRUE(client.needs_begin_impl_frame()); 532 EXPECT_TRUE(client.needs_begin_impl_frame());
533 client.Reset(); 533 client.Reset();
534 } 534 }
535 535
536 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { 536 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) {
537 FakeSchedulerClient client; 537 FakeSchedulerClient client;
538 SchedulerSettings scheduler_settings; 538 SchedulerSettings scheduler_settings;
539 Scheduler* scheduler = client.CreateScheduler(scheduler_settings); 539 Scheduler* scheduler = client.CreateScheduler(scheduler_settings);
540 scheduler->SetCanStart(); 540 scheduler->SetCanStart();
541 scheduler->SetVisible(true); 541 scheduler->SetVisible(true);
542 scheduler->SetCanDraw(true); 542 scheduler->SetCanDraw(true);
543 543
544 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 544 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
545 client.Reset(); 545 client.Reset();
546 scheduler->DidCreateAndInitializeOutputSurface(); 546 scheduler->DidCreateAndInitializeOutputSurface();
547 547
548 scheduler->SetNeedsCommit(); 548 scheduler->SetNeedsCommit();
549 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 549 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
550 scheduler->OnBeginImplFrameDeadline(); 550 scheduler->OnBeginImplFrameDeadline();
551 scheduler->NotifyBeginMainFrameStarted(); 551 scheduler->NotifyBeginMainFrameStarted();
552 scheduler->FinishCommit(); 552 scheduler->NotifyReadyToCommit();
553 scheduler->SetMainThreadNeedsLayerTextures(); 553 scheduler->SetMainThreadNeedsLayerTextures();
554 scheduler->SetNeedsCommit(); 554 scheduler->SetNeedsCommit();
555 client.Reset(); 555 client.Reset();
556 // Verify that pending texture acquisition fires when visibility 556 // Verify that pending texture acquisition fires when visibility
557 // is lost in order to avoid a deadlock. 557 // is lost in order to avoid a deadlock.
558 scheduler->SetVisible(false); 558 scheduler->SetVisible(false);
559 EXPECT_SINGLE_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", 559 EXPECT_SINGLE_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
560 client); 560 client);
561 561
562 client.Reset(); 562 client.Reset();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 EXPECT_TRUE(client.needs_begin_impl_frame()); 737 EXPECT_TRUE(client.needs_begin_impl_frame());
738 738
739 client.SetNeedsCommitOnNextDraw(); 739 client.SetNeedsCommitOnNextDraw();
740 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 740 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
741 client.SetNeedsCommitOnNextDraw(); 741 client.SetNeedsCommitOnNextDraw();
742 scheduler->OnBeginImplFrameDeadline(); 742 scheduler->OnBeginImplFrameDeadline();
743 EXPECT_EQ(1, client.num_draws()); 743 EXPECT_EQ(1, client.num_draws());
744 EXPECT_TRUE(scheduler->CommitPending()); 744 EXPECT_TRUE(scheduler->CommitPending());
745 EXPECT_TRUE(client.needs_begin_impl_frame()); 745 EXPECT_TRUE(client.needs_begin_impl_frame());
746 scheduler->NotifyBeginMainFrameStarted(); 746 scheduler->NotifyBeginMainFrameStarted();
747 scheduler->FinishCommit(); 747 scheduler->NotifyReadyToCommit();
748 748
749 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 749 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
750 scheduler->OnBeginImplFrameDeadline(); 750 scheduler->OnBeginImplFrameDeadline();
751 EXPECT_EQ(2, client.num_draws()); 751 EXPECT_EQ(2, client.num_draws());
752 752
753 EXPECT_FALSE(scheduler->RedrawPending()); 753 EXPECT_FALSE(scheduler->RedrawPending());
754 EXPECT_FALSE(scheduler->CommitPending()); 754 EXPECT_FALSE(scheduler->CommitPending());
755 EXPECT_TRUE(client.needs_begin_impl_frame()); 755 EXPECT_TRUE(client.needs_begin_impl_frame());
756 756
757 // We stop requesting BeginImplFrames after a BeginImplFrame where we don't 757 // We stop requesting BeginImplFrames after a BeginImplFrame where we don't
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 851
852 // Tell the client that it will fail to swap. 852 // Tell the client that it will fail to swap.
853 client.SetDrawWillHappen(true); 853 client.SetDrawWillHappen(true);
854 client.SetSwapWillHappenIfDrawHappens(false); 854 client.SetSwapWillHappenIfDrawHappens(false);
855 855
856 // Get the compositor to do a ScheduledActionDrawAndReadback. 856 // Get the compositor to do a ScheduledActionDrawAndReadback.
857 scheduler->SetCanDraw(true); 857 scheduler->SetCanDraw(true);
858 scheduler->SetNeedsRedraw(); 858 scheduler->SetNeedsRedraw();
859 scheduler->SetNeedsForcedCommitForReadback(); 859 scheduler->SetNeedsForcedCommitForReadback();
860 scheduler->NotifyBeginMainFrameStarted(); 860 scheduler->NotifyBeginMainFrameStarted();
861 scheduler->FinishCommit(); 861 scheduler->NotifyReadyToCommit();
862 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback")); 862 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback"));
863 } 863 }
864 864
865 TEST(SchedulerTest, BackToBackReadbackAllowed) { 865 TEST(SchedulerTest, BackToBackReadbackAllowed) {
866 // Some clients call readbacks twice in a row before the replacement 866 // Some clients call readbacks twice in a row before the replacement
867 // commit comes in. Make sure it is allowed. 867 // commit comes in. Make sure it is allowed.
868 FakeSchedulerClient client; 868 FakeSchedulerClient client;
869 SchedulerSettings default_scheduler_settings; 869 SchedulerSettings default_scheduler_settings;
870 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 870 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
871 871
872 // Get the compositor to do 2 ScheduledActionDrawAndReadbacks before 872 // Get the compositor to do 2 ScheduledActionDrawAndReadbacks before
873 // the replacement commit comes in. 873 // the replacement commit comes in.
874 scheduler->SetCanDraw(true); 874 scheduler->SetCanDraw(true);
875 scheduler->SetNeedsRedraw(); 875 scheduler->SetNeedsRedraw();
876 scheduler->SetNeedsForcedCommitForReadback(); 876 scheduler->SetNeedsForcedCommitForReadback();
877 scheduler->NotifyBeginMainFrameStarted(); 877 scheduler->NotifyBeginMainFrameStarted();
878 scheduler->FinishCommit(); 878 scheduler->NotifyReadyToCommit();
879 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback")); 879 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback"));
880 880
881 client.Reset(); 881 client.Reset();
882 scheduler->SetNeedsForcedCommitForReadback(); 882 scheduler->SetNeedsForcedCommitForReadback();
883 scheduler->NotifyBeginMainFrameStarted(); 883 scheduler->NotifyBeginMainFrameStarted();
884 scheduler->FinishCommit(); 884 scheduler->NotifyReadyToCommit();
885 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback")); 885 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback"));
886 886
887 // The replacement commit comes in after 2 readbacks. 887 // The replacement commit comes in after 2 readbacks.
888 client.Reset(); 888 client.Reset();
889 scheduler->NotifyBeginMainFrameStarted(); 889 scheduler->NotifyBeginMainFrameStarted();
890 scheduler->FinishCommit(); 890 scheduler->NotifyReadyToCommit();
891 } 891 }
892 892
893 893
894 class SchedulerClientNeedsManageTilesInDraw : public FakeSchedulerClient { 894 class SchedulerClientNeedsManageTilesInDraw : public FakeSchedulerClient {
895 public: 895 public:
896 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() 896 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible()
897 OVERRIDE { 897 OVERRIDE {
898 scheduler_->SetNeedsManageTiles(); 898 scheduler_->SetNeedsManageTiles();
899 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 899 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
900 } 900 }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 1145
1146 // Impl thread hits deadline before commit finishes. 1146 // Impl thread hits deadline before commit finishes.
1147 client.Reset(); 1147 client.Reset();
1148 scheduler->SetNeedsCommit(); 1148 scheduler->SetNeedsCommit();
1149 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); 1149 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode());
1150 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 1150 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
1151 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); 1151 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode());
1152 scheduler->OnBeginImplFrameDeadline(); 1152 scheduler->OnBeginImplFrameDeadline();
1153 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1153 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1154 scheduler->NotifyBeginMainFrameStarted(); 1154 scheduler->NotifyBeginMainFrameStarted();
1155 scheduler->FinishCommit(); 1155 scheduler->NotifyReadyToCommit();
1156 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1156 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1157 EXPECT_TRUE(client.HasAction("ScheduledActionSendBeginMainFrame")); 1157 EXPECT_TRUE(client.HasAction("ScheduledActionSendBeginMainFrame"));
1158 1158
1159 client.Reset(); 1159 client.Reset();
1160 scheduler->SetNeedsCommit(); 1160 scheduler->SetNeedsCommit();
1161 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1161 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1162 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 1162 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
1163 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1163 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
1164 scheduler->OnBeginImplFrameDeadline(); 1164 scheduler->OnBeginImplFrameDeadline();
1165 EXPECT_EQ(scheduler->MainThreadIsInHighLatencyMode(), 1165 EXPECT_EQ(scheduler->MainThreadIsInHighLatencyMode(),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 Scheduler* scheduler = client.CreateScheduler(settings); 1204 Scheduler* scheduler = client.CreateScheduler(settings);
1205 1205
1206 scheduler->SetCanDraw(true); 1206 scheduler->SetCanDraw(true);
1207 scheduler->SetCanStart(); 1207 scheduler->SetCanStart();
1208 scheduler->SetVisible(true); 1208 scheduler->SetVisible(true);
1209 scheduler->DidCreateAndInitializeOutputSurface(); 1209 scheduler->DidCreateAndInitializeOutputSurface();
1210 1210
1211 scheduler->SetNeedsCommit(); 1211 scheduler->SetNeedsCommit();
1212 EXPECT_TRUE(scheduler->CommitPending()); 1212 EXPECT_TRUE(scheduler->CommitPending());
1213 scheduler->NotifyBeginMainFrameStarted(); 1213 scheduler->NotifyBeginMainFrameStarted();
1214 scheduler->FinishCommit(); 1214 scheduler->NotifyReadyToCommit();
1215 scheduler->SetNeedsRedraw(); 1215 scheduler->SetNeedsRedraw();
1216 BeginFrameArgs impl_frame_args = BeginFrameArgs::CreateForTesting(); 1216 BeginFrameArgs impl_frame_args = BeginFrameArgs::CreateForTesting();
1217 const int interval = 1; 1217 const int interval = 1;
1218 impl_frame_args.interval = base::TimeDelta::FromMilliseconds(interval); 1218 impl_frame_args.interval = base::TimeDelta::FromMilliseconds(interval);
1219 scheduler->BeginImplFrame(impl_frame_args); 1219 scheduler->BeginImplFrame(impl_frame_args);
1220 scheduler->OnBeginImplFrameDeadline(); 1220 scheduler->OnBeginImplFrameDeadline();
1221 1221
1222 // At this point, we've drawn a frame. Start another commit, but hold off on 1222 // At this point, we've drawn a frame. Start another commit, but hold off on
1223 // the FinishCommit for now. 1223 // the NotifyReadyToCommit for now.
1224 EXPECT_FALSE(scheduler->CommitPending()); 1224 EXPECT_FALSE(scheduler->CommitPending());
1225 scheduler->SetNeedsCommit(); 1225 scheduler->SetNeedsCommit();
1226 EXPECT_TRUE(scheduler->CommitPending()); 1226 EXPECT_TRUE(scheduler->CommitPending());
1227 1227
1228 // Spin the event loop a few times and make sure we get more 1228 // Spin the event loop a few times and make sure we get more
1229 // DidAnticipateDrawTimeChange calls every time. 1229 // DidAnticipateDrawTimeChange calls every time.
1230 int actions_so_far = client.num_actions_(); 1230 int actions_so_far = client.num_actions_();
1231 1231
1232 // Does three iterations to make sure that the timer is properly repeating. 1232 // Does three iterations to make sure that the timer is properly repeating.
1233 for (int i = 0; i < 3; ++i) { 1233 for (int i = 0; i < 3; ++i) {
1234 // Wait for 2x the frame interval to match 1234 // Wait for 2x the frame interval to match
1235 // Scheduler::advance_commit_state_timer_'s rate. 1235 // Scheduler::advance_commit_state_timer_'s rate.
1236 SpinForMillis(interval * 2); 1236 SpinForMillis(interval * 2);
1237 EXPECT_GT(client.num_actions_(), actions_so_far); 1237 EXPECT_GT(client.num_actions_(), actions_so_far);
1238 EXPECT_STREQ(client.Action(client.num_actions_() - 1), 1238 EXPECT_STREQ(client.Action(client.num_actions_() - 1),
1239 "DidAnticipatedDrawTimeChange"); 1239 "DidAnticipatedDrawTimeChange");
1240 actions_so_far = client.num_actions_(); 1240 actions_so_far = client.num_actions_();
1241 } 1241 }
1242 } 1242 }
1243 1243
1244 } // namespace 1244 } // namespace
1245 } // namespace cc 1245 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/trees/thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698