| 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 #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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 client.Reset(); | 1324 client.Reset(); |
| 1325 | 1325 |
| 1326 // Swapping will put us into a swap throttled state. | 1326 // Swapping will put us into a swap throttled state. |
| 1327 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1327 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 1328 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); | 1328 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); |
| 1329 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); | 1329 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); |
| 1330 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1330 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 1331 EXPECT_TRUE(client.needs_begin_frames()); | 1331 EXPECT_TRUE(client.needs_begin_frames()); |
| 1332 client.Reset(); | 1332 client.Reset(); |
| 1333 | 1333 |
| 1334 // While swap throttled, BeginRetroFrames should trigger BeginImplFrames and | 1334 // While swap throttled, BeginRetroFrames should trigger BeginImplFrames |
| 1335 // BeginMainFrame, but not draw. | 1335 // but not a BeginMainFrame or draw. |
| 1336 scheduler->SetNeedsCommit(); | 1336 scheduler->SetNeedsCommit(); |
| 1337 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. | 1337 client.task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. |
| 1338 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 1338 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); |
| 1339 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); | |
| 1340 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1339 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 1341 EXPECT_TRUE(client.needs_begin_frames()); | 1340 EXPECT_TRUE(client.needs_begin_frames()); |
| 1342 client.Reset(); | 1341 client.Reset(); |
| 1343 | 1342 |
| 1344 // Queue BeginFrame while we are still handling the previous BeginFrame. | 1343 // Queue BeginFrame while we are still handling the previous BeginFrame. |
| 1345 args.frame_time += base::TimeDelta::FromSeconds(1); | 1344 args.frame_time += base::TimeDelta::FromSeconds(1); |
| 1346 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); | 1345 client.ExternalBeginFrameSource()->TestOnBeginFrame(args); |
| 1347 EXPECT_NO_ACTION(client); | 1346 EXPECT_NO_ACTION(client); |
| 1348 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1347 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 1349 EXPECT_TRUE(client.needs_begin_frames()); | 1348 EXPECT_TRUE(client.needs_begin_frames()); |
| 1350 client.Reset(); | 1349 client.Reset(); |
| 1351 | 1350 |
| 1352 // Take us out of a swap throttled state. | 1351 // Take us out of a swap throttled state. |
| 1353 scheduler->DidSwapBuffersComplete(); | 1352 scheduler->DidSwapBuffersComplete(); |
| 1354 EXPECT_EQ(0, client.num_actions_()); | 1353 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); |
| 1355 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1354 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 1356 EXPECT_TRUE(client.needs_begin_frames()); | 1355 EXPECT_TRUE(client.needs_begin_frames()); |
| 1357 client.Reset(); | 1356 client.Reset(); |
| 1358 | 1357 |
| 1359 // BeginImplFrame deadline should draw. | 1358 // BeginImplFrame deadline should draw. |
| 1360 scheduler->SetNeedsRedraw(); | 1359 scheduler->SetNeedsRedraw(); |
| 1361 | 1360 |
| 1362 EXPECT_TRUE(client.task_runner().RunTasksWhile( | 1361 EXPECT_TRUE(client.task_runner().RunTasksWhile( |
| 1363 client.ImplFrameDeadlinePending(true))); | 1362 client.ImplFrameDeadlinePending(true))); |
| 1364 | 1363 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 client.Reset(); | 1503 client.Reset(); |
| 1505 | 1504 |
| 1506 // Swapping will put us into a swap throttled state. | 1505 // Swapping will put us into a swap throttled state. |
| 1507 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1506 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 1508 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); | 1507 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); |
| 1509 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); | 1508 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); |
| 1510 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1509 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| 1511 EXPECT_FALSE(client.needs_begin_frames()); | 1510 EXPECT_FALSE(client.needs_begin_frames()); |
| 1512 client.Reset(); | 1511 client.Reset(); |
| 1513 | 1512 |
| 1514 // While swap throttled, BeginFrames should trigger BeginImplFrames and | 1513 // While swap throttled, BeginFrames should trigger BeginImplFrames, |
| 1515 // BeginMainFrame, but not draw. | 1514 // but not a BeginMainFrame or draw. |
| 1516 scheduler->SetNeedsCommit(); | 1515 scheduler->SetNeedsCommit(); |
| 1517 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. | 1516 client.task_runner().RunPendingTasks(); // Run posted BeginFrame. |
| 1518 EXPECT_ACTION("WillBeginImplFrame", client, 0, 2); | 1517 EXPECT_ACTION("WillBeginImplFrame", client, 0, 1); |
| 1519 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 1, 2); | |
| 1520 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1518 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 1521 EXPECT_FALSE(client.needs_begin_frames()); | 1519 EXPECT_FALSE(client.needs_begin_frames()); |
| 1522 client.Reset(); | 1520 client.Reset(); |
| 1523 | 1521 |
| 1524 // Take us out of a swap throttled state. | 1522 // Take us out of a swap throttled state. |
| 1525 scheduler->DidSwapBuffersComplete(); | 1523 scheduler->DidSwapBuffersComplete(); |
| 1526 EXPECT_EQ(0, client.num_actions_()); | 1524 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client, 0, 1); |
| 1527 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); | 1525 EXPECT_TRUE(scheduler->BeginImplFrameDeadlinePending()); |
| 1528 EXPECT_FALSE(client.needs_begin_frames()); | 1526 EXPECT_FALSE(client.needs_begin_frames()); |
| 1529 client.Reset(); | 1527 client.Reset(); |
| 1530 | 1528 |
| 1531 // BeginImplFrame deadline should draw. | 1529 // BeginImplFrame deadline should draw. |
| 1532 scheduler->SetNeedsRedraw(); | 1530 scheduler->SetNeedsRedraw(); |
| 1533 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1531 client.task_runner().RunPendingTasks(); // Run posted deadline. |
| 1534 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); | 1532 EXPECT_ACTION("ScheduledActionAnimate", client, 0, 2); |
| 1535 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); | 1533 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); |
| 1536 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1534 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 | 1962 |
| 1965 client.Reset(); | 1963 client.Reset(); |
| 1966 scheduler->SetVisible(false); | 1964 scheduler->SetVisible(false); |
| 1967 // Sync tree should be forced to activate. | 1965 // Sync tree should be forced to activate. |
| 1968 EXPECT_ACTION("SetNeedsBeginFrames(false)", client, 0, 2); | 1966 EXPECT_ACTION("SetNeedsBeginFrames(false)", client, 0, 2); |
| 1969 EXPECT_ACTION("ScheduledActionActivateSyncTree", client, 1, 2); | 1967 EXPECT_ACTION("ScheduledActionActivateSyncTree", client, 1, 2); |
| 1970 } | 1968 } |
| 1971 | 1969 |
| 1972 } // namespace | 1970 } // namespace |
| 1973 } // namespace cc | 1971 } // namespace cc |
| OLD | NEW |