Index: cc/surfaces/surface_aggregator.cc |
diff --git a/cc/surfaces/surface_aggregator.cc b/cc/surfaces/surface_aggregator.cc |
index 91beec72f885805a62df73ed3cd10e7f6ca29128..a5e31ddc480f8a6f040c0b4cb7c8a3ac25e0ce35 100644 |
--- a/cc/surfaces/surface_aggregator.cc |
+++ b/cc/surfaces/surface_aggregator.cc |
@@ -144,7 +144,8 @@ |
} |
int SurfaceAggregator::ChildIdForSurface(Surface* surface) { |
- auto it = surface_id_to_resource_child_id_.find(surface->surface_id()); |
+ SurfaceToResourceChildIdMap::iterator it = |
+ surface_id_to_resource_child_id_.find(surface->surface_id()); |
if (it == surface_id_to_resource_child_id_.end()) { |
int child_id = |
provider_->CreateChild(base::Bind(&UnrefHelper, surface->factory())); |
@@ -238,7 +239,7 @@ |
return; |
} |
- referenced_surfaces_.insert(surface_id); |
+ SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |
// TODO(vmpstr): provider check is a hack for unittests that don't set up a |
// resource provider. |
ResourceProvider::ResourceIdMap empty_map; |
@@ -336,8 +337,7 @@ |
gfx::RectF(surface_quad->rect)); |
} |
- // Need to re-query since referenced_surfaces_ iterators are not stable. |
- referenced_surfaces_.erase(referenced_surfaces_.find(surface_id)); |
+ referenced_surfaces_.erase(it); |
} |
void SurfaceAggregator::AddColorConversionPass() { |
@@ -568,7 +568,8 @@ |
for (const auto& surface : previous_contained_surfaces_) { |
if (!contained_surfaces_.count(surface.first)) { |
// Release resources of removed surface. |
- auto it = surface_id_to_resource_child_id_.find(surface.first); |
+ SurfaceToResourceChildIdMap::iterator it = |
+ surface_id_to_resource_child_id_.find(surface.first); |
if (it != surface_id_to_resource_child_id_.end()) { |
provider_->DestroyChild(it->second); |
surface_id_to_resource_child_id_.erase(it); |
@@ -652,18 +653,13 @@ |
}; |
std::vector<SurfaceInfo> child_surfaces; |
- // This data is created once and typically small or empty. Collect all items |
- // and pass to a flat_vector to sort once. |
- std::vector<int> pixel_moving_background_filter_passes_data; |
+ std::unordered_set<int> pixel_moving_background_filter_passes; |
for (const auto& render_pass : frame.render_pass_list) { |
if (render_pass->background_filters.HasFilterThatMovesPixels()) { |
- pixel_moving_background_filter_passes_data.push_back( |
+ pixel_moving_background_filter_passes.insert( |
RemapPassId(render_pass->id, surface_id)); |
} |
} |
- base::flat_set<int> pixel_moving_background_filter_passes( |
- std::move(pixel_moving_background_filter_passes_data), |
- base::KEEP_FIRST_OF_DUPES); |
for (const auto& render_pass : base::Reversed(frame.render_pass_list)) { |
int remapped_pass_id = RemapPassId(render_pass->id, surface_id); |
@@ -732,7 +728,8 @@ |
// Avoid infinite recursion by adding current surface to |
// referenced_surfaces_. |
- referenced_surfaces_.insert(surface->surface_id()); |
+ SurfaceSet::iterator it = |
+ referenced_surfaces_.insert(surface->surface_id()).first; |
for (const auto& surface_info : child_surfaces) { |
gfx::Rect surface_damage = |
PrewalkTree(surface_info.id, surface_info.has_moved_pixels, |
@@ -772,7 +769,7 @@ |
} |
} |
- referenced_surfaces_.erase(referenced_surfaces_.find(surface->surface_id())); |
+ referenced_surfaces_.erase(it); |
if (!damage_rect.IsEmpty() && frame.metadata.may_contain_video) |
result->may_contain_video = true; |
return damage_rect; |
@@ -813,7 +810,7 @@ |
} |
} |
} else { |
- auto it = referenced_surfaces_.insert(surface_id).first; |
+ SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |
CopyPasses(frame, surface); |
referenced_surfaces_.erase(it); |
} |
@@ -863,7 +860,7 @@ |
frame.metadata.may_contain_video = prewalk_result.may_contain_video; |
CopyUndrawnSurfaces(&prewalk_result); |
- auto it = referenced_surfaces_.insert(surface_id).first; |
+ SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |
CopyPasses(root_surface_frame, surface); |
referenced_surfaces_.erase(it); |
AddColorConversionPass(); |
@@ -893,8 +890,10 @@ |
contained_surfaces_.swap(previous_contained_surfaces_); |
contained_surfaces_.clear(); |
- for (auto it : previous_contained_surfaces_) { |
- Surface* surface = manager_->GetSurfaceForId(it.first); |
+ for (SurfaceIndexMap::iterator it = previous_contained_surfaces_.begin(); |
+ it != previous_contained_surfaces_.end(); |
+ ++it) { |
+ Surface* surface = manager_->GetSurfaceForId(it->first); |
if (surface) |
surface->TakeLatencyInfo(&frame.metadata.latency_info); |
} |
@@ -915,7 +914,8 @@ |
} |
void SurfaceAggregator::ReleaseResources(const SurfaceId& surface_id) { |
- auto it = surface_id_to_resource_child_id_.find(surface_id); |
+ SurfaceToResourceChildIdMap::iterator it = |
+ surface_id_to_resource_child_id_.find(surface_id); |
if (it != surface_id_to_resource_child_id_.end()) { |
provider_->DestroyChild(it->second); |
surface_id_to_resource_child_id_.erase(it); |