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

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

Issue 1100713004: Reserve space in the resource ID set. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | no next file » | 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 #include "cc/surfaces/surface_aggregator.h" 5 #include "cc/surfaces/surface_aggregator.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 const DelegatedFrameData* frame_data) { 163 const DelegatedFrameData* frame_data) {
164 if (!provider_) // TODO(jamesr): hack for unit tests that don't set up rp 164 if (!provider_) // TODO(jamesr): hack for unit tests that don't set up rp
165 return false; 165 return false;
166 166
167 int child_id = ChildIdForSurface(surface); 167 int child_id = ChildIdForSurface(surface);
168 if (surface->factory()) 168 if (surface->factory())
169 surface->factory()->RefResources(frame_data->resource_list); 169 surface->factory()->RefResources(frame_data->resource_list);
170 provider_->ReceiveFromChild(child_id, frame_data->resource_list); 170 provider_->ReceiveFromChild(child_id, frame_data->resource_list);
171 171
172 ResourceProvider::ResourceIdSet referenced_resources; 172 ResourceProvider::ResourceIdSet referenced_resources;
173 size_t reserve_size =
174 std::max(static_cast<size_t>(1), frame_data->resource_list.size());
danakj 2015/04/25 17:16:44 why the Max 1?
175 #if defined(COMPILER_MSVC)
176 referenced_resources.reserve(reserve_size);
177 #elif defined(COMPILER_GCC)
178 // Pre-standard hash-tables only implement resize, which behaves similarly
danakj 2015/04/25 17:16:44 wow really? I'm surprised this is all we have in o
179 // to reserve for these keys.
180 referenced_resources.resize(reserve_size);
181 #endif
173 182
174 bool invalid_frame = false; 183 bool invalid_frame = false;
175 DrawQuad::ResourceIteratorCallback remap = 184 DrawQuad::ResourceIteratorCallback remap =
176 base::Bind(&ValidateResourceHelper, &invalid_frame, 185 base::Bind(&ValidateResourceHelper, &invalid_frame,
177 base::ConstRef(provider_->GetChildToParentMap(child_id)), 186 base::ConstRef(provider_->GetChildToParentMap(child_id)),
178 &referenced_resources); 187 &referenced_resources);
179 for (const auto& render_pass : frame_data->render_pass_list) { 188 for (const auto& render_pass : frame_data->render_pass_list) {
180 for (const auto& quad : render_pass->quad_list) 189 for (const auto& quad : render_pass->quad_list)
181 quad->IterateResources(remap); 190 quad->IterateResources(remap);
182 } 191 }
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 552
544 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) { 553 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) {
545 auto it = previous_contained_surfaces_.find(surface_id); 554 auto it = previous_contained_surfaces_.find(surface_id);
546 if (it == previous_contained_surfaces_.end()) 555 if (it == previous_contained_surfaces_.end())
547 return; 556 return;
548 // Set the last drawn index as 0 to ensure full damage next time it's drawn. 557 // Set the last drawn index as 0 to ensure full damage next time it's drawn.
549 it->second = 0; 558 it->second = 0;
550 } 559 }
551 560
552 } // namespace cc 561 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698