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

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

Issue 2540783004: Add SurfaceManager option to use references exclusively. (Closed)
Patch Set: 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') | cc/surfaces/surface_manager.cc » ('J')
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 13 matching lines...) Expand all
24 #include "cc/surfaces/surfaces_export.h" 24 #include "cc/surfaces/surfaces_export.h"
25 25
26 namespace cc { 26 namespace cc {
27 class BeginFrameSource; 27 class BeginFrameSource;
28 class CompositorFrame; 28 class CompositorFrame;
29 class Surface; 29 class Surface;
30 class SurfaceFactoryClient; 30 class SurfaceFactoryClient;
31 31
32 class CC_SURFACES_EXPORT SurfaceManager : public SurfaceReferenceManager { 32 class CC_SURFACES_EXPORT SurfaceManager : public SurfaceReferenceManager {
33 public: 33 public:
34 SurfaceManager(); 34 explicit SurfaceManager(bool use_references = false);
vmpstr 2016/12/01 21:04:02 minor nit: we'll either have to put comments every
kylechar 2016/12/01 22:49:58 Done.
35 ~SurfaceManager() override; 35 ~SurfaceManager() override;
36 36
37 void RegisterSurface(Surface* surface); 37 void RegisterSurface(Surface* surface);
38 void DeregisterSurface(const SurfaceId& surface_id); 38 void DeregisterSurface(const SurfaceId& surface_id);
39 39
40 // Destroy the Surface once a set of sequence numbers has been satisfied. 40 // Destroy the Surface once a set of sequence numbers has been satisfied.
41 void Destroy(std::unique_ptr<Surface> surface); 41 void Destroy(std::unique_ptr<Surface> surface);
42 42
43 Surface* GetSurfaceForId(const SurfaceId& surface_id); 43 Surface* GetSurfaceForId(const SurfaceId& surface_id);
44 44
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 private: 113 private:
114 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, 114 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id,
115 BeginFrameSource* source); 115 BeginFrameSource* source);
116 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, 116 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id,
117 BeginFrameSource* source); 117 BeginFrameSource* source);
118 // Returns true if |child namespace| is or has |search_frame_sink_id| as a 118 // Returns true if |child namespace| is or has |search_frame_sink_id| as a
119 // child. 119 // child.
120 bool ChildContains(const FrameSinkId& child_frame_sink_id, 120 bool ChildContains(const FrameSinkId& child_frame_sink_id,
121 const FrameSinkId& search_frame_sink_id) const; 121 const FrameSinkId& search_frame_sink_id) const;
122 122
123 // Garbage collects all destroyed surfaces not reachable from the root. Used
124 // when |use_references_| is true.
125 void GarbageCollectSurfacesFromRoot();
123 void GarbageCollectSurfaces(); 126 void GarbageCollectSurfaces();
124 127
125 // Removes reference from a parent surface to a child surface. Used to remove 128 // Removes reference from a parent surface to a child surface. Used to remove
126 // references without triggered GC. 129 // references without triggered GC.
127 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id, 130 void RemoveSurfaceReferenceImpl(const SurfaceId& parent_id,
128 const SurfaceId& child_id); 131 const SurfaceId& child_id);
129 132
133 // Use surface reference based lifetime management.
134 bool use_references_;
135
130 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>; 136 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>;
131 SurfaceMap surface_map_; 137 SurfaceMap surface_map_;
132 base::ObserverList<SurfaceObserver> observer_list_; 138 base::ObserverList<SurfaceObserver> observer_list_;
133 base::ThreadChecker thread_checker_; 139 base::ThreadChecker thread_checker_;
134 140
135 // List of surfaces to be destroyed, along with what sequences they're still 141 // List of surfaces to be destroyed, along with what sequences they're still
136 // waiting on. 142 // waiting on.
137 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>; 143 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>;
138 SurfaceDestroyList surfaces_to_destroy_; 144 SurfaceDestroyList surfaces_to_destroy_;
139 145
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash> 180 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash>
175 parent_to_child_refs_; 181 parent_to_child_refs_;
176 182
177 // Set of which sources are registered to which namespace. Any child 183 // Set of which sources are registered to which namespace. Any child
178 // that is implicitly using this namespace must be reachable by the 184 // that is implicitly using this namespace must be reachable by the
179 // parent in the dag. 185 // parent in the dag.
180 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; 186 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_;
181 187
182 // Root SurfaceId that references display root surfaces. There is no Surface 188 // Root SurfaceId that references display root surfaces. There is no Surface
183 // with this id, it's for bookkeeping purposes only. 189 // with this id, it's for bookkeeping purposes only.
184 const SurfaceId kRootSurfaceId; 190 const SurfaceId root_surface_id_;
185 191
186 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); 192 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
187 }; 193 };
188 194
189 } // namespace cc 195 } // namespace cc
190 196
191 #endif // CC_SURFACES_SURFACE_MANAGER_H_ 197 #endif // CC_SURFACES_SURFACE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/surface_manager.cc » ('j') | cc/surfaces/surface_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698