Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: cc/surfaces/surface_manager.h

Issue 2715973003: Refactor how temporary references are stored. (Closed)
Patch Set: Rebase. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support_unittest.cc ('k') | cc/surfaces/surface_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CC_SURFACES_SURFACE_MANAGER_H_ 5 #ifndef CC_SURFACES_SURFACE_MANAGER_H_
6 #define CC_SURFACES_SURFACE_MANAGER_H_ 6 #define CC_SURFACES_SURFACE_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 void RegisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, 132 void RegisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id,
133 const FrameSinkId& child_frame_sink_id); 133 const FrameSinkId& child_frame_sink_id);
134 void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, 134 void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id,
135 const FrameSinkId& child_frame_sink_id); 135 const FrameSinkId& child_frame_sink_id);
136 136
137 // Returns the top level root SurfaceId. Surfaces that are not reachable 137 // Returns the top level root SurfaceId. Surfaces that are not reachable
138 // from the top level root may be garbage collected. It will not be a valid 138 // from the top level root may be garbage collected. It will not be a valid
139 // SurfaceId and will never correspond to a surface. 139 // SurfaceId and will never correspond to a surface.
140 const SurfaceId& GetRootSurfaceId() const; 140 const SurfaceId& GetRootSurfaceId() const;
141 141
142 // Adds a reference from |parent_id| to |child_id|. If there is a temporary
143 // references for |child_id| then it will be removed.
144 void AddSurfaceReference(const SurfaceId& parent_id,
145 const SurfaceId& child_id);
146
147 // Removes a reference from |parent_id| to |child_id|.
148 void RemoveSurfaceReference(const SurfaceId& parent_id,
149 const SurfaceId& child_id);
150
151 // Adds all surface references in |references|. This will remove any temporary 142 // Adds all surface references in |references|. This will remove any temporary
152 // references for child surface in a surface reference. 143 // references for child surface in a surface reference.
153 void AddSurfaceReferences(const std::vector<SurfaceReference>& references); 144 void AddSurfaceReferences(const std::vector<SurfaceReference>& references);
154 145
155 // Removes all surface references in |references| then runs garbage 146 // Removes all surface references in |references| then runs garbage
156 // collection to delete unreachable surfaces. 147 // collection to delete unreachable surfaces.
157 void RemoveSurfaceReferences(const std::vector<SurfaceReference>& references); 148 void RemoveSurfaceReferences(const std::vector<SurfaceReference>& references);
158 149
159 scoped_refptr<SurfaceReferenceFactory> reference_factory() { 150 scoped_refptr<SurfaceReferenceFactory> reference_factory() {
160 return reference_factory_; 151 return reference_factory_;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 const SurfaceId& child_id); 186 const SurfaceId& child_id);
196 187
197 // Removes a reference from a |parent_id| to |child_id|. 188 // Removes a reference from a |parent_id| to |child_id|.
198 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id, 189 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id,
199 const SurfaceId& child_id); 190 const SurfaceId& child_id);
200 191
201 // Removes all surface references to or from |surface_id|. Used when the 192 // Removes all surface references to or from |surface_id|. Used when the
202 // surface is about to be deleted. 193 // surface is about to be deleted.
203 void RemoveAllSurfaceReferences(const SurfaceId& surface_id); 194 void RemoveAllSurfaceReferences(const SurfaceId& surface_id);
204 195
196 bool HasTemporaryReference(const SurfaceId& surface_id) const;
197
198 // Adds a temporary reference to |surface_id|.
199 void AddTemporaryReference(const SurfaceId& surface_id);
200
201 // Removes temporary reference to |surface_id|. If |remove_range| is true then
202 // all temporary references to surfaces with the same FrameSinkId as
203 // |surface_id| that were added before |surface_id| will also be removed.
204 void RemoveTemporaryReference(const SurfaceId& surface_id, bool remove_range);
205
205 #if DCHECK_IS_ON() 206 #if DCHECK_IS_ON()
206 // Recursively prints surface references starting at |surface_id| to |str|. 207 // Recursively prints surface references starting at |surface_id| to |str|.
207 void SurfaceReferencesToStringImpl(const SurfaceId& surface_id, 208 void SurfaceReferencesToStringImpl(const SurfaceId& surface_id,
208 std::string indent, 209 std::string indent,
209 std::stringstream* str); 210 std::stringstream* str);
210 #endif 211 #endif
211 212
212 // Use reference or sequence based lifetime management. 213 // Use reference or sequence based lifetime management.
213 LifetimeType lifetime_type_; 214 LifetimeType lifetime_type_;
214 215
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; 265 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_;
265 266
266 // Root SurfaceId that references display root surfaces. There is no Surface 267 // Root SurfaceId that references display root surfaces. There is no Surface
267 // with this id, it's for bookkeeping purposes only. 268 // with this id, it's for bookkeeping purposes only.
268 const SurfaceId root_surface_id_; 269 const SurfaceId root_surface_id_;
269 270
270 // The DirectSurfaceReferenceFactory that uses this manager to create surface 271 // The DirectSurfaceReferenceFactory that uses this manager to create surface
271 // references. 272 // references.
272 scoped_refptr<SurfaceReferenceFactory> reference_factory_; 273 scoped_refptr<SurfaceReferenceFactory> reference_factory_;
273 274
274 // SurfaceIds that have temporary references from top level root so they 275 // A map of surfaces that have temporary references to them. The key is the
275 // aren't GC'd before a real reference is added. This is basically a 276 // SurfaceId and the value is the owner.
276 // collection of surface ids, for example: 277 // TODO(kylechar): Use owner value.
278 std::unordered_map<SurfaceId, base::Optional<FrameSinkId>, SurfaceIdHash>
279 temporary_references_;
280
281 // Range tracking information for temporary references. Each map entry is an
282 // is an ordered list of SurfaceIds that have temporary references with the
283 // same FrameSinkId. A SurfaceId can be reconstructed with:
277 // SurfaceId surface_id(key, value[index]); 284 // SurfaceId surface_id(key, value[index]);
278 // The LocalSurfaceIds are stored in the order the surfaces are created in. 285 // The LocalSurfaceIds are stored in the order the surfaces are created in. If
286 // a reference is added to a later SurfaceId then all temporary references up
287 // to that point will be removed. This is to handle clients getting out of
288 // sync, for example the embedded client producing new SurfaceIds faster than
289 // the embedding client can use them.
279 std::unordered_map<FrameSinkId, std::vector<LocalSurfaceId>, FrameSinkIdHash> 290 std::unordered_map<FrameSinkId, std::vector<LocalSurfaceId>, FrameSinkIdHash>
280 temp_references_; 291 temporary_reference_ranges_;
281 292
282 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; 293 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_;
283 294
284 base::WeakPtrFactory<SurfaceManager> weak_factory_; 295 base::WeakPtrFactory<SurfaceManager> weak_factory_;
285 296
286 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); 297 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
287 }; 298 };
288 299
289 } // namespace cc 300 } // namespace cc
290 301
291 #endif // CC_SURFACES_SURFACE_MANAGER_H_ 302 #endif // CC_SURFACES_SURFACE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support_unittest.cc ('k') | cc/surfaces/surface_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698