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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 121 } |
122 | 122 |
123 void TestCompositorFrameSink::SetLocalSurfaceId( | 123 void TestCompositorFrameSink::SetLocalSurfaceId( |
124 const LocalSurfaceId& local_surface_id) { | 124 const LocalSurfaceId& local_surface_id) { |
125 test_client_->DisplayReceivedLocalSurfaceId(local_surface_id); | 125 test_client_->DisplayReceivedLocalSurfaceId(local_surface_id); |
126 } | 126 } |
127 | 127 |
128 void TestCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { | 128 void TestCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { |
129 test_client_->DisplayReceivedCompositorFrame(frame); | 129 test_client_->DisplayReceivedCompositorFrame(frame); |
130 | 130 |
131 if (!delegated_local_surface_id_.is_valid()) { | 131 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); |
132 delegated_local_surface_id_ = local_surface_id_allocator_->GenerateId(); | 132 float device_scale_factor = frame.metadata.device_scale_factor; |
| 133 if (!local_surface_id_.is_valid() || frame_size != display_size_ || |
| 134 device_scale_factor != device_scale_factor_) { |
| 135 local_surface_id_ = local_surface_id_allocator_->GenerateId(); |
| 136 display_->SetLocalSurfaceId(local_surface_id_, device_scale_factor); |
| 137 display_->Resize(frame_size); |
| 138 display_size_ = frame_size; |
| 139 device_scale_factor_ = device_scale_factor; |
133 } | 140 } |
134 display_->SetLocalSurfaceId(delegated_local_surface_id_, | |
135 frame.metadata.device_scale_factor); | |
136 | 141 |
137 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); | 142 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); |
138 display_->Resize(frame_size); | |
139 | |
140 support_->SubmitCompositorFrame(delegated_local_surface_id_, | |
141 std::move(frame)); | |
142 | 143 |
143 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) { | 144 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) { |
144 support_->RequestCopyOfSurface(std::move(copy_request)); | 145 support_->RequestCopyOfSurface(std::move(copy_request)); |
145 } | 146 } |
146 copy_requests_.clear(); | 147 copy_requests_.clear(); |
147 | 148 |
148 if (!display_->has_scheduler()) { | 149 if (!display_->has_scheduler()) { |
149 display_->DrawAndSwap(); | 150 display_->DrawAndSwap(); |
150 // Post this to get a new stack frame so that we exit this function before | 151 // Post this to get a new stack frame so that we exit this function before |
151 // calling the client to tell it that it is done. | 152 // calling the client to tell it that it is done. |
(...skipping 20 matching lines...) Expand all Loading... |
172 | 173 |
173 void TestCompositorFrameSink::ReclaimResources( | 174 void TestCompositorFrameSink::ReclaimResources( |
174 const ReturnedResourceArray& resources) { | 175 const ReturnedResourceArray& resources) { |
175 client_->ReclaimResources(resources); | 176 client_->ReclaimResources(resources); |
176 } | 177 } |
177 | 178 |
178 void TestCompositorFrameSink::WillDrawSurface( | 179 void TestCompositorFrameSink::WillDrawSurface( |
179 const LocalSurfaceId& local_surface_id, | 180 const LocalSurfaceId& local_surface_id, |
180 const gfx::Rect& damage_rect) {} | 181 const gfx::Rect& damage_rect) {} |
181 | 182 |
| 183 void TestCompositorFrameSink::DidRejectCompositorFrame() { |
| 184 NOTREACHED(); |
| 185 } |
| 186 |
182 void TestCompositorFrameSink::DisplayOutputSurfaceLost() { | 187 void TestCompositorFrameSink::DisplayOutputSurfaceLost() { |
183 client_->DidLoseCompositorFrameSink(); | 188 client_->DidLoseCompositorFrameSink(); |
184 } | 189 } |
185 | 190 |
186 void TestCompositorFrameSink::DisplayWillDrawAndSwap( | 191 void TestCompositorFrameSink::DisplayWillDrawAndSwap( |
187 bool will_draw_and_swap, | 192 bool will_draw_and_swap, |
188 const RenderPassList& render_passes) { | 193 const RenderPassList& render_passes) { |
189 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); | 194 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); |
190 } | 195 } |
191 | 196 |
192 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { | 197 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { |
193 test_client_->DisplayDidDrawAndSwap(); | 198 test_client_->DisplayDidDrawAndSwap(); |
194 } | 199 } |
195 | 200 |
196 void TestCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { | 201 void TestCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { |
197 support_->SetNeedsBeginFrame(needs_begin_frames); | 202 support_->SetNeedsBeginFrame(needs_begin_frames); |
198 } | 203 } |
199 | 204 |
200 void TestCompositorFrameSink::OnDidFinishFrame(const BeginFrameAck& ack) {} | 205 void TestCompositorFrameSink::OnDidFinishFrame(const BeginFrameAck& ack) {} |
201 | 206 |
202 void TestCompositorFrameSink::SendCompositorFrameAckToClient() { | 207 void TestCompositorFrameSink::SendCompositorFrameAckToClient() { |
203 client_->DidReceiveCompositorFrameAck(); | 208 client_->DidReceiveCompositorFrameAck(); |
204 } | 209 } |
205 | 210 |
206 } // namespace cc | 211 } // namespace cc |
OLD | NEW |