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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 if (last_sent_frame_.delegated_frame_data) { | 70 if (last_sent_frame_.delegated_frame_data) { |
71 resources_held_by_parent_.insert( | 71 resources_held_by_parent_.insert( |
72 resources_held_by_parent_.end(), | 72 resources_held_by_parent_.end(), |
73 last_sent_frame_.delegated_frame_data->resource_list.begin(), | 73 last_sent_frame_.delegated_frame_data->resource_list.begin(), |
74 last_sent_frame_.delegated_frame_data->resource_list.end()); | 74 last_sent_frame_.delegated_frame_data->resource_list.end()); |
75 } | 75 } |
76 | 76 |
77 ++num_sent_frames_; | 77 ++num_sent_frames_; |
78 PostSwapBuffersComplete(); | 78 PostSwapBuffersComplete(); |
79 DidSwapBuffers(); | 79 client_->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::SetNeedsBeginFrame(bool enable) { | 87 void FakeOutputSurface::SetNeedsBeginFrame(bool enable) { |
88 needs_begin_frame_ = enable; | 88 needs_begin_frame_ = enable; |
89 OutputSurface::SetNeedsBeginFrame(enable); | 89 OutputSurface::SetNeedsBeginFrame(enable); |
90 | 90 |
91 // If there is not BeginFrame emulation from the FrameRateController, | 91 if (enable) { |
92 // then we just post a BeginFrame to emulate it as part of the test. | |
93 if (enable && !frame_rate_controller_) { | |
94 base::MessageLoop::current()->PostDelayedTask( | 92 base::MessageLoop::current()->PostDelayedTask( |
95 FROM_HERE, | 93 FROM_HERE, |
96 base::Bind(&FakeOutputSurface::OnBeginFrame, | 94 base::Bind(&FakeOutputSurface::OnBeginFrame, |
97 fake_weak_ptr_factory_.GetWeakPtr()), | 95 fake_weak_ptr_factory_.GetWeakPtr()), |
98 base::TimeDelta::FromMilliseconds(16)); | 96 base::TimeDelta::FromMilliseconds(16)); |
99 } | 97 } |
100 } | 98 } |
101 | 99 |
102 void FakeOutputSurface::OnBeginFrame() { | 100 void FakeOutputSurface::OnBeginFrame() { |
103 OutputSurface::BeginFrame(BeginFrameArgs::CreateForTesting()); | 101 client_->BeginFrame(BeginFrameArgs::CreateForTesting()); |
104 } | 102 } |
105 | 103 |
106 | 104 |
107 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const { | 105 bool FakeOutputSurface::ForcedDrawToSoftwareDevice() const { |
108 return forced_draw_to_software_device_; | 106 return forced_draw_to_software_device_; |
109 } | 107 } |
110 | 108 |
111 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { | 109 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { |
112 if (OutputSurface::BindToClient(client)) { | 110 if (OutputSurface::BindToClient(client)) { |
113 client_ = client; | 111 client_ = client; |
(...skipping 29 matching lines...) Expand all Loading... |
143 bool FakeOutputSurface::HasExternalStencilTest() const { | 141 bool FakeOutputSurface::HasExternalStencilTest() const { |
144 return has_external_stencil_test_; | 142 return has_external_stencil_test_; |
145 } | 143 } |
146 | 144 |
147 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( | 145 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( |
148 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { | 146 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { |
149 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); | 147 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); |
150 } | 148 } |
151 | 149 |
152 } // namespace cc | 150 } // namespace cc |
OLD | NEW |