OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/test_compositor_frame_sink.h" | 5 #include "cc/test/test_compositor_frame_sink.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 test_client_ = nullptr; | 120 test_client_ = nullptr; |
121 CompositorFrameSink::DetachFromClient(); | 121 CompositorFrameSink::DetachFromClient(); |
122 } | 122 } |
123 | 123 |
124 void TestCompositorFrameSink::SetLocalSurfaceId( | 124 void TestCompositorFrameSink::SetLocalSurfaceId( |
125 const LocalSurfaceId& local_surface_id) { | 125 const LocalSurfaceId& local_surface_id) { |
126 test_client_->DisplayReceivedLocalSurfaceId(local_surface_id); | 126 test_client_->DisplayReceivedLocalSurfaceId(local_surface_id); |
127 } | 127 } |
128 | 128 |
129 void TestCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { | 129 void TestCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { |
| 130 DCHECK(frame.metadata.begin_frame_ack.has_damage); |
| 131 DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, |
| 132 frame.metadata.begin_frame_ack.sequence_number); |
130 test_client_->DisplayReceivedCompositorFrame(frame); | 133 test_client_->DisplayReceivedCompositorFrame(frame); |
131 | 134 |
132 if (!delegated_local_surface_id_.is_valid()) { | 135 if (!delegated_local_surface_id_.is_valid()) { |
133 delegated_local_surface_id_ = local_surface_id_allocator_->GenerateId(); | 136 delegated_local_surface_id_ = local_surface_id_allocator_->GenerateId(); |
134 } | 137 } |
135 display_->SetLocalSurfaceId(delegated_local_surface_id_, | 138 display_->SetLocalSurfaceId(delegated_local_surface_id_, |
136 frame.metadata.device_scale_factor); | 139 frame.metadata.device_scale_factor); |
137 | 140 |
138 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); | 141 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); |
139 display_->Resize(frame_size); | 142 display_->Resize(frame_size); |
(...skipping 10 matching lines...) Expand all Loading... |
150 display_->DrawAndSwap(); | 153 display_->DrawAndSwap(); |
151 // Post this to get a new stack frame so that we exit this function before | 154 // Post this to get a new stack frame so that we exit this function before |
152 // calling the client to tell it that it is done. | 155 // calling the client to tell it that it is done. |
153 task_runner_->PostTask( | 156 task_runner_->PostTask( |
154 FROM_HERE, | 157 FROM_HERE, |
155 base::BindOnce(&TestCompositorFrameSink::SendCompositorFrameAckToClient, | 158 base::BindOnce(&TestCompositorFrameSink::SendCompositorFrameAckToClient, |
156 weak_ptr_factory_.GetWeakPtr())); | 159 weak_ptr_factory_.GetWeakPtr())); |
157 } | 160 } |
158 } | 161 } |
159 | 162 |
| 163 void TestCompositorFrameSink::DidNotProduceFrame(const BeginFrameAck& ack) { |
| 164 DCHECK(!ack.has_damage); |
| 165 DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, ack.sequence_number); |
| 166 support_->DidNotProduceFrame(ack); |
| 167 } |
| 168 |
160 void TestCompositorFrameSink::DidReceiveCompositorFrameAck( | 169 void TestCompositorFrameSink::DidReceiveCompositorFrameAck( |
161 const ReturnedResourceArray& resources) { | 170 const ReturnedResourceArray& resources) { |
162 ReclaimResources(resources); | 171 ReclaimResources(resources); |
163 // In synchronous mode, we manually send acks and this method should not be | 172 // In synchronous mode, we manually send acks and this method should not be |
164 // used. | 173 // used. |
165 if (!display_->has_scheduler()) | 174 if (!display_->has_scheduler()) |
166 return; | 175 return; |
167 client_->DidReceiveCompositorFrameAck(); | 176 client_->DidReceiveCompositorFrameAck(); |
168 } | 177 } |
169 | 178 |
(...skipping 21 matching lines...) Expand all Loading... |
191 } | 200 } |
192 | 201 |
193 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { | 202 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { |
194 test_client_->DisplayDidDrawAndSwap(); | 203 test_client_->DisplayDidDrawAndSwap(); |
195 } | 204 } |
196 | 205 |
197 void TestCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { | 206 void TestCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { |
198 support_->SetNeedsBeginFrame(needs_begin_frames); | 207 support_->SetNeedsBeginFrame(needs_begin_frames); |
199 } | 208 } |
200 | 209 |
201 void TestCompositorFrameSink::OnDidFinishFrame(const BeginFrameAck& ack) {} | |
202 | |
203 void TestCompositorFrameSink::SendCompositorFrameAckToClient() { | 210 void TestCompositorFrameSink::SendCompositorFrameAckToClient() { |
204 client_->DidReceiveCompositorFrameAck(); | 211 client_->DidReceiveCompositorFrameAck(); |
205 } | 212 } |
206 | 213 |
207 } // namespace cc | 214 } // namespace cc |
OLD | NEW |