Chromium Code Reviews| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 // id namespace. | 59 // id namespace. |
| 60 void DidSatisfySequences(const FrameSinkId& frame_sink_id, | 60 void DidSatisfySequences(const FrameSinkId& frame_sink_id, |
| 61 std::vector<uint32_t>* sequence); | 61 std::vector<uint32_t>* sequence); |
| 62 | 62 |
| 63 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); | 63 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); |
| 64 | 64 |
| 65 // Invalidate a frame_sink_id that might still have associated sequences, | 65 // Invalidate a frame_sink_id that might still have associated sequences, |
| 66 // possibly because a renderer process has crashed. | 66 // possibly because a renderer process has crashed. |
| 67 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); | 67 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); |
| 68 | 68 |
| 69 // Adds a reference from a parent surface to a child surface. This signifies | |
| 70 // the parent surface is embedding the child surface and the child surface | |
| 71 // is needed until the reference is removed. | |
| 72 void AddSurfaceIdReference(const SurfaceId& parent_id, | |
| 73 const SurfaceId& child_id); | |
| 74 | |
| 75 // Removes a reference from a parent surface to a child surface. This signals | |
| 76 // the parent surface no longer needs the child surface. | |
| 77 void RemoveSurfaceIdReference(const SurfaceId& parent_id, | |
| 78 const SurfaceId& child_id); | |
| 79 | |
| 80 // Removes all references to and from surfaces that were created for | |
| 81 // |frame_sink_id|. | |
| 82 void RemoveAllReferencesForFrameSink(const FrameSinkId& frame_sink_id); | |
| 83 | |
| 84 // Returns the number of surfaces that have references to |surface_id|. When | |
| 85 // the count is zero nothing is referencing the surface and it may be garbage | |
| 86 // collected. | |
| 87 int CountSurfaceReferences(const SurfaceId& surface_id) const; | |
|
Fady Samuel
2016/10/27 04:14:49
nit: GetSurfaceReferenceCount?
kylechar
2016/10/27 21:14:10
Done.
| |
| 88 | |
| 89 // Returns the number of surfaces that |surface_id| refers to. | |
| 90 int CountSurfaceReferees(const SurfaceId& surface_id) const; | |
| 91 | |
| 69 // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered | 92 // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered |
| 70 // and unregistered in any order with respect to each other. | 93 // and unregistered in any order with respect to each other. |
| 71 // | 94 // |
| 72 // This happens in practice, e.g. the relationship to between ui::Compositor / | 95 // This happens in practice, e.g. the relationship to between ui::Compositor / |
| 73 // DelegatedFrameHost is known before ui::Compositor has a surface/client). | 96 // DelegatedFrameHost is known before ui::Compositor has a surface/client). |
| 74 // However, DelegatedFrameHost can register itself as a client before its | 97 // However, DelegatedFrameHost can register itself as a client before its |
| 75 // relationship with the ui::Compositor is known. | 98 // relationship with the ui::Compositor is known. |
| 76 | 99 |
| 77 // Associates a SurfaceFactoryClient with the surface id frame_sink_id it | 100 // Associates a SurfaceFactoryClient with the surface id frame_sink_id it |
| 78 // uses. | 101 // uses. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 bool is_empty() const { return !client && children.empty(); } | 163 bool is_empty() const { return !client && children.empty(); } |
| 141 // The client that's responsible for creating this namespace. Never null. | 164 // The client that's responsible for creating this namespace. Never null. |
| 142 SurfaceFactoryClient* client; | 165 SurfaceFactoryClient* client; |
| 143 // The currently assigned begin frame source for this client. | 166 // The currently assigned begin frame source for this client. |
| 144 BeginFrameSource* source; | 167 BeginFrameSource* source; |
| 145 // This represents a dag of parent -> children mapping. | 168 // This represents a dag of parent -> children mapping. |
| 146 std::vector<FrameSinkId> children; | 169 std::vector<FrameSinkId> children; |
| 147 }; | 170 }; |
| 148 std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash> | 171 std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash> |
| 149 frame_sink_source_map_; | 172 frame_sink_source_map_; |
| 173 | |
| 174 using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>; | |
| 175 // References from the child surface to parent surface. If there are zero | |
| 176 // entries in the set for a SurfaceId then nothing is referencing the surface | |
| 177 // and it can be garbage collected. | |
| 178 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash> | |
| 179 child_to_parent_refs_; | |
| 180 // References from the parent surface to child surface. | |
| 181 std::unordered_map<SurfaceId, SurfaceIdSet, SurfaceIdHash> | |
| 182 parent_to_child_refs_; | |
| 183 | |
| 150 // Set of which sources are registered to which namespace. Any child | 184 // Set of which sources are registered to which namespace. Any child |
| 151 // that is implicitly using this namespace must be reachable by the | 185 // that is implicitly using this namespace must be reachable by the |
| 152 // parent in the dag. | 186 // parent in the dag. |
| 153 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; | 187 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; |
| 154 | 188 |
| 155 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); | 189 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); |
| 156 }; | 190 }; |
| 157 | 191 |
| 158 } // namespace cc | 192 } // namespace cc |
| 159 | 193 |
| 160 #endif // CC_SURFACES_SURFACE_MANAGER_H_ | 194 #endif // CC_SURFACES_SURFACE_MANAGER_H_ |
| OLD | NEW |