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

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

Issue 2716553004: Add temporary reference ownership to SurfaceManager. (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 | « no previous file | 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 const SurfaceId& GetRootSurfaceId() const; 140 const SurfaceId& GetRootSurfaceId() const;
141 141
142 // Adds all surface references in |references|. This will remove any temporary 142 // Adds all surface references in |references|. This will remove any temporary
143 // references for child surface in a surface reference. 143 // references for child surface in a surface reference.
144 void AddSurfaceReferences(const std::vector<SurfaceReference>& references); 144 void AddSurfaceReferences(const std::vector<SurfaceReference>& references);
145 145
146 // Removes all surface references in |references| then runs garbage 146 // Removes all surface references in |references| then runs garbage
147 // collection to delete unreachable surfaces. 147 // collection to delete unreachable surfaces.
148 void RemoveSurfaceReferences(const std::vector<SurfaceReference>& references); 148 void RemoveSurfaceReferences(const std::vector<SurfaceReference>& references);
149 149
150 // Assigns |frame_sink_id| as the owner of the temporary reference to
151 // |surface_id|. If |frame_sink_id| is invalidated the temporary reference
152 // will be removed. If a surface reference has already been added from the
153 // parent to |surface_id| then this will do nothing.
154 void AssignTemporaryReference(const SurfaceId& surface_id,
155 const FrameSinkId& owner);
156
157 // Drops the temporary reference for |surface_id|. If a surface reference has
158 // already been added from the parent to |surface_id| then this will do
159 // nothing.
160 void DropTemporaryReference(const SurfaceId& surface_id);
161
150 scoped_refptr<SurfaceReferenceFactory> reference_factory() { 162 scoped_refptr<SurfaceReferenceFactory> reference_factory() {
151 return reference_factory_; 163 return reference_factory_;
152 } 164 }
153 165
154 bool using_surface_references() const { 166 bool using_surface_references() const {
155 return lifetime_type_ == LifetimeType::REFERENCES; 167 return lifetime_type_ == LifetimeType::REFERENCES;
156 } 168 }
157 169
158 private: 170 private:
159 friend class test::CompositorFrameSinkSupportTest; 171 friend class test::CompositorFrameSinkSupportTest;
(...skipping 28 matching lines...) Expand all
188 // Removes a reference from a |parent_id| to |child_id|. 200 // Removes a reference from a |parent_id| to |child_id|.
189 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id, 201 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id,
190 const SurfaceId& child_id); 202 const SurfaceId& child_id);
191 203
192 // Removes all surface references to or from |surface_id|. Used when the 204 // Removes all surface references to or from |surface_id|. Used when the
193 // surface is about to be deleted. 205 // surface is about to be deleted.
194 void RemoveAllSurfaceReferences(const SurfaceId& surface_id); 206 void RemoveAllSurfaceReferences(const SurfaceId& surface_id);
195 207
196 bool HasTemporaryReference(const SurfaceId& surface_id) const; 208 bool HasTemporaryReference(const SurfaceId& surface_id) const;
197 209
198 // Adds a temporary reference to |surface_id|. 210 // Adds a temporary reference to |surface_id|. The reference will not have an
211 // owner initially.
199 void AddTemporaryReference(const SurfaceId& surface_id); 212 void AddTemporaryReference(const SurfaceId& surface_id);
200 213
201 // Removes temporary reference to |surface_id|. If |remove_range| is true then 214 // Removes temporary reference to |surface_id|. If |remove_range| is true then
202 // all temporary references to surfaces with the same FrameSinkId as 215 // all temporary references to surfaces with the same FrameSinkId as
203 // |surface_id| that were added before |surface_id| will also be removed. 216 // |surface_id| that were added before |surface_id| will also be removed.
204 void RemoveTemporaryReference(const SurfaceId& surface_id, bool remove_range); 217 void RemoveTemporaryReference(const SurfaceId& surface_id, bool remove_range);
205 218
206 #if DCHECK_IS_ON() 219 #if DCHECK_IS_ON()
207 // Recursively prints surface references starting at |surface_id| to |str|. 220 // Recursively prints surface references starting at |surface_id| to |str|.
208 void SurfaceReferencesToStringImpl(const SurfaceId& surface_id, 221 void SurfaceReferencesToStringImpl(const SurfaceId& surface_id,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 279
267 // Root SurfaceId that references display root surfaces. There is no Surface 280 // Root SurfaceId that references display root surfaces. There is no Surface
268 // with this id, it's for bookkeeping purposes only. 281 // with this id, it's for bookkeeping purposes only.
269 const SurfaceId root_surface_id_; 282 const SurfaceId root_surface_id_;
270 283
271 // The DirectSurfaceReferenceFactory that uses this manager to create surface 284 // The DirectSurfaceReferenceFactory that uses this manager to create surface
272 // references. 285 // references.
273 scoped_refptr<SurfaceReferenceFactory> reference_factory_; 286 scoped_refptr<SurfaceReferenceFactory> reference_factory_;
274 287
275 // A map of surfaces that have temporary references to them. The key is the 288 // A map of surfaces that have temporary references to them. The key is the
276 // SurfaceId and the value is the owner. 289 // SurfaceId and the value is the owner. The owner will initially be empty and
277 // TODO(kylechar): Use owner value. 290 // set later by AssignTemporaryReference().
278 std::unordered_map<SurfaceId, base::Optional<FrameSinkId>, SurfaceIdHash> 291 std::unordered_map<SurfaceId, base::Optional<FrameSinkId>, SurfaceIdHash>
279 temporary_references_; 292 temporary_references_;
280 293
281 // Range tracking information for temporary references. Each map entry is an 294 // Range tracking information for temporary references. Each map entry is an
282 // is an ordered list of SurfaceIds that have temporary references with the 295 // is an ordered list of SurfaceIds that have temporary references with the
283 // same FrameSinkId. A SurfaceId can be reconstructed with: 296 // same FrameSinkId. A SurfaceId can be reconstructed with:
284 // SurfaceId surface_id(key, value[index]); 297 // SurfaceId surface_id(key, value[index]);
285 // The LocalSurfaceIds are stored in the order the surfaces are created in. If 298 // 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 299 // 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 300 // 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 301 // sync, for example the embedded client producing new SurfaceIds faster than
289 // the embedding client can use them. 302 // the embedding client can use them.
290 std::unordered_map<FrameSinkId, std::vector<LocalSurfaceId>, FrameSinkIdHash> 303 std::unordered_map<FrameSinkId, std::vector<LocalSurfaceId>, FrameSinkIdHash>
291 temporary_reference_ranges_; 304 temporary_reference_ranges_;
292 305
293 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; 306 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_;
294 307
295 base::WeakPtrFactory<SurfaceManager> weak_factory_; 308 base::WeakPtrFactory<SurfaceManager> weak_factory_;
296 309
297 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); 310 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
298 }; 311 };
299 312
300 } // namespace cc 313 } // namespace cc
301 314
302 #endif // CC_SURFACES_SURFACE_MANAGER_H_ 315 #endif // CC_SURFACES_SURFACE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/surface_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698