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

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

Issue 1640483003: Switch SurfaceId maps from base::hash_map to std::unordered_map. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing comments Created 4 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_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 <set> 8 #include <set>
9 #include <unordered_map>
10 #include <unordered_set>
9 11
10 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
11 #include "base/containers/scoped_ptr_hash_map.h" 13 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_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"
(...skipping 10 matching lines...) Expand all
29 class CC_SURFACES_EXPORT SurfaceAggregatorClient { 31 class CC_SURFACES_EXPORT SurfaceAggregatorClient {
30 public: 32 public:
31 virtual ~SurfaceAggregatorClient() {} 33 virtual ~SurfaceAggregatorClient() {}
32 34
33 virtual void AddSurface(Surface* surface) = 0; 35 virtual void AddSurface(Surface* surface) = 0;
34 virtual void RemoveSurface(Surface* surface) = 0; 36 virtual void RemoveSurface(Surface* surface) = 0;
35 }; 37 };
36 38
37 class CC_SURFACES_EXPORT SurfaceAggregator { 39 class CC_SURFACES_EXPORT SurfaceAggregator {
38 public: 40 public:
39 typedef base::hash_map<SurfaceId, int> SurfaceIndexMap; 41 using SurfaceIndexMap = std::unordered_map<SurfaceId, int, SurfaceIdHash>;
40 42
41 SurfaceAggregator(SurfaceAggregatorClient* client, 43 SurfaceAggregator(SurfaceAggregatorClient* client,
42 SurfaceManager* manager, 44 SurfaceManager* manager,
43 ResourceProvider* provider, 45 ResourceProvider* provider,
44 bool aggregate_only_damaged); 46 bool aggregate_only_damaged);
45 ~SurfaceAggregator(); 47 ~SurfaceAggregator();
46 48
47 scoped_ptr<CompositorFrame> Aggregate(SurfaceId surface_id); 49 scoped_ptr<CompositorFrame> Aggregate(SurfaceId surface_id);
48 void ReleaseResources(SurfaceId surface_id); 50 void ReleaseResources(SurfaceId surface_id);
49 SurfaceIndexMap& previous_contained_surfaces() { 51 SurfaceIndexMap& previous_contained_surfaces() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 int ChildIdForSurface(Surface* surface); 108 int ChildIdForSurface(Surface* surface);
107 gfx::Rect DamageRectForSurface(const Surface* surface, 109 gfx::Rect DamageRectForSurface(const Surface* surface,
108 const RenderPass& source, 110 const RenderPass& source,
109 const gfx::Rect& full_rect) const; 111 const gfx::Rect& full_rect) const;
110 112
111 SurfaceAggregatorClient* client_; // Outlives this class. 113 SurfaceAggregatorClient* client_; // Outlives this class.
112 SurfaceManager* manager_; 114 SurfaceManager* manager_;
113 ResourceProvider* provider_; 115 ResourceProvider* provider_;
114 116
115 class RenderPassIdAllocator; 117 class RenderPassIdAllocator;
116 typedef base::ScopedPtrHashMap<SurfaceId, scoped_ptr<RenderPassIdAllocator>> 118 using RenderPassIdAllocatorMap =
117 RenderPassIdAllocatorMap; 119 std::unordered_map<SurfaceId,
120 scoped_ptr<RenderPassIdAllocator>,
121 SurfaceIdHash>;
118 RenderPassIdAllocatorMap render_pass_allocator_map_; 122 RenderPassIdAllocatorMap render_pass_allocator_map_;
119 int next_render_pass_id_; 123 int next_render_pass_id_;
120 const bool aggregate_only_damaged_; 124 const bool aggregate_only_damaged_;
121 125
122 typedef base::hash_map<SurfaceId, int> SurfaceToResourceChildIdMap; 126 using SurfaceToResourceChildIdMap =
127 std::unordered_map<SurfaceId, int, SurfaceIdHash>;
123 SurfaceToResourceChildIdMap surface_id_to_resource_child_id_; 128 SurfaceToResourceChildIdMap surface_id_to_resource_child_id_;
124 129
125 // The following state is only valid for the duration of one Aggregate call 130 // The following state is only valid for the duration of one Aggregate call
126 // and is only stored on the class to avoid having to pass through every 131 // and is only stored on the class to avoid having to pass through every
127 // function call. 132 // function call.
128 133
129 // This is the set of surfaces referenced in the aggregation so far, used to 134 // This is the set of surfaces referenced in the aggregation so far, used to
130 // detect cycles. 135 // detect cycles.
131 typedef std::set<SurfaceId> SurfaceSet; 136 typedef std::set<SurfaceId> SurfaceSet;
132 SurfaceSet referenced_surfaces_; 137 SurfaceSet referenced_surfaces_;
133 138
134 // For each Surface used in the last aggregation, gives the frame_index at 139 // For each Surface used in the last aggregation, gives the frame_index at
135 // that time. 140 // that time.
136 SurfaceIndexMap previous_contained_surfaces_; 141 SurfaceIndexMap previous_contained_surfaces_;
137 SurfaceIndexMap contained_surfaces_; 142 SurfaceIndexMap contained_surfaces_;
138 143
139 // After surface validation, every Surface in this set is valid. 144 // After surface validation, every Surface in this set is valid.
140 base::hash_set<SurfaceId> valid_surfaces_; 145 std::unordered_set<SurfaceId, SurfaceIdHash> valid_surfaces_;
141 146
142 // This is the pass list for the aggregated frame. 147 // This is the pass list for the aggregated frame.
143 RenderPassList* dest_pass_list_; 148 RenderPassList* dest_pass_list_;
144 149
145 // The root damage rect of the currently-aggregating frame. 150 // The root damage rect of the currently-aggregating frame.
146 gfx::Rect root_damage_rect_; 151 gfx::Rect root_damage_rect_;
147 152
148 // True if the frame that's currently being aggregated has copy requests. 153 // True if the frame that's currently being aggregated has copy requests.
149 // This is valid during Aggregate after PrewalkTree is called. 154 // This is valid during Aggregate after PrewalkTree is called.
150 bool has_copy_requests_; 155 bool has_copy_requests_;
151 156
152 // Resource list for the aggregated frame. 157 // Resource list for the aggregated frame.
153 TransferableResourceArray* dest_resource_list_; 158 TransferableResourceArray* dest_resource_list_;
154 159
155 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator); 160 DISALLOW_COPY_AND_ASSIGN(SurfaceAggregator);
156 }; 161 };
157 162
158 } // namespace cc 163 } // namespace cc
159 164
160 #endif // CC_SURFACES_SURFACE_AGGREGATOR_H_ 165 #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