Chromium Code Reviews| Index: services/ui/surfaces/gpu_compositor_frame_sink.cc |
| diff --git a/services/ui/surfaces/gpu_compositor_frame_sink.cc b/services/ui/surfaces/gpu_compositor_frame_sink.cc |
| index 4b472776b264e9802b1bd8c2687cb6661e3178a1..7d2dbe8b7ff7270e679badbb849b5c1c12e3257b 100644 |
| --- a/services/ui/surfaces/gpu_compositor_frame_sink.cc |
| +++ b/services/ui/surfaces/gpu_compositor_frame_sink.cc |
| @@ -10,19 +10,21 @@ |
| namespace ui { |
| GpuCompositorFrameSink::GpuCompositorFrameSink( |
| - DisplayCompositor* display_compositor, |
| + cc::CompositorFrameSinkDelegate* delegate, |
| + cc::SurfaceManager* surface_manager, |
| const cc::FrameSinkId& frame_sink_id, |
| std::unique_ptr<cc::Display> display, |
| std::unique_ptr<cc::BeginFrameSource> begin_frame_source, |
| cc::mojom::MojoCompositorFrameSinkPrivateRequest |
| compositor_frame_sink_private_request, |
| cc::mojom::MojoCompositorFrameSinkClientPtr client) |
| - : display_compositor_(display_compositor), |
| + : delegate_(delegate), |
| support_(this, |
| - display_compositor->manager(), |
| + surface_manager, |
| frame_sink_id, |
| std::move(display), |
| std::move(begin_frame_source)), |
| + surface_manager_(surface_manager), |
| surface_tracker_(frame_sink_id), |
| client_(std::move(client)), |
| compositor_frame_sink_private_binding_( |
| @@ -38,10 +40,10 @@ GpuCompositorFrameSink::~GpuCompositorFrameSink() { |
| // indicate the display root surface is no longer visible. |
| if (support_.display() && surface_tracker_.current_surface_id().is_valid()) { |
| const cc::SurfaceId top_level_root_surface_id = |
| - display_compositor_->manager()->GetRootSurfaceId(); |
| + surface_manager_->GetRootSurfaceId(); |
| std::vector<cc::SurfaceReference> references_to_remove{cc::SurfaceReference( |
| top_level_root_surface_id, surface_tracker_.current_surface_id())}; |
| - display_compositor_->RemoveSurfaceReferences(references_to_remove); |
| + RemoveSurfaceReferences(references_to_remove); |
| } |
| } |
| @@ -74,7 +76,7 @@ void GpuCompositorFrameSink::SubmitCompositorFrame( |
| if (support_.display() && |
| start_surface_id != surface_tracker_.current_surface_id()) { |
| const cc::SurfaceId top_level_root_surface_id = |
| - display_compositor_->manager()->GetRootSurfaceId(); |
| + surface_manager_->GetRootSurfaceId(); |
| // The first frame will not have a valid |start_surface_id| and there will |
| // be no surface to remove. |
| @@ -88,9 +90,27 @@ void GpuCompositorFrameSink::SubmitCompositorFrame( |
| } |
| if (!references_to_add.empty()) |
| - display_compositor_->AddSurfaceReferences(references_to_add); |
| + AddSurfaceReferences(references_to_add); |
| if (!references_to_remove.empty()) |
| - display_compositor_->RemoveSurfaceReferences(references_to_remove); |
| + RemoveSurfaceReferences(references_to_remove); |
| +} |
| + |
| +void GpuCompositorFrameSink::AddSurfaceReferences( |
|
Fady Samuel
2017/01/24 13:09:43
Move this to SurfaceManager.
|
| + const std::vector<cc::SurfaceReference>& references) { |
| + for (const auto& reference : references) { |
| + surface_manager_->AddSurfaceReference(reference.parent_id(), |
| + reference.child_id()); |
| + } |
| +} |
| + |
| +void GpuCompositorFrameSink::RemoveSurfaceReferences( |
|
Fady Samuel
2017/01/24 13:09:43
I'd just move this to SurfaceManager.
|
| + const std::vector<cc::SurfaceReference>& references) { |
| + // TODO(kylechar): Each remove reference can trigger GC, it would be better if |
| + // we GC only once if removing multiple references. |
| + for (const auto& reference : references) { |
| + surface_manager_->RemoveSurfaceReference(reference.parent_id(), |
| + reference.child_id()); |
| + } |
| } |
| void GpuCompositorFrameSink::Require(const cc::LocalFrameId& local_frame_id, |
| @@ -136,15 +156,15 @@ void GpuCompositorFrameSink::WillDrawSurface() { |
| void GpuCompositorFrameSink::OnClientConnectionLost() { |
| client_connection_lost_ = true; |
| // Request destruction of |this| only if both connections are lost. |
| - display_compositor_->OnCompositorFrameSinkClientConnectionLost( |
| - support_.frame_sink_id(), private_connection_lost_); |
| + delegate_->OnClientConnectionLost(support_.frame_sink_id(), |
| + private_connection_lost_); |
| } |
| void GpuCompositorFrameSink::OnPrivateConnectionLost() { |
| private_connection_lost_ = true; |
| // Request destruction of |this| only if both connections are lost. |
| - display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( |
| - support_.frame_sink_id(), client_connection_lost_); |
| + delegate_->OnPrivateConnectionLost(support_.frame_sink_id(), |
| + client_connection_lost_); |
| } |
| } // namespace ui |