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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE { | 222 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE { |
223 return base::TimeDelta(); | 223 return base::TimeDelta(); |
224 } | 224 } |
225 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE { | 225 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE { |
226 return base::TimeDelta(); | 226 return base::TimeDelta(); |
227 } | 227 } |
228 | 228 |
229 virtual void DidBeginImplFrameDeadline() OVERRIDE {} | 229 virtual void DidBeginImplFrameDeadline() OVERRIDE {} |
230 | 230 |
| 231 virtual void SendBeginFrameToChildren(const BeginFrameArgs& args) OVERRIDE {} |
| 232 |
231 protected: | 233 protected: |
232 bool needs_begin_frame_; | 234 bool needs_begin_frame_; |
233 bool draw_will_happen_; | 235 bool draw_will_happen_; |
234 bool swap_will_happen_if_draw_happens_; | 236 bool swap_will_happen_if_draw_happens_; |
235 bool automatic_swap_ack_; | 237 bool automatic_swap_ack_; |
236 int num_draws_; | 238 int num_draws_; |
237 bool log_anticipated_draw_time_change_; | 239 bool log_anticipated_draw_time_change_; |
238 bool swap_contains_incomplete_tile_; | 240 bool swap_contains_incomplete_tile_; |
239 bool redraw_will_happen_if_update_visible_tiles_happens_; | 241 bool redraw_will_happen_if_update_visible_tiles_happens_; |
240 base::TimeTicks posted_begin_impl_frame_deadline_; | 242 base::TimeTicks posted_begin_impl_frame_deadline_; |
241 std::vector<const char*> actions_; | 243 std::vector<const char*> actions_; |
242 std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat> > states_; | 244 std::vector<scoped_refptr<base::debug::ConvertableToTraceFormat> > states_; |
243 scoped_ptr<TestScheduler> scheduler_; | 245 scoped_ptr<TestScheduler> scheduler_; |
244 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 246 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
245 }; | 247 }; |
246 | 248 |
247 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, | 249 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler, |
248 FakeSchedulerClient* client) { | 250 FakeSchedulerClient* client) { |
249 bool client_initiates_begin_frame = | 251 bool client_initiates_begin_frame = |
250 scheduler->settings().begin_frame_scheduling_enabled && | 252 // scheduler->settings().begin_frame_scheduling_enabled && |
251 scheduler->settings().throttle_frame_production; | 253 scheduler->settings().throttle_frame_production; |
252 | 254 |
253 scheduler->DidCreateAndInitializeOutputSurface(); | 255 scheduler->DidCreateAndInitializeOutputSurface(); |
254 scheduler->SetNeedsCommit(); | 256 scheduler->SetNeedsCommit(); |
255 scheduler->NotifyBeginMainFrameStarted(); | 257 scheduler->NotifyBeginMainFrameStarted(); |
256 scheduler->NotifyReadyToCommit(); | 258 scheduler->NotifyReadyToCommit(); |
257 if (scheduler->settings().impl_side_painting) | 259 if (scheduler->settings().impl_side_painting) |
258 scheduler->NotifyReadyToActivate(); | 260 scheduler->NotifyReadyToActivate(); |
259 // Go through the motions to draw the commit. | 261 // Go through the motions to draw the commit. |
260 if (client_initiates_begin_frame) | 262 if (client_initiates_begin_frame) |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); | 1352 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 1, 2); |
1351 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); | 1353 EXPECT_FALSE(scheduler->BeginImplFrameDeadlinePending()); |
1352 EXPECT_TRUE(client.needs_begin_frame()); | 1354 EXPECT_TRUE(client.needs_begin_frame()); |
1353 client.Reset(); | 1355 client.Reset(); |
1354 } | 1356 } |
1355 | 1357 |
1356 void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled, | 1358 void BeginFramesNotFromClient(bool begin_frame_scheduling_enabled, |
1357 bool throttle_frame_production) { | 1359 bool throttle_frame_production) { |
1358 FakeSchedulerClient client; | 1360 FakeSchedulerClient client; |
1359 SchedulerSettings scheduler_settings; | 1361 SchedulerSettings scheduler_settings; |
1360 scheduler_settings.begin_frame_scheduling_enabled = | 1362 // scheduler_settings.begin_frame_scheduling_enabled = |
1361 begin_frame_scheduling_enabled; | 1363 // begin_frame_scheduling_enabled; |
1362 scheduler_settings.throttle_frame_production = throttle_frame_production; | 1364 scheduler_settings.throttle_frame_production = throttle_frame_production; |
1363 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); | 1365 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); |
1364 scheduler->SetCanStart(); | 1366 scheduler->SetCanStart(); |
1365 scheduler->SetVisible(true); | 1367 scheduler->SetVisible(true); |
1366 scheduler->SetCanDraw(true); | 1368 scheduler->SetCanDraw(true); |
1367 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); | 1369 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); |
1368 | 1370 |
1369 // SetNeedsCommit should begin the frame on the next BeginImplFrame | 1371 // SetNeedsCommit should begin the frame on the next BeginImplFrame |
1370 // without calling SetNeedsBeginFrame. | 1372 // without calling SetNeedsBeginFrame. |
1371 client.Reset(); | 1373 client.Reset(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 bool begin_frame_scheduling_enabled = false; | 1449 bool begin_frame_scheduling_enabled = false; |
1448 bool throttle_frame_production = false; | 1450 bool throttle_frame_production = false; |
1449 BeginFramesNotFromClient(begin_frame_scheduling_enabled, | 1451 BeginFramesNotFromClient(begin_frame_scheduling_enabled, |
1450 throttle_frame_production); | 1452 throttle_frame_production); |
1451 } | 1453 } |
1452 | 1454 |
1453 void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled, | 1455 void BeginFramesNotFromClient_SwapThrottled(bool begin_frame_scheduling_enabled, |
1454 bool throttle_frame_production) { | 1456 bool throttle_frame_production) { |
1455 FakeSchedulerClient client; | 1457 FakeSchedulerClient client; |
1456 SchedulerSettings scheduler_settings; | 1458 SchedulerSettings scheduler_settings; |
1457 scheduler_settings.begin_frame_scheduling_enabled = | 1459 // scheduler_settings.begin_frame_scheduling_enabled = |
1458 begin_frame_scheduling_enabled; | 1460 // begin_frame_scheduling_enabled; |
1459 scheduler_settings.throttle_frame_production = throttle_frame_production; | 1461 scheduler_settings.throttle_frame_production = throttle_frame_production; |
1460 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); | 1462 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); |
1461 scheduler->SetCanStart(); | 1463 scheduler->SetCanStart(); |
1462 scheduler->SetVisible(true); | 1464 scheduler->SetVisible(true); |
1463 scheduler->SetCanDraw(true); | 1465 scheduler->SetCanDraw(true); |
1464 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); | 1466 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); |
1465 | 1467 |
1466 // To test swap ack throttling, this test disables automatic swap acks. | 1468 // To test swap ack throttling, this test disables automatic swap acks. |
1467 scheduler->SetMaxSwapsPending(1); | 1469 scheduler->SetMaxSwapsPending(1); |
1468 client.SetAutomaticSwapAck(false); | 1470 client.SetAutomaticSwapAck(false); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 client.task_runner().RunPendingTasks(); | 1879 client.task_runner().RunPendingTasks(); |
1878 EXPECT_NO_ACTION(client); | 1880 EXPECT_NO_ACTION(client); |
1879 } | 1881 } |
1880 | 1882 |
1881 // See: http://crbug.com/380889 | 1883 // See: http://crbug.com/380889 |
1882 TEST( | 1884 TEST( |
1883 SchedulerTest, | 1885 SchedulerTest, |
1884 DISABLED_StopBeginFrameAfterDidLoseOutputSurfaceWithSyntheticBeginFrameSourc
e) { | 1886 DISABLED_StopBeginFrameAfterDidLoseOutputSurfaceWithSyntheticBeginFrameSourc
e) { |
1885 FakeSchedulerClient client; | 1887 FakeSchedulerClient client; |
1886 SchedulerSettings scheduler_settings; | 1888 SchedulerSettings scheduler_settings; |
1887 scheduler_settings.begin_frame_scheduling_enabled = false; | 1889 // scheduler_settings.begin_frame_scheduling_enabled = false; |
1888 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); | 1890 TestScheduler* scheduler = client.CreateScheduler(scheduler_settings); |
1889 scheduler->SetCanStart(); | 1891 scheduler->SetCanStart(); |
1890 scheduler->SetVisible(true); | 1892 scheduler->SetVisible(true); |
1891 scheduler->SetCanDraw(true); | 1893 scheduler->SetCanDraw(true); |
1892 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); | 1894 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); |
1893 | 1895 |
1894 // SetNeedsCommit should begin the frame on the next BeginImplFrame. | 1896 // SetNeedsCommit should begin the frame on the next BeginImplFrame. |
1895 client.Reset(); | 1897 client.Reset(); |
1896 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive()); | 1898 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive()); |
1897 scheduler->SetNeedsCommit(); | 1899 scheduler->SetNeedsCommit(); |
(...skipping 19 matching lines...) Expand all Loading... |
1917 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive()); | 1919 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive()); |
1918 | 1920 |
1919 client.Reset(); | 1921 client.Reset(); |
1920 client.task_runner().RunPendingTasks(); // Run posted deadline. | 1922 client.task_runner().RunPendingTasks(); // Run posted deadline. |
1921 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); | 1923 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); |
1922 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive()); | 1924 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive()); |
1923 } | 1925 } |
1924 | 1926 |
1925 } // namespace | 1927 } // namespace |
1926 } // namespace cc | 1928 } // namespace cc |
OLD | NEW |