OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/surfaces/compositor_frame_sink_support.h" | 5 #include "cc/surfaces/compositor_frame_sink_support.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Unregister |this| as a BeginFrameObserver so that the BeginFrameSource does | 43 // Unregister |this| as a BeginFrameObserver so that the BeginFrameSource does |
44 // not call into |this| after it's deleted. | 44 // not call into |this| after it's deleted. |
45 SetNeedsBeginFrame(false); | 45 SetNeedsBeginFrame(false); |
46 | 46 |
47 // For display root surfaces, the surface is no longer going to be visible | 47 // For display root surfaces, the surface is no longer going to be visible |
48 // so make it unreachable from the top-level root. | 48 // so make it unreachable from the top-level root. |
49 if (surface_manager_->using_surface_references() && is_root_ && | 49 if (surface_manager_->using_surface_references() && is_root_ && |
50 reference_tracker_.current_surface_id().is_valid()) | 50 reference_tracker_.current_surface_id().is_valid()) |
51 RemoveTopLevelRootReference(reference_tracker_.current_surface_id()); | 51 RemoveTopLevelRootReference(reference_tracker_.current_surface_id()); |
52 | 52 |
53 for (auto& child_frame_sink_id : child_frame_sinks_) { | |
54 DCHECK(child_frame_sink_id.is_valid()); | |
55 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, | |
56 child_frame_sink_id); | |
57 } | |
58 // SurfaceFactory's destructor will attempt to return resources which will | 53 // SurfaceFactory's destructor will attempt to return resources which will |
59 // call back into here and access |client_| so we should destroy | 54 // call back into here and access |client_| so we should destroy |
60 // |surface_factory_|'s resources early on. | 55 // |surface_factory_|'s resources early on. |
61 surface_factory_.EvictSurface(); | 56 surface_factory_.EvictSurface(); |
62 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); | 57 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); |
63 if (handles_frame_sink_id_invalidation_) | 58 if (handles_frame_sink_id_invalidation_) |
64 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | 59 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); |
65 } | 60 } |
66 | 61 |
67 void CompositorFrameSinkSupport::EvictFrame() { | 62 void CompositorFrameSinkSupport::EvictFrame() { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 140 |
146 if (!client_) | 141 if (!client_) |
147 return; | 142 return; |
148 client_->DidReceiveCompositorFrameAck(); | 143 client_->DidReceiveCompositorFrameAck(); |
149 if (!surface_returned_resources_.empty()) { | 144 if (!surface_returned_resources_.empty()) { |
150 client_->ReclaimResources(surface_returned_resources_); | 145 client_->ReclaimResources(surface_returned_resources_); |
151 surface_returned_resources_.clear(); | 146 surface_returned_resources_.clear(); |
152 } | 147 } |
153 } | 148 } |
154 | 149 |
155 void CompositorFrameSinkSupport::AddChildFrameSink( | |
156 const FrameSinkId& child_frame_sink_id) { | |
157 child_frame_sinks_.insert(child_frame_sink_id); | |
158 surface_manager_->RegisterFrameSinkHierarchy(frame_sink_id_, | |
159 child_frame_sink_id); | |
160 } | |
161 | |
162 void CompositorFrameSinkSupport::RemoveChildFrameSink( | |
163 const FrameSinkId& child_frame_sink_id) { | |
164 auto it = child_frame_sinks_.find(child_frame_sink_id); | |
165 DCHECK(it != child_frame_sinks_.end()); | |
166 DCHECK(it->is_valid()); | |
167 surface_manager_->UnregisterFrameSinkHierarchy(frame_sink_id_, | |
168 child_frame_sink_id); | |
169 child_frame_sinks_.erase(it); | |
170 } | |
171 | |
172 void CompositorFrameSinkSupport::ForceReclaimResources() { | 150 void CompositorFrameSinkSupport::ForceReclaimResources() { |
173 surface_factory_.ClearSurface(); | 151 surface_factory_.ClearSurface(); |
174 } | 152 } |
175 | 153 |
176 void CompositorFrameSinkSupport::ReferencedSurfacesChanged( | 154 void CompositorFrameSinkSupport::ReferencedSurfacesChanged( |
177 const LocalSurfaceId& local_surface_id, | 155 const LocalSurfaceId& local_surface_id, |
178 const std::vector<SurfaceId>* active_referenced_surfaces, | 156 const std::vector<SurfaceId>* active_referenced_surfaces, |
179 const std::vector<SurfaceId>* pending_referenced_surfaces) { | 157 const std::vector<SurfaceId>* pending_referenced_surfaces) { |
180 if (!surface_manager_->using_surface_references()) | 158 if (!surface_manager_->using_surface_references()) |
181 return; | 159 return; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 else | 228 else |
251 begin_frame_source_->RemoveObserver(this); | 229 begin_frame_source_->RemoveObserver(this); |
252 } | 230 } |
253 | 231 |
254 void CompositorFrameSinkSupport::RequestCopyOfSurface( | 232 void CompositorFrameSinkSupport::RequestCopyOfSurface( |
255 std::unique_ptr<CopyOutputRequest> request) { | 233 std::unique_ptr<CopyOutputRequest> request) { |
256 surface_factory_.RequestCopyOfSurface(std::move(request)); | 234 surface_factory_.RequestCopyOfSurface(std::move(request)); |
257 } | 235 } |
258 | 236 |
259 } // namespace cc | 237 } // namespace cc |
OLD | NEW |