| 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" |
| (...skipping 66 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_impl_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 |