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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "cc/test/scheduler_test_common.h" | 10 #include "cc/test/scheduler_test_common.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 void SetDrawWillHappen(bool draw_will_happen) { | 38 void SetDrawWillHappen(bool draw_will_happen) { |
39 draw_will_happen_ = draw_will_happen; | 39 draw_will_happen_ = draw_will_happen; |
40 } | 40 } |
41 void SetSwapWillHappenIfDrawHappens(bool swap_will_happen_if_draw_happens) { | 41 void SetSwapWillHappenIfDrawHappens(bool swap_will_happen_if_draw_happens) { |
42 swap_will_happen_if_draw_happens_ = swap_will_happen_if_draw_happens; | 42 swap_will_happen_if_draw_happens_ = swap_will_happen_if_draw_happens; |
43 } | 43 } |
44 | 44 |
45 // Scheduler Implementation. | 45 // Scheduler Implementation. |
46 virtual void ScheduledActionBeginFrame() OVERRIDE { | 46 virtual void ScheduledActionBeginMainFrame() OVERRIDE { |
47 actions_.push_back("ScheduledActionBeginFrame"); | 47 actions_.push_back("ScheduledActionBeginMainFrame"); |
48 } | 48 } |
49 virtual ScheduledActionDrawAndSwapResult | 49 virtual ScheduledActionDrawAndSwapResult |
50 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { | 50 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { |
51 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); | 51 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); |
52 num_draws_++; | 52 num_draws_++; |
53 return ScheduledActionDrawAndSwapResult(draw_will_happen_, | 53 return ScheduledActionDrawAndSwapResult(draw_will_happen_, |
54 draw_will_happen_ && | 54 draw_will_happen_ && |
55 swap_will_happen_if_draw_happens_); | 55 swap_will_happen_if_draw_happens_); |
56 } | 56 } |
57 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() | 57 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 scheduler->SetCanDraw(true); | 97 scheduler->SetCanDraw(true); |
98 | 98 |
99 EXPECT_EQ(1, client.num_actions_()); | 99 EXPECT_EQ(1, client.num_actions_()); |
100 EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); | 100 EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); |
101 client.Reset(); | 101 client.Reset(); |
102 scheduler->DidCreateAndInitializeOutputSurface(); | 102 scheduler->DidCreateAndInitializeOutputSurface(); |
103 | 103 |
104 // SetNeedsCommit should begin the frame. | 104 // SetNeedsCommit should begin the frame. |
105 scheduler->SetNeedsCommit(); | 105 scheduler->SetNeedsCommit(); |
106 EXPECT_EQ(1, client.num_actions_()); | 106 EXPECT_EQ(1, client.num_actions_()); |
107 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); | 107 EXPECT_STREQ("ScheduledActionBeginMainFrame", client.Action(0)); |
108 EXPECT_FALSE(time_source->Active()); | 108 EXPECT_FALSE(time_source->Active()); |
109 client.Reset(); | 109 client.Reset(); |
110 | 110 |
111 // BeginFrameComplete should commit | 111 // BeginMainFrameComplete should commit |
112 scheduler->BeginFrameComplete(); | 112 scheduler->BeginMainFrameComplete(); |
113 EXPECT_EQ(1, client.num_actions_()); | 113 EXPECT_EQ(1, client.num_actions_()); |
114 EXPECT_STREQ("ScheduledActionCommit", client.Action(0)); | 114 EXPECT_STREQ("ScheduledActionCommit", client.Action(0)); |
115 EXPECT_TRUE(time_source->Active()); | 115 EXPECT_TRUE(time_source->Active()); |
116 client.Reset(); | 116 client.Reset(); |
117 | 117 |
118 // Tick should draw. | 118 // Tick should draw. |
119 time_source->Tick(); | 119 time_source->Tick(); |
120 EXPECT_EQ(1, client.num_actions_()); | 120 EXPECT_EQ(1, client.num_actions_()); |
121 EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); | 121 EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); |
122 EXPECT_FALSE(time_source->Active()); | 122 EXPECT_FALSE(time_source->Active()); |
123 client.Reset(); | 123 client.Reset(); |
124 | 124 |
125 // Timer should be off. | 125 // Timer should be off. |
126 EXPECT_FALSE(time_source->Active()); | 126 EXPECT_FALSE(time_source->Active()); |
127 } | 127 } |
128 | 128 |
129 TEST(SchedulerTest, RequestCommitAfterBeginFrame) { | 129 TEST(SchedulerTest, RequestCommitAfterBeginMainFrame) { |
130 FakeSchedulerClient client; | 130 FakeSchedulerClient client; |
131 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 131 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
132 SchedulerSettings default_scheduler_settings; | 132 SchedulerSettings default_scheduler_settings; |
133 scoped_ptr<Scheduler> scheduler = | 133 scoped_ptr<Scheduler> scheduler = |
134 Scheduler::Create(&client, | 134 Scheduler::Create(&client, |
135 make_scoped_ptr(new FrameRateController(time_source)), | 135 make_scoped_ptr(new FrameRateController(time_source)), |
136 default_scheduler_settings); | 136 default_scheduler_settings); |
137 scheduler->SetCanStart(); | 137 scheduler->SetCanStart(); |
138 scheduler->SetVisible(true); | 138 scheduler->SetVisible(true); |
139 scheduler->SetCanDraw(true); | 139 scheduler->SetCanDraw(true); |
140 | 140 |
141 EXPECT_EQ(1, client.num_actions_()); | 141 EXPECT_EQ(1, client.num_actions_()); |
142 EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); | 142 EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); |
143 client.Reset(); | 143 client.Reset(); |
144 scheduler->DidCreateAndInitializeOutputSurface(); | 144 scheduler->DidCreateAndInitializeOutputSurface(); |
145 | 145 |
146 // SetNedsCommit should begin the frame. | 146 // SetNedsCommit should begin the frame. |
147 scheduler->SetNeedsCommit(); | 147 scheduler->SetNeedsCommit(); |
148 EXPECT_EQ(1, client.num_actions_()); | 148 EXPECT_EQ(1, client.num_actions_()); |
149 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); | 149 EXPECT_STREQ("ScheduledActionBeginMainFrame", client.Action(0)); |
150 client.Reset(); | 150 client.Reset(); |
151 | 151 |
152 // Now SetNeedsCommit again. Calling here means we need a second frame. | 152 // Now SetNeedsCommit again. Calling here means we need a second frame. |
153 scheduler->SetNeedsCommit(); | 153 scheduler->SetNeedsCommit(); |
154 | 154 |
155 // Since, another commit is needed, BeginFrameComplete should commit, | 155 // Since, another commit is needed, BeginMainFrameComplete should commit, |
156 // then begin another frame. | 156 // then begin another frame. |
157 scheduler->BeginFrameComplete(); | 157 scheduler->BeginMainFrameComplete(); |
158 EXPECT_EQ(1, client.num_actions_()); | 158 EXPECT_EQ(1, client.num_actions_()); |
159 EXPECT_STREQ("ScheduledActionCommit", client.Action(0)); | 159 EXPECT_STREQ("ScheduledActionCommit", client.Action(0)); |
160 client.Reset(); | 160 client.Reset(); |
161 | 161 |
162 // Tick should draw but then begin another frame. | 162 // Tick should draw but then begin another frame. |
163 time_source->Tick(); | 163 time_source->Tick(); |
164 EXPECT_FALSE(time_source->Active()); | 164 EXPECT_FALSE(time_source->Active()); |
165 EXPECT_EQ(2, client.num_actions_()); | 165 EXPECT_EQ(2, client.num_actions_()); |
166 EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); | 166 EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); |
167 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(1)); | 167 EXPECT_STREQ("ScheduledActionBeginMainFrame", client.Action(1)); |
168 client.Reset(); | 168 client.Reset(); |
169 } | 169 } |
170 | 170 |
171 TEST(SchedulerTest, TextureAcquisitionCollision) { | 171 TEST(SchedulerTest, TextureAcquisitionCollision) { |
172 FakeSchedulerClient client; | 172 FakeSchedulerClient client; |
173 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 173 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
174 SchedulerSettings default_scheduler_settings; | 174 SchedulerSettings default_scheduler_settings; |
175 scoped_ptr<Scheduler> scheduler = | 175 scoped_ptr<Scheduler> scheduler = |
176 Scheduler::Create(&client, | 176 Scheduler::Create(&client, |
177 make_scoped_ptr(new FrameRateController(time_source)), | 177 make_scoped_ptr(new FrameRateController(time_source)), |
178 default_scheduler_settings); | 178 default_scheduler_settings); |
179 scheduler->SetCanStart(); | 179 scheduler->SetCanStart(); |
180 scheduler->SetVisible(true); | 180 scheduler->SetVisible(true); |
181 scheduler->SetCanDraw(true); | 181 scheduler->SetCanDraw(true); |
182 | 182 |
183 EXPECT_EQ(1, client.num_actions_()); | 183 EXPECT_EQ(1, client.num_actions_()); |
184 EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); | 184 EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); |
185 client.Reset(); | 185 client.Reset(); |
186 scheduler->DidCreateAndInitializeOutputSurface(); | 186 scheduler->DidCreateAndInitializeOutputSurface(); |
187 | 187 |
188 scheduler->SetNeedsCommit(); | 188 scheduler->SetNeedsCommit(); |
189 scheduler->SetMainThreadNeedsLayerTextures(); | 189 scheduler->SetMainThreadNeedsLayerTextures(); |
190 EXPECT_EQ(2, client.num_actions_()); | 190 EXPECT_EQ(2, client.num_actions_()); |
191 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); | 191 EXPECT_STREQ("ScheduledActionBeginMainFrame", client.Action(0)); |
192 EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread", | 192 EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread", |
193 client.Action(1)); | 193 client.Action(1)); |
194 client.Reset(); | 194 client.Reset(); |
195 | 195 |
196 // Compositor not scheduled to draw because textures are locked by main thread | 196 // Compositor not scheduled to draw because textures are locked by main thread |
197 EXPECT_FALSE(time_source->Active()); | 197 EXPECT_FALSE(time_source->Active()); |
198 | 198 |
199 // Trigger the commit | 199 // Trigger the commit |
200 scheduler->BeginFrameComplete(); | 200 scheduler->BeginMainFrameComplete(); |
201 EXPECT_TRUE(time_source->Active()); | 201 EXPECT_TRUE(time_source->Active()); |
202 client.Reset(); | 202 client.Reset(); |
203 | 203 |
204 // Between commit and draw, texture acquisition for main thread delayed, | 204 // Between commit and draw, texture acquisition for main thread delayed, |
205 // and main thread blocks. | 205 // and main thread blocks. |
206 scheduler->SetMainThreadNeedsLayerTextures(); | 206 scheduler->SetMainThreadNeedsLayerTextures(); |
207 EXPECT_EQ(0, client.num_actions_()); | 207 EXPECT_EQ(0, client.num_actions_()); |
208 client.Reset(); | 208 client.Reset(); |
209 | 209 |
210 // Once compositor draw complete, the delayed texture acquisition fires. | 210 // Once compositor draw complete, the delayed texture acquisition fires. |
211 time_source->Tick(); | 211 time_source->Tick(); |
212 EXPECT_EQ(3, client.num_actions_()); | 212 EXPECT_EQ(3, client.num_actions_()); |
213 EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); | 213 EXPECT_STREQ("ScheduledActionDrawAndSwapIfPossible", client.Action(0)); |
214 EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread", | 214 EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread", |
215 client.Action(1)); | 215 client.Action(1)); |
216 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(2)); | 216 EXPECT_STREQ("ScheduledActionBeginMainFrame", client.Action(2)); |
217 client.Reset(); | 217 client.Reset(); |
218 } | 218 } |
219 | 219 |
220 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { | 220 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { |
221 FakeSchedulerClient client; | 221 FakeSchedulerClient client; |
222 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 222 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
223 SchedulerSettings default_scheduler_settings; | 223 SchedulerSettings default_scheduler_settings; |
224 scoped_ptr<Scheduler> scheduler = | 224 scoped_ptr<Scheduler> scheduler = |
225 Scheduler::Create(&client, | 225 Scheduler::Create(&client, |
226 make_scoped_ptr(new FrameRateController(time_source)), | 226 make_scoped_ptr(new FrameRateController(time_source)), |
227 default_scheduler_settings); | 227 default_scheduler_settings); |
228 scheduler->SetCanStart(); | 228 scheduler->SetCanStart(); |
229 scheduler->SetVisible(true); | 229 scheduler->SetVisible(true); |
230 scheduler->SetCanDraw(true); | 230 scheduler->SetCanDraw(true); |
231 | 231 |
232 EXPECT_EQ(1, client.num_actions_()); | 232 EXPECT_EQ(1, client.num_actions_()); |
233 EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); | 233 EXPECT_STREQ("ScheduledActionBeginOutputSurfaceCreation", client.Action(0)); |
234 client.Reset(); | 234 client.Reset(); |
235 scheduler->DidCreateAndInitializeOutputSurface(); | 235 scheduler->DidCreateAndInitializeOutputSurface(); |
236 | 236 |
237 scheduler->SetNeedsCommit(); | 237 scheduler->SetNeedsCommit(); |
238 scheduler->BeginFrameComplete(); | 238 scheduler->BeginMainFrameComplete(); |
239 scheduler->SetMainThreadNeedsLayerTextures(); | 239 scheduler->SetMainThreadNeedsLayerTextures(); |
240 client.Reset(); | 240 client.Reset(); |
241 // Verify that pending texture acquisition fires when visibility | 241 // Verify that pending texture acquisition fires when visibility |
242 // is lost in order to avoid a deadlock. | 242 // is lost in order to avoid a deadlock. |
243 scheduler->SetVisible(false); | 243 scheduler->SetVisible(false); |
244 EXPECT_EQ(1, client.num_actions_()); | 244 EXPECT_EQ(1, client.num_actions_()); |
245 EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread", | 245 EXPECT_STREQ("ScheduledActionAcquireLayerTexturesForMainThread", |
246 client.Action(0)); | 246 client.Action(0)); |
247 client.Reset(); | 247 client.Reset(); |
248 | 248 |
249 // Regaining visibility with textures acquired by main thread while | 249 // Regaining visibility with textures acquired by main thread while |
250 // compositor is waiting for first draw should result in a request | 250 // compositor is waiting for first draw should result in a request |
251 // for a new frame in order to escape a deadlock. | 251 // for a new frame in order to escape a deadlock. |
252 scheduler->SetVisible(true); | 252 scheduler->SetVisible(true); |
253 EXPECT_EQ(1, client.num_actions_()); | 253 EXPECT_EQ(1, client.num_actions_()); |
254 EXPECT_STREQ("ScheduledActionBeginFrame", client.Action(0)); | 254 EXPECT_STREQ("ScheduledActionBeginMainFrame", client.Action(0)); |
255 client.Reset(); | 255 client.Reset(); |
256 } | 256 } |
257 | 257 |
258 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient { | 258 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient { |
259 public: | 259 public: |
260 SchedulerClientThatsetNeedsDrawInsideDraw() : scheduler_(NULL) {} | 260 SchedulerClientThatsetNeedsDrawInsideDraw() : scheduler_(NULL) {} |
261 | 261 |
262 void SetScheduler(Scheduler* scheduler) { scheduler_ = scheduler; } | 262 void SetScheduler(Scheduler* scheduler) { scheduler_ = scheduler; } |
263 | 263 |
264 virtual void ScheduledActionBeginFrame() OVERRIDE {} | 264 virtual void ScheduledActionBeginMainFrame() OVERRIDE {} |
265 virtual ScheduledActionDrawAndSwapResult | 265 virtual ScheduledActionDrawAndSwapResult |
266 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { | 266 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { |
267 // Only SetNeedsRedraw the first time this is called | 267 // Only SetNeedsRedraw the first time this is called |
268 if (!num_draws_) | 268 if (!num_draws_) |
269 scheduler_->SetNeedsRedraw(); | 269 scheduler_->SetNeedsRedraw(); |
270 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 270 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
271 } | 271 } |
272 | 272 |
273 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() | 273 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() |
274 OVERRIDE { | 274 OVERRIDE { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 EXPECT_FALSE(scheduler->RedrawPending()); | 365 EXPECT_FALSE(scheduler->RedrawPending()); |
366 EXPECT_FALSE(time_source->Active()); | 366 EXPECT_FALSE(time_source->Active()); |
367 } | 367 } |
368 | 368 |
369 class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient { | 369 class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient { |
370 public: | 370 public: |
371 SchedulerClientThatsetNeedsCommitInsideDraw() : scheduler_(NULL) {} | 371 SchedulerClientThatsetNeedsCommitInsideDraw() : scheduler_(NULL) {} |
372 | 372 |
373 void SetScheduler(Scheduler* scheduler) { scheduler_ = scheduler; } | 373 void SetScheduler(Scheduler* scheduler) { scheduler_ = scheduler; } |
374 | 374 |
375 virtual void ScheduledActionBeginFrame() OVERRIDE {} | 375 virtual void ScheduledActionBeginMainFrame() OVERRIDE {} |
376 virtual ScheduledActionDrawAndSwapResult | 376 virtual ScheduledActionDrawAndSwapResult |
377 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { | 377 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { |
378 // Only SetNeedsCommit the first time this is called | 378 // Only SetNeedsCommit the first time this is called |
379 if (!num_draws_) | 379 if (!num_draws_) |
380 scheduler_->SetNeedsCommit(); | 380 scheduler_->SetNeedsCommit(); |
381 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); | 381 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); |
382 } | 382 } |
383 | 383 |
384 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() | 384 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() |
385 OVERRIDE { | 385 OVERRIDE { |
(...skipping 27 matching lines...) Expand all Loading... |
413 | 413 |
414 scheduler->SetNeedsRedraw(); | 414 scheduler->SetNeedsRedraw(); |
415 EXPECT_TRUE(scheduler->RedrawPending()); | 415 EXPECT_TRUE(scheduler->RedrawPending()); |
416 EXPECT_EQ(0, client.num_draws()); | 416 EXPECT_EQ(0, client.num_draws()); |
417 EXPECT_TRUE(time_source->Active()); | 417 EXPECT_TRUE(time_source->Active()); |
418 | 418 |
419 time_source->Tick(); | 419 time_source->Tick(); |
420 EXPECT_FALSE(time_source->Active()); | 420 EXPECT_FALSE(time_source->Active()); |
421 EXPECT_EQ(1, client.num_draws()); | 421 EXPECT_EQ(1, client.num_draws()); |
422 EXPECT_TRUE(scheduler->CommitPending()); | 422 EXPECT_TRUE(scheduler->CommitPending()); |
423 scheduler->BeginFrameComplete(); | 423 scheduler->BeginMainFrameComplete(); |
424 | 424 |
425 time_source->Tick(); | 425 time_source->Tick(); |
426 EXPECT_EQ(2, client.num_draws()); | 426 EXPECT_EQ(2, client.num_draws()); |
427 EXPECT_FALSE(time_source->Active()); | 427 EXPECT_FALSE(time_source->Active()); |
428 EXPECT_FALSE(scheduler->RedrawPending()); | 428 EXPECT_FALSE(scheduler->RedrawPending()); |
429 } | 429 } |
430 | 430 |
431 // Tests that when a draw fails then the pending commit should not be dropped. | 431 // Tests that when a draw fails then the pending commit should not be dropped. |
432 TEST(SchedulerTest, RequestCommitInsideFailedDraw) { | 432 TEST(SchedulerTest, RequestCommitInsideFailedDraw) { |
433 SchedulerClientThatsetNeedsDrawInsideDraw client; | 433 SchedulerClientThatsetNeedsDrawInsideDraw client; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 | 469 |
470 // Draw successfully. | 470 // Draw successfully. |
471 client.SetDrawWillHappen(true); | 471 client.SetDrawWillHappen(true); |
472 time_source->Tick(); | 472 time_source->Tick(); |
473 EXPECT_EQ(3, client.num_draws()); | 473 EXPECT_EQ(3, client.num_draws()); |
474 EXPECT_TRUE(scheduler->CommitPending()); | 474 EXPECT_TRUE(scheduler->CommitPending()); |
475 EXPECT_FALSE(scheduler->RedrawPending()); | 475 EXPECT_FALSE(scheduler->RedrawPending()); |
476 EXPECT_FALSE(time_source->Active()); | 476 EXPECT_FALSE(time_source->Active()); |
477 } | 477 } |
478 | 478 |
479 TEST(SchedulerTest, NoBeginFrameWhenDrawFails) { | 479 TEST(SchedulerTest, NoSwapWhenDrawFails) { |
480 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 480 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
481 SchedulerClientThatsetNeedsCommitInsideDraw client; | 481 SchedulerClientThatsetNeedsCommitInsideDraw client; |
482 scoped_ptr<FakeFrameRateController> controller( | 482 scoped_ptr<FakeFrameRateController> controller( |
483 new FakeFrameRateController(time_source)); | 483 new FakeFrameRateController(time_source)); |
484 FakeFrameRateController* controller_ptr = controller.get(); | 484 FakeFrameRateController* controller_ptr = controller.get(); |
485 SchedulerSettings default_scheduler_settings; | 485 SchedulerSettings default_scheduler_settings; |
486 scoped_ptr<Scheduler> scheduler = | 486 scoped_ptr<Scheduler> scheduler = |
487 Scheduler::Create(&client, | 487 Scheduler::Create(&client, |
488 controller.PassAs<FrameRateController>(), | 488 controller.PassAs<FrameRateController>(), |
489 default_scheduler_settings); | 489 default_scheduler_settings); |
(...skipping 21 matching lines...) Expand all Loading... |
511 EXPECT_TRUE(scheduler->RedrawPending()); | 511 EXPECT_TRUE(scheduler->RedrawPending()); |
512 EXPECT_TRUE(time_source->Active()); | 512 EXPECT_TRUE(time_source->Active()); |
513 | 513 |
514 // Fail to draw, this should not start a frame. | 514 // Fail to draw, this should not start a frame. |
515 client.SetDrawWillHappen(false); | 515 client.SetDrawWillHappen(false); |
516 time_source->Tick(); | 516 time_source->Tick(); |
517 EXPECT_EQ(2, client.num_draws()); | 517 EXPECT_EQ(2, client.num_draws()); |
518 EXPECT_EQ(0, controller_ptr->NumFramesPending()); | 518 EXPECT_EQ(0, controller_ptr->NumFramesPending()); |
519 } | 519 } |
520 | 520 |
521 TEST(SchedulerTest, NoBeginFrameWhenSwapFailsDuringForcedCommit) { | 521 TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) { |
522 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); | 522 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource()); |
523 FakeSchedulerClient client; | 523 FakeSchedulerClient client; |
524 scoped_ptr<FakeFrameRateController> controller( | 524 scoped_ptr<FakeFrameRateController> controller( |
525 new FakeFrameRateController(time_source)); | 525 new FakeFrameRateController(time_source)); |
526 FakeFrameRateController* controller_ptr = controller.get(); | 526 FakeFrameRateController* controller_ptr = controller.get(); |
527 SchedulerSettings default_scheduler_settings; | 527 SchedulerSettings default_scheduler_settings; |
528 scoped_ptr<Scheduler> scheduler = | 528 scoped_ptr<Scheduler> scheduler = |
529 Scheduler::Create(&client, | 529 Scheduler::Create(&client, |
530 controller.PassAs<FrameRateController>(), | 530 controller.PassAs<FrameRateController>(), |
531 default_scheduler_settings); | 531 default_scheduler_settings); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 scheduler->DidLoseOutputSurface(); | 570 scheduler->DidLoseOutputSurface(); |
571 // Verifying that it's 1 so that we know that it's reset on recreate. | 571 // Verifying that it's 1 so that we know that it's reset on recreate. |
572 EXPECT_EQ(1, controller_ptr->NumFramesPending()); | 572 EXPECT_EQ(1, controller_ptr->NumFramesPending()); |
573 | 573 |
574 scheduler->DidCreateAndInitializeOutputSurface(); | 574 scheduler->DidCreateAndInitializeOutputSurface(); |
575 EXPECT_EQ(0, controller_ptr->NumFramesPending()); | 575 EXPECT_EQ(0, controller_ptr->NumFramesPending()); |
576 } | 576 } |
577 | 577 |
578 } // namespace | 578 } // namespace |
579 } // namespace cc | 579 } // namespace cc |
OLD | NEW |