| Index: services/ui/surfaces/display_compositor.cc
|
| diff --git a/services/ui/surfaces/display_compositor.cc b/services/ui/surfaces/display_compositor.cc
|
| index 51ce69ef70fd532c6d8c374afea0663f3ac74bf7..9a53712cd6ab385293e2c9645bff488e1e0b4e8f 100644
|
| --- a/services/ui/surfaces/display_compositor.cc
|
| +++ b/services/ui/surfaces/display_compositor.cc
|
| @@ -29,6 +29,8 @@ DisplayCompositor::DisplayCompositor(
|
| reference_manager_(&manager_),
|
| binding_(this, std::move(request)) {
|
| manager_.AddObserver(this);
|
| + if (client_)
|
| + client_->OnRootSurfaceId(GetRootSurfaceId());
|
| }
|
|
|
| void DisplayCompositor::CreateCompositorFrameSink(
|
| @@ -54,18 +56,16 @@ void DisplayCompositor::CreateCompositorFrameSink(
|
| std::move(private_request), std::move(client));
|
| }
|
|
|
| -void DisplayCompositor::AddRootSurfaceReference(const cc::SurfaceId& child_id) {
|
| - AddSurfaceReference(GetRootSurfaceId(), child_id);
|
| -}
|
| +void DisplayCompositor::AddSurfaceReference(const cc::SurfaceReference& ref) {
|
| + const cc::SurfaceId& parent_id = ref.parent_id();
|
| + const cc::SurfaceId& child_id = ref.child_id();
|
|
|
| -void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
|
| - const cc::SurfaceId& child_id) {
|
| auto vector_iter = temp_references_.find(child_id.frame_sink_id());
|
|
|
| // If there are no temporary references for the FrameSinkId then we can just
|
| // add reference and return.
|
| if (vector_iter == temp_references_.end()) {
|
| - reference_manager_->AddSurfaceReference(parent_id, child_id);
|
| + CHECK(reference_manager_->AddSurfaceReference(parent_id, child_id));
|
| return;
|
| }
|
|
|
| @@ -77,7 +77,7 @@ 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()) {
|
| - reference_manager_->AddSurfaceReference(parent_id, child_id);
|
| + CHECK(reference_manager_->AddSurfaceReference(parent_id, child_id));
|
| return;
|
| }
|
|
|
| @@ -85,8 +85,9 @@ void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
|
| // wants to add a reference to the top level root then we do nothing.
|
| // Otherwise remove the temporary reference and add the reference.
|
| if (parent_id != GetRootSurfaceId()) {
|
| - reference_manager_->AddSurfaceReference(parent_id, child_id);
|
| - reference_manager_->RemoveSurfaceReference(GetRootSurfaceId(), child_id);
|
| + CHECK(reference_manager_->AddSurfaceReference(parent_id, child_id));
|
| + CHECK(reference_manager_->RemoveSurfaceReference(GetRootSurfaceId(),
|
| + child_id));
|
| }
|
|
|
| // Remove temporary references for surfaces with the same FrameSinkId that
|
| @@ -95,7 +96,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);
|
| - reference_manager_->RemoveSurfaceReference(GetRootSurfaceId(), id);
|
| + CHECK(reference_manager_->RemoveSurfaceReference(GetRootSurfaceId(), id));
|
| }
|
|
|
| // Remove markers for temporary references up to |child_id|, as the temporary
|
| @@ -108,16 +109,12 @@ void DisplayCompositor::AddSurfaceReference(const cc::SurfaceId& parent_id,
|
| refs.erase(refs.begin(), ++temp_ref_iter);
|
| }
|
|
|
| -void DisplayCompositor::RemoveRootSurfaceReference(
|
| - const cc::SurfaceId& child_id) {
|
| - RemoveSurfaceReference(GetRootSurfaceId(), child_id);
|
| -}
|
| -
|
| -void DisplayCompositor::RemoveSurfaceReference(const cc::SurfaceId& parent_id,
|
| - const cc::SurfaceId& child_id) {
|
| +void DisplayCompositor::RemoveSurfaceReference(
|
| + const cc::SurfaceReference& ref) {
|
| // TODO(kylechar): Each remove reference can trigger GC, it would be better if
|
| // we GC only once if removing multiple references.
|
| - reference_manager_->RemoveSurfaceReference(parent_id, child_id);
|
| + CHECK(reference_manager_->RemoveSurfaceReference(ref.parent_id(),
|
| + ref.child_id()));
|
| }
|
|
|
| DisplayCompositor::~DisplayCompositor() {
|
|
|