Chromium Code Reviews| Index: cc/surfaces/surface_manager.h |
| diff --git a/cc/surfaces/surface_manager.h b/cc/surfaces/surface_manager.h |
| index 01d18b2dc1986ca3c0f22aad6105610916b313a5..fa9232775fdeb378dbd3a2c407c8523f57413c56 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,12 @@ class CC_SURFACES_EXPORT SurfaceManager { |
| void RequestSurfaceResolution(Surface* pending_surface); |
| - std::unique_ptr<Surface> CreateSurface( |
| + Surface* CreateSurface( |
|
Fady Samuel
2017/06/20 17:29:07
nit: Comment explaining ownership of Surface.
Saman Sami
2017/06/20 22:47:10
Done.
|
| 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); |
| Surface* GetSurfaceForId(const SurfaceId& surface_id); |
| @@ -207,6 +207,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); |
| + |
| private: |
| friend class test::SurfaceSynchronizationTest; |
| friend class SurfaceManagerRefTest; |
| @@ -257,9 +260,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|. |
| @@ -273,15 +275,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. |