Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Side by Side Diff: cc/surfaces/surface_manager.h

Issue 2540783004: Add SurfaceManager option to use references exclusively. (Closed)
Patch Set: Add .push(). Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/surfaces/surface_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 26
27 namespace cc { 27 namespace cc {
28 class BeginFrameSource; 28 class BeginFrameSource;
29 class CompositorFrame; 29 class CompositorFrame;
30 class Surface; 30 class Surface;
31 class SurfaceFactoryClient; 31 class SurfaceFactoryClient;
32 32
33 class CC_SURFACES_EXPORT SurfaceManager 33 class CC_SURFACES_EXPORT SurfaceManager
34 : public NON_EXPORTED_BASE(SurfaceReferenceManager) { 34 : public NON_EXPORTED_BASE(SurfaceReferenceManager) {
35 public: 35 public:
36 SurfaceManager(); 36 enum class LifetimeType {
37 REFERENCES,
38 SEQUENCES,
39 };
40
41 explicit SurfaceManager(LifetimeType lifetime_type = LifetimeType::SEQUENCES);
37 ~SurfaceManager() override; 42 ~SurfaceManager() override;
38 43
39 void RegisterSurface(Surface* surface); 44 void RegisterSurface(Surface* surface);
40 void DeregisterSurface(const SurfaceId& surface_id); 45 void DeregisterSurface(const SurfaceId& surface_id);
41 46
42 // Destroy the Surface once a set of sequence numbers has been satisfied. 47 // Destroy the Surface once a set of sequence numbers has been satisfied.
43 void Destroy(std::unique_ptr<Surface> surface); 48 void Destroy(std::unique_ptr<Surface> surface);
44 49
45 Surface* GetSurfaceForId(const SurfaceId& surface_id); 50 Surface* GetSurfaceForId(const SurfaceId& surface_id);
46 51
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 private: 120 private:
116 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, 121 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id,
117 BeginFrameSource* source); 122 BeginFrameSource* source);
118 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, 123 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id,
119 BeginFrameSource* source); 124 BeginFrameSource* source);
120 // Returns true if |child namespace| is or has |search_frame_sink_id| as a 125 // Returns true if |child namespace| is or has |search_frame_sink_id| as a
121 // child. 126 // child.
122 bool ChildContains(const FrameSinkId& child_frame_sink_id, 127 bool ChildContains(const FrameSinkId& child_frame_sink_id,
123 const FrameSinkId& search_frame_sink_id) const; 128 const FrameSinkId& search_frame_sink_id) const;
124 129
130 // Garbage collects all destroyed surfaces not reachable from the root. Used
131 // when |use_references_| is true.
132 void GarbageCollectSurfacesFromRoot();
125 void GarbageCollectSurfaces(); 133 void GarbageCollectSurfaces();
126 134
127 // Removes reference from a parent surface to a child surface. Used to remove 135 // Removes reference from a parent surface to a child surface. Used to remove
128 // references without triggered GC. 136 // references without triggered GC.
129 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id, 137 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id,
130 const SurfaceId& child_id); 138 const SurfaceId& child_id);
131 139
140 // Use reference or sequence based lifetime management.
141 LifetimeType lifetime_type_;
142
132 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>; 143 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>;
133 SurfaceMap surface_map_; 144 SurfaceMap surface_map_;
134 base::ObserverList<SurfaceObserver> observer_list_; 145 base::ObserverList<SurfaceObserver> observer_list_;
135 base::ThreadChecker thread_checker_; 146 base::ThreadChecker thread_checker_;
136 147
137 // List of surfaces to be destroyed, along with what sequences they're still 148 // List of surfaces to be destroyed, along with what sequences they're still
138 // waiting on. 149 // waiting on.
139 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>; 150 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>;
140 SurfaceDestroyList surfaces_to_destroy_; 151 SurfaceDestroyList surfaces_to_destroy_;
141 152
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash> 187 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash>
177 parent_to_child_refs_; 188 parent_to_child_refs_;
178 189
179 // Set of which sources are registered to which namespace. Any child 190 // Set of which sources are registered to which namespace. Any child
180 // that is implicitly using this namespace must be reachable by the 191 // that is implicitly using this namespace must be reachable by the
181 // parent in the dag. 192 // parent in the dag.
182 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; 193 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_;
183 194
184 // Root SurfaceId that references display root surfaces. There is no Surface 195 // Root SurfaceId that references display root surfaces. There is no Surface
185 // with this id, it's for bookkeeping purposes only. 196 // with this id, it's for bookkeeping purposes only.
186 const SurfaceId kRootSurfaceId; 197 const SurfaceId root_surface_id_;
187 198
188 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); 199 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
189 }; 200 };
190 201
191 } // namespace cc 202 } // namespace cc
192 203
193 #endif // CC_SURFACES_SURFACE_MANAGER_H_ 204 #endif // CC_SURFACES_SURFACE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/surface_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698