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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 1587283002: Switch cc to std::unordered_*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@unordered-map
Patch Set: 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <limits> 11 #include <limits>
12 #include <map> 12 #include <map>
13 #include <set> 13 #include <set>
14 #include <unordered_map>
15 #include <utility>
14 16
15 #include "base/auto_reset.h" 17 #include "base/auto_reset.h"
16 #include "base/containers/hash_tables.h"
17 #include "base/containers/small_map.h" 18 #include "base/containers/small_map.h"
18 #include "base/json/json_writer.h" 19 #include "base/json/json_writer.h"
19 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
20 #include "base/numerics/safe_conversions.h" 21 #include "base/numerics/safe_conversions.h"
21 #include "base/stl_util.h" 22 #include "base/stl_util.h"
22 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
23 #include "base/trace_event/trace_event_argument.h" 24 #include "base/trace_event/trace_event_argument.h"
24 #include "cc/animation/animation_host.h" 25 #include "cc/animation/animation_host.h"
25 #include "cc/animation/animation_id_provider.h" 26 #include "cc/animation/animation_id_provider.h"
26 #include "cc/animation/scroll_offset_animation_curve.h" 27 #include "cc/animation/scroll_offset_animation_curve.h"
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 } 1179 }
1179 1180
1180 void LayerTreeHostImpl::RemoveRenderPasses(FrameData* frame) { 1181 void LayerTreeHostImpl::RemoveRenderPasses(FrameData* frame) {
1181 // There is always at least a root RenderPass. 1182 // There is always at least a root RenderPass.
1182 DCHECK_GE(frame->render_passes.size(), 1u); 1183 DCHECK_GE(frame->render_passes.size(), 1u);
1183 1184
1184 // A set of RenderPasses that we have seen. 1185 // A set of RenderPasses that we have seen.
1185 std::set<RenderPassId> pass_exists; 1186 std::set<RenderPassId> pass_exists;
1186 // A set of RenderPassDrawQuads that we have seen (stored by the RenderPasses 1187 // A set of RenderPassDrawQuads that we have seen (stored by the RenderPasses
1187 // they refer to). 1188 // they refer to).
1188 base::SmallMap<base::hash_map<RenderPassId, int>> pass_references; 1189 base::SmallMap<std::unordered_map<RenderPassId, int, RenderPassIdHash>>
1190 pass_references;
1189 1191
1190 // Iterate RenderPasses in draw order, removing empty render passes (except 1192 // Iterate RenderPasses in draw order, removing empty render passes (except
1191 // the root RenderPass). 1193 // the root RenderPass).
1192 for (size_t i = 0; i < frame->render_passes.size(); ++i) { 1194 for (size_t i = 0; i < frame->render_passes.size(); ++i) {
1193 RenderPass* pass = frame->render_passes[i].get(); 1195 RenderPass* pass = frame->render_passes[i].get();
1194 1196
1195 // Remove orphan RenderPassDrawQuads. 1197 // Remove orphan RenderPassDrawQuads.
1196 for (auto it = pass->quad_list.begin(); it != pass->quad_list.end();) { 1198 for (auto it = pass->quad_list.begin(); it != pass->quad_list.end();) {
1197 if (it->material != DrawQuad::RENDER_PASS) { 1199 if (it->material != DrawQuad::RENDER_PASS) {
1198 ++it; 1200 ++it;
(...skipping 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after
3281 } 3283 }
3282 return str; 3284 return str;
3283 } 3285 }
3284 3286
3285 void LayerTreeHostImpl::RegisterScrollbarAnimationController( 3287 void LayerTreeHostImpl::RegisterScrollbarAnimationController(
3286 int scroll_layer_id) { 3288 int scroll_layer_id) {
3287 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) 3289 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR)
3288 return; 3290 return;
3289 if (ScrollbarAnimationControllerForId(scroll_layer_id)) 3291 if (ScrollbarAnimationControllerForId(scroll_layer_id))
3290 return; 3292 return;
3291 scrollbar_animation_controllers_.add( 3293 // TODO(davidben): Is this the same as using operator[]? The check above
danakj 2016/01/14 21:12:32 You're worried for the case where the scroll_layer
davidben 2016/01/14 21:28:19 I'm worried about the case where scroll_layer_id e
danakj 2016/01/14 21:31:54 Yah it is a bit awkward. I think operator[] will b
davidben 2016/01/21 01:33:58 Done.
3294 // doesn't quite work if scroll_layer_id gets modified in
3295 // ScrollbarAnimationControllerForId.
3296 scrollbar_animation_controllers_.insert(std::make_pair(
3292 scroll_layer_id, 3297 scroll_layer_id,
3293 active_tree_->CreateScrollbarAnimationController(scroll_layer_id)); 3298 active_tree_->CreateScrollbarAnimationController(scroll_layer_id)));
3294 } 3299 }
3295 3300
3296 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( 3301 void LayerTreeHostImpl::UnregisterScrollbarAnimationController(
3297 int scroll_layer_id) { 3302 int scroll_layer_id) {
3298 scrollbar_animation_controllers_.erase(scroll_layer_id); 3303 scrollbar_animation_controllers_.erase(scroll_layer_id);
3299 } 3304 }
3300 3305
3301 ScrollbarAnimationController* 3306 ScrollbarAnimationController*
3302 LayerTreeHostImpl::ScrollbarAnimationControllerForId( 3307 LayerTreeHostImpl::ScrollbarAnimationControllerForId(
3303 int scroll_layer_id) const { 3308 int scroll_layer_id) const {
3304 if (InnerViewportScrollLayer() && OuterViewportScrollLayer() && 3309 if (InnerViewportScrollLayer() && OuterViewportScrollLayer() &&
3305 scroll_layer_id == InnerViewportScrollLayer()->id()) 3310 scroll_layer_id == InnerViewportScrollLayer()->id())
3306 scroll_layer_id = OuterViewportScrollLayer()->id(); 3311 scroll_layer_id = OuterViewportScrollLayer()->id();
3307 auto i = scrollbar_animation_controllers_.find(scroll_layer_id); 3312 auto i = scrollbar_animation_controllers_.find(scroll_layer_id);
3308 if (i == scrollbar_animation_controllers_.end()) 3313 if (i == scrollbar_animation_controllers_.end())
3309 return nullptr; 3314 return nullptr;
3310 return i->second; 3315 return i->second.get();
3311 } 3316 }
3312 3317
3313 void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask( 3318 void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask(
3314 const base::Closure& task, 3319 const base::Closure& task,
3315 base::TimeDelta delay) { 3320 base::TimeDelta delay) {
3316 client_->PostDelayedAnimationTaskOnImplThread(task, delay); 3321 client_->PostDelayedAnimationTaskOnImplThread(task, delay);
3317 } 3322 }
3318 3323
3319 // TODO(danakj): Make this a return value from the Animate() call instead of an 3324 // TODO(danakj): Make this a return value from the Animate() call instead of an
3320 // interface on LTHI. (Also, crbug.com/551138.) 3325 // interface on LTHI. (Also, crbug.com/551138.)
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
3793 return task_runner_provider_->HasImplThread(); 3798 return task_runner_provider_->HasImplThread();
3794 } 3799 }
3795 3800
3796 bool LayerTreeHostImpl::CommitToActiveTree() const { 3801 bool LayerTreeHostImpl::CommitToActiveTree() const {
3797 // In single threaded mode we skip the pending tree and commit directly to the 3802 // In single threaded mode we skip the pending tree and commit directly to the
3798 // active tree. 3803 // active tree.
3799 return !task_runner_provider_->HasImplThread(); 3804 return !task_runner_provider_->HasImplThread();
3800 } 3805 }
3801 3806
3802 } // namespace cc 3807 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698