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 18 matching lines...) Expand all Loading... |
29 #include "cc/surfaces/surfaces_export.h" | 29 #include "cc/surfaces/surfaces_export.h" |
30 | 30 |
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 CompositorFrameSinkSupport; |
39 class Surface; | 40 class Surface; |
40 class SurfaceFactory; | |
41 class SurfaceFactoryClient; | |
42 | 41 |
43 namespace test { | 42 namespace test { |
44 class CompositorFrameSinkSupportTest; | 43 class CompositorFrameSinkSupportTest; |
45 } | 44 } |
46 | 45 |
47 class CC_SURFACES_EXPORT SurfaceManager { | 46 class CC_SURFACES_EXPORT SurfaceManager { |
48 public: | 47 public: |
49 enum class LifetimeType { | 48 enum class LifetimeType { |
50 REFERENCES, | 49 REFERENCES, |
51 SEQUENCES, | 50 SEQUENCES, |
52 }; | 51 }; |
53 | 52 |
54 explicit SurfaceManager(LifetimeType lifetime_type = LifetimeType::SEQUENCES); | 53 explicit SurfaceManager(LifetimeType lifetime_type = LifetimeType::SEQUENCES); |
55 ~SurfaceManager(); | 54 ~SurfaceManager(); |
56 | 55 |
57 #if DCHECK_IS_ON() | 56 #if DCHECK_IS_ON() |
58 // Returns a string representation of all reachable surface references. | 57 // Returns a string representation of all reachable surface references. |
59 std::string SurfaceReferencesToString(); | 58 std::string SurfaceReferencesToString(); |
60 #endif | 59 #endif |
61 | 60 |
62 void SetDependencyTracker( | 61 void SetDependencyTracker( |
63 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker); | 62 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker); |
64 SurfaceDependencyTracker* dependency_tracker() { | 63 SurfaceDependencyTracker* dependency_tracker() { |
65 return dependency_tracker_.get(); | 64 return dependency_tracker_.get(); |
66 } | 65 } |
67 | 66 |
68 void RequestSurfaceResolution(Surface* pending_surface); | 67 void RequestSurfaceResolution(Surface* pending_surface); |
69 | 68 |
70 std::unique_ptr<Surface> CreateSurface( | 69 std::unique_ptr<Surface> CreateSurface( |
71 base::WeakPtr<SurfaceFactory> surface_factory, | 70 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support, |
72 const LocalSurfaceId& local_surface_id); | 71 const LocalSurfaceId& local_surface_id); |
73 | 72 |
74 // 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. |
75 void DestroySurface(std::unique_ptr<Surface> surface); | 74 void DestroySurface(std::unique_ptr<Surface> surface); |
76 | 75 |
77 Surface* GetSurfaceForId(const SurfaceId& surface_id); | 76 Surface* GetSurfaceForId(const SurfaceId& surface_id); |
78 | 77 |
79 void AddObserver(SurfaceObserver* obs) { observer_list_.AddObserver(obs); } | 78 void AddObserver(SurfaceObserver* obs) { observer_list_.AddObserver(obs); } |
80 | 79 |
81 void RemoveObserver(SurfaceObserver* obs) { | 80 void RemoveObserver(SurfaceObserver* obs) { |
82 observer_list_.RemoveObserver(obs); | 81 observer_list_.RemoveObserver(obs); |
83 } | 82 } |
84 | 83 |
85 bool SurfaceModified(const SurfaceId& surface_id); | 84 bool SurfaceModified(const SurfaceId& surface_id); |
86 | 85 |
87 // Called when a CompositorFrame is submitted to a SurfaceFactory for a given | 86 // Called when a CompositorFrame is submitted to a CompositorFrameSinkSupport |
88 // |surface_id| for the first time. | 87 // for a given |surface_id| for the first time. |
89 void SurfaceCreated(const SurfaceInfo& surface_info); | 88 void SurfaceCreated(const SurfaceInfo& surface_info); |
90 | 89 |
91 // Require that the given sequence number must be satisfied (using | 90 // Require that the given sequence number must be satisfied (using |
92 // SatisfySequence) before the given surface can be destroyed. | 91 // SatisfySequence) before the given surface can be destroyed. |
93 void RequireSequence(const SurfaceId& surface_id, | 92 void RequireSequence(const SurfaceId& surface_id, |
94 const SurfaceSequence& sequence); | 93 const SurfaceSequence& sequence); |
95 | 94 |
96 // Satisfies the given sequence number. Once all sequence numbers that | 95 // Satisfies the given sequence number. Once all sequence numbers that |
97 // a surface depends on are satisfied, the surface can be destroyed. | 96 // a surface depends on are satisfied, the surface can be destroyed. |
98 void SatisfySequence(const SurfaceSequence& sequence); | 97 void SatisfySequence(const SurfaceSequence& sequence); |
99 | 98 |
100 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); | 99 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); |
101 | 100 |
102 // Invalidate a frame_sink_id that might still have associated sequences, | 101 // Invalidate a frame_sink_id that might still have associated sequences, |
103 // possibly because a renderer process has crashed. | 102 // possibly because a renderer process has crashed. |
104 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); | 103 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); |
105 | 104 |
106 // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered | 105 // CompositorFrameSinkSupport, hierarchy, and BeginFrameSource can be |
107 // and unregistered in any order with respect to each other. | 106 // registered and unregistered in any order with respect to each other. |
108 // | 107 // |
109 // 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 / |
110 // DelegatedFrameHost is known before ui::Compositor has a surface/client). | 109 // DelegatedFrameHost is known before ui::Compositor has a surface/client). |
111 // However, DelegatedFrameHost can register itself as a client before its | 110 // However, DelegatedFrameHost can register itself as a client before its |
112 // relationship with the ui::Compositor is known. | 111 // relationship with the ui::Compositor is known. |
113 | 112 |
114 // Associates a SurfaceFactoryClient with the surface id frame_sink_id it | 113 // Associates a CompositorFrameSinkSupport with the surface id frame_sink_id |
115 // uses. | 114 // it uses. |
116 // SurfaceFactoryClient and surface namespaces/allocators have a 1:1 mapping. | 115 // CompositorFrameSinkSupport and surface namespaces/allocators have a 1:1 |
117 // Caller guarantees the client is alive between register/unregister. | 116 // mapping. |
118 // Reregistering the same namespace when a previous client is active is not | 117 // Caller guarantees |support| is alive between register/unregister. |
119 // valid. | 118 // Reregistering the same namespace when a previous CompositorFrameSinkSupport |
120 void RegisterSurfaceFactoryClient(const FrameSinkId& frame_sink_id, | 119 // is active is not valid. |
121 SurfaceFactoryClient* client); | 120 void RegisterCompositorFrameSinkSupport(const FrameSinkId& frame_sink_id, |
122 void UnregisterSurfaceFactoryClient(const FrameSinkId& frame_sink_id); | 121 CompositorFrameSinkSupport* client); |
| 122 void UnregisterCompositorFrameSinkSupport(const FrameSinkId& frame_sink_id); |
123 | 123 |
124 // Associates a |source| with a particular namespace. That namespace and | 124 // Associates a |source| with a particular namespace. That namespace and |
125 // any children of that namespace with valid clients can potentially use | 125 // any children of that namespace with valid clients can potentially use |
126 // that |source|. | 126 // that |source|. |
127 void RegisterBeginFrameSource(BeginFrameSource* source, | 127 void RegisterBeginFrameSource(BeginFrameSource* source, |
128 const FrameSinkId& frame_sink_id); | 128 const FrameSinkId& frame_sink_id); |
129 void UnregisterBeginFrameSource(BeginFrameSource* source); | 129 void UnregisterBeginFrameSource(BeginFrameSource* source); |
130 | 130 |
131 // Register a relationship between two namespaces. This relationship means | 131 // Register a relationship between two namespaces. This relationship means |
132 // that surfaces from the child namespace will be displayed in the parent. | 132 // that surfaces from the child namespace will be displayed in the parent. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; | 278 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; |
279 | 279 |
280 base::WeakPtrFactory<SurfaceManager> weak_factory_; | 280 base::WeakPtrFactory<SurfaceManager> weak_factory_; |
281 | 281 |
282 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); | 282 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); |
283 }; | 283 }; |
284 | 284 |
285 } // namespace cc | 285 } // namespace cc |
286 | 286 |
287 #endif // CC_SURFACES_SURFACE_MANAGER_H_ | 287 #endif // CC_SURFACES_SURFACE_MANAGER_H_ |
OLD | NEW |