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

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

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