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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); | 130 DCHECK(frame.metadata.begin_frame_ack.has_damage); |
131 DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, | 131 DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, |
132 frame.metadata.begin_frame_ack.sequence_number); | 132 frame.metadata.begin_frame_ack.sequence_number); |
133 test_client_->DisplayReceivedCompositorFrame(frame); | 133 test_client_->DisplayReceivedCompositorFrame(frame); |
134 | 134 |
| 135 if (!delegated_local_surface_id_.is_valid()) { |
| 136 delegated_local_surface_id_ = local_surface_id_allocator_->GenerateId(); |
| 137 } |
| 138 display_->SetLocalSurfaceId(delegated_local_surface_id_, |
| 139 frame.metadata.device_scale_factor); |
| 140 |
135 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(); |
136 float device_scale_factor = frame.metadata.device_scale_factor; | 142 display_->Resize(frame_size); |
137 if (!local_surface_id_.is_valid() || frame_size != display_size_ || | |
138 device_scale_factor != device_scale_factor_) { | |
139 local_surface_id_ = local_surface_id_allocator_->GenerateId(); | |
140 display_->SetLocalSurfaceId(local_surface_id_, device_scale_factor); | |
141 display_->Resize(frame_size); | |
142 display_size_ = frame_size; | |
143 device_scale_factor_ = device_scale_factor; | |
144 } | |
145 | 143 |
146 bool result = | 144 support_->SubmitCompositorFrame(delegated_local_surface_id_, |
147 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); | 145 std::move(frame)); |
148 DCHECK(result); | |
149 | 146 |
150 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) { | 147 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) { |
151 support_->RequestCopyOfSurface(std::move(copy_request)); | 148 support_->RequestCopyOfSurface(std::move(copy_request)); |
152 } | 149 } |
153 copy_requests_.clear(); | 150 copy_requests_.clear(); |
154 | 151 |
155 if (!display_->has_scheduler()) { | 152 if (!display_->has_scheduler()) { |
156 display_->DrawAndSwap(); | 153 display_->DrawAndSwap(); |
157 // 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 |
158 // calling the client to tell it that it is done. | 155 // calling the client to tell it that it is done. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 205 |
209 void TestCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { | 206 void TestCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { |
210 support_->SetNeedsBeginFrame(needs_begin_frames); | 207 support_->SetNeedsBeginFrame(needs_begin_frames); |
211 } | 208 } |
212 | 209 |
213 void TestCompositorFrameSink::SendCompositorFrameAckToClient() { | 210 void TestCompositorFrameSink::SendCompositorFrameAckToClient() { |
214 client_->DidReceiveCompositorFrameAck(); | 211 client_->DidReceiveCompositorFrameAck(); |
215 } | 212 } |
216 | 213 |
217 } // namespace cc | 214 } // namespace cc |
OLD | NEW |