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

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

Issue 206793003: cc: Split animating and drawing into separate actions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup. Created 6 years, 8 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
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // SchedulerClient implementation. 102 // SchedulerClient implementation.
103 virtual void SetNeedsBeginImplFrame(bool enable) OVERRIDE { 103 virtual void SetNeedsBeginImplFrame(bool enable) OVERRIDE {
104 actions_.push_back("SetNeedsBeginImplFrame"); 104 actions_.push_back("SetNeedsBeginImplFrame");
105 states_.push_back(scheduler_->StateAsValue().release()); 105 states_.push_back(scheduler_->StateAsValue().release());
106 needs_begin_impl_frame_ = enable; 106 needs_begin_impl_frame_ = enable;
107 } 107 }
108 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE { 108 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE {
109 actions_.push_back("ScheduledActionSendBeginMainFrame"); 109 actions_.push_back("ScheduledActionSendBeginMainFrame");
110 states_.push_back(scheduler_->StateAsValue().release()); 110 states_.push_back(scheduler_->StateAsValue().release());
111 } 111 }
112 virtual void ScheduledActionAnimate() OVERRIDE {
113 actions_.push_back("ScheduledActionAnimate");
114 states_.push_back(scheduler_->StateAsValue().release());
115 }
112 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() 116 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible()
113 OVERRIDE { 117 OVERRIDE {
114 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); 118 actions_.push_back("ScheduledActionDrawAndSwapIfPossible");
115 states_.push_back(scheduler_->StateAsValue().release()); 119 states_.push_back(scheduler_->StateAsValue().release());
116 num_draws_++; 120 num_draws_++;
117 bool did_readback = false; 121 bool did_readback = false;
118 DrawSwapReadbackResult::DrawResult result = 122 DrawSwapReadbackResult::DrawResult result =
119 draw_will_happen_ 123 draw_will_happen_
120 ? DrawSwapReadbackResult::DRAW_SUCCESS 124 ? DrawSwapReadbackResult::DRAW_SUCCESS
121 : DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS; 125 : DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 244
241 // NotifyReadyToCommit should trigger the commit. 245 // NotifyReadyToCommit should trigger the commit.
242 scheduler->NotifyBeginMainFrameStarted(); 246 scheduler->NotifyBeginMainFrameStarted();
243 scheduler->NotifyReadyToCommit(); 247 scheduler->NotifyReadyToCommit();
244 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 248 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
245 EXPECT_TRUE(client.needs_begin_impl_frame()); 249 EXPECT_TRUE(client.needs_begin_impl_frame());
246 client.Reset(); 250 client.Reset();
247 251
248 // BeginImplFrame should prepare the draw. 252 // BeginImplFrame should prepare the draw.
249 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 253 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
250 EXPECT_EQ(client.num_actions_(), 0); 254 EXPECT_SINGLE_ACTION("ScheduledActionAnimate", client);
251 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 255 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
252 EXPECT_TRUE(client.needs_begin_impl_frame()); 256 EXPECT_TRUE(client.needs_begin_impl_frame());
253 client.Reset(); 257 client.Reset();
254 258
255 // BeginImplFrame deadline should draw. 259 // BeginImplFrame deadline should draw.
256 scheduler->OnBeginImplFrameDeadline(); 260 scheduler->OnBeginImplFrameDeadline();
257 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 261 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
258 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); 262 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2);
259 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 263 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
260 EXPECT_TRUE(client.needs_begin_impl_frame()); 264 EXPECT_TRUE(client.needs_begin_impl_frame());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 EXPECT_EQ(client.num_actions_(), 0); 306 EXPECT_EQ(client.num_actions_(), 0);
303 client.Reset(); 307 client.Reset();
304 308
305 // Finish the first commit. 309 // Finish the first commit.
306 scheduler->NotifyBeginMainFrameStarted(); 310 scheduler->NotifyBeginMainFrameStarted();
307 scheduler->NotifyReadyToCommit(); 311 scheduler->NotifyReadyToCommit();
308 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 312 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
309 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 313 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
310 client.Reset(); 314 client.Reset();
311 scheduler->OnBeginImplFrameDeadline(); 315 scheduler->OnBeginImplFrameDeadline();
312 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 316 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 3);
313 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); 317 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 3);
318 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 2, 3);
314 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 319 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
315 320
316 // Because we just swapped, the Scheduler should also request the next 321 // Because we just swapped, the Scheduler should also request the next
317 // BeginImplFrame from the OutputSurface. 322 // BeginImplFrame from the OutputSurface.
318 EXPECT_TRUE(client.needs_begin_impl_frame()); 323 EXPECT_TRUE(client.needs_begin_impl_frame());
319 client.Reset(); 324 client.Reset();
320 325
321 // Since another commit is needed, the next BeginImplFrame should initiate 326 // Since another commit is needed, the next BeginImplFrame should initiate
322 // the second commit. 327 // the second commit.
323 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 328 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
324 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client); 329 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client);
325 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 330 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
326 client.Reset(); 331 client.Reset();
327 332
328 // Finishing the commit before the deadline should post a new deadline task 333 // Finishing the commit before the deadline should post a new deadline task
329 // to trigger the deadline early. 334 // to trigger the deadline early.
330 scheduler->NotifyBeginMainFrameStarted(); 335 scheduler->NotifyBeginMainFrameStarted();
331 scheduler->NotifyReadyToCommit(); 336 scheduler->NotifyReadyToCommit();
332 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 337 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
333 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 338 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
334 client.Reset(); 339 client.Reset();
335 scheduler->OnBeginImplFrameDeadline(); 340 scheduler->OnBeginImplFrameDeadline();
336 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 341 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 3);
337 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); 342 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 3);
343 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 2, 3);
338 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 344 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
339 EXPECT_TRUE(client.needs_begin_impl_frame()); 345 EXPECT_TRUE(client.needs_begin_impl_frame());
340 client.Reset(); 346 client.Reset();
341 347
342 // On the next BeginImplFrame, verify we go back to a quiescent state and 348 // On the next BeginImplFrame, verify we go back to a quiescent state and
343 // no longer request BeginImplFrames. 349 // no longer request BeginImplFrames.
344 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 350 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
345 scheduler->OnBeginImplFrameDeadline(); 351 scheduler->OnBeginImplFrameDeadline();
346 EXPECT_FALSE(client.needs_begin_impl_frame()); 352 EXPECT_FALSE(client.needs_begin_impl_frame());
347 client.Reset(); 353 client.Reset();
(...skipping 10 matching lines...) Expand all
358 364
359 InitializeOutputSurfaceAndFirstCommit(scheduler); 365 InitializeOutputSurfaceAndFirstCommit(scheduler);
360 client.Reset(); 366 client.Reset();
361 scheduler->SetNeedsRedraw(); 367 scheduler->SetNeedsRedraw();
362 EXPECT_TRUE(scheduler->RedrawPending()); 368 EXPECT_TRUE(scheduler->RedrawPending());
363 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); 369 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
364 EXPECT_TRUE(client.needs_begin_impl_frame()); 370 EXPECT_TRUE(client.needs_begin_impl_frame());
365 371
366 client.Reset(); 372 client.Reset();
367 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 373 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
368 EXPECT_EQ(client.num_actions_(), 0); 374 EXPECT_SINGLE_ACTION("ScheduledActionAnimate", client);
369 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 375 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
370 client.Reset(); 376 client.Reset();
371 scheduler->OnBeginImplFrameDeadline(); 377 scheduler->OnBeginImplFrameDeadline();
372 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 378 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
373 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); 379 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2);
374 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 380 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
375 EXPECT_FALSE(scheduler->RedrawPending()); 381 EXPECT_FALSE(scheduler->RedrawPending());
376 EXPECT_TRUE(client.needs_begin_impl_frame()); 382 EXPECT_TRUE(client.needs_begin_impl_frame());
377 383
378 client.Reset(); 384 client.Reset();
(...skipping 15 matching lines...) Expand all
394 // We should request a BeginImplFrame in anticipation of a draw. 400 // We should request a BeginImplFrame in anticipation of a draw.
395 client.Reset(); 401 client.Reset();
396 scheduler->SetNeedsRedraw(); 402 scheduler->SetNeedsRedraw();
397 EXPECT_TRUE(scheduler->RedrawPending()); 403 EXPECT_TRUE(scheduler->RedrawPending());
398 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); 404 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
399 EXPECT_TRUE(client.needs_begin_impl_frame()); 405 EXPECT_TRUE(client.needs_begin_impl_frame());
400 406
401 // No draw happens since the textures are acquired by the main thread. 407 // No draw happens since the textures are acquired by the main thread.
402 client.Reset(); 408 client.Reset();
403 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 409 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
404 EXPECT_EQ(client.num_actions_(), 0); 410 EXPECT_SINGLE_ACTION("ScheduledActionAnimate", client);
405 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 411 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
406 client.Reset(); 412 client.Reset();
407 scheduler->OnBeginImplFrameDeadline(); 413 scheduler->OnBeginImplFrameDeadline();
408 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); 414 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
409 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 415 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
410 EXPECT_TRUE(scheduler->RedrawPending()); 416 EXPECT_TRUE(scheduler->RedrawPending());
411 EXPECT_TRUE(client.needs_begin_impl_frame()); 417 EXPECT_TRUE(client.needs_begin_impl_frame());
412 418
413 client.Reset(); 419 client.Reset();
414 scheduler->SetNeedsCommit(); 420 scheduler->SetNeedsCommit();
415 EXPECT_EQ(0, client.num_actions_()); 421 EXPECT_EQ(0, client.num_actions_());
416 422
417 client.Reset(); 423 client.Reset();
418 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 424 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
419 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client); 425 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2);
426 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2);
420 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 427 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
421 428
422 // Commit will release the texture. 429 // Commit will release the texture.
423 client.Reset(); 430 client.Reset();
424 scheduler->NotifyBeginMainFrameStarted(); 431 scheduler->NotifyBeginMainFrameStarted();
425 scheduler->NotifyReadyToCommit(); 432 scheduler->NotifyReadyToCommit();
426 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 433 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
427 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 434 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
428 EXPECT_TRUE(scheduler->RedrawPending()); 435 EXPECT_TRUE(scheduler->RedrawPending());
429 436
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 495
489 // Between commit and draw, texture acquisition for main thread delayed, 496 // Between commit and draw, texture acquisition for main thread delayed,
490 // and main thread blocks. 497 // and main thread blocks.
491 client.Reset(); 498 client.Reset();
492 scheduler->SetMainThreadNeedsLayerTextures(); 499 scheduler->SetMainThreadNeedsLayerTextures();
493 EXPECT_EQ(0, client.num_actions_()); 500 EXPECT_EQ(0, client.num_actions_());
494 501
495 // No implicit commit is expected. 502 // No implicit commit is expected.
496 client.Reset(); 503 client.Reset();
497 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 504 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
498 EXPECT_EQ(client.num_actions_(), 0); 505 EXPECT_SINGLE_ACTION("ScheduledActionAnimate", client);
499 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 506 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
500 507
501 client.Reset(); 508 client.Reset();
502 scheduler->OnBeginImplFrameDeadline(); 509 scheduler->OnBeginImplFrameDeadline();
503 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3); 510 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3);
504 EXPECT_ACTION( 511 EXPECT_ACTION(
505 "ScheduledActionAcquireLayerTexturesForMainThread", client, 1, 3); 512 "ScheduledActionAcquireLayerTexturesForMainThread", client, 1, 3);
506 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 2, 3); 513 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 2, 3);
507 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 514 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
508 EXPECT_TRUE(client.needs_begin_impl_frame()); 515 EXPECT_TRUE(client.needs_begin_impl_frame());
(...skipping 26 matching lines...) Expand all
535 // Trigger the commit, which will trigger the deadline task early. 542 // Trigger the commit, which will trigger the deadline task early.
536 scheduler->NotifyBeginMainFrameStarted(); 543 scheduler->NotifyBeginMainFrameStarted();
537 scheduler->NotifyReadyToCommit(); 544 scheduler->NotifyReadyToCommit();
538 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 545 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
539 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 546 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
540 EXPECT_TRUE(client.needs_begin_impl_frame()); 547 EXPECT_TRUE(client.needs_begin_impl_frame());
541 client.Reset(); 548 client.Reset();
542 549
543 // Verify we draw on the next BeginImplFrame deadline 550 // Verify we draw on the next BeginImplFrame deadline
544 scheduler->OnBeginImplFrameDeadline(); 551 scheduler->OnBeginImplFrameDeadline();
545 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 552 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 3);
546 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 1, 2); 553 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 3);
554 EXPECT_ACTION("SetNeedsBeginImplFrame", client, 2, 3);
547 EXPECT_TRUE(client.needs_begin_impl_frame()); 555 EXPECT_TRUE(client.needs_begin_impl_frame());
548 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 556 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
549 client.Reset(); 557 client.Reset();
550 } 558 }
551 559
552 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { 560 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) {
553 FakeSchedulerClient client; 561 FakeSchedulerClient client;
554 SchedulerSettings scheduler_settings; 562 SchedulerSettings scheduler_settings;
555 Scheduler* scheduler = client.CreateScheduler(scheduler_settings); 563 Scheduler* scheduler = client.CreateScheduler(scheduler_settings);
556 scheduler->SetCanStart(); 564 scheduler->SetCanStart();
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 client.Reset(); 939 client.Reset();
932 scheduler->SetNeedsManageTiles(); 940 scheduler->SetNeedsManageTiles();
933 scheduler->SetNeedsRedraw(); 941 scheduler->SetNeedsRedraw();
934 EXPECT_TRUE(scheduler->RedrawPending()); 942 EXPECT_TRUE(scheduler->RedrawPending());
935 EXPECT_TRUE(scheduler->ManageTilesPending()); 943 EXPECT_TRUE(scheduler->ManageTilesPending());
936 EXPECT_TRUE(client.needs_begin_impl_frame()); 944 EXPECT_TRUE(client.needs_begin_impl_frame());
937 EXPECT_EQ(0, client.num_draws()); 945 EXPECT_EQ(0, client.num_draws());
938 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 946 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
939 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 947 EXPECT_FALSE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
940 948
941 // We have no immediate actions to perform, so the BeginImplFrame should post 949 // We have no immediate actions to perform beyond animating, so the
942 // the deadline task. 950 // BeginImplFrame should post the deadline task.
943 client.Reset(); 951 client.Reset();
944 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 952 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
945 EXPECT_EQ(client.num_actions_(), 0); 953 EXPECT_TRUE(client.HasAction("ScheduledActionAnimate"));
946 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 954 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
947 955
948 // On the deadline, he actions should have occured in the right order. 956 // On the deadline, he actions should have occured in the right order.
949 client.Reset(); 957 client.Reset();
950 scheduler->OnBeginImplFrameDeadline(); 958 scheduler->OnBeginImplFrameDeadline();
951 EXPECT_EQ(1, client.num_draws()); 959 EXPECT_EQ(1, client.num_draws());
952 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 960 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
953 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 961 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
954 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 962 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
955 client.ActionIndex("ScheduledActionManageTiles")); 963 client.ActionIndex("ScheduledActionManageTiles"));
956 EXPECT_FALSE(scheduler->RedrawPending()); 964 EXPECT_FALSE(scheduler->RedrawPending());
957 EXPECT_FALSE(scheduler->ManageTilesPending()); 965 EXPECT_FALSE(scheduler->ManageTilesPending());
958 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 966 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
959 967
960 // Request a draw. We don't need a ManageTiles yet. 968 // Request a draw. We don't need a ManageTiles yet.
961 client.Reset(); 969 client.Reset();
962 scheduler->SetNeedsRedraw(); 970 scheduler->SetNeedsRedraw();
963 EXPECT_TRUE(scheduler->RedrawPending()); 971 EXPECT_TRUE(scheduler->RedrawPending());
964 EXPECT_FALSE(scheduler->ManageTilesPending()); 972 EXPECT_FALSE(scheduler->ManageTilesPending());
965 EXPECT_TRUE(client.needs_begin_impl_frame()); 973 EXPECT_TRUE(client.needs_begin_impl_frame());
966 EXPECT_EQ(0, client.num_draws()); 974 EXPECT_EQ(0, client.num_draws());
967 975
968 // We have no immediate actions to perform, so the BeginImplFrame should post 976 // We have no immediate actions to perform beyond animating, so the
969 // the deadline task. 977 // BeginImplFrame should post the deadline task.
970 client.Reset(); 978 client.Reset();
971 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 979 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
972 EXPECT_EQ(client.num_actions_(), 0); 980 EXPECT_TRUE(client.HasAction("ScheduledActionAnimate"));
973 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 981 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
974 982
975 // Draw. The draw will trigger SetNeedsManageTiles, and 983 // Draw. The draw will trigger SetNeedsManageTiles, and
976 // then the ManageTiles action will be triggered after the Draw. 984 // then the ManageTiles action will be triggered after the Draw.
977 // Afterwards, neither a draw nor ManageTiles are pending. 985 // Afterwards, neither a draw nor ManageTiles are pending.
978 client.Reset(); 986 client.Reset();
979 scheduler->OnBeginImplFrameDeadline(); 987 scheduler->OnBeginImplFrameDeadline();
980 EXPECT_EQ(1, client.num_draws()); 988 EXPECT_EQ(1, client.num_draws());
981 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 989 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
982 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 990 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
983 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 991 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
984 client.ActionIndex("ScheduledActionManageTiles")); 992 client.ActionIndex("ScheduledActionManageTiles"));
985 EXPECT_FALSE(scheduler->RedrawPending()); 993 EXPECT_FALSE(scheduler->RedrawPending());
986 EXPECT_FALSE(scheduler->ManageTilesPending()); 994 EXPECT_FALSE(scheduler->ManageTilesPending());
987 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 995 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
988 996
989 // We need a BeginImplFrame where we don't swap to go idle. 997 // We need a BeginImplFrame where we don't swap to go idle.
990 client.Reset(); 998 client.Reset();
991 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 999 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
992 EXPECT_EQ(client.num_actions_(), 0); 1000 EXPECT_EQ(0, client.num_draws());
993 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1001 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
994 client.Reset(); 1002 client.Reset();
995 scheduler->OnBeginImplFrameDeadline(); 1003 scheduler->OnBeginImplFrameDeadline();
996 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client); 1004 EXPECT_SINGLE_ACTION("SetNeedsBeginImplFrame", client);
997 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1005 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
998 EXPECT_EQ(0, client.num_draws()); 1006 EXPECT_EQ(0, client.num_draws());
999 1007
1000 // Now trigger a ManageTiles outside of a draw. We will then need 1008 // Now trigger a ManageTiles outside of a draw. We will then need
1001 // a begin-frame for the ManageTiles, but we don't need a draw. 1009 // a begin-frame for the ManageTiles, but we don't need a draw.
1002 client.Reset(); 1010 client.Reset();
(...skipping 25 matching lines...) Expand all
1028 scheduler->SetCanStart(); 1036 scheduler->SetCanStart();
1029 scheduler->SetVisible(true); 1037 scheduler->SetVisible(true);
1030 scheduler->SetCanDraw(true); 1038 scheduler->SetCanDraw(true);
1031 InitializeOutputSurfaceAndFirstCommit(scheduler); 1039 InitializeOutputSurfaceAndFirstCommit(scheduler);
1032 1040
1033 // If DidManageTiles during a frame, then ManageTiles should not occur again. 1041 // If DidManageTiles during a frame, then ManageTiles should not occur again.
1034 scheduler->SetNeedsManageTiles(); 1042 scheduler->SetNeedsManageTiles();
1035 scheduler->SetNeedsRedraw(); 1043 scheduler->SetNeedsRedraw();
1036 client.Reset(); 1044 client.Reset();
1037 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 1045 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
1038 EXPECT_EQ(client.num_actions_(), 0); 1046 EXPECT_TRUE(client.HasAction("ScheduledActionAnimate"));
1039 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1047 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1040 1048
1041 EXPECT_TRUE(scheduler->ManageTilesPending()); 1049 EXPECT_TRUE(scheduler->ManageTilesPending());
1042 scheduler->DidManageTiles(); // An explicit ManageTiles. 1050 scheduler->DidManageTiles(); // An explicit ManageTiles.
1043 EXPECT_FALSE(scheduler->ManageTilesPending()); 1051 EXPECT_FALSE(scheduler->ManageTilesPending());
1044 1052
1045 client.Reset(); 1053 client.Reset();
1046 scheduler->OnBeginImplFrameDeadline(); 1054 scheduler->OnBeginImplFrameDeadline();
1047 EXPECT_EQ(1, client.num_draws()); 1055 EXPECT_EQ(1, client.num_draws());
1048 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 1056 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
1049 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 1057 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
1050 EXPECT_FALSE(scheduler->RedrawPending()); 1058 EXPECT_FALSE(scheduler->RedrawPending());
1051 EXPECT_FALSE(scheduler->ManageTilesPending()); 1059 EXPECT_FALSE(scheduler->ManageTilesPending());
1052 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1060 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1053 1061
1054 // Next frame without DidManageTiles should ManageTiles with draw. 1062 // Next frame without DidManageTiles should ManageTiles with draw.
1055 scheduler->SetNeedsManageTiles(); 1063 scheduler->SetNeedsManageTiles();
1056 scheduler->SetNeedsRedraw(); 1064 scheduler->SetNeedsRedraw();
1057 client.Reset(); 1065 client.Reset();
1058 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 1066 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
1059 EXPECT_EQ(client.num_actions_(), 0); 1067 EXPECT_TRUE(client.HasAction("ScheduledActionAnimate"));
1060 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1068 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1061 1069
1062 client.Reset(); 1070 client.Reset();
1063 scheduler->OnBeginImplFrameDeadline(); 1071 scheduler->OnBeginImplFrameDeadline();
1064 EXPECT_EQ(1, client.num_draws()); 1072 EXPECT_EQ(1, client.num_draws());
1065 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 1073 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
1066 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 1074 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
1067 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 1075 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
1068 client.ActionIndex("ScheduledActionManageTiles")); 1076 client.ActionIndex("ScheduledActionManageTiles"));
1069 EXPECT_FALSE(scheduler->RedrawPending()); 1077 EXPECT_FALSE(scheduler->RedrawPending());
1070 EXPECT_FALSE(scheduler->ManageTilesPending()); 1078 EXPECT_FALSE(scheduler->ManageTilesPending());
1071 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1079 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1072 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles 1080 scheduler->DidManageTiles(); // Corresponds to ScheduledActionManageTiles
1073 1081
1074 // If we get another DidManageTiles within the same frame, we should 1082 // If we get another DidManageTiles within the same frame, we should
1075 // not ManageTiles on the next frame. 1083 // not ManageTiles on the next frame.
1076 scheduler->DidManageTiles(); // An explicit ManageTiles. 1084 scheduler->DidManageTiles(); // An explicit ManageTiles.
1077 scheduler->SetNeedsManageTiles(); 1085 scheduler->SetNeedsManageTiles();
1078 scheduler->SetNeedsRedraw(); 1086 scheduler->SetNeedsRedraw();
1079 client.Reset(); 1087 client.Reset();
1080 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 1088 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
1081 EXPECT_EQ(client.num_actions_(), 0); 1089 EXPECT_TRUE(client.HasAction("ScheduledActionAnimate"));
1082 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1090 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1083 1091
1084 EXPECT_TRUE(scheduler->ManageTilesPending()); 1092 EXPECT_TRUE(scheduler->ManageTilesPending());
1085 1093
1086 client.Reset(); 1094 client.Reset();
1087 scheduler->OnBeginImplFrameDeadline(); 1095 scheduler->OnBeginImplFrameDeadline();
1088 EXPECT_EQ(1, client.num_draws()); 1096 EXPECT_EQ(1, client.num_draws());
1089 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 1097 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
1090 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 1098 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
1091 EXPECT_FALSE(scheduler->RedrawPending()); 1099 EXPECT_FALSE(scheduler->RedrawPending());
1092 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1100 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1093 1101
1094 // If we get another DidManageTiles, we should not ManageTiles on the next 1102 // If we get another DidManageTiles, we should not ManageTiles on the next
1095 // frame. This verifies we don't alternate calling ManageTiles once and twice. 1103 // frame. This verifies we don't alternate calling ManageTiles once and twice.
1096 EXPECT_TRUE(scheduler->ManageTilesPending()); 1104 EXPECT_TRUE(scheduler->ManageTilesPending());
1097 scheduler->DidManageTiles(); // An explicit ManageTiles. 1105 scheduler->DidManageTiles(); // An explicit ManageTiles.
1098 EXPECT_FALSE(scheduler->ManageTilesPending()); 1106 EXPECT_FALSE(scheduler->ManageTilesPending());
1099 scheduler->SetNeedsManageTiles(); 1107 scheduler->SetNeedsManageTiles();
1100 scheduler->SetNeedsRedraw(); 1108 scheduler->SetNeedsRedraw();
1101 client.Reset(); 1109 client.Reset();
1102 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 1110 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
1103 EXPECT_EQ(client.num_actions_(), 0); 1111 EXPECT_TRUE(client.HasAction("ScheduledActionAnimate"));
1104 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1112 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1105 1113
1106 EXPECT_TRUE(scheduler->ManageTilesPending()); 1114 EXPECT_TRUE(scheduler->ManageTilesPending());
1107 1115
1108 client.Reset(); 1116 client.Reset();
1109 scheduler->OnBeginImplFrameDeadline(); 1117 scheduler->OnBeginImplFrameDeadline();
1110 EXPECT_EQ(1, client.num_draws()); 1118 EXPECT_EQ(1, client.num_draws());
1111 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 1119 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
1112 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles")); 1120 EXPECT_FALSE(client.HasAction("ScheduledActionManageTiles"));
1113 EXPECT_FALSE(scheduler->RedrawPending()); 1121 EXPECT_FALSE(scheduler->RedrawPending());
1114 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); 1122 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending());
1115 1123
1116 // Next frame without DidManageTiles should ManageTiles with draw. 1124 // Next frame without DidManageTiles should ManageTiles with draw.
1117 scheduler->SetNeedsManageTiles(); 1125 scheduler->SetNeedsManageTiles();
1118 scheduler->SetNeedsRedraw(); 1126 scheduler->SetNeedsRedraw();
1119 client.Reset(); 1127 client.Reset();
1120 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting()); 1128 scheduler->BeginImplFrame(BeginFrameArgs::CreateForTesting());
1121 EXPECT_EQ(client.num_actions_(), 0); 1129 EXPECT_TRUE(client.HasAction("ScheduledActionAnimate"));
1122 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); 1130 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending());
1123 1131
1124 client.Reset(); 1132 client.Reset();
1125 scheduler->OnBeginImplFrameDeadline(); 1133 scheduler->OnBeginImplFrameDeadline();
1126 EXPECT_EQ(1, client.num_draws()); 1134 EXPECT_EQ(1, client.num_draws());
1127 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible")); 1135 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapIfPossible"));
1128 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles")); 1136 EXPECT_TRUE(client.HasAction("ScheduledActionManageTiles"));
1129 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"), 1137 EXPECT_LT(client.ActionIndex("ScheduledActionDrawAndSwapIfPossible"),
1130 client.ActionIndex("ScheduledActionManageTiles")); 1138 client.ActionIndex("ScheduledActionManageTiles"));
1131 EXPECT_FALSE(scheduler->RedrawPending()); 1139 EXPECT_FALSE(scheduler->RedrawPending());
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 SpinForMillis(interval * 2); 1311 SpinForMillis(interval * 2);
1304 EXPECT_GT(client.num_actions_(), actions_so_far); 1312 EXPECT_GT(client.num_actions_(), actions_so_far);
1305 EXPECT_STREQ(client.Action(client.num_actions_() - 1), 1313 EXPECT_STREQ(client.Action(client.num_actions_() - 1),
1306 "DidAnticipatedDrawTimeChange"); 1314 "DidAnticipatedDrawTimeChange");
1307 actions_so_far = client.num_actions_(); 1315 actions_so_far = client.num_actions_();
1308 } 1316 }
1309 } 1317 }
1310 1318
1311 } // namespace 1319 } // namespace
1312 } // namespace cc 1320 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698