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

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

Issue 2826823002: Revert of Use flat_set in SurfaceAggregator. (Closed)
Patch Set: Created 3 years, 8 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_aggregator.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_AGGREGATOR_H_ 5 #ifndef CC_SURFACES_SURFACE_AGGREGATOR_H_
6 #define CC_SURFACES_SURFACE_AGGREGATOR_H_ 6 #define CC_SURFACES_SURFACE_AGGREGATOR_H_
7 7
8 #include <map>
8 #include <memory> 9 #include <memory>
10 #include <set>
11 #include <unordered_map>
12 #include <unordered_set>
9 13
10 #include "base/containers/flat_map.h"
11 #include "base/containers/flat_set.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
14 #include "cc/quads/draw_quad.h" 16 #include "cc/quads/draw_quad.h"
15 #include "cc/quads/render_pass.h" 17 #include "cc/quads/render_pass.h"
16 #include "cc/resources/transferable_resource.h" 18 #include "cc/resources/transferable_resource.h"
17 #include "cc/surfaces/surface_id.h" 19 #include "cc/surfaces/surface_id.h"
18 #include "cc/surfaces/surfaces_export.h" 20 #include "cc/surfaces/surfaces_export.h"
19 #include "ui/gfx/color_space.h" 21 #include "ui/gfx/color_space.h"
20 22
21 namespace cc { 23 namespace cc {
22 24
23 class CompositorFrame; 25 class CompositorFrame;
24 class ResourceProvider; 26 class ResourceProvider;
25 class Surface; 27 class Surface;
26 class SurfaceDrawQuad; 28 class SurfaceDrawQuad;
27 class SurfaceManager; 29 class SurfaceManager;
28 30
29 class CC_SURFACES_EXPORT SurfaceAggregator { 31 class CC_SURFACES_EXPORT SurfaceAggregator {
30 public: 32 public:
31 using SurfaceIndexMap = base::flat_map<SurfaceId, int>; 33 using SurfaceIndexMap = std::unordered_map<SurfaceId, int, SurfaceIdHash>;
32 34
33 SurfaceAggregator(SurfaceManager* manager, 35 SurfaceAggregator(SurfaceManager* manager,
34 ResourceProvider* provider, 36 ResourceProvider* provider,
35 bool aggregate_only_damaged); 37 bool aggregate_only_damaged);
36 ~SurfaceAggregator(); 38 ~SurfaceAggregator();
37 39
38 CompositorFrame Aggregate(const SurfaceId& surface_id); 40 CompositorFrame Aggregate(const SurfaceId& surface_id);
39 void ReleaseResources(const SurfaceId& surface_id); 41 void ReleaseResources(const SurfaceId& surface_id);
40 SurfaceIndexMap& previous_contained_surfaces() { 42 SurfaceIndexMap& previous_contained_surfaces() {
41 return previous_contained_surfaces_; 43 return previous_contained_surfaces_;
(...skipping 14 matching lines...) Expand all
56 58
57 bool is_clipped; 59 bool is_clipped;
58 gfx::Rect rect; 60 gfx::Rect rect;
59 }; 61 };
60 62
61 struct PrewalkResult { 63 struct PrewalkResult {
62 PrewalkResult(); 64 PrewalkResult();
63 ~PrewalkResult(); 65 ~PrewalkResult();
64 // This is the set of Surfaces that were referenced by another Surface, but 66 // This is the set of Surfaces that were referenced by another Surface, but
65 // not included in a SurfaceDrawQuad. 67 // not included in a SurfaceDrawQuad.
66 base::flat_set<SurfaceId> undrawn_surfaces; 68 std::set<SurfaceId> undrawn_surfaces;
67 bool may_contain_video = false; 69 bool may_contain_video = false;
68 }; 70 };
69 71
70 struct RenderPassInfo { 72 struct RenderPassInfo {
71 // This is the id the pass is mapped to. 73 // This is the id the pass is mapped to.
72 int id; 74 int id;
73 // This is true if the pass was used in the last aggregated frame. 75 // This is true if the pass was used in the last aggregated frame.
74 bool in_use = true; 76 bool in_use = true;
75 }; 77 };
76 78
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 const RenderPass& source, 138 const RenderPass& source,
137 const gfx::Rect& full_rect) const; 139 const gfx::Rect& full_rect) const;
138 140
139 SurfaceManager* manager_; 141 SurfaceManager* manager_;
140 ResourceProvider* provider_; 142 ResourceProvider* provider_;
141 143
142 // Every Surface has its own RenderPass ID namespace. This structure maps 144 // Every Surface has its own RenderPass ID namespace. This structure maps
143 // each source (SurfaceId, RenderPass id) to a unified ID namespace that's 145 // each source (SurfaceId, RenderPass id) to a unified ID namespace that's
144 // used in the aggregated frame. An entry is removed from the map if it's not 146 // used in the aggregated frame. An entry is removed from the map if it's not
145 // used for one output frame. 147 // used for one output frame.
146 base::flat_map<std::pair<SurfaceId, int>, RenderPassInfo> 148 using RenderPassIdAllocatorMap =
147 render_pass_allocator_map_; 149 std::map<std::pair<SurfaceId, int>, RenderPassInfo>;
150 RenderPassIdAllocatorMap render_pass_allocator_map_;
148 int next_render_pass_id_; 151 int next_render_pass_id_;
149 const bool aggregate_only_damaged_; 152 const bool aggregate_only_damaged_;
150 bool output_is_secure_; 153 bool output_is_secure_;
151 154
152 // The color space for the root render pass. If this is different from 155 // The color space for the root render pass. If this is different from
153 // |blending_color_space_|, then a final render pass to convert between 156 // |blending_color_space_|, then a final render pass to convert between
154 // the two will be added. 157 // the two will be added.
155 gfx::ColorSpace output_color_space_; 158 gfx::ColorSpace output_color_space_;
156 // The color space in which blending is done, used for all non-root render 159 // The color space in which blending is done, used for all non-root render
157 // passes. 160 // passes.
158 gfx::ColorSpace blending_color_space_; 161 gfx::ColorSpace blending_color_space_;
159 // The id for the final color conversion render pass. 162 // The id for the final color conversion render pass.
160 int color_conversion_render_pass_id_ = 0; 163 int color_conversion_render_pass_id_ = 0;
161 164
162 base::flat_map<SurfaceId, int> surface_id_to_resource_child_id_; 165 using SurfaceToResourceChildIdMap =
166 std::unordered_map<SurfaceId, int, SurfaceIdHash>;
167 SurfaceToResourceChildIdMap surface_id_to_resource_child_id_;
163 168
164 // The following state is only valid for the duration of one Aggregate call 169 // The following state is only valid for the duration of one Aggregate call
165 // and is only stored on the class to avoid having to pass through every 170 // and is only stored on the class to avoid having to pass through every
166 // function call. 171 // function call.
167 172
168 // This is the set of surfaces referenced in the aggregation so far, used to 173 // This is the set of surfaces referenced in the aggregation so far, used to
169 // detect cycles. 174 // detect cycles.
170 base::flat_set<SurfaceId> referenced_surfaces_; 175 using SurfaceSet = std::set<SurfaceId>;
176 SurfaceSet referenced_surfaces_;
171 177
172 // For each Surface used in the last aggregation, gives the frame_index at 178 // For each Surface used in the last aggregation, gives the frame_index at
173 // that time. 179 // that time.
174 SurfaceIndexMap previous_contained_surfaces_; 180 SurfaceIndexMap previous_contained_surfaces_;
175 SurfaceIndexMap contained_surfaces_; 181 SurfaceIndexMap contained_surfaces_;
176 182
177 // After surface validation, every Surface in this set is valid. 183 // After surface validation, every Surface in this set is valid.
178 base::flat_set<SurfaceId> valid_surfaces_; 184 std::unordered_set<SurfaceId, SurfaceIdHash> valid_surfaces_;
179 185
180 // This is the pass list for the aggregated frame. 186 // This is the pass list for the aggregated frame.
181 RenderPassList* dest_pass_list_; 187 RenderPassList* dest_pass_list_;
182 188
183 // This is the set of aggregated pass ids that are affected by filters that 189 // This is the set of aggregated pass ids that are affected by filters that
184 // move pixels. 190 // move pixels.
185 base::flat_set<int> moved_pixel_passes_; 191 std::unordered_set<int> moved_pixel_passes_;
186 192
187 // This is the set of aggregated pass ids that are drawn by copy requests, so 193 // This is the set of aggregated pass ids that are drawn by copy requests, so
188 // should not have their damage rects clipped to the root damage rect. 194 // should not have their damage rects clipped to the root damage rect.
189 base::flat_set<int> copy_request_passes_; 195 std::unordered_set<int> copy_request_passes_;
190 196
191 // This maps each aggregated pass id to the set of (aggregated) pass ids 197 // This maps each aggregated pass id to the set of (aggregated) pass ids
192 // that its RenderPassDrawQuads depend on 198 // that its RenderPassDrawQuads depend on
193 base::flat_map<int, base::flat_set<int>> render_pass_dependencies_; 199 std::unordered_map<int, std::unordered_set<int>> render_pass_dependencies_;
194 200
195 // The root damage rect of the currently-aggregating frame. 201 // The root damage rect of the currently-aggregating frame.
196 gfx::Rect root_damage_rect_; 202 gfx::Rect root_damage_rect_;
197 203
198 // True if the frame that's currently being aggregated has copy requests. 204 // True if the frame that's currently being aggregated has copy requests.
199 // This is valid during Aggregate after PrewalkTree is called. 205 // This is valid during Aggregate after PrewalkTree is called.
200 bool has_copy_requests_; 206 bool has_copy_requests_;
201 207
202 // Resource list for the aggregated frame. 208 // Resource list for the aggregated frame.
203 TransferableResourceArray* dest_resource_list_; 209 TransferableResourceArray* dest_resource_list_;
204 210
205 // Tracks UMA stats for SurfaceDrawQuads during a call to Aggregate(). 211 // Tracks UMA stats for SurfaceDrawQuads during a call to Aggregate().
206 SurfaceDrawQuadUmaStats uma_stats_; 212 SurfaceDrawQuadUmaStats uma_stats_;
207 213
208 base::WeakPtrFactory<SurfaceAggregator> weak_factory_; 214 base::WeakPtrFactory<SurfaceAggregator> weak_factory_;
209 215
210 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator); 216 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator);
211 }; 217 };
212 218
213 } // namespace cc 219 } // namespace cc
214 220
215 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_ 221 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/surface_aggregator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698