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 20 matching lines...) Expand all Loading... |
31 #if DCHECK_IS_ON() | 31 #if DCHECK_IS_ON() |
32 #include <iosfwd> | 32 #include <iosfwd> |
33 #include <string> | 33 #include <string> |
34 #endif | 34 #endif |
35 | 35 |
36 namespace cc { | 36 namespace cc { |
37 class BeginFrameSource; | 37 class BeginFrameSource; |
38 class CompositorFrame; | 38 class CompositorFrame; |
39 class FrameSinkManagerClient; | 39 class FrameSinkManagerClient; |
40 class Surface; | 40 class Surface; |
41 class SurfaceFactory; | |
42 class SurfaceFactoryClient; | |
43 | 41 |
44 namespace test { | 42 namespace test { |
45 class CompositorFrameSinkSupportTest; | 43 class SurfaceSynchronizationTest; |
46 } | 44 } |
47 | 45 |
48 class CC_SURFACES_EXPORT SurfaceManager { | 46 class CC_SURFACES_EXPORT SurfaceManager { |
49 public: | 47 public: |
50 enum class LifetimeType { | 48 enum class LifetimeType { |
51 REFERENCES, | 49 REFERENCES, |
52 SEQUENCES, | 50 SEQUENCES, |
53 }; | 51 }; |
54 | 52 |
55 explicit SurfaceManager(LifetimeType lifetime_type = LifetimeType::SEQUENCES); | 53 explicit SurfaceManager(LifetimeType lifetime_type = LifetimeType::SEQUENCES); |
56 ~SurfaceManager(); | 54 ~SurfaceManager(); |
57 | 55 |
58 #if DCHECK_IS_ON() | 56 #if DCHECK_IS_ON() |
59 // Returns a string representation of all reachable surface references. | 57 // Returns a string representation of all reachable surface references. |
60 std::string SurfaceReferencesToString(); | 58 std::string SurfaceReferencesToString(); |
61 #endif | 59 #endif |
62 | 60 |
63 void SetDependencyTracker( | 61 void SetDependencyTracker( |
64 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker); | 62 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker); |
65 SurfaceDependencyTracker* dependency_tracker() { | 63 SurfaceDependencyTracker* dependency_tracker() { |
66 return dependency_tracker_.get(); | 64 return dependency_tracker_.get(); |
67 } | 65 } |
68 | 66 |
69 void RequestSurfaceResolution(Surface* pending_surface); | 67 void RequestSurfaceResolution(Surface* pending_surface); |
70 | 68 |
71 std::unique_ptr<Surface> CreateSurface( | 69 std::unique_ptr<Surface> CreateSurface( |
72 base::WeakPtr<SurfaceFactory> surface_factory, | 70 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support, |
73 const LocalSurfaceId& local_surface_id); | 71 const LocalSurfaceId& local_surface_id); |
74 | 72 |
75 // Destroy the Surface once a set of sequence numbers has been satisfied. | 73 // Destroy the Surface once a set of sequence numbers has been satisfied. |
76 void DestroySurface(std::unique_ptr<Surface> surface); | 74 void DestroySurface(std::unique_ptr<Surface> surface); |
77 | 75 |
78 Surface* GetSurfaceForId(const SurfaceId& surface_id); | 76 Surface* GetSurfaceForId(const SurfaceId& surface_id); |
79 | 77 |
80 void AddObserver(SurfaceObserver* obs) { observer_list_.AddObserver(obs); } | 78 void AddObserver(SurfaceObserver* obs) { observer_list_.AddObserver(obs); } |
81 | 79 |
82 void RemoveObserver(SurfaceObserver* obs) { | 80 void RemoveObserver(SurfaceObserver* obs) { |
83 observer_list_.RemoveObserver(obs); | 81 observer_list_.RemoveObserver(obs); |
84 } | 82 } |
85 | 83 |
86 bool SurfaceModified(const SurfaceId& surface_id); | 84 bool SurfaceModified(const SurfaceId& surface_id); |
87 | 85 |
88 // Called when a CompositorFrame is submitted to a SurfaceFactory for a given | 86 // Called when a CompositorFrame is submitted to a CompositorFrameSinkSupport |
89 // |surface_id| for the first time. | 87 // for a given |surface_id| for the first time. |
90 void SurfaceCreated(const SurfaceInfo& surface_info); | 88 void SurfaceCreated(const SurfaceInfo& surface_info); |
91 | 89 |
92 // Require that the given sequence number must be satisfied (using | 90 // Require that the given sequence number must be satisfied (using |
93 // SatisfySequence) before the given surface can be destroyed. | 91 // SatisfySequence) before the given surface can be destroyed. |
94 void RequireSequence(const SurfaceId& surface_id, | 92 void RequireSequence(const SurfaceId& surface_id, |
95 const SurfaceSequence& sequence); | 93 const SurfaceSequence& sequence); |
96 | 94 |
97 // Satisfies the given sequence number. Once all sequence numbers that | 95 // Satisfies the given sequence number. Once all sequence numbers that |
98 // a surface depends on are satisfied, the surface can be destroyed. | 96 // a surface depends on are satisfied, the surface can be destroyed. |
99 void SatisfySequence(const SurfaceSequence& sequence); | 97 void SatisfySequence(const SurfaceSequence& sequence); |
100 | 98 |
101 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); | 99 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); |
102 | 100 |
103 // Invalidate a frame_sink_id that might still have associated sequences, | 101 // Invalidate a frame_sink_id that might still have associated sequences, |
104 // possibly because a renderer process has crashed. | 102 // possibly because a renderer process has crashed. |
105 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); | 103 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); |
106 | 104 |
107 // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered | 105 // CompositorFrameSinkSupport, hierarchy, and BeginFrameSource can be |
108 // and unregistered in any order with respect to each other. | 106 // registered and unregistered in any order with respect to each other. |
109 // | 107 // |
110 // This happens in practice, e.g. the relationship to between ui::Compositor / | 108 // This happens in practice, e.g. the relationship to between ui::Compositor / |
111 // DelegatedFrameHost is known before ui::Compositor has a surface/client). | 109 // DelegatedFrameHost is known before ui::Compositor has a surface/client). |
112 // However, DelegatedFrameHost can register itself as a client before its | 110 // However, DelegatedFrameHost can register itself as a client before its |
113 // relationship with the ui::Compositor is known. | 111 // relationship with the ui::Compositor is known. |
114 | 112 |
115 // Associates a FrameSinkManagerClient with the surface id frame_sink_id it | 113 // Associates a FrameSinkManagerClient with the surface id frame_sink_id it |
116 // uses. | 114 // uses. |
117 // FrameSinkManagerClient and surface namespaces/allocators have a 1:1 | 115 // FrameSinkManagerClient and surface namespaces/allocators have a 1:1 |
118 // mapping. Caller guarantees the client is alive between register/unregister. | 116 // mapping. Caller guarantees the client is alive between register/unregister. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 163 |
166 scoped_refptr<SurfaceReferenceFactory> reference_factory() { | 164 scoped_refptr<SurfaceReferenceFactory> reference_factory() { |
167 return reference_factory_; | 165 return reference_factory_; |
168 } | 166 } |
169 | 167 |
170 bool using_surface_references() const { | 168 bool using_surface_references() const { |
171 return lifetime_type_ == LifetimeType::REFERENCES; | 169 return lifetime_type_ == LifetimeType::REFERENCES; |
172 } | 170 } |
173 | 171 |
174 private: | 172 private: |
175 friend class test::CompositorFrameSinkSupportTest; | 173 friend class test::SurfaceSynchronizationTest; |
176 friend class SurfaceManagerRefTest; | 174 friend class SurfaceManagerRefTest; |
177 | 175 |
178 using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>; | 176 using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>; |
179 | 177 |
180 // Garbage collects all destroyed surfaces that aren't live. | 178 // Garbage collects all destroyed surfaces that aren't live. |
181 void GarbageCollectSurfaces(); | 179 void GarbageCollectSurfaces(); |
182 | 180 |
183 // Returns set of live surfaces for |lifetime_manager_| is REFERENCES. | 181 // Returns set of live surfaces for |lifetime_manager_| is REFERENCES. |
184 SurfaceIdSet GetLiveSurfacesForReferences(); | 182 SurfaceIdSet GetLiveSurfacesForReferences(); |
185 | 183 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; | 277 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; |
280 | 278 |
281 base::WeakPtrFactory<SurfaceManager> weak_factory_; | 279 base::WeakPtrFactory<SurfaceManager> weak_factory_; |
282 | 280 |
283 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); | 281 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); |
284 }; | 282 }; |
285 | 283 |
286 } // namespace cc | 284 } // namespace cc |
287 | 285 |
288 #endif // CC_SURFACES_SURFACE_MANAGER_H_ | 286 #endif // CC_SURFACES_SURFACE_MANAGER_H_ |
OLD | NEW |