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

Unified Diff: cc/surfaces/surface_manager.h

Issue 2716553004: Add temporary reference ownership to SurfaceManager. (Closed)
Patch Set: Cleanup. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: cc/surfaces/surface_manager.h
diff --git a/cc/surfaces/surface_manager.h b/cc/surfaces/surface_manager.h
index b4785a246836dd4085202d496482e72856590764..569c6e44c0306d3ae694b4adb5a1dd1a918ccd7f 100644
--- a/cc/surfaces/surface_manager.h
+++ b/cc/surfaces/surface_manager.h
@@ -139,15 +139,6 @@ class CC_SURFACES_EXPORT SurfaceManager {
// SurfaceId and will never correspond to a surface.
const SurfaceId& GetRootSurfaceId() const;
- // Adds a reference from |parent_id| to |child_id|. If there is a temporary
- // references for |child_id| then it will be removed.
- void AddSurfaceReference(const SurfaceId& parent_id,
- const SurfaceId& child_id);
-
- // Removes a reference from |parent_id| to |child_id|.
- void RemoveSurfaceReference(const SurfaceId& parent_id,
- const SurfaceId& child_id);
-
// Adds all surface references in |references|. This will remove any temporary
// references for child surface in a surface reference.
void AddSurfaceReferences(const std::vector<SurfaceReference>& references);
@@ -156,6 +147,18 @@ class CC_SURFACES_EXPORT SurfaceManager {
// collection to delete unreachable surfaces.
void RemoveSurfaceReferences(const std::vector<SurfaceReference>& references);
+ // Assigns |frame_sink_id| as the owner of the temporary reference to
+ // |surface_id|. If |frame_sink_id| is invalidated the temporary reference
+ // will be removed. If a surface reference has already been added from the
+ // parent to |surface_id| then this will do nothing.
+ void AssignTemporaryReference(const SurfaceId& surface_id,
+ const FrameSinkId& owner);
+
+ // Drops the temporary reference for |surface_id|. If a surface reference has
+ // already been added from the parent to |surface_id| then this will do
+ // nothing.
+ void DropTemporaryReference(const SurfaceId& surface_id);
+
scoped_refptr<SurfaceReferenceFactory> reference_factory() {
return reference_factory_;
}
@@ -202,6 +205,17 @@ class CC_SURFACES_EXPORT SurfaceManager {
// surface is about to be deleted.
void RemoveAllSurfaceReferences(const SurfaceId& surface_id);
+ bool HasTemporaryReference(const SurfaceId& surface_id) const;
+
+ // Adds a temporary reference to |surface_id|. The reference will not have an
+ // owner initially.
+ void AddTemporaryReference(const SurfaceId& surface_id);
+
+ // Removes temporary reference to |surface_id|. If |remove_range| is true then
+ // all temporary references to surfaces with the same FrameSinkId as
+ // |surface_id| that were added before |surface_id| will also be removed.
+ void RemoveTemporaryReference(const SurfaceId& surface_id, bool remove_range);
+
#if DCHECK_IS_ON()
// Recursively prints surface references starting at |surface_id| to |str|.
void SurfaceReferencesToStringImpl(const SurfaceId& surface_id,
@@ -271,13 +285,23 @@ class CC_SURFACES_EXPORT SurfaceManager {
// references.
scoped_refptr<SurfaceReferenceFactory> reference_factory_;
- // SurfaceIds that have temporary references from top level root so they
- // aren't GC'd before a real reference is added. This is basically a
- // collection of surface ids, for example:
+ // A map of surfaces that have temporary references to them. The key is the
+ // SurfaceId and the value is the owner. The owner will initially be empty and
+ // set later by AssignTemporaryReference().
+ std::unordered_map<SurfaceId, base::Optional<FrameSinkId>, SurfaceIdHash>
+ temporary_references_;
+
+ // Range tracking information for temporary references. Each map entry is an
+ // is an ordered list of SurfaceIds that have temporary references with the
+ // same FrameSinkId. A SurfaceId can be reconstructed with:
// SurfaceId surface_id(key, value[index]);
- // The LocalSurfaceIds are stored in the order the surfaces are created in.
+ // The LocalSurfaceIds are stored in the order the surfaces are created in. If
+ // a reference is added to a later SurfaceId then all temporary references up
+ // to that point will be removed. This is to handle clients getting out of
+ // sync, for example the embedded client producing new SurfaceIds faster than
+ // the embedding client can use them.
std::unordered_map<FrameSinkId, std::vector<LocalSurfaceId>, FrameSinkIdHash>
- temp_references_;
+ temporary_reference_ranges_;
std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_;

Powered by Google App Engine
This is Rietveld 408576698