Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(823)

Side by Side Diff: cc/output/output_surface_unittest.cc

Issue 23767011: cc: Always use SetNeedsBeginFrame to request the next BeginFrame (Closed) Base URL: http://git.chromium.org/chromium/src.git@pollForDrawTriggers
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // DidSwapBuffers should clear the pending BeginFrame.
danakj 2013/09/12 16:53:59 comment should be replaced?
brianderson 2013/09/12 18:46:44 Yes. I will comb the code for similar comments to
214 output_surface.DidSwapBuffersForTesting(); 214 output_surface.DidSwapBuffersForTesting();
215 output_surface.SetNeedsBeginFrame(true);
215 EXPECT_EQ(client.begin_frame_count(), 1); 216 EXPECT_EQ(client.begin_frame_count(), 1);
216 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); 217 EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
217 task_runner->RunPendingTasks(); 218 task_runner->RunPendingTasks();
218 EXPECT_EQ(client.begin_frame_count(), 2); 219 EXPECT_EQ(client.begin_frame_count(), 2);
219 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); 220 EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
220 221
221 // BeginFrame should be throttled by pending swap buffers. 222 // BeginFrame should be throttled by pending swap buffers.
danakj 2013/09/12 16:53:59 So if it's not tied to swap, what will throttle be
brianderson 2013/09/12 18:46:44 The OutputSurface will throttle sending the next B
222 output_surface.DidSwapBuffersForTesting(); 223 output_surface.DidSwapBuffersForTesting();
224 output_surface.SetNeedsBeginFrame(true);
223 EXPECT_EQ(client.begin_frame_count(), 2); 225 EXPECT_EQ(client.begin_frame_count(), 2);
224 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); 226 EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
225 task_runner->RunPendingTasks(); 227 task_runner->RunPendingTasks();
226 EXPECT_EQ(client.begin_frame_count(), 2); 228 EXPECT_EQ(client.begin_frame_count(), 2);
227 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); 229 EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
228 230
229 // SwapAck should decrement pending swap buffers and unblock BeginFrame again. 231 // SwapAck should decrement pending swap buffers and unblock BeginFrame again.
230 output_surface.OnSwapBuffersCompleteForTesting(); 232 output_surface.OnSwapBuffersCompleteForTesting();
231 EXPECT_EQ(client.begin_frame_count(), 2); 233 EXPECT_EQ(client.begin_frame_count(), 2);
232 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); 234 EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // BeginFrames... 279 // BeginFrames...
278 output_surface.BeginFrameForTesting(); 280 output_surface.BeginFrameForTesting();
279 EXPECT_EQ(client.begin_frame_count(), 1); 281 EXPECT_EQ(client.begin_frame_count(), 1);
280 // ...and retroactively triggered by a SetNeedsBeginFrame. 282 // ...and retroactively triggered by a SetNeedsBeginFrame.
281 output_surface.SetNeedsBeginFrame(true); 283 output_surface.SetNeedsBeginFrame(true);
282 EXPECT_EQ(client.begin_frame_count(), 2); 284 EXPECT_EQ(client.begin_frame_count(), 2);
283 // ...or retroactively triggered by a Swap. 285 // ...or retroactively triggered by a Swap.
284 output_surface.BeginFrameForTesting(); 286 output_surface.BeginFrameForTesting();
285 EXPECT_EQ(client.begin_frame_count(), 2); 287 EXPECT_EQ(client.begin_frame_count(), 2);
286 output_surface.DidSwapBuffersForTesting(); 288 output_surface.DidSwapBuffersForTesting();
289 output_surface.SetNeedsBeginFrame(true);
287 EXPECT_EQ(client.begin_frame_count(), 3); 290 EXPECT_EQ(client.begin_frame_count(), 3);
288 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); 291 EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
289 292
290 // Optimistically injected BeginFrames should be by throttled by pending 293 // Optimistically injected BeginFrames should be by throttled by pending
291 // swap buffers... 294 // swap buffers...
292 output_surface.DidSwapBuffersForTesting(); 295 output_surface.DidSwapBuffersForTesting();
296 output_surface.SetNeedsBeginFrame(true);
293 EXPECT_EQ(client.begin_frame_count(), 3); 297 EXPECT_EQ(client.begin_frame_count(), 3);
294 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); 298 EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
295 output_surface.BeginFrameForTesting(); 299 output_surface.BeginFrameForTesting();
296 EXPECT_EQ(client.begin_frame_count(), 3); 300 EXPECT_EQ(client.begin_frame_count(), 3);
297 // ...and retroactively triggered by OnSwapBuffersComplete 301 // ...and retroactively triggered by OnSwapBuffersComplete
298 output_surface.OnSwapBuffersCompleteForTesting(); 302 output_surface.OnSwapBuffersCompleteForTesting();
299 EXPECT_EQ(client.begin_frame_count(), 4); 303 EXPECT_EQ(client.begin_frame_count(), 4);
300 } 304 }
301 305
302 TEST(OutputSurfaceTest, RetroactiveBeginFrameDoesNotDoubleTickWhenEmulating) { 306 TEST(OutputSurfaceTest, RetroactiveBeginFrameDoesNotDoubleTickWhenEmulating) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 406
403 // 0 bytes limit should be ignored. 407 // 0 bytes limit should be ignored.
404 policy.bytes_limit_when_visible = 0; 408 policy.bytes_limit_when_visible = 0;
405 context_provider->SetMemoryAllocation(policy, 409 context_provider->SetMemoryAllocation(policy,
406 discard_backbuffer_when_not_visible); 410 discard_backbuffer_when_not_visible);
407 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible); 411 EXPECT_EQ(1234u, client.memory_policy().bytes_limit_when_visible);
408 } 412 }
409 413
410 } // namespace 414 } // namespace
411 } // namespace cc 415 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698