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

Unified Diff: cc/surfaces/surface_manager.h

Issue 2540783004: Add SurfaceManager option to use references exclusively. (Closed)
Patch Set: Add .push(). Created 4 years 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
« no previous file with comments | « no previous file | cc/surfaces/surface_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/surface_manager.h
diff --git a/cc/surfaces/surface_manager.h b/cc/surfaces/surface_manager.h
index 9e6144bf6879252c5b53fe90f5fdbf4c872a39bc..5dd3bb2bfb162bc1b61589d27319754afcf10b38 100644
--- a/cc/surfaces/surface_manager.h
+++ b/cc/surfaces/surface_manager.h
@@ -33,7 +33,12 @@ class SurfaceFactoryClient;
class CC_SURFACES_EXPORT SurfaceManager
: public NON_EXPORTED_BASE(SurfaceReferenceManager) {
public:
- SurfaceManager();
+ enum class LifetimeType {
+ REFERENCES,
+ SEQUENCES,
+ };
+
+ explicit SurfaceManager(LifetimeType lifetime_type = LifetimeType::SEQUENCES);
~SurfaceManager() override;
void RegisterSurface(Surface* surface);
@@ -122,6 +127,9 @@ class CC_SURFACES_EXPORT SurfaceManager
bool ChildContains(const FrameSinkId& child_frame_sink_id,
const FrameSinkId& search_frame_sink_id) const;
+ // Garbage collects all destroyed surfaces not reachable from the root. Used
+ // when |use_references_| is true.
+ void GarbageCollectSurfacesFromRoot();
void GarbageCollectSurfaces();
// Removes reference from a parent surface to a child surface. Used to remove
@@ -129,6 +137,9 @@ class CC_SURFACES_EXPORT SurfaceManager
void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id,
const SurfaceId& child_id);
+ // Use reference or sequence based lifetime management.
+ LifetimeType lifetime_type_;
+
using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>;
SurfaceMap surface_map_;
base::ObserverList<SurfaceObserver> observer_list_;
@@ -183,7 +194,7 @@ class CC_SURFACES_EXPORT SurfaceManager
// Root SurfaceId that references display root surfaces. There is no Surface
// with this id, it's for bookkeeping purposes only.
- const SurfaceId kRootSurfaceId;
+ const SurfaceId root_surface_id_;
DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
};
« 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