OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
6 | 6 |
7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "cc/debug/test_context_provider.h" | 8 #include "cc/debug/test_context_provider.h" |
9 #include "cc/debug/test_web_graphics_context_3d.h" | 9 #include "cc/debug/test_web_graphics_context_3d.h" |
10 #include "cc/output/managed_memory_policy.h" | 10 #include "cc/output/managed_memory_policy.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // BeginFrame should be called on the first tick. | 203 // BeginFrame should be called on the first tick. |
204 task_runner->RunPendingTasks(); | 204 task_runner->RunPendingTasks(); |
205 EXPECT_EQ(client.begin_frame_count(), 1); | 205 EXPECT_EQ(client.begin_frame_count(), 1); |
206 EXPECT_EQ(output_surface.pending_swap_buffers(), 0); | 206 EXPECT_EQ(output_surface.pending_swap_buffers(), 0); |
207 | 207 |
208 // BeginFrame should not be called when there is a pending BeginFrame. | 208 // BeginFrame should not be called when there is a pending BeginFrame. |
209 task_runner->RunPendingTasks(); | 209 task_runner->RunPendingTasks(); |
210 EXPECT_EQ(client.begin_frame_count(), 1); | 210 EXPECT_EQ(client.begin_frame_count(), 1); |
211 EXPECT_EQ(output_surface.pending_swap_buffers(), 0); | 211 EXPECT_EQ(output_surface.pending_swap_buffers(), 0); |
212 | 212 |
213 // DidSwapBuffers should clear the pending BeginFrame. | 213 // SetNeedsBeginFrame should clear the pending BeginFrame after |
| 214 // a SwapBuffers. |
214 output_surface.DidSwapBuffersForTesting(); | 215 output_surface.DidSwapBuffersForTesting(); |
| 216 output_surface.SetNeedsBeginFrame(true); |
215 EXPECT_EQ(client.begin_frame_count(), 1); | 217 EXPECT_EQ(client.begin_frame_count(), 1); |
216 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); | 218 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); |
217 task_runner->RunPendingTasks(); | 219 task_runner->RunPendingTasks(); |
218 EXPECT_EQ(client.begin_frame_count(), 2); | 220 EXPECT_EQ(client.begin_frame_count(), 2); |
219 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); | 221 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); |
220 | 222 |
221 // BeginFrame should be throttled by pending swap buffers. | 223 // BeginFrame should be throttled by pending swap buffers. |
222 output_surface.DidSwapBuffersForTesting(); | 224 output_surface.DidSwapBuffersForTesting(); |
| 225 output_surface.SetNeedsBeginFrame(true); |
223 EXPECT_EQ(client.begin_frame_count(), 2); | 226 EXPECT_EQ(client.begin_frame_count(), 2); |
224 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); | 227 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); |
225 task_runner->RunPendingTasks(); | 228 task_runner->RunPendingTasks(); |
226 EXPECT_EQ(client.begin_frame_count(), 2); | 229 EXPECT_EQ(client.begin_frame_count(), 2); |
227 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); | 230 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); |
228 | 231 |
229 // SwapAck should decrement pending swap buffers and unblock BeginFrame again. | 232 // SwapAck should decrement pending swap buffers and unblock BeginFrame again. |
230 output_surface.OnSwapBuffersCompleteForTesting(); | 233 output_surface.OnSwapBuffersCompleteForTesting(); |
231 EXPECT_EQ(client.begin_frame_count(), 2); | 234 EXPECT_EQ(client.begin_frame_count(), 2); |
232 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); | 235 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // BeginFrames... | 280 // BeginFrames... |
278 output_surface.BeginFrameForTesting(); | 281 output_surface.BeginFrameForTesting(); |
279 EXPECT_EQ(client.begin_frame_count(), 1); | 282 EXPECT_EQ(client.begin_frame_count(), 1); |
280 // ...and retroactively triggered by a SetNeedsBeginFrame. | 283 // ...and retroactively triggered by a SetNeedsBeginFrame. |
281 output_surface.SetNeedsBeginFrame(true); | 284 output_surface.SetNeedsBeginFrame(true); |
282 EXPECT_EQ(client.begin_frame_count(), 2); | 285 EXPECT_EQ(client.begin_frame_count(), 2); |
283 // ...or retroactively triggered by a Swap. | 286 // ...or retroactively triggered by a Swap. |
284 output_surface.BeginFrameForTesting(); | 287 output_surface.BeginFrameForTesting(); |
285 EXPECT_EQ(client.begin_frame_count(), 2); | 288 EXPECT_EQ(client.begin_frame_count(), 2); |
286 output_surface.DidSwapBuffersForTesting(); | 289 output_surface.DidSwapBuffersForTesting(); |
| 290 output_surface.SetNeedsBeginFrame(true); |
287 EXPECT_EQ(client.begin_frame_count(), 3); | 291 EXPECT_EQ(client.begin_frame_count(), 3); |
288 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); | 292 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); |
289 | 293 |
290 // Optimistically injected BeginFrames should be by throttled by pending | 294 // Optimistically injected BeginFrames should be by throttled by pending |
291 // swap buffers... | 295 // swap buffers... |
292 output_surface.DidSwapBuffersForTesting(); | 296 output_surface.DidSwapBuffersForTesting(); |
| 297 output_surface.SetNeedsBeginFrame(true); |
293 EXPECT_EQ(client.begin_frame_count(), 3); | 298 EXPECT_EQ(client.begin_frame_count(), 3); |
294 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); | 299 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); |
295 output_surface.BeginFrameForTesting(); | 300 output_surface.BeginFrameForTesting(); |
296 EXPECT_EQ(client.begin_frame_count(), 3); | 301 EXPECT_EQ(client.begin_frame_count(), 3); |
297 // ...and retroactively triggered by OnSwapBuffersComplete | 302 // ...and retroactively triggered by OnSwapBuffersComplete |
298 output_surface.OnSwapBuffersCompleteForTesting(); | 303 output_surface.OnSwapBuffersCompleteForTesting(); |
299 EXPECT_EQ(client.begin_frame_count(), 4); | 304 EXPECT_EQ(client.begin_frame_count(), 4); |
300 } | 305 } |
301 | 306 |
302 TEST(OutputSurfaceTest, RetroactiveBeginFrameDoesNotDoubleTickWhenEmulating) { | 307 TEST(OutputSurfaceTest, RetroactiveBeginFrameDoesNotDoubleTickWhenEmulating) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 407 |
403 // 0 bytes limit should be ignored. | 408 // 0 bytes limit should be ignored. |
404 policy.bytes_limit_when_visible = 0; | 409 policy.bytes_limit_when_visible = 0; |
405 context_provider->SetMemoryAllocation(policy, | 410 context_provider->SetMemoryAllocation(policy, |
406 discard_backbuffer_when_not_visible); | 411 discard_backbuffer_when_not_visible); |
407 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); | 412 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); |
408 } | 413 } |
409 | 414 |
410 } // namespace | 415 } // namespace |
411 } // namespace cc | 416 } // namespace cc |
OLD | NEW |