| Index: cc/surfaces/surface_manager.h
|
| diff --git a/cc/surfaces/surface_manager.h b/cc/surfaces/surface_manager.h
|
| index 9ba2eea2543043d8f7d06e6a5c9738185924b25d..5db5f15cd0504b0dccdc17637db1c1ec8f500163 100644
|
| --- a/cc/surfaces/surface_manager.h
|
| +++ b/cc/surfaces/surface_manager.h
|
| @@ -30,6 +30,8 @@ class SurfaceFactoryClient;
|
|
|
| class CC_SURFACES_EXPORT SurfaceManager {
|
| public:
|
| + using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>;
|
| +
|
| SurfaceManager();
|
| ~SurfaceManager();
|
|
|
| @@ -66,6 +68,32 @@ class CC_SURFACES_EXPORT SurfaceManager {
|
| // possibly because a renderer process has crashed.
|
| void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id);
|
|
|
| + // Adds a reference from a parent surface to a child surface. This signifies
|
| + // the parent surface is embedding the child surface and the child surface
|
| + // is needed until the reference is removed.
|
| + void AddSurfaceIdReference(const SurfaceId& parent_id,
|
| + const SurfaceId& child_id);
|
| +
|
| + // Removes a reference from a parent surface to a child surface. This signals
|
| + // the parent surface no longer needs the child surface. Will run GC if
|
| + // |should_run_gc| is true and child surface drops to zero references.
|
| + void RemoveSurfaceIdReference(const SurfaceId& parent_id,
|
| + const SurfaceId& child_id,
|
| + bool should_run_gc = true);
|
| +
|
| + // Removes all references to and from surfaces that were created for
|
| + // |frame_sink_id|.
|
| + void RemoveAllReferencesForFrameSink(const FrameSinkId& frame_sink_id);
|
| + void RemoveAllReferencesForSurfaceId(const SurfaceId& surface_id);
|
| +
|
| + // Returns the number of surfaces that have references to |surface_id|. When
|
| + // the count is zero nothing is referencing the surface and it may be garbage
|
| + // collected.
|
| + size_t GetSurfaceReferenceCount(const SurfaceId& surface_id) const;
|
| +
|
| + // Returns the number of surfaces that |surface_id| refers to.
|
| + size_t GetSurfaceRefereeCount(const SurfaceId& surface_id) const;
|
| +
|
| // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered
|
| // and unregistered in any order with respect to each other.
|
| //
|
| @@ -147,6 +175,16 @@ class CC_SURFACES_EXPORT SurfaceManager {
|
| };
|
| std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash>
|
| frame_sink_source_map_;
|
| +
|
| + // References from the child surface to parent surface. If there are zero
|
| + // entries in the set for a SurfaceId then nothing is referencing the surface
|
| + // and it can be garbage collected.
|
| + std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash>
|
| + child_to_parent_refs_;
|
| + // References from the parent surface to child surface.
|
| + std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash>
|
| + parent_to_child_refs_;
|
| +
|
| // Set of which sources are registered to which namespace. Any child
|
| // that is implicitly using this namespace must be reachable by the
|
| // parent in the dag.
|
|
|