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