| 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 <string> |     7 #include <string> | 
|     8 #include <vector> |     8 #include <vector> | 
|     9  |     9  | 
|    10 #include "base/logging.h" |    10 #include "base/logging.h" | 
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   305     EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |   305     EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 
|   306     client_->Reset(); |   306     client_->Reset(); | 
|   307  |   307  | 
|   308     { |   308     { | 
|   309       SCOPED_TRACE("Do first frame to commit after initialize."); |   309       SCOPED_TRACE("Do first frame to commit after initialize."); | 
|   310       AdvanceFrame(); |   310       AdvanceFrame(); | 
|   311  |   311  | 
|   312       scheduler_->NotifyBeginMainFrameStarted(); |   312       scheduler_->NotifyBeginMainFrameStarted(); | 
|   313       scheduler_->NotifyReadyToCommit(); |   313       scheduler_->NotifyReadyToCommit(); | 
|   314       scheduler_->NotifyReadyToActivate(); |   314       scheduler_->NotifyReadyToActivate(); | 
 |   315       scheduler_->NotifyReadyToDraw(); | 
|   315  |   316  | 
|   316       EXPECT_FALSE(scheduler_->CommitPending()); |   317       EXPECT_FALSE(scheduler_->CommitPending()); | 
|   317  |   318  | 
|   318       if (scheduler_settings_.using_synchronous_renderer_compositor) { |   319       if (scheduler_settings_.using_synchronous_renderer_compositor) { | 
|   319         scheduler_->SetNeedsRedraw(); |   320         scheduler_->SetNeedsRedraw(); | 
|   320         scheduler_->OnDrawForOutputSurface(); |   321         scheduler_->OnDrawForOutputSurface(); | 
|   321       } else { |   322       } else { | 
|   322         // Run the posted deadline task. |   323         // Run the posted deadline task. | 
|   323         EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |   324         EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 
|   324         task_runner_->RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |   325         task_runner_->RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1240  |  1241  | 
|  1241   // The deadline should be zero since there is no work other than drawing |  1242   // The deadline should be zero since there is no work other than drawing | 
|  1242   // pending. |  1243   // pending. | 
|  1243   EXPECT_EQ(base::TimeTicks(), client->posted_begin_impl_frame_deadline()); |  1244   EXPECT_EQ(base::TimeTicks(), client->posted_begin_impl_frame_deadline()); | 
|  1244 } |  1245 } | 
|  1245  |  1246  | 
|  1246 TEST_F(SchedulerTest, WaitForReadyToDrawDoNotPostDeadline) { |  1247 TEST_F(SchedulerTest, WaitForReadyToDrawDoNotPostDeadline) { | 
|  1247   SchedulerClientNeedsPrepareTilesInDraw* client = |  1248   SchedulerClientNeedsPrepareTilesInDraw* client = | 
|  1248       new SchedulerClientNeedsPrepareTilesInDraw; |  1249       new SchedulerClientNeedsPrepareTilesInDraw; | 
|  1249   scheduler_settings_.use_external_begin_frame_source = true; |  1250   scheduler_settings_.use_external_begin_frame_source = true; | 
 |  1251   scheduler_settings_.commit_to_active_tree = true; | 
|  1250   SetUpScheduler(make_scoped_ptr(client).Pass(), true); |  1252   SetUpScheduler(make_scoped_ptr(client).Pass(), true); | 
|  1251  |  1253  | 
|  1252   // SetNeedsCommit should begin the frame on the next BeginImplFrame. |  1254   // SetNeedsCommit should begin the frame on the next BeginImplFrame. | 
|  1253   scheduler_->SetNeedsCommit(); |  1255   scheduler_->SetNeedsCommit(); | 
|  1254   EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |  1256   EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 
|  1255   client_->Reset(); |  1257   client_->Reset(); | 
|  1256  |  1258  | 
|  1257   // Begin new frame. |  1259   // Begin new frame. | 
|  1258   EXPECT_SCOPED(AdvanceFrame()); |  1260   EXPECT_SCOPED(AdvanceFrame()); | 
|  1259   scheduler_->NotifyBeginMainFrameStarted(); |  1261   scheduler_->NotifyBeginMainFrameStarted(); | 
|  1260   EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |  1262   EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 
|  1261   EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |  1263   EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 
|  1262  |  1264  | 
|  1263   client_->Reset(); |  1265   client_->Reset(); | 
|  1264   scheduler_->NotifyReadyToCommit(); |  1266   scheduler_->NotifyReadyToCommit(); | 
|  1265   EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); |  1267   EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 
|  1266  |  1268  | 
|  1267   client_->Reset(); |  1269   client_->Reset(); | 
|  1268   scheduler_->NotifyReadyToActivate(); |  1270   scheduler_->NotifyReadyToActivate(); | 
|  1269   EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); |  1271   EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); | 
|  1270  |  1272  | 
|  1271   // Set scheduler to wait for ready to draw. Schedule won't post deadline in |  1273   // Scheduler won't post deadline in the mode. | 
|  1272   // the mode. |  | 
|  1273   scheduler_->SetWaitForReadyToDraw(); |  | 
|  1274   client_->Reset(); |  1274   client_->Reset(); | 
|  1275   task_runner().RunPendingTasks();  // Try to run posted deadline. |  1275   task_runner().RunPendingTasks();  // Try to run posted deadline. | 
|  1276   // There is no posted deadline. |  1276   // There is no posted deadline. | 
|  1277   EXPECT_NO_ACTION(client_); |  1277   EXPECT_NO_ACTION(client_); | 
|  1278  |  1278  | 
|  1279   // Scheduler received ready to draw signal, and posted deadline. |  1279   // Scheduler received ready to draw signal, and posted deadline. | 
|  1280   scheduler_->NotifyReadyToDraw(); |  1280   scheduler_->NotifyReadyToDraw(); | 
|  1281   client_->Reset(); |  1281   client_->Reset(); | 
|  1282   task_runner().RunPendingTasks();  // Run posted deadline. |  1282   task_runner().RunPendingTasks();  // Run posted deadline. | 
|  1283   EXPECT_EQ(1, client_->num_draws()); |  1283   EXPECT_EQ(1, client_->num_draws()); | 
|  1284   EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); |  1284   EXPECT_TRUE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); | 
|  1285 } |  1285 } | 
|  1286  |  1286  | 
|  1287 TEST_F(SchedulerTest, WaitForReadyToDrawCancelledWhenLostOutputSurface) { |  1287 TEST_F(SchedulerTest, WaitForReadyToDrawCancelledWhenLostOutputSurface) { | 
|  1288   SchedulerClientNeedsPrepareTilesInDraw* client = |  1288   SchedulerClientNeedsPrepareTilesInDraw* client = | 
|  1289       new SchedulerClientNeedsPrepareTilesInDraw; |  1289       new SchedulerClientNeedsPrepareTilesInDraw; | 
|  1290   scheduler_settings_.use_external_begin_frame_source = true; |  1290   scheduler_settings_.use_external_begin_frame_source = true; | 
 |  1291   scheduler_settings_.commit_to_active_tree = true; | 
|  1291   SetUpScheduler(make_scoped_ptr(client).Pass(), true); |  1292   SetUpScheduler(make_scoped_ptr(client).Pass(), true); | 
|  1292  |  1293  | 
|  1293   // SetNeedsCommit should begin the frame on the next BeginImplFrame. |  1294   // SetNeedsCommit should begin the frame on the next BeginImplFrame. | 
|  1294   scheduler_->SetNeedsCommit(); |  1295   scheduler_->SetNeedsCommit(); | 
|  1295   EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |  1296   EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 
|  1296   client_->Reset(); |  1297   client_->Reset(); | 
|  1297  |  1298  | 
|  1298   // Begin new frame. |  1299   // Begin new frame. | 
|  1299   EXPECT_SCOPED(AdvanceFrame()); |  1300   EXPECT_SCOPED(AdvanceFrame()); | 
|  1300   scheduler_->NotifyBeginMainFrameStarted(); |  1301   scheduler_->NotifyBeginMainFrameStarted(); | 
|  1301   EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |  1302   EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 
|  1302   EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |  1303   EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 
|  1303  |  1304  | 
|  1304   client_->Reset(); |  1305   client_->Reset(); | 
|  1305   scheduler_->NotifyReadyToCommit(); |  1306   scheduler_->NotifyReadyToCommit(); | 
|  1306   EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); |  1307   EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); | 
|  1307  |  1308  | 
|  1308   client_->Reset(); |  1309   client_->Reset(); | 
|  1309   scheduler_->NotifyReadyToActivate(); |  1310   scheduler_->NotifyReadyToActivate(); | 
|  1310   EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); |  1311   EXPECT_SINGLE_ACTION("ScheduledActionActivateSyncTree", client_); | 
|  1311  |  1312  | 
|  1312   // Set scheduler to wait for ready to draw. Schedule won't post deadline in |  1313   // Scheduler won't post deadline in the mode. | 
|  1313   // the mode. |  | 
|  1314   scheduler_->SetWaitForReadyToDraw(); |  | 
|  1315   client_->Reset(); |  1314   client_->Reset(); | 
|  1316   task_runner().RunPendingTasks();  // Try to run posted deadline. |  1315   task_runner().RunPendingTasks();  // Try to run posted deadline. | 
|  1317   // There is no posted deadline. |  1316   // There is no posted deadline. | 
|  1318   EXPECT_NO_ACTION(client_); |  1317   EXPECT_NO_ACTION(client_); | 
|  1319  |  1318  | 
|  1320   // Scheduler loses output surface, and stops waiting for ready to draw signal. |  1319   // Scheduler loses output surface, and stops waiting for ready to draw signal. | 
|  1321   client_->Reset(); |  1320   client_->Reset(); | 
|  1322   scheduler_->DidLoseOutputSurface(); |  1321   scheduler_->DidLoseOutputSurface(); | 
|  1323   EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |  1322   EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 
|  1324   task_runner().RunPendingTasks();  // Run posted deadline. |  1323   task_runner().RunPendingTasks();  // Run posted deadline. | 
| (...skipping 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3492   scheduler_->SetImplLatencyTakesPriority(true); |  3491   scheduler_->SetImplLatencyTakesPriority(true); | 
|  3493   scheduler_->SetChildrenNeedBeginFrames(true); |  3492   scheduler_->SetChildrenNeedBeginFrames(true); | 
|  3494  |  3493  | 
|  3495   EXPECT_SCOPED(AdvanceFrame()); |  3494   EXPECT_SCOPED(AdvanceFrame()); | 
|  3496   EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |  3495   EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 
|  3497   EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); |  3496   EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); | 
|  3498 } |  3497 } | 
|  3499  |  3498  | 
|  3500 }  // namespace |  3499 }  // namespace | 
|  3501 }  // namespace cc |  3500 }  // namespace cc | 
| OLD | NEW |