Chromium Code Reviews| Index: services/ui/surfaces/display_compositor.cc |
| diff --git a/services/ui/surfaces/display_compositor.cc b/services/ui/surfaces/display_compositor.cc |
| index 35c92cd31db5df72c58eea5c23a44c971aeff84a..b3263b1087a828ef43a092109704d3126547df1a 100644 |
| --- a/services/ui/surfaces/display_compositor.cc |
| +++ b/services/ui/surfaces/display_compositor.cc |
| @@ -49,7 +49,8 @@ void DisplayCompositor::AddSurfaceReferences( |
| const std::vector<cc::SurfaceReference>& references) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| for (auto& reference : references) |
|
danakj
2017/01/17 21:56:42
{}
Saman Sami
2017/01/18 18:03:36
Done.
|
| - AddSurfaceReference(reference); |
| + reference_manager_->AddSurfaceReference(reference.parent_id(), |
| + reference.child_id()); |
| } |
| void DisplayCompositor::RemoveSurfaceReferences( |
| @@ -59,19 +60,12 @@ void DisplayCompositor::RemoveSurfaceReferences( |
| // TODO(kylechar): Each remove reference can trigger GC, it would be better if |
| // we GC only once if removing multiple references. |
| for (auto& reference : references) |
|
danakj
2017/01/17 21:56:42
{}
Saman Sami
2017/01/18 18:03:36
Done.
|
| - RemoveSurfaceReference(reference); |
| + reference_manager_->RemoveSurfaceReference(reference.parent_id(), |
| + reference.child_id()); |
| } |
| DisplayCompositor::~DisplayCompositor() { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| - // Remove all temporary references on shutdown. |
| - for (auto& map_entry : temp_references_) { |
| - const cc::FrameSinkId& frame_sink_id = map_entry.first; |
| - for (auto& local_frame_id : map_entry.second) { |
| - reference_manager_->RemoveSurfaceReference( |
| - GetRootSurfaceId(), cc::SurfaceId(frame_sink_id, local_frame_id)); |
| - } |
| - } |
| manager_.RemoveObserver(this); |
| } |
| @@ -126,63 +120,6 @@ void DisplayCompositor::CreateOffscreenCompositorFrameSink( |
| std::move(client), nullptr); |
| } |
| -void DisplayCompositor::AddSurfaceReference(const cc::SurfaceReference& ref) { |
| - const cc::SurfaceId& parent_id = ref.parent_id(); |
| - const cc::SurfaceId& child_id = ref.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); |
| - return; |
| - } |
| - |
| - // Get the vector<LocalFrameId> for the appropriate FrameSinkId and look for |
| - // |child_id.local_frame_id| in that vector. If found, there is a temporary |
| - // reference to |child_id|. |
| - std::vector<cc::LocalFrameId>& refs = vector_iter->second; |
| - auto temp_ref_iter = |
| - std::find(refs.begin(), refs.end(), child_id.local_frame_id()); |
| - |
| - if (temp_ref_iter == refs.end()) { |
| - reference_manager_->AddSurfaceReference(parent_id, child_id); |
| - return; |
| - } |
| - |
| - // All surfaces get a temporary reference to the top level root. If the parent |
| - // 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); |
| - } |
| - |
| - // Remove temporary references for surfaces with the same FrameSinkId that |
| - // were created before |child_id|. The earlier surfaces were never embedded in |
| - // the parent and the parent is embedding a later surface, so we know the |
| - // 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); |
| - } |
| - |
| - // Remove markers for temporary references up to |child_id|, as the temporary |
| - // references they correspond to were removed above. If |temp_ref_iter| points |
| - // at the last element in |refs| then we are removing all temporary references |
| - // for the FrameSinkId and can remove the map entry entirely. |
| - if (++temp_ref_iter == refs.end()) |
| - temp_references_.erase(child_id.frame_sink_id()); |
| - else |
| - refs.erase(refs.begin(), temp_ref_iter); |
| -} |
| - |
| -void DisplayCompositor::RemoveSurfaceReference( |
| - const cc::SurfaceReference& ref) { |
| - reference_manager_->RemoveSurfaceReference(ref.parent_id(), ref.child_id()); |
| -} |
| - |
| std::unique_ptr<cc::Display> DisplayCompositor::CreateDisplay( |
| const cc::FrameSinkId& frame_sink_id, |
| gpu::SurfaceHandle surface_handle, |
| @@ -254,16 +191,6 @@ const cc::SurfaceId& DisplayCompositor::GetRootSurfaceId() const { |
| void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| DCHECK_GT(surface_info.device_scale_factor(), 0.0f); |
| - // We can get into a situation where multiple CompositorFrames arrive for a |
| - // CompositorFrameSink before the DisplayCompositorClient can add any |
| - // references for the frame. When the second frame with a new size arrives, |
| - // 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. |
| - reference_manager_->AddSurfaceReference(GetRootSurfaceId(), |
| - surface_info.id()); |
| - temp_references_[surface_info.id().frame_sink_id()].push_back( |
| - surface_info.id().local_frame_id()); |
| if (client_) |
| client_->OnSurfaceCreated(surface_info); |