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

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

Issue 16863005: cc: Add BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@nofrc12
Patch Set: Fix android compile Created 7 years, 6 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 #include "cc/output/output_surface_client.h" 6 #include "cc/output/output_surface_client.h"
7 #include "cc/output/software_output_device.h" 7 #include "cc/output/software_output_device.h"
8 #include "cc/test/scheduler_test_common.h" 8 #include "cc/test/scheduler_test_common.h"
9 #include "cc/test/test_web_graphics_context_3d.h" 9 #include "cc/test/test_web_graphics_context_3d.h"
10 #include "gpu/GLES2/gl2extchromium.h" 10 #include "gpu/GLES2/gl2extchromium.h"
(...skipping 23 matching lines...) Expand all
34 34
35 bool HasClientForTesting() { 35 bool HasClientForTesting() {
36 return HasClient(); 36 return HasClient();
37 } 37 }
38 38
39 void OnVSyncParametersChangedForTesting(base::TimeTicks timebase, 39 void OnVSyncParametersChangedForTesting(base::TimeTicks timebase,
40 base::TimeDelta interval) { 40 base::TimeDelta interval) {
41 OnVSyncParametersChanged(timebase, interval); 41 OnVSyncParametersChanged(timebase, interval);
42 } 42 }
43 43
44 void BeginFrameForTesting(base::TimeTicks frame_time) { 44 void BeginFrameForTesting() {
45 BeginFrame(frame_time); 45 BeginFrame(BeginFrameArgs::CreateForTesting());
46 } 46 }
47 47
48 void DidSwapBuffersForTesting() { 48 void DidSwapBuffersForTesting() {
49 DidSwapBuffers(); 49 DidSwapBuffers();
50 } 50 }
51 51
52 int pending_swap_buffers() { 52 int pending_swap_buffers() {
53 return pending_swap_buffers_; 53 return pending_swap_buffers_;
54 } 54 }
55 55
56 void OnSwapBuffersCompleteForTesting() { 56 void OnSwapBuffersCompleteForTesting() {
57 OnSwapBuffersComplete(NULL); 57 OnSwapBuffersComplete(NULL);
58 } 58 }
59 }; 59 };
60 60
61 class FakeOutputSurfaceClient : public OutputSurfaceClient { 61 class FakeOutputSurfaceClient : public OutputSurfaceClient {
62 public: 62 public:
63 FakeOutputSurfaceClient() 63 FakeOutputSurfaceClient()
64 : begin_frame_count_(0), 64 : begin_frame_count_(0),
65 deferred_initialize_result_(true), 65 deferred_initialize_result_(true),
66 deferred_initialize_called_(false), 66 deferred_initialize_called_(false),
67 did_lose_output_surface_called_(false) {} 67 did_lose_output_surface_called_(false) {}
68 68
69 virtual bool DeferredInitialize( 69 virtual bool DeferredInitialize(
70 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE { 70 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE {
71 deferred_initialize_called_ = true; 71 deferred_initialize_called_ = true;
72 return deferred_initialize_result_; 72 return deferred_initialize_result_;
73 } 73 }
74 virtual void SetNeedsRedrawRect(gfx::Rect damage_rect) OVERRIDE {} 74 virtual void SetNeedsRedrawRect(gfx::Rect damage_rect) OVERRIDE {}
75 virtual void BeginFrame(base::TimeTicks frame_time) OVERRIDE { 75 virtual void BeginFrame(BeginFrameArgs args) OVERRIDE {
76 begin_frame_count_++; 76 begin_frame_count_++;
77 } 77 }
78 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE {} 78 virtual void OnSwapBuffersComplete(const CompositorFrameAck* ack) OVERRIDE {}
79 virtual void DidLoseOutputSurface() OVERRIDE { 79 virtual void DidLoseOutputSurface() OVERRIDE {
80 did_lose_output_surface_called_ = true; 80 did_lose_output_surface_called_ = true;
81 } 81 }
82 virtual void SetExternalDrawConstraints(const gfx::Transform& transform, 82 virtual void SetExternalDrawConstraints(const gfx::Transform& transform,
83 gfx::Rect viewport) OVERRIDE {} 83 gfx::Rect viewport) OVERRIDE {}
84 84
85 int begin_frame_count() { 85 int begin_frame_count() {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 // Disabling SetNeedsBeginFrame should prevent further BeginFrames. 273 // Disabling SetNeedsBeginFrame should prevent further BeginFrames.
274 output_surface.SetNeedsBeginFrame(false); 274 output_surface.SetNeedsBeginFrame(false);
275 impl_thread.RunPendingTask(); 275 impl_thread.RunPendingTask();
276 EXPECT_FALSE(impl_thread.HasPendingTask()); 276 EXPECT_FALSE(impl_thread.HasPendingTask());
277 EXPECT_EQ(client.begin_frame_count(), 4); 277 EXPECT_EQ(client.begin_frame_count(), 4);
278 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); 278 EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
279 279
280 // Optimistically injected BeginFrames without a SetNeedsBeginFrame should be 280 // Optimistically injected BeginFrames without a SetNeedsBeginFrame should be
281 // allowed. 281 // allowed.
282 output_surface.BeginFrameForTesting(base::TimeTicks::Now()); 282 output_surface.BeginFrameForTesting();
283 EXPECT_EQ(client.begin_frame_count(), 5); 283 EXPECT_EQ(client.begin_frame_count(), 5);
284 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); 284 EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
285 285
286 // Optimistically injected BeginFrames without a SetNeedsBeginFrame should 286 // Optimistically injected BeginFrames without a SetNeedsBeginFrame should
287 // still be throttled by pending begin frames however. 287 // still be throttled by pending begin frames however.
288 output_surface.BeginFrameForTesting(base::TimeTicks::Now()); 288 output_surface.BeginFrameForTesting();
289 EXPECT_EQ(client.begin_frame_count(), 5); 289 EXPECT_EQ(client.begin_frame_count(), 5);
290 EXPECT_EQ(output_surface.pending_swap_buffers(), 1); 290 EXPECT_EQ(output_surface.pending_swap_buffers(), 1);
291 291
292 // Optimistically injected BeginFrames without a SetNeedsBeginFrame should 292 // Optimistically injected BeginFrames without a SetNeedsBeginFrame should
293 // also be throttled by pending swap buffers. 293 // also be throttled by pending swap buffers.
294 output_surface.DidSwapBuffersForTesting(); 294 output_surface.DidSwapBuffersForTesting();
295 EXPECT_EQ(client.begin_frame_count(), 5); 295 EXPECT_EQ(client.begin_frame_count(), 5);
296 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); 296 EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
297 output_surface.BeginFrameForTesting(base::TimeTicks::Now()); 297 output_surface.BeginFrameForTesting();
298 EXPECT_EQ(client.begin_frame_count(), 5); 298 EXPECT_EQ(client.begin_frame_count(), 5);
299 EXPECT_EQ(output_surface.pending_swap_buffers(), 2); 299 EXPECT_EQ(output_surface.pending_swap_buffers(), 2);
300 } 300 }
301 301
302 } // namespace 302 } // namespace
303 } // namespace cc 303 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698