 Chromium Code Reviews
 Chromium Code Reviews Issue 2684933003:
  Move frame_sink_id management to framesink_manager.cc/h from  (Closed)
    
  
    Issue 2684933003:
  Move frame_sink_id management to framesink_manager.cc/h from  (Closed) 
  | 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> | 
| 11 #include <memory> | 11 #include <memory> | 
| 12 #include <unordered_map> | 12 #include <unordered_map> | 
| 13 #include <unordered_set> | 13 #include <unordered_set> | 
| 14 #include <vector> | 14 #include <vector> | 
| 15 | 15 | 
| 16 #include "base/logging.h" | 16 #include "base/logging.h" | 
| 17 #include "base/macros.h" | 17 #include "base/macros.h" | 
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" | 
| 19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" | 
| 20 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" | 
| 21 #include "cc/surfaces/frame_sink_id.h" | 21 #include "cc/surfaces/frame_sink_id.h" | 
| 22 #include "cc/surfaces/framesink_manager.h" | |
| 22 #include "cc/surfaces/surface_dependency_tracker.h" | 23 #include "cc/surfaces/surface_dependency_tracker.h" | 
| 23 #include "cc/surfaces/surface_id.h" | 24 #include "cc/surfaces/surface_id.h" | 
| 24 #include "cc/surfaces/surface_observer.h" | 25 #include "cc/surfaces/surface_observer.h" | 
| 25 #include "cc/surfaces/surface_reference.h" | 26 #include "cc/surfaces/surface_reference.h" | 
| 26 #include "cc/surfaces/surface_reference_factory.h" | 27 #include "cc/surfaces/surface_reference_factory.h" | 
| 27 #include "cc/surfaces/surface_sequence.h" | 28 #include "cc/surfaces/surface_sequence.h" | 
| 28 #include "cc/surfaces/surfaces_export.h" | 29 #include "cc/surfaces/surfaces_export.h" | 
| 29 | 30 | 
| 30 #if DCHECK_IS_ON() | 31 #if DCHECK_IS_ON() | 
| 31 #include <iosfwd> | 32 #include <iosfwd> | 
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 | 168 | 
| 168 bool using_surface_references() const { | 169 bool using_surface_references() const { | 
| 169 return lifetime_type_ == LifetimeType::REFERENCES; | 170 return lifetime_type_ == LifetimeType::REFERENCES; | 
| 170 } | 171 } | 
| 171 | 172 | 
| 172 private: | 173 private: | 
| 173 friend class test::CompositorFrameSinkSupportTest; | 174 friend class test::CompositorFrameSinkSupportTest; | 
| 174 friend class SurfaceManagerRefTest; | 175 friend class SurfaceManagerRefTest; | 
| 175 | 176 | 
| 176 using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>; | 177 using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>; | 
| 178 FrameSinkManager* framesink_manager_; | |
| 
enne (OOO)
2017/03/20 18:28:53
Can this just be a member directly instead of a ra
 
Fady Samuel
2017/03/20 18:36:30
+1
 | |
| 177 | 179 | 
| 178 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, | 180 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, | 
| 179 BeginFrameSource* source); | 181 BeginFrameSource* source); | 
| 180 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, | 182 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, | 
| 181 BeginFrameSource* source); | 183 BeginFrameSource* source); | 
| 182 | 184 | 
| 183 // Returns true if |child namespace| is or has |search_frame_sink_id| as a | 185 // Returns true if |child namespace| is or has |search_frame_sink_id| as a | 
| 184 // child. | 186 // child. | 
| 185 bool ChildContains(const FrameSinkId& child_frame_sink_id, | 187 bool ChildContains(const FrameSinkId& child_frame_sink_id, | 
| 186 const FrameSinkId& search_frame_sink_id) const; | 188 const FrameSinkId& search_frame_sink_id) const; | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 | 241 | 
| 240 // List of surfaces to be destroyed, along with what sequences they're still | 242 // List of surfaces to be destroyed, along with what sequences they're still | 
| 241 // waiting on. | 243 // waiting on. | 
| 242 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>; | 244 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>; | 
| 243 SurfaceDestroyList surfaces_to_destroy_; | 245 SurfaceDestroyList surfaces_to_destroy_; | 
| 244 | 246 | 
| 245 // Set of SurfaceSequences that have been satisfied by a frame but not yet | 247 // Set of SurfaceSequences that have been satisfied by a frame but not yet | 
| 246 // waited on. | 248 // waited on. | 
| 247 std::unordered_set<SurfaceSequence, SurfaceSequenceHash> satisfied_sequences_; | 249 std::unordered_set<SurfaceSequence, SurfaceSequenceHash> satisfied_sequences_; | 
| 248 | 250 | 
| 249 // Set of valid surface ID namespaces. When a namespace is removed from | |
| 250 // this set, any remaining sequences with that namespace are considered | |
| 251 // satisfied. | |
| 252 std::unordered_set<FrameSinkId, FrameSinkIdHash> valid_frame_sink_ids_; | |
| 253 | |
| 254 // Begin frame source routing. Both BeginFrameSource and SurfaceFactoryClient | |
| 255 // pointers guaranteed alive by callers until unregistered. | |
| 256 struct FrameSinkSourceMapping { | |
| 257 FrameSinkSourceMapping(); | |
| 258 FrameSinkSourceMapping(const FrameSinkSourceMapping& other); | |
| 259 ~FrameSinkSourceMapping(); | |
| 260 bool has_children() const { return !children.empty(); } | |
| 261 // The currently assigned begin frame source for this client. | |
| 262 BeginFrameSource* source; | |
| 263 // This represents a dag of parent -> children mapping. | |
| 264 std::vector<FrameSinkId> children; | |
| 265 }; | |
| 266 | |
| 267 std::unordered_map<FrameSinkId, SurfaceFactoryClient*, FrameSinkIdHash> | |
| 268 clients_; | |
| 269 | |
| 270 std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash> | |
| 271 frame_sink_source_map_; | |
| 272 | |
| 273 // Tracks references from the child surface to parent surface. If there are | 251 // Tracks references from the child surface to parent surface. If there are | 
| 274 // zero entries in the set for a SurfaceId then nothing is referencing the | 252 // zero entries in the set for a SurfaceId then nothing is referencing the | 
| 275 // surface and it can be garbage collected. | 253 // surface and it can be garbage collected. | 
| 276 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash> | 254 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash> | 
| 277 child_to_parent_refs_; | 255 child_to_parent_refs_; | 
| 278 // Tracks references from the parent surface to child surface. Is the inverse | 256 // Tracks references from the parent surface to child surface. Is the inverse | 
| 279 // of |child_to_parent_refs_|. | 257 // of |child_to_parent_refs_|. | 
| 280 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash> | 258 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash> | 
| 281 parent_to_child_refs_; | 259 parent_to_child_refs_; | 
| 282 | 260 | 
| 283 // Set of which sources are registered to which namespace. Any child | |
| 284 // that is implicitly using this namespace must be reachable by the | |
| 285 // parent in the dag. | |
| 286 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; | |
| 287 | |
| 288 // Root SurfaceId that references display root surfaces. There is no Surface | 261 // Root SurfaceId that references display root surfaces. There is no Surface | 
| 289 // with this id, it's for bookkeeping purposes only. | 262 // with this id, it's for bookkeeping purposes only. | 
| 290 const SurfaceId root_surface_id_; | 263 const SurfaceId root_surface_id_; | 
| 291 | 264 | 
| 292 // The DirectSurfaceReferenceFactory that uses this manager to create surface | 265 // The DirectSurfaceReferenceFactory that uses this manager to create surface | 
| 293 // references. | 266 // references. | 
| 294 scoped_refptr<SurfaceReferenceFactory> reference_factory_; | 267 scoped_refptr<SurfaceReferenceFactory> reference_factory_; | 
| 295 | 268 | 
| 296 // A map of surfaces that have temporary references to them. The key is the | 269 // A map of surfaces that have temporary references to them. The key is the | 
| 297 // SurfaceId and the value is the owner. The owner will initially be empty and | 270 // SurfaceId and the value is the owner. The owner will initially be empty and | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 314 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; | 287 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; | 
| 315 | 288 | 
| 316 base::WeakPtrFactory<SurfaceManager> weak_factory_; | 289 base::WeakPtrFactory<SurfaceManager> weak_factory_; | 
| 317 | 290 | 
| 318 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); | 291 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); | 
| 319 }; | 292 }; | 
| 320 | 293 | 
| 321 } // namespace cc | 294 } // namespace cc | 
| 322 | 295 | 
| 323 #endif // CC_SURFACES_SURFACE_MANAGER_H_ | 296 #endif // CC_SURFACES_SURFACE_MANAGER_H_ | 
| OLD | NEW |