| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 support_->SetNeedsBeginFrame(needs_begin_frames); | 198 support_->SetNeedsBeginFrame(needs_begin_frames); |
| 198 } | 199 } |
| 199 | 200 |
| 200 void TestCompositorFrameSink::OnDidFinishFrame(const BeginFrameAck& ack) {} | 201 void TestCompositorFrameSink::OnDidFinishFrame(const BeginFrameAck& ack) {} |
| 201 | 202 |
| 202 void TestCompositorFrameSink::SendCompositorFrameAckToClient() { | 203 void TestCompositorFrameSink::SendCompositorFrameAckToClient() { |
| 203 client_->DidReceiveCompositorFrameAck(); | 204 client_->DidReceiveCompositorFrameAck(); |
| 204 } | 205 } |
| 205 | 206 |
| 206 } // namespace cc | 207 } // namespace cc |
| OLD | NEW |