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

Unified Diff: cc/surfaces/surface_manager.h

Issue 2940183002: cc: Move ownership of surfaces to SurfaceManager (Closed)
Patch Set: c Created 3 years, 6 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 6cca04223e82de8af88785e5823fdad5b3afc55f..83c7451906e3049ede8e0a5cf96d2ae540ed795e 100644
--- a/cc/surfaces/surface_manager.h
+++ b/cc/surfaces/surface_manager.h
@@ -7,12 +7,12 @@
#include <stdint.h>
-#include <list>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <vector>
+#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/logging.h"
#include "base/macros.h"
@@ -67,12 +67,15 @@ class CC_SURFACES_EXPORT SurfaceManager {
void RequestSurfaceResolution(Surface* pending_surface);
- std::unique_ptr<Surface> CreateSurface(
+ // Creates a Surface for the given CompositorFrameSinkSupport. The surface
+ // will be destroyed when DestroySurface is called, all of its destruction
+ // dependencies are satisfied, and it is not reachable from the root surface.
+ Surface* CreateSurface(
base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support,
const SurfaceInfo& surface_info);
// Destroy the Surface once a set of sequence numbers has been satisfied.
- void DestroySurface(std::unique_ptr<Surface> surface);
+ void DestroySurface(const SurfaceId& surface_id);
// Called when a surface has been added to the aggregated CompositorFrame
// and will notify observers with SurfaceObserver::OnSurfaceWillDraw.
@@ -211,6 +214,9 @@ class CC_SURFACES_EXPORT SurfaceManager {
return lifetime_type_ == LifetimeType::REFERENCES;
}
+ // Returns true if |surface_id| is in the garbage collector's queue.
+ bool IsMarkedForDestruction(const SurfaceId& surface_id);
danakj 2017/06/21 21:24:09 Do we want this to be part of the public API for p
Saman Sami 2017/06/26 20:44:05 I made it private.
+
private:
friend class test::SurfaceSynchronizationTest;
friend class SurfaceManagerRefTest;
@@ -261,9 +267,8 @@ class CC_SURFACES_EXPORT SurfaceManager {
// |surface_id| that were added before |surface_id| will also be removed.
void RemoveTemporaryReference(const SurfaceId& surface_id, bool remove_range);
- // Called when a surface is destroyed and it needs to be removed from the
- // surface map.
- void UnregisterSurface(const SurfaceId& surface_id);
+ // Removes the surface from the surface map and destroys it.
+ void DestroySurfaceInternal(const SurfaceId& surface_id);
#if DCHECK_IS_ON()
// Recursively prints surface references starting at |surface_id| to |str|.
@@ -277,15 +282,12 @@ class CC_SURFACES_EXPORT SurfaceManager {
FrameSinkManager framesink_manager_;
- using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>;
+ using SurfaceMap = base::flat_map<SurfaceId, std::unique_ptr<Surface>>;
SurfaceMap surface_map_;
base::ObserverList<SurfaceObserver> observer_list_;
base::ThreadChecker thread_checker_;
- // List of surfaces to be destroyed, along with what sequences they're still
- // waiting on.
- using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>;
- SurfaceDestroyList surfaces_to_destroy_;
+ base::flat_set<SurfaceId> surfaces_to_destroy_;
// Set of SurfaceSequences that have been satisfied by a frame but not yet
// waited on.

Powered by Google App Engine
This is Rietveld 408576698