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

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

Issue 2638833002: Moving temporary reference logic to SurfaceManager (Closed)
Patch Set: c Created 3 years, 11 months 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void RemoveSurfaceReference(const SurfaceId& parent_id, 130 void RemoveSurfaceReference(const SurfaceId& parent_id,
131 const SurfaceId& child_id) override; 131 const SurfaceId& child_id) override;
132 size_t GetSurfaceReferenceCount(const SurfaceId& surface_id) const override; 132 size_t GetSurfaceReferenceCount(const SurfaceId& surface_id) const override;
133 size_t GetReferencedSurfaceCount(const SurfaceId& surface_id) const override; 133 size_t GetReferencedSurfaceCount(const SurfaceId& surface_id) const override;
134 134
135 scoped_refptr<SurfaceReferenceFactory> reference_factory() { 135 scoped_refptr<SurfaceReferenceFactory> reference_factory() {
136 return reference_factory_; 136 return reference_factory_;
137 } 137 }
138 138
139 private: 139 private:
140 friend class SurfaceManagerRefTest;
141
140 using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>; 142 using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>;
141 143
142 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, 144 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id,
143 BeginFrameSource* source); 145 BeginFrameSource* source);
144 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, 146 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id,
145 BeginFrameSource* source); 147 BeginFrameSource* source);
146 // Returns true if |child namespace| is or has |search_frame_sink_id| as a 148 // Returns true if |child namespace| is or has |search_frame_sink_id| as a
147 // child. 149 // child.
148 bool ChildContains(const FrameSinkId& child_frame_sink_id, 150 bool ChildContains(const FrameSinkId& child_frame_sink_id,
149 const FrameSinkId& search_frame_sink_id) const; 151 const FrameSinkId& search_frame_sink_id) const;
150 152
151 // Garbage collects all destroyed surfaces not reachable from the root. Used 153 // Garbage collects all destroyed surfaces not reachable from the root. Used
152 // when |use_references_| is true. 154 // when |use_references_| is true.
153 void GarbageCollectSurfacesFromRoot(); 155 void GarbageCollectSurfacesFromRoot();
154 void GarbageCollectSurfaces(); 156 void GarbageCollectSurfaces();
155 157
156 // Removes reference from a parent surface to a child surface. Used to remove 158 // Removes reference from a parent surface to a child surface. Used to remove
157 // references without triggered GC. 159 // references without triggered GC.
158 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id, 160 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id,
159 const SurfaceId& child_id); 161 const SurfaceId& child_id);
160 162
163 // Adds a reference from parent id to child id without dealing with temporary
164 // references.
165 void AddSurfaceReferenceImpl(const SurfaceId& parent_id,
166 const SurfaceId& child_id);
167
161 #if DCHECK_IS_ON() 168 #if DCHECK_IS_ON()
162 // Recursively prints surface references starting at |surface_id| to |str|. 169 // Recursively prints surface references starting at |surface_id| to |str|.
163 void SurfaceReferencesToStringImpl(const SurfaceId& surface_id, 170 void SurfaceReferencesToStringImpl(const SurfaceId& surface_id,
164 std::string indent, 171 std::string indent,
165 std::stringstream* str); 172 std::stringstream* str);
166 #endif 173 #endif
167 174
168 // Use reference or sequence based lifetime management. 175 // Use reference or sequence based lifetime management.
169 LifetimeType lifetime_type_; 176 LifetimeType lifetime_type_;
170 177
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; 227 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_;
221 228
222 // Root SurfaceId that references display root surfaces. There is no Surface 229 // Root SurfaceId that references display root surfaces. There is no Surface
223 // with this id, it's for bookkeeping purposes only. 230 // with this id, it's for bookkeeping purposes only.
224 const SurfaceId root_surface_id_; 231 const SurfaceId root_surface_id_;
225 232
226 // The DirectSurfaceReferenceFactory that uses this manager to create surface 233 // The DirectSurfaceReferenceFactory that uses this manager to create surface
227 // references. 234 // references.
228 scoped_refptr<SurfaceReferenceFactory> reference_factory_; 235 scoped_refptr<SurfaceReferenceFactory> reference_factory_;
229 236
237 // SurfaceIds that have temporary references from top level root so they
238 // aren't GC'd before a real reference is added. This is basically a
239 // collection of surface ids, for example:
240 // SurfaceId surface_id(key, value[index]);
241 // The LocalFrameIds are stored in the order the surfaces are created in.
242 std::unordered_map<FrameSinkId, std::vector<LocalFrameId>, FrameSinkIdHash>
243 temp_references_;
244
230 base::WeakPtrFactory<SurfaceManager> weak_factory_; 245 base::WeakPtrFactory<SurfaceManager> weak_factory_;
231 246
232 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); 247 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
233 }; 248 };
234 249
235 } // namespace cc 250 } // namespace cc
236 251
237 #endif // CC_SURFACES_SURFACE_MANAGER_H_ 252 #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