| Index: components/display_compositor/gpu_compositor_frame_sink.cc
|
| diff --git a/components/display_compositor/gpu_compositor_frame_sink.cc b/components/display_compositor/gpu_compositor_frame_sink.cc
|
| index 9c1a4df2f8a94af97d71e9e5943ad8dd52f324f5..e5d2781b57bcb6c77bc15ab317b1a4921036a71a 100644
|
| --- a/components/display_compositor/gpu_compositor_frame_sink.cc
|
| +++ b/components/display_compositor/gpu_compositor_frame_sink.cc
|
| @@ -24,6 +24,7 @@
|
| true /* handles_frame_sink_id_invalidation */,
|
| true /* needs_sync_points */),
|
| surface_manager_(surface_manager),
|
| + surface_tracker_(frame_sink_id),
|
| client_(std::move(client)),
|
| compositor_frame_sink_private_binding_(
|
| this,
|
| @@ -33,7 +34,17 @@
|
| base::Unretained(this)));
|
| }
|
|
|
| -GpuCompositorFrameSink::~GpuCompositorFrameSink() {}
|
| +GpuCompositorFrameSink::~GpuCompositorFrameSink() {
|
| + // For display root surfaces, remove the reference from top level root to
|
| + // 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 =
|
| + surface_manager_->GetRootSurfaceId();
|
| + std::vector<cc::SurfaceReference> references_to_remove{cc::SurfaceReference(
|
| + top_level_root_surface_id, surface_tracker_.current_surface_id())};
|
| + surface_manager_->RemoveSurfaceReferences(references_to_remove);
|
| + }
|
| +}
|
|
|
| void GpuCompositorFrameSink::EvictFrame() {
|
| support_.EvictFrame();
|
| @@ -46,7 +57,43 @@
|
| void GpuCompositorFrameSink::SubmitCompositorFrame(
|
| const cc::LocalSurfaceId& local_surface_id,
|
| cc::CompositorFrame frame) {
|
| + cc::SurfaceId start_surface_id = surface_tracker_.current_surface_id();
|
| + surface_tracker_.UpdateReferences(local_surface_id,
|
| + frame.metadata.referenced_surfaces);
|
| + // TODO(kylechar): Move adding top-level root references to
|
| + // GpuDisplayCompositorFrameSink.
|
| +
|
| support_.SubmitCompositorFrame(local_surface_id, std::move(frame));
|
| +
|
| + // Get the list of surfaces to add/remove from |surface_tracker_| so we can
|
| + // append to them before adding/removing.
|
| + std::vector<cc::SurfaceReference>& references_to_add =
|
| + surface_tracker_.references_to_add();
|
| + std::vector<cc::SurfaceReference>& references_to_remove =
|
| + surface_tracker_.references_to_remove();
|
| +
|
| + // Append TLR references for the display root surfaces when display root
|
| + // surface changes.
|
| + if (support_.display() &&
|
| + start_surface_id != surface_tracker_.current_surface_id()) {
|
| + const cc::SurfaceId top_level_root_surface_id =
|
| + surface_manager_->GetRootSurfaceId();
|
| +
|
| + // The first frame will not have a valid |start_surface_id| and there will
|
| + // be no surface to remove.
|
| + if (start_surface_id.local_surface_id().is_valid()) {
|
| + references_to_remove.push_back(
|
| + cc::SurfaceReference(top_level_root_surface_id, start_surface_id));
|
| + }
|
| +
|
| + references_to_add.push_back(cc::SurfaceReference(
|
| + top_level_root_surface_id, surface_tracker_.current_surface_id()));
|
| + }
|
| +
|
| + if (!references_to_add.empty())
|
| + surface_manager_->AddSurfaceReferences(references_to_add);
|
| + if (!references_to_remove.empty())
|
| + surface_manager_->RemoveSurfaceReferences(references_to_remove);
|
| }
|
|
|
| void GpuCompositorFrameSink::Require(const cc::LocalSurfaceId& local_surface_id,
|
|
|