OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/surfaces/display_scheduler.h" | 5 #include "cc/surfaces/display_scheduler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/test/null_task_runner.h" | 8 #include "base/test/null_task_runner.h" |
| 9 #include "base/test/simple_test_tick_clock.h" |
9 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
10 #include "cc/output/begin_frame_args.h" | 11 #include "cc/output/begin_frame_args.h" |
11 #include "cc/surfaces/display.h" | 12 #include "cc/surfaces/display.h" |
12 #include "cc/test/scheduler_test_common.h" | 13 #include "cc/test/scheduler_test_common.h" |
13 #include "cc/test/test_now_source.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 namespace { | 17 namespace { |
18 | 18 |
19 class FakeDisplaySchedulerClient : public DisplaySchedulerClient { | 19 class FakeDisplaySchedulerClient : public DisplaySchedulerClient { |
20 public: | 20 public: |
21 FakeDisplaySchedulerClient() : draw_and_swap_count_(0) {} | 21 FakeDisplaySchedulerClient() : draw_and_swap_count_(0) {} |
22 | 22 |
23 ~FakeDisplaySchedulerClient() override {} | 23 ~FakeDisplaySchedulerClient() override {} |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 int scheduler_begin_frame_deadline_count() { | 61 int scheduler_begin_frame_deadline_count() { |
62 return scheduler_begin_frame_deadline_count_; | 62 return scheduler_begin_frame_deadline_count_; |
63 } | 63 } |
64 | 64 |
65 protected: | 65 protected: |
66 int scheduler_begin_frame_deadline_count_; | 66 int scheduler_begin_frame_deadline_count_; |
67 }; | 67 }; |
68 | 68 |
69 class DisplaySchedulerTest : public testing::Test { | 69 class DisplaySchedulerTest : public testing::Test { |
70 public: | 70 public: |
71 DisplaySchedulerTest() { | 71 DisplaySchedulerTest() : now_src_(new base::SimpleTestTickClock()) { |
72 const int max_pending_swaps = 1; | 72 const int max_pending_swaps = 1; |
73 now_src_ = TestNowSource::Create(); | 73 now_src_->Advance(base::TimeDelta::FromInternalValue(10000)); |
74 null_task_runner_ = make_scoped_refptr(new base::NullTaskRunner); | 74 null_task_runner_ = make_scoped_refptr(new base::NullTaskRunner); |
75 client_ = make_scoped_ptr(new FakeDisplaySchedulerClient); | 75 client_ = make_scoped_ptr(new FakeDisplaySchedulerClient); |
76 scheduler_ = make_scoped_ptr( | 76 scheduler_ = make_scoped_ptr( |
77 new TestDisplayScheduler(client_.get(), &fake_begin_frame_source_, | 77 new TestDisplayScheduler(client_.get(), &fake_begin_frame_source_, |
78 null_task_runner_, max_pending_swaps)); | 78 null_task_runner_, max_pending_swaps)); |
79 } | 79 } |
80 | 80 |
81 ~DisplaySchedulerTest() override {} | 81 ~DisplaySchedulerTest() override {} |
82 | 82 |
83 void SetUp() override { scheduler_->SetRootSurfaceResourcesLocked(false); } | 83 void SetUp() override { scheduler_->SetRootSurfaceResourcesLocked(false); } |
84 | 84 |
85 void BeginFrameForTest() { | 85 void BeginFrameForTest() { |
86 base::TimeTicks frame_time = now_src_->Now(); | 86 base::TimeTicks frame_time = now_src_->NowTicks(); |
87 base::TimeDelta interval = BeginFrameArgs::DefaultInterval(); | 87 base::TimeDelta interval = BeginFrameArgs::DefaultInterval(); |
88 base::TimeTicks deadline = frame_time + interval - | 88 base::TimeTicks deadline = frame_time + interval - |
89 BeginFrameArgs::DefaultEstimatedParentDrawTime(); | 89 BeginFrameArgs::DefaultEstimatedParentDrawTime(); |
90 fake_begin_frame_source_.TestOnBeginFrame( | 90 fake_begin_frame_source_.TestOnBeginFrame( |
91 BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, | 91 BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, |
92 interval, BeginFrameArgs::NORMAL)); | 92 interval, BeginFrameArgs::NORMAL)); |
93 } | 93 } |
94 | 94 |
95 protected: | 95 protected: |
96 TestNowSource& now_src() { return *now_src_; } | 96 base::SimpleTestTickClock& now_src() { return *now_src_; } |
97 FakeDisplaySchedulerClient& client() { return *client_; } | 97 FakeDisplaySchedulerClient& client() { return *client_; } |
98 DisplayScheduler& scheduler() { return *scheduler_; } | 98 DisplayScheduler& scheduler() { return *scheduler_; } |
99 | 99 |
100 scoped_refptr<TestNowSource> now_src_; | 100 scoped_ptr<base::SimpleTestTickClock> now_src_; |
101 scoped_refptr<base::NullTaskRunner> null_task_runner_; | 101 scoped_refptr<base::NullTaskRunner> null_task_runner_; |
102 | 102 |
103 FakeBeginFrameSource fake_begin_frame_source_; | 103 FakeBeginFrameSource fake_begin_frame_source_; |
104 scoped_ptr<FakeDisplaySchedulerClient> client_; | 104 scoped_ptr<FakeDisplaySchedulerClient> client_; |
105 scoped_ptr<TestDisplayScheduler> scheduler_; | 105 scoped_ptr<TestDisplayScheduler> scheduler_; |
106 }; | 106 }; |
107 | 107 |
108 TEST_F(DisplaySchedulerTest, EntireDisplayDamagedDrawsImmediately) { | 108 TEST_F(DisplaySchedulerTest, EntireDisplayDamagedDrawsImmediately) { |
109 SurfaceId root_surface_id(1); | 109 SurfaceId root_surface_id(1); |
110 BeginFrameForTest(); | 110 BeginFrameForTest(); |
111 EXPECT_LT(now_src().Now(), | 111 EXPECT_LT(now_src().NowTicks(), |
112 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 112 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
113 scheduler_->EntireDisplayDamaged(root_surface_id); | 113 scheduler_->EntireDisplayDamaged(root_surface_id); |
114 EXPECT_GE(now_src().Now(), | 114 EXPECT_GE(now_src().NowTicks(), |
115 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 115 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
116 } | 116 } |
117 | 117 |
118 TEST_F(DisplaySchedulerTest, SurfaceDamaged) { | 118 TEST_F(DisplaySchedulerTest, SurfaceDamaged) { |
119 SurfaceId root_surface_id(0); | 119 SurfaceId root_surface_id(0); |
120 SurfaceId sid1(1); | 120 SurfaceId sid1(1); |
121 SurfaceId sid2(2); | 121 SurfaceId sid2(2); |
122 | 122 |
123 // Set the root surface | 123 // Set the root surface |
124 scheduler_->EntireDisplayDamaged(root_surface_id); | 124 scheduler_->EntireDisplayDamaged(root_surface_id); |
125 | 125 |
126 // Get scheduler to detect surface 1 as active by drawing | 126 // Get scheduler to detect surface 1 as active by drawing |
127 // two frames in a row with damage from surface 1. | 127 // two frames in a row with damage from surface 1. |
128 BeginFrameForTest(); | 128 BeginFrameForTest(); |
129 scheduler_->SurfaceDamaged(sid1); | 129 scheduler_->SurfaceDamaged(sid1); |
130 scheduler_->BeginFrameDeadlineForTest(); | 130 scheduler_->BeginFrameDeadlineForTest(); |
131 BeginFrameForTest(); | 131 BeginFrameForTest(); |
132 scheduler_->SurfaceDamaged(sid1); | 132 scheduler_->SurfaceDamaged(sid1); |
133 scheduler_->BeginFrameDeadlineForTest(); | 133 scheduler_->BeginFrameDeadlineForTest(); |
134 | 134 |
135 // Damage only from surface 2 (inactive) does not trigger deadline early. | 135 // Damage only from surface 2 (inactive) does not trigger deadline early. |
136 BeginFrameForTest(); | 136 BeginFrameForTest(); |
137 scheduler_->SurfaceDamaged(sid2); | 137 scheduler_->SurfaceDamaged(sid2); |
138 EXPECT_LT(now_src().Now(), | 138 EXPECT_LT(now_src().NowTicks(), |
139 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 139 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
140 | 140 |
141 // Damage from surface 1 triggers deadline early. | 141 // Damage from surface 1 triggers deadline early. |
142 scheduler_->SurfaceDamaged(sid1); | 142 scheduler_->SurfaceDamaged(sid1); |
143 EXPECT_GE(now_src().Now(), | 143 EXPECT_GE(now_src().NowTicks(), |
144 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 144 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
145 scheduler_->BeginFrameDeadlineForTest(); | 145 scheduler_->BeginFrameDeadlineForTest(); |
146 | 146 |
147 // Make both surface 1 and 2 active. | 147 // Make both surface 1 and 2 active. |
148 BeginFrameForTest(); | 148 BeginFrameForTest(); |
149 scheduler_->SurfaceDamaged(sid2); | 149 scheduler_->SurfaceDamaged(sid2); |
150 scheduler_->SurfaceDamaged(sid1); | 150 scheduler_->SurfaceDamaged(sid1); |
151 scheduler_->BeginFrameDeadlineForTest(); | 151 scheduler_->BeginFrameDeadlineForTest(); |
152 | 152 |
153 // Deadline doesn't trigger early until surface 1 and 2 are both damaged. | 153 // Deadline doesn't trigger early until surface 1 and 2 are both damaged. |
154 BeginFrameForTest(); | 154 BeginFrameForTest(); |
155 EXPECT_LT(now_src().Now(), | 155 EXPECT_LT(now_src().NowTicks(), |
156 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 156 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
157 scheduler_->SurfaceDamaged(sid1); | 157 scheduler_->SurfaceDamaged(sid1); |
158 EXPECT_LT(now_src().Now(), | 158 EXPECT_LT(now_src().NowTicks(), |
159 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 159 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
160 scheduler_->SurfaceDamaged(sid2); | 160 scheduler_->SurfaceDamaged(sid2); |
161 EXPECT_GE(now_src().Now(), | 161 EXPECT_GE(now_src().NowTicks(), |
162 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 162 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
163 scheduler_->BeginFrameDeadlineForTest(); | 163 scheduler_->BeginFrameDeadlineForTest(); |
164 | 164 |
165 // Make the system idle | 165 // Make the system idle |
166 BeginFrameForTest(); | 166 BeginFrameForTest(); |
167 scheduler_->BeginFrameDeadlineForTest(); | 167 scheduler_->BeginFrameDeadlineForTest(); |
168 BeginFrameForTest(); | 168 BeginFrameForTest(); |
169 scheduler_->BeginFrameDeadlineForTest(); | 169 scheduler_->BeginFrameDeadlineForTest(); |
170 | 170 |
171 // Deadline should trigger early if child surfaces are idle and | 171 // Deadline should trigger early if child surfaces are idle and |
172 // we get damage on the root surface. | 172 // we get damage on the root surface. |
173 BeginFrameForTest(); | 173 BeginFrameForTest(); |
174 EXPECT_LT(now_src().Now(), | 174 EXPECT_LT(now_src().NowTicks(), |
175 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 175 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
176 scheduler_->SurfaceDamaged(root_surface_id); | 176 scheduler_->SurfaceDamaged(root_surface_id); |
177 EXPECT_GE(now_src().Now(), | 177 EXPECT_GE(now_src().NowTicks(), |
178 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 178 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
179 scheduler_->BeginFrameDeadlineForTest(); | 179 scheduler_->BeginFrameDeadlineForTest(); |
180 } | 180 } |
181 | 181 |
182 TEST_F(DisplaySchedulerTest, OutputSurfaceLost) { | 182 TEST_F(DisplaySchedulerTest, OutputSurfaceLost) { |
183 SurfaceId sid1(1); | 183 SurfaceId sid1(1); |
184 | 184 |
185 // DrawAndSwap normally. | 185 // DrawAndSwap normally. |
186 BeginFrameForTest(); | 186 BeginFrameForTest(); |
187 EXPECT_LT(now_src().Now(), | 187 EXPECT_LT(now_src().NowTicks(), |
188 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 188 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
189 EXPECT_EQ(0, client_->draw_and_swap_count()); | 189 EXPECT_EQ(0, client_->draw_and_swap_count()); |
190 scheduler_->SurfaceDamaged(sid1); | 190 scheduler_->SurfaceDamaged(sid1); |
191 scheduler_->BeginFrameDeadlineForTest(); | 191 scheduler_->BeginFrameDeadlineForTest(); |
192 EXPECT_EQ(1, client_->draw_and_swap_count()); | 192 EXPECT_EQ(1, client_->draw_and_swap_count()); |
193 | 193 |
194 // Deadline triggers immediately on OutputSurfaceLost. | 194 // Deadline triggers immediately on OutputSurfaceLost. |
195 BeginFrameForTest(); | 195 BeginFrameForTest(); |
196 EXPECT_LT(now_src().Now(), | 196 EXPECT_LT(now_src().NowTicks(), |
197 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 197 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
198 scheduler_->OutputSurfaceLost(); | 198 scheduler_->OutputSurfaceLost(); |
199 EXPECT_GE(now_src().Now(), | 199 EXPECT_GE(now_src().NowTicks(), |
200 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 200 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
201 | 201 |
202 // Deadline does not DrawAndSwap after OutputSurfaceLost. | 202 // Deadline does not DrawAndSwap after OutputSurfaceLost. |
203 EXPECT_EQ(1, client_->draw_and_swap_count()); | 203 EXPECT_EQ(1, client_->draw_and_swap_count()); |
204 scheduler_->SurfaceDamaged(sid1); | 204 scheduler_->SurfaceDamaged(sid1); |
205 scheduler_->BeginFrameDeadlineForTest(); | 205 scheduler_->BeginFrameDeadlineForTest(); |
206 EXPECT_EQ(1, client_->draw_and_swap_count()); | 206 EXPECT_EQ(1, client_->draw_and_swap_count()); |
207 } | 207 } |
208 | 208 |
209 TEST_F(DisplaySchedulerTest, RootSurfaceResourcesLocked) { | 209 TEST_F(DisplaySchedulerTest, RootSurfaceResourcesLocked) { |
210 SurfaceId sid1(1); | 210 SurfaceId sid1(1); |
211 base::TimeTicks late_deadline; | 211 base::TimeTicks late_deadline; |
212 | 212 |
213 // DrawAndSwap normally. | 213 // DrawAndSwap normally. |
214 BeginFrameForTest(); | 214 BeginFrameForTest(); |
215 EXPECT_LT(now_src().Now(), | 215 EXPECT_LT(now_src().NowTicks(), |
216 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 216 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
217 EXPECT_EQ(0, client_->draw_and_swap_count()); | 217 EXPECT_EQ(0, client_->draw_and_swap_count()); |
218 scheduler_->SurfaceDamaged(sid1); | 218 scheduler_->SurfaceDamaged(sid1); |
219 scheduler_->BeginFrameDeadlineForTest(); | 219 scheduler_->BeginFrameDeadlineForTest(); |
220 EXPECT_EQ(1, client_->draw_and_swap_count()); | 220 EXPECT_EQ(1, client_->draw_and_swap_count()); |
221 | 221 |
222 // Deadline triggers late while root resources are locked. | 222 // Deadline triggers late while root resources are locked. |
223 late_deadline = now_src().Now() + BeginFrameArgs::DefaultInterval(); | 223 late_deadline = now_src().NowTicks() + BeginFrameArgs::DefaultInterval(); |
224 BeginFrameForTest(); | 224 BeginFrameForTest(); |
225 scheduler_->SurfaceDamaged(sid1); | 225 scheduler_->SurfaceDamaged(sid1); |
226 EXPECT_GT(late_deadline, scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 226 EXPECT_GT(late_deadline, scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
227 scheduler_->SetRootSurfaceResourcesLocked(true); | 227 scheduler_->SetRootSurfaceResourcesLocked(true); |
228 EXPECT_EQ(late_deadline, scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 228 EXPECT_EQ(late_deadline, scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
229 | 229 |
230 // Deadline does not DrawAndSwap while root resources are locked. | 230 // Deadline does not DrawAndSwap while root resources are locked. |
231 EXPECT_EQ(1, client_->draw_and_swap_count()); | 231 EXPECT_EQ(1, client_->draw_and_swap_count()); |
232 scheduler_->SurfaceDamaged(sid1); | 232 scheduler_->SurfaceDamaged(sid1); |
233 scheduler_->BeginFrameDeadlineForTest(); | 233 scheduler_->BeginFrameDeadlineForTest(); |
234 EXPECT_EQ(1, client_->draw_and_swap_count()); | 234 EXPECT_EQ(1, client_->draw_and_swap_count()); |
235 | 235 |
236 // Deadline triggers normally when root resources are unlocked. | 236 // Deadline triggers normally when root resources are unlocked. |
237 late_deadline = now_src().Now() + BeginFrameArgs::DefaultInterval(); | 237 late_deadline = now_src().NowTicks() + BeginFrameArgs::DefaultInterval(); |
238 BeginFrameForTest(); | 238 BeginFrameForTest(); |
239 scheduler_->SurfaceDamaged(sid1); | 239 scheduler_->SurfaceDamaged(sid1); |
240 EXPECT_EQ(late_deadline, scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 240 EXPECT_EQ(late_deadline, scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
241 scheduler_->SetRootSurfaceResourcesLocked(false); | 241 scheduler_->SetRootSurfaceResourcesLocked(false); |
242 EXPECT_EQ(base::TimeTicks(), | 242 EXPECT_EQ(base::TimeTicks(), |
243 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 243 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
244 | 244 |
245 EXPECT_EQ(1, client_->draw_and_swap_count()); | 245 EXPECT_EQ(1, client_->draw_and_swap_count()); |
246 scheduler_->BeginFrameDeadlineForTest(); | 246 scheduler_->BeginFrameDeadlineForTest(); |
247 EXPECT_EQ(2, client_->draw_and_swap_count()); | 247 EXPECT_EQ(2, client_->draw_and_swap_count()); |
248 } | 248 } |
249 | 249 |
250 TEST_F(DisplaySchedulerTest, DidSwapBuffers) { | 250 TEST_F(DisplaySchedulerTest, DidSwapBuffers) { |
251 SurfaceId sid1(1); | 251 SurfaceId sid1(1); |
252 SurfaceId sid2(2); | 252 SurfaceId sid2(2); |
253 base::TimeTicks late_deadline; | 253 base::TimeTicks late_deadline; |
254 | 254 |
255 // Get scheduler to detect surface 1 and 2 as active. | 255 // Get scheduler to detect surface 1 and 2 as active. |
256 BeginFrameForTest(); | 256 BeginFrameForTest(); |
257 scheduler_->SurfaceDamaged(sid1); | 257 scheduler_->SurfaceDamaged(sid1); |
258 scheduler_->SurfaceDamaged(sid2); | 258 scheduler_->SurfaceDamaged(sid2); |
259 scheduler_->BeginFrameDeadlineForTest(); | 259 scheduler_->BeginFrameDeadlineForTest(); |
260 BeginFrameForTest(); | 260 BeginFrameForTest(); |
261 scheduler_->SurfaceDamaged(sid1); | 261 scheduler_->SurfaceDamaged(sid1); |
262 scheduler_->SurfaceDamaged(sid2); | 262 scheduler_->SurfaceDamaged(sid2); |
263 scheduler_->BeginFrameDeadlineForTest(); | 263 scheduler_->BeginFrameDeadlineForTest(); |
264 | 264 |
265 // DrawAndSwap normally. | 265 // DrawAndSwap normally. |
266 BeginFrameForTest(); | 266 BeginFrameForTest(); |
267 EXPECT_LT(now_src().Now(), | 267 EXPECT_LT(now_src().NowTicks(), |
268 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); | 268 scheduler_->DesiredBeginFrameDeadlineTimeForTest()); |
269 EXPECT_EQ(2, client_->draw_and_swap_count()); | 269 EXPECT_EQ(2, client_->draw_and_swap_count()); |
270 scheduler_->SurfaceDamaged(sid1); | 270 scheduler_->SurfaceDamaged(sid1); |
271 scheduler_->SurfaceDamaged(sid2); | 271 scheduler_->SurfaceDamaged(sid2); |
272 scheduler_->BeginFrameDeadlineForTest(); | 272 scheduler_->BeginFrameDeadlineForTest(); |
273 EXPECT_EQ(3, client_->draw_and_swap_count()); | 273 EXPECT_EQ(3, client_->draw_and_swap_count()); |
274 scheduler_->DidSwapBuffers(); | 274 scheduler_->DidSwapBuffers(); |
275 | 275 |
276 // Deadline triggers early when swap throttled. | 276 // Deadline triggers early when swap throttled. |
277 BeginFrameForTest(); | 277 BeginFrameForTest(); |
278 // Damage surface 1, but not surface 2 so we avoid triggering deadline | 278 // Damage surface 1, but not surface 2 so we avoid triggering deadline |
279 // early because all surfaces are ready. | 279 // early because all surfaces are ready. |
280 scheduler_->SurfaceDamaged(sid1); | 280 scheduler_->SurfaceDamaged(sid1); |
281 EXPECT_EQ(scheduler_->DesiredBeginFrameDeadlineTimeForTest(), | 281 EXPECT_EQ(scheduler_->DesiredBeginFrameDeadlineTimeForTest(), |
282 base::TimeTicks()); | 282 base::TimeTicks()); |
283 | 283 |
284 // Don't draw and swap in deadline while swap throttled. | 284 // Don't draw and swap in deadline while swap throttled. |
285 EXPECT_EQ(3, client_->draw_and_swap_count()); | 285 EXPECT_EQ(3, client_->draw_and_swap_count()); |
286 scheduler_->BeginFrameDeadlineForTest(); | 286 scheduler_->BeginFrameDeadlineForTest(); |
287 EXPECT_EQ(3, client_->draw_and_swap_count()); | 287 EXPECT_EQ(3, client_->draw_and_swap_count()); |
288 | 288 |
289 // Deadline triggers normally once not swap throttled. | 289 // Deadline triggers normally once not swap throttled. |
290 // Damage from previous BeginFrame should cary over, so don't damage again. | 290 // Damage from previous BeginFrame should cary over, so don't damage again. |
291 late_deadline = now_src().Now() + BeginFrameArgs::DefaultInterval(); | 291 late_deadline = now_src().NowTicks() + BeginFrameArgs::DefaultInterval(); |
292 scheduler_->DidSwapBuffersComplete(); | 292 scheduler_->DidSwapBuffersComplete(); |
293 BeginFrameForTest(); | 293 BeginFrameForTest(); |
294 EXPECT_GT(scheduler_->DesiredBeginFrameDeadlineTimeForTest(), | 294 EXPECT_GT(scheduler_->DesiredBeginFrameDeadlineTimeForTest(), |
295 now_src().Now()); | 295 now_src().NowTicks()); |
296 EXPECT_LT(scheduler_->DesiredBeginFrameDeadlineTimeForTest(), late_deadline); | 296 EXPECT_LT(scheduler_->DesiredBeginFrameDeadlineTimeForTest(), late_deadline); |
297 // Still waiting for surface 2. Once it updates, deadline should trigger | 297 // Still waiting for surface 2. Once it updates, deadline should trigger |
298 // immediately again. | 298 // immediately again. |
299 scheduler_->SurfaceDamaged(sid2); | 299 scheduler_->SurfaceDamaged(sid2); |
300 EXPECT_EQ(scheduler_->DesiredBeginFrameDeadlineTimeForTest(), | 300 EXPECT_EQ(scheduler_->DesiredBeginFrameDeadlineTimeForTest(), |
301 base::TimeTicks()); | 301 base::TimeTicks()); |
302 // Draw and swap now that we aren't throttled. | 302 // Draw and swap now that we aren't throttled. |
303 EXPECT_EQ(3, client_->draw_and_swap_count()); | 303 EXPECT_EQ(3, client_->draw_and_swap_count()); |
304 scheduler_->BeginFrameDeadlineForTest(); | 304 scheduler_->BeginFrameDeadlineForTest(); |
305 EXPECT_EQ(4, client_->draw_and_swap_count()); | 305 EXPECT_EQ(4, client_->draw_and_swap_count()); |
(...skipping 26 matching lines...) Expand all Loading... |
332 | 332 |
333 scheduler_->SetRootSurfaceResourcesLocked(true); | 333 scheduler_->SetRootSurfaceResourcesLocked(true); |
334 EXPECT_EQ(count++, scheduler_->scheduler_begin_frame_deadline_count()); | 334 EXPECT_EQ(count++, scheduler_->scheduler_begin_frame_deadline_count()); |
335 | 335 |
336 scheduler_->OutputSurfaceLost(); | 336 scheduler_->OutputSurfaceLost(); |
337 EXPECT_EQ(count++, scheduler_->scheduler_begin_frame_deadline_count()); | 337 EXPECT_EQ(count++, scheduler_->scheduler_begin_frame_deadline_count()); |
338 } | 338 } |
339 | 339 |
340 } // namespace | 340 } // namespace |
341 } // namespace cc | 341 } // namespace cc |
OLD | NEW |