| Index: services/ui/surfaces/display_compositor.cc
|
| diff --git a/services/ui/surfaces/display_compositor.cc b/services/ui/surfaces/display_compositor.cc
|
| index bb27998d8480fddfd95da63a6e6b760b70f2a2ca..cfe1e5157663b14c2e8896813683f9e4d515f1c4 100644
|
| --- a/services/ui/surfaces/display_compositor.cc
|
| +++ b/services/ui/surfaces/display_compositor.cc
|
| @@ -10,7 +10,9 @@ namespace ui {
|
|
|
| DisplayCompositor::DisplayCompositor(
|
| cc::mojom::DisplayCompositorClientPtr client)
|
| - : client_(std::move(client)) {
|
| + : client_(std::move(client)),
|
| + reference_manager_(&manager_),
|
| + root_surface_id_(reference_manager_->GetRootSurfaceId()) {
|
| manager_.AddObserver(this);
|
| }
|
|
|
| @@ -25,7 +27,7 @@ void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
|
| // If there are no temporary references for the FrameSinkId then we can just
|
| // add reference and return.
|
| if (vector_iter == temp_references_.end()) {
|
| - manager_.AddSurfaceReference(parent_id, child_id);
|
| + reference_manager_->AddSurfaceReference(parent_id, child_id);
|
| return;
|
| }
|
|
|
| @@ -37,16 +39,16 @@ void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
|
| std::find(refs.begin(), refs.end(), child_id.local_frame_id());
|
|
|
| if (temp_ref_iter == refs.end()) {
|
| - manager_.AddSurfaceReference(parent_id, child_id);
|
| + reference_manager_->AddSurfaceReference(parent_id, child_id);
|
| return;
|
| }
|
|
|
| // All surfaces get a temporary reference to the top level root. If we want to
|
| // add a real reference to the top level root then we do nothing. Otherwise
|
| // remove the temporary reference and add the real reference.
|
| - if (parent_id != manager_.GetRootSurfaceId()) {
|
| - manager_.AddSurfaceReference(parent_id, child_id);
|
| - manager_.RemoveSurfaceReference(manager_.GetRootSurfaceId(), child_id);
|
| + if (parent_id != root_surface_id_) {
|
| + reference_manager_->AddSurfaceReference(parent_id, child_id);
|
| + reference_manager_->RemoveSurfaceReference(root_surface_id_, child_id);
|
| }
|
|
|
| // Remove temporary references for surfaces with the same FrameSinkId that
|
| @@ -55,7 +57,7 @@ void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
|
| // parent doesn't need them anymore.
|
| for (auto iter = refs.begin(); iter != temp_ref_iter; ++iter) {
|
| cc::SurfaceId id = cc::SurfaceId(child_id.frame_sink_id(), *iter);
|
| - manager_.RemoveSurfaceReference(manager_.GetRootSurfaceId(), id);
|
| + reference_manager_->RemoveSurfaceReference(root_surface_id_, id);
|
| }
|
|
|
| // Remove markers for temporary references up to |child_id|, as the temporary
|
| @@ -70,14 +72,14 @@ void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
|
|
|
| void DisplayCompositor::RemoveRootSurfaceReference(
|
| const cc::SurfaceId& child_id) {
|
| - RemoveSurfaceReference(manager_.GetRootSurfaceId(), child_id);
|
| + RemoveSurfaceReference(root_surface_id_, child_id);
|
| }
|
|
|
| void DisplayCompositor::RemoveSurfaceReference(const cc::SurfaceId& parent_id,
|
| const cc::SurfaceId& child_id) {
|
| // TODO(kylechar): Each remove reference can trigger GC, it would be better if
|
| // we GC only once if removing multiple references.
|
| - manager_.RemoveSurfaceReference(parent_id, child_id);
|
| + reference_manager_->RemoveSurfaceReference(parent_id, child_id);
|
| }
|
|
|
| DisplayCompositor::~DisplayCompositor() {
|
| @@ -85,9 +87,8 @@ DisplayCompositor::~DisplayCompositor() {
|
| for (auto& map_entry : temp_references_) {
|
| const cc::FrameSinkId& frame_sink_id = map_entry.first;
|
| for (auto& local_frame_id : map_entry.second) {
|
| - manager_.RemoveSurfaceReference(
|
| - manager_.GetRootSurfaceId(),
|
| - cc::SurfaceId(frame_sink_id, local_frame_id));
|
| + reference_manager_->RemoveSurfaceReference(
|
| + root_surface_id_, cc::SurfaceId(frame_sink_id, local_frame_id));
|
| }
|
| }
|
| manager_.RemoveObserver(this);
|
| @@ -102,7 +103,7 @@ void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceId& surface_id,
|
| // the first will be destroyed and then if there are no references it will be
|
| // deleted during surface GC. A temporary reference, removed when a real
|
| // reference is received, is added to prevent this from happening.
|
| - manager_.AddSurfaceReference(manager_.GetRootSurfaceId(), surface_id);
|
| + reference_manager_->AddSurfaceReference(root_surface_id_, surface_id);
|
| temp_references_[surface_id.frame_sink_id()].push_back(
|
| surface_id.local_frame_id());
|
|
|
|
|