| 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/compiler_specific.h" | |
| 17 #include "base/logging.h" | 16 #include "base/logging.h" |
| 18 #include "base/macros.h" | 17 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 20 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 21 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" |
| 22 #include "cc/surfaces/frame_sink_id.h" | 21 #include "cc/surfaces/frame_sink_id.h" |
| 23 #include "cc/surfaces/surface_id.h" | 22 #include "cc/surfaces/surface_id.h" |
| 24 #include "cc/surfaces/surface_observer.h" | 23 #include "cc/surfaces/surface_observer.h" |
| 24 #include "cc/surfaces/surface_reference.h" |
| 25 #include "cc/surfaces/surface_reference_factory.h" | 25 #include "cc/surfaces/surface_reference_factory.h" |
| 26 #include "cc/surfaces/surface_reference_manager.h" | |
| 27 #include "cc/surfaces/surface_sequence.h" | 26 #include "cc/surfaces/surface_sequence.h" |
| 28 #include "cc/surfaces/surfaces_export.h" | 27 #include "cc/surfaces/surfaces_export.h" |
| 29 | 28 |
| 30 #if DCHECK_IS_ON() | 29 #if DCHECK_IS_ON() |
| 31 #include <iosfwd> | 30 #include <iosfwd> |
| 32 #include <string> | 31 #include <string> |
| 33 #endif | 32 #endif |
| 34 | 33 |
| 35 namespace cc { | 34 namespace cc { |
| 36 class BeginFrameSource; | 35 class BeginFrameSource; |
| 37 class CompositorFrame; | 36 class CompositorFrame; |
| 38 class Surface; | 37 class Surface; |
| 39 class SurfaceFactoryClient; | 38 class SurfaceFactoryClient; |
| 40 | 39 |
| 41 class CC_SURFACES_EXPORT SurfaceManager | 40 class CC_SURFACES_EXPORT SurfaceManager { |
| 42 : public NON_EXPORTED_BASE(SurfaceReferenceManager) { | |
| 43 public: | 41 public: |
| 44 enum class LifetimeType { | 42 enum class LifetimeType { |
| 45 REFERENCES, | 43 REFERENCES, |
| 46 SEQUENCES, | 44 SEQUENCES, |
| 47 }; | 45 }; |
| 48 | 46 |
| 49 explicit SurfaceManager(LifetimeType lifetime_type = LifetimeType::SEQUENCES); | 47 explicit SurfaceManager(LifetimeType lifetime_type = LifetimeType::SEQUENCES); |
| 50 ~SurfaceManager() override; | 48 ~SurfaceManager(); |
| 51 | 49 |
| 52 #if DCHECK_IS_ON() | 50 #if DCHECK_IS_ON() |
| 53 // Returns a string representation of all reachable surface references. | 51 // Returns a string representation of all reachable surface references. |
| 54 std::string SurfaceReferencesToString(); | 52 std::string SurfaceReferencesToString(); |
| 55 #endif | 53 #endif |
| 56 | 54 |
| 57 void RegisterSurface(Surface* surface); | 55 void RegisterSurface(Surface* surface); |
| 58 void DeregisterSurface(const SurfaceId& surface_id); | 56 void DeregisterSurface(const SurfaceId& surface_id); |
| 59 | 57 |
| 60 // Destroy the Surface once a set of sequence numbers has been satisfied. | 58 // Destroy the Surface once a set of sequence numbers has been satisfied. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 114 |
| 117 // Register a relationship between two namespaces. This relationship means | 115 // Register a relationship between two namespaces. This relationship means |
| 118 // that surfaces from the child namespace will be displayed in the parent. | 116 // that surfaces from the child namespace will be displayed in the parent. |
| 119 // Children are allowed to use any begin frame source that their parent can | 117 // Children are allowed to use any begin frame source that their parent can |
| 120 // use. | 118 // use. |
| 121 void RegisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, | 119 void RegisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, |
| 122 const FrameSinkId& child_frame_sink_id); | 120 const FrameSinkId& child_frame_sink_id); |
| 123 void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, | 121 void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, |
| 124 const FrameSinkId& child_frame_sink_id); | 122 const FrameSinkId& child_frame_sink_id); |
| 125 | 123 |
| 126 // SurfaceReferenceManager: | 124 // Returns the top level root SurfaceId. Surfaces that are not reachable |
| 127 const SurfaceId& GetRootSurfaceId() const override; | 125 // from the top level root may be garbage collected. It will not be a valid |
| 126 // SurfaceId and will never correspond to a surface. |
| 127 const SurfaceId& GetRootSurfaceId() const; |
| 128 |
| 129 // Adds a reference from |parent_id| to |child_id|. If there is a temporary |
| 130 // references for |child_id| then it will be removed. |
| 128 void AddSurfaceReference(const SurfaceId& parent_id, | 131 void AddSurfaceReference(const SurfaceId& parent_id, |
| 129 const SurfaceId& child_id) override; | 132 const SurfaceId& child_id); |
| 133 |
| 134 // Removes a reference from |parent_id| to |child_id|. |
| 130 void RemoveSurfaceReference(const SurfaceId& parent_id, | 135 void RemoveSurfaceReference(const SurfaceId& parent_id, |
| 131 const SurfaceId& child_id) override; | 136 const SurfaceId& child_id); |
| 132 void AddSurfaceReferences( | 137 |
| 133 const std::vector<SurfaceReference>& references) override; | 138 // Adds all surface references in |references|. This will remove any temporary |
| 134 void RemoveSurfaceReferences( | 139 // references for child surface in a surface reference. |
| 135 const std::vector<SurfaceReference>& references) override; | 140 void AddSurfaceReferences(const std::vector<SurfaceReference>& references); |
| 136 size_t GetSurfaceReferenceCount(const SurfaceId& surface_id) const override; | 141 |
| 137 size_t GetReferencedSurfaceCount(const SurfaceId& surface_id) const override; | 142 // Removes all surface references in |references| then runs garbage |
| 143 // collection to delete unreachable surfaces. |
| 144 void RemoveSurfaceReferences(const std::vector<SurfaceReference>& references); |
| 138 | 145 |
| 139 scoped_refptr<SurfaceReferenceFactory> reference_factory() { | 146 scoped_refptr<SurfaceReferenceFactory> reference_factory() { |
| 140 return reference_factory_; | 147 return reference_factory_; |
| 141 } | 148 } |
| 142 | 149 |
| 143 private: | 150 private: |
| 144 friend class SurfaceManagerRefTest; | 151 friend class SurfaceManagerRefTest; |
| 145 | 152 |
| 146 using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>; | 153 using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>; |
| 147 | 154 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 temp_references_; | 262 temp_references_; |
| 256 | 263 |
| 257 base::WeakPtrFactory<SurfaceManager> weak_factory_; | 264 base::WeakPtrFactory<SurfaceManager> weak_factory_; |
| 258 | 265 |
| 259 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); | 266 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); |
| 260 }; | 267 }; |
| 261 | 268 |
| 262 } // namespace cc | 269 } // namespace cc |
| 263 | 270 |
| 264 #endif // CC_SURFACES_SURFACE_MANAGER_H_ | 271 #endif // CC_SURFACES_SURFACE_MANAGER_H_ |
| OLD | NEW |