| 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/surfaces/compositor_frame_sink_support.h" | 5 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 "RenderWidgetHostImpl::OnSwapCompositorFrame")) { | 118 "RenderWidgetHostImpl::OnSwapCompositorFrame")) { |
| 119 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info); | 119 std::vector<ui::LatencyInfo>().swap(frame.metadata.latency_info); |
| 120 } | 120 } |
| 121 for (ui::LatencyInfo& latency : frame.metadata.latency_info) { | 121 for (ui::LatencyInfo& latency : frame.metadata.latency_info) { |
| 122 if (latency.latency_components().size() > 0) { | 122 if (latency.latency_components().size() > 0) { |
| 123 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, | 123 latency.AddLatencyNumber(ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, |
| 124 0, 0); | 124 0, 0); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 SurfaceId surface_id(frame_sink_id_, local_surface_id); |
| 129 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); |
| 130 float device_scale_factor = frame.metadata.device_scale_factor; |
| 131 SurfaceInfo surface_info(surface_id, device_scale_factor, frame_size); |
| 132 |
| 128 std::unique_ptr<Surface> surface; | 133 std::unique_ptr<Surface> surface; |
| 129 bool create_new_surface = | 134 bool create_new_surface = |
| 130 (!current_surface_ || | 135 (!current_surface_ || |
| 131 local_surface_id != current_surface_->surface_id().local_surface_id()); | 136 local_surface_id != current_surface_->surface_id().local_surface_id()); |
| 132 if (!create_new_surface) { | 137 if (!create_new_surface) { |
| 133 surface = std::move(current_surface_); | 138 surface = std::move(current_surface_); |
| 134 } else { | 139 } else { |
| 135 surface = CreateSurface(local_surface_id); | 140 surface = CreateSurface(surface_info); |
| 136 } | 141 } |
| 137 | 142 |
| 138 surface->QueueFrame( | 143 surface->QueueFrame( |
| 139 std::move(frame), | 144 std::move(frame), |
| 140 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, | 145 base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck, |
| 141 weak_factory_.GetWeakPtr()), | 146 weak_factory_.GetWeakPtr()), |
| 142 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface, | 147 base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface, |
| 143 weak_factory_.GetWeakPtr())); | 148 weak_factory_.GetWeakPtr())); |
| 144 | 149 |
| 145 if (current_surface_) { | 150 if (current_surface_) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 return; | 335 return; |
| 331 | 336 |
| 332 added_frame_observer_ = needs_begin_frame_; | 337 added_frame_observer_ = needs_begin_frame_; |
| 333 if (needs_begin_frame_) | 338 if (needs_begin_frame_) |
| 334 begin_frame_source_->AddObserver(this); | 339 begin_frame_source_->AddObserver(this); |
| 335 else | 340 else |
| 336 begin_frame_source_->RemoveObserver(this); | 341 begin_frame_source_->RemoveObserver(this); |
| 337 } | 342 } |
| 338 | 343 |
| 339 std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface( | 344 std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface( |
| 340 const LocalSurfaceId& local_surface_id) { | 345 const SurfaceInfo& surface_info) { |
| 341 seen_first_frame_activation_ = false; | 346 seen_first_frame_activation_ = false; |
| 342 std::unique_ptr<Surface> surface = surface_manager_->CreateSurface( | 347 std::unique_ptr<Surface> surface = |
| 343 weak_factory_.GetWeakPtr(), local_surface_id); | 348 surface_manager_->CreateSurface(weak_factory_.GetWeakPtr(), surface_info); |
| 344 return surface; | 349 return surface; |
| 345 } | 350 } |
| 346 | 351 |
| 347 void CompositorFrameSinkSupport::DestroyCurrentSurface() { | 352 void CompositorFrameSinkSupport::DestroyCurrentSurface() { |
| 348 surface_manager_->DestroySurface(std::move(current_surface_)); | 353 surface_manager_->DestroySurface(std::move(current_surface_)); |
| 349 } | 354 } |
| 350 | 355 |
| 351 void CompositorFrameSinkSupport::RequestCopyOfSurface( | 356 void CompositorFrameSinkSupport::RequestCopyOfSurface( |
| 352 std::unique_ptr<CopyOutputRequest> copy_request) { | 357 std::unique_ptr<CopyOutputRequest> copy_request) { |
| 353 if (!current_surface_) | 358 if (!current_surface_) |
| 354 return; | 359 return; |
| 355 | 360 |
| 356 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); | 361 DCHECK(current_surface_->compositor_frame_sink_support().get() == this); |
| 357 current_surface_->RequestCopyOfOutput(std::move(copy_request)); | 362 current_surface_->RequestCopyOfOutput(std::move(copy_request)); |
| 358 surface_manager_->SurfaceModified(current_surface_->surface_id()); | 363 surface_manager_->SurfaceModified(current_surface_->surface_id()); |
| 359 } | 364 } |
| 360 | 365 |
| 361 } // namespace cc | 366 } // namespace cc |
| OLD | NEW |