OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/test/fake_output_surface.h" | 5 #include "cc/test/fake_output_surface.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "cc/output/compositor_frame_ack.h" | 9 #include "cc/output/compositor_frame_ack.h" |
10 #include "cc/output/output_surface_client.h" | 10 #include "cc/output/output_surface_client.h" |
11 #include "cc/resources/returned_resource.h" | 11 #include "cc/resources/returned_resource.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 FakeOutputSurface::FakeOutputSurface( | 16 FakeOutputSurface::FakeOutputSurface( |
17 scoped_refptr<ContextProvider> context_provider, | 17 scoped_refptr<ContextProvider> context_provider, |
18 bool delegated_rendering) | 18 bool delegated_rendering) |
19 : OutputSurface(context_provider), | 19 : OutputSurface(context_provider), |
20 client_(NULL), | 20 client_(NULL), |
21 num_sent_frames_(0), | 21 num_sent_frames_(0), |
22 needs_begin_impl_frame_(false), | 22 needs_begin_frame_(false), |
23 forced_draw_to_software_device_(false), | 23 forced_draw_to_software_device_(false), |
24 has_external_stencil_test_(false), | 24 has_external_stencil_test_(false), |
25 fake_weak_ptr_factory_(this) { | 25 fake_weak_ptr_factory_(this) { |
26 if (delegated_rendering) { | 26 if (delegated_rendering) { |
27 capabilities_.delegated_rendering = true; | 27 capabilities_.delegated_rendering = true; |
28 capabilities_.max_frames_pending = 1; | 28 capabilities_.max_frames_pending = 1; |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 FakeOutputSurface::FakeOutputSurface( | 32 FakeOutputSurface::FakeOutputSurface( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 ++num_sent_frames_; | 77 ++num_sent_frames_; |
78 PostSwapBuffersComplete(); | 78 PostSwapBuffersComplete(); |
79 DidSwapBuffers(); | 79 DidSwapBuffers(); |
80 } else { | 80 } else { |
81 OutputSurface::SwapBuffers(frame); | 81 OutputSurface::SwapBuffers(frame); |
82 frame->AssignTo(&last_sent_frame_); | 82 frame->AssignTo(&last_sent_frame_); |
83 ++num_sent_frames_; | 83 ++num_sent_frames_; |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 void FakeOutputSurface::SetNeedsBeginImplFrame(bool enable) { | 87 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) { |
88 needs_begin_impl_frame_ = enable; | 88 needs_begin_frame_ = enable; |
89 OutputSurface::SetNeedsBeginImplFrame(enable); | 89 OutputSurface::SetNeedsBeginFrame(enable); |
90 | 90 |
91 // If there is not BeginImplFrame emulation from the FrameRateController, | 91 // If there is not BeginFrame emulation from the FrameRateController, |
92 // then we just post a BeginImplFrame to emulate it as part of the test. | 92 // then we just post a BeginFrame to emulate it as part of the test. |
93 if (enable && !frame_rate_controller_) { | 93 if (enable && !frame_rate_controller_) { |
94 base::MessageLoop::current()->PostDelayedTask( | 94 base::MessageLoop::current()->PostDelayedTask( |
95 FROM_HERE, base::Bind(&FakeOutputSurface::OnBeginImplFrame, | 95 FROM_HERE, |
96 fake_weak_ptr_factory_.GetWeakPtr()), | 96 base::Bind(&FakeOutputSurface::OnBeginFrame, |
| 97 fake_weak_ptr_factory_.GetWeakPtr()), |
97 base::TimeDelta::FromMilliseconds(16)); | 98 base::TimeDelta::FromMilliseconds(16)); |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
101 void FakeOutputSurface::OnBeginImplFrame() { | 102 void FakeOutputSurface::OnBeginFrame() { |
102 OutputSurface::BeginImplFrame(BeginFrameArgs::CreateForTesting()); | 103 OutputSurface::BeginFrame(BeginFrameArgs::CreateForTesting()); |
103 } | 104 } |
104 | 105 |
105 | 106 |
106 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const { | 107 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const { |
107 return forced_draw_to_software_device_; | 108 return forced_draw_to_software_device_; |
108 } | 109 } |
109 | 110 |
110 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { | 111 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { |
111 if (OutputSurface::BindToClient(client)) { | 112 if (OutputSurface::BindToClient(client)) { |
112 client_ = client; | 113 client_ = client; |
(...skipping 29 matching lines...) Expand all Loading... |
142 bool FakeOutputSurface::HasExternalStencilTest() const { | 143 bool FakeOutputSurface::HasExternalStencilTest() const { |
143 return has_external_stencil_test_; | 144 return has_external_stencil_test_; |
144 } | 145 } |
145 | 146 |
146 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( | 147 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( |
147 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { | 148 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { |
148 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); | 149 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); |
149 } | 150 } |
150 | 151 |
151 } // namespace cc | 152 } // namespace cc |
OLD | NEW |