| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_SURFACES_SURFACE_MANAGER_H_ | 5 #ifndef CC_SURFACES_SURFACE_MANAGER_H_ |
| 6 #define CC_SURFACES_SURFACE_MANAGER_H_ | 6 #define CC_SURFACES_SURFACE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "cc/surfaces/surfaces_export.h" | 24 #include "cc/surfaces/surfaces_export.h" |
| 25 | 25 |
| 26 namespace cc { | 26 namespace cc { |
| 27 class BeginFrameSource; | 27 class BeginFrameSource; |
| 28 class CompositorFrame; | 28 class CompositorFrame; |
| 29 class Surface; | 29 class Surface; |
| 30 class SurfaceFactoryClient; | 30 class SurfaceFactoryClient; |
| 31 | 31 |
| 32 class CC_SURFACES_EXPORT SurfaceManager : public SurfaceReferenceManager { | 32 class CC_SURFACES_EXPORT SurfaceManager : public SurfaceReferenceManager { |
| 33 public: | 33 public: |
| 34 SurfaceManager(); | 34 enum class LifetimeType { |
| 35 USE_REFERENCES, |
| 36 USE_SEQUENCES, |
| 37 }; |
| 38 |
| 39 explicit SurfaceManager( |
| 40 LifetimeType lifetime_type = LifetimeType::USE_SEQUENCES); |
| 35 ~SurfaceManager() override; | 41 ~SurfaceManager() override; |
| 36 | 42 |
| 37 void RegisterSurface(Surface* surface); | 43 void RegisterSurface(Surface* surface); |
| 38 void DeregisterSurface(const SurfaceId& surface_id); | 44 void DeregisterSurface(const SurfaceId& surface_id); |
| 39 | 45 |
| 40 // Destroy the Surface once a set of sequence numbers has been satisfied. | 46 // Destroy the Surface once a set of sequence numbers has been satisfied. |
| 41 void Destroy(std::unique_ptr<Surface> surface); | 47 void Destroy(std::unique_ptr<Surface> surface); |
| 42 | 48 |
| 43 Surface* GetSurfaceForId(const SurfaceId& surface_id); | 49 Surface* GetSurfaceForId(const SurfaceId& surface_id); |
| 44 | 50 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 private: | 119 private: |
| 114 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, | 120 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, |
| 115 BeginFrameSource* source); | 121 BeginFrameSource* source); |
| 116 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, | 122 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, |
| 117 BeginFrameSource* source); | 123 BeginFrameSource* source); |
| 118 // Returns true if |child namespace| is or has |search_frame_sink_id| as a | 124 // Returns true if |child namespace| is or has |search_frame_sink_id| as a |
| 119 // child. | 125 // child. |
| 120 bool ChildContains(const FrameSinkId& child_frame_sink_id, | 126 bool ChildContains(const FrameSinkId& child_frame_sink_id, |
| 121 const FrameSinkId& search_frame_sink_id) const; | 127 const FrameSinkId& search_frame_sink_id) const; |
| 122 | 128 |
| 129 // Garbage collects all destroyed surfaces not reachable from the root. Used |
| 130 // when |use_references_| is true. |
| 131 void GarbageCollectSurfacesFromRoot(); |
| 123 void GarbageCollectSurfaces(); | 132 void GarbageCollectSurfaces(); |
| 124 | 133 |
| 125 // Removes reference from a parent surface to a child surface. Used to remove | 134 // Removes reference from a parent surface to a child surface. Used to remove |
| 126 // references without triggered GC. | 135 // references without triggered GC. |
| 127 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id, | 136 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id, |
| 128 const SurfaceId& child_id); | 137 const SurfaceId& child_id); |
| 129 | 138 |
| 139 // Use reference or sequence based lifetime management. |
| 140 LifetimeType lifetime_type_; |
| 141 |
| 130 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>; | 142 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>; |
| 131 SurfaceMap surface_map_; | 143 SurfaceMap surface_map_; |
| 132 base::ObserverList<SurfaceObserver> observer_list_; | 144 base::ObserverList<SurfaceObserver> observer_list_; |
| 133 base::ThreadChecker thread_checker_; | 145 base::ThreadChecker thread_checker_; |
| 134 | 146 |
| 135 // List of surfaces to be destroyed, along with what sequences they're still | 147 // List of surfaces to be destroyed, along with what sequences they're still |
| 136 // waiting on. | 148 // waiting on. |
| 137 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>; | 149 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>; |
| 138 SurfaceDestroyList surfaces_to_destroy_; | 150 SurfaceDestroyList surfaces_to_destroy_; |
| 139 | 151 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash> | 186 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash> |
| 175 parent_to_child_refs_; | 187 parent_to_child_refs_; |
| 176 | 188 |
| 177 // Set of which sources are registered to which namespace. Any child | 189 // Set of which sources are registered to which namespace. Any child |
| 178 // that is implicitly using this namespace must be reachable by the | 190 // that is implicitly using this namespace must be reachable by the |
| 179 // parent in the dag. | 191 // parent in the dag. |
| 180 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; | 192 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; |
| 181 | 193 |
| 182 // Root SurfaceId that references display root surfaces. There is no Surface | 194 // Root SurfaceId that references display root surfaces. There is no Surface |
| 183 // with this id, it's for bookkeeping purposes only. | 195 // with this id, it's for bookkeeping purposes only. |
| 184 const SurfaceId kRootSurfaceId; | 196 const SurfaceId root_surface_id_; |
| 185 | 197 |
| 186 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); | 198 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); |
| 187 }; | 199 }; |
| 188 | 200 |
| 189 } // namespace cc | 201 } // namespace cc |
| 190 | 202 |
| 191 #endif // CC_SURFACES_SURFACE_MANAGER_H_ | 203 #endif // CC_SURFACES_SURFACE_MANAGER_H_ |
| OLD | NEW |