| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 void RemoveSurfaceReference(const SurfaceId& parent_id, | 119 void RemoveSurfaceReference(const SurfaceId& parent_id, |
| 120 const SurfaceId& child_id) override; | 120 const SurfaceId& child_id) override; |
| 121 size_t GetSurfaceReferenceCount(const SurfaceId& surface_id) const override; | 121 size_t GetSurfaceReferenceCount(const SurfaceId& surface_id) const override; |
| 122 size_t GetReferencedSurfaceCount(const SurfaceId& surface_id) const override; | 122 size_t GetReferencedSurfaceCount(const SurfaceId& surface_id) const override; |
| 123 | 123 |
| 124 scoped_refptr<SurfaceReferenceFactory> reference_factory() { | 124 scoped_refptr<SurfaceReferenceFactory> reference_factory() { |
| 125 return reference_factory_; | 125 return reference_factory_; |
| 126 } | 126 } |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 friend class SurfaceManagerRefTest; |
| 130 |
| 129 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, | 131 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, |
| 130 BeginFrameSource* source); | 132 BeginFrameSource* source); |
| 131 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, | 133 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, |
| 132 BeginFrameSource* source); | 134 BeginFrameSource* source); |
| 133 // Returns true if |child namespace| is or has |search_frame_sink_id| as a | 135 // Returns true if |child namespace| is or has |search_frame_sink_id| as a |
| 134 // child. | 136 // child. |
| 135 bool ChildContains(const FrameSinkId& child_frame_sink_id, | 137 bool ChildContains(const FrameSinkId& child_frame_sink_id, |
| 136 const FrameSinkId& search_frame_sink_id) const; | 138 const FrameSinkId& search_frame_sink_id) const; |
| 137 | 139 |
| 138 // Garbage collects all destroyed surfaces not reachable from the root. Used | 140 // Garbage collects all destroyed surfaces not reachable from the root. Used |
| 139 // when |use_references_| is true. | 141 // when |use_references_| is true. |
| 140 void GarbageCollectSurfacesFromRoot(); | 142 void GarbageCollectSurfacesFromRoot(); |
| 141 void GarbageCollectSurfaces(); | 143 void GarbageCollectSurfaces(); |
| 142 | 144 |
| 143 // Removes reference from a parent surface to a child surface. Used to remove | 145 // Removes reference from a parent surface to a child surface. Used to remove |
| 144 // references without triggered GC. | 146 // references without triggered GC. |
| 145 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id, | 147 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id, |
| 146 const SurfaceId& child_id); | 148 const SurfaceId& child_id); |
| 147 | 149 |
| 150 // Adds a reference from parent id to child id without dealing with temporary |
| 151 // references. |
| 152 void AddSurfaceReferenceImpl(const SurfaceId& parent_id, |
| 153 const SurfaceId& child_id); |
| 154 |
| 148 // Use reference or sequence based lifetime management. | 155 // Use reference or sequence based lifetime management. |
| 149 LifetimeType lifetime_type_; | 156 LifetimeType lifetime_type_; |
| 150 | 157 |
| 151 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>; | 158 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>; |
| 152 SurfaceMap surface_map_; | 159 SurfaceMap surface_map_; |
| 153 base::ObserverList<SurfaceObserver> observer_list_; | 160 base::ObserverList<SurfaceObserver> observer_list_; |
| 154 base::ThreadChecker thread_checker_; | 161 base::ThreadChecker thread_checker_; |
| 155 | 162 |
| 156 // List of surfaces to be destroyed, along with what sequences they're still | 163 // List of surfaces to be destroyed, along with what sequences they're still |
| 157 // waiting on. | 164 // waiting on. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; | 208 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; |
| 202 | 209 |
| 203 // Root SurfaceId that references display root surfaces. There is no Surface | 210 // Root SurfaceId that references display root surfaces. There is no Surface |
| 204 // with this id, it's for bookkeeping purposes only. | 211 // with this id, it's for bookkeeping purposes only. |
| 205 const SurfaceId root_surface_id_; | 212 const SurfaceId root_surface_id_; |
| 206 | 213 |
| 207 // The DirectSurfaceReferenceFactory that uses this manager to create surface | 214 // The DirectSurfaceReferenceFactory that uses this manager to create surface |
| 208 // references. | 215 // references. |
| 209 scoped_refptr<SurfaceReferenceFactory> reference_factory_; | 216 scoped_refptr<SurfaceReferenceFactory> reference_factory_; |
| 210 | 217 |
| 218 // SurfaceIds that have temporary references from top level root so they |
| 219 // aren't GC'd before a real reference is added. This is basically a |
| 220 // collection of surface ids, for example: |
| 221 // SurfaceId surface_id(key, value[index]); |
| 222 // The LocalFrameIds are stored in the order the surfaces are created in. |
| 223 std::unordered_map<FrameSinkId, std::vector<LocalFrameId>, FrameSinkIdHash> |
| 224 temp_references_; |
| 225 |
| 211 base::WeakPtrFactory<SurfaceManager> weak_factory_; | 226 base::WeakPtrFactory<SurfaceManager> weak_factory_; |
| 212 | 227 |
| 213 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); | 228 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); |
| 214 }; | 229 }; |
| 215 | 230 |
| 216 } // namespace cc | 231 } // namespace cc |
| 217 | 232 |
| 218 #endif // CC_SURFACES_SURFACE_MANAGER_H_ | 233 #endif // CC_SURFACES_SURFACE_MANAGER_H_ |
| OLD | NEW |