diff options
author | davidben <davidben@chromium.org> | 2016-01-27 16:29:51 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-28 00:35:15 +0000 |
commit | 5877ffe39d049730251b7f49f890c820e26643fa (patch) | |
tree | 85afd4d3b8c30b36e911027329262a44a8ea9bc2 | |
parent | a4861dc20689e685d8d91c436c9b0a02fc248b4e (diff) | |
download | chromium_src-5877ffe39d049730251b7f49f890c820e26643fa.zip chromium_src-5877ffe39d049730251b7f49f890c820e26643fa.tar.gz chromium_src-5877ffe39d049730251b7f49f890c820e26643fa.tar.bz2 |
Switch cc to std::unordered_*.
This removes all uses of base::hash_*, BASE_HASH_NAMESPACE, and
base::ScopedPtrHashMap in favor of the C++11 versions.
BUG=576864, 579229
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1587283002
Cr-Commit-Position: refs/heads/master@{#371937}
53 files changed, 200 insertions, 211 deletions
diff --git a/cc/animation/animation_host.cc b/cc/animation/animation_host.cc index 1df11d0..cf34e38 100644 --- a/cc/animation/animation_host.cc +++ b/cc/animation/animation_host.cc @@ -225,8 +225,8 @@ void AnimationHost::RegisterPlayerForLayer(int layer_id, auto new_element_animations = ElementAnimations::Create(this); element_animations = new_element_animations.get(); - layer_to_element_animations_map_.add(layer_id, - std::move(new_element_animations)); + layer_to_element_animations_map_[layer_id] = + std::move(new_element_animations); element_animations->CreateLayerAnimationController(layer_id); } @@ -312,7 +312,7 @@ void AnimationHost::PushPropertiesToImplThread(AnimationHost* host_impl) { // Secondly, sync properties for created layer animation controllers. for (auto& kv : layer_to_element_animations_map_) { - ElementAnimations* element_animations = kv.second; + ElementAnimations* element_animations = kv.second.get(); ElementAnimations* element_animations_impl = host_impl->GetElementAnimationsForLayerId(kv.first); if (element_animations_impl) @@ -335,7 +335,7 @@ ElementAnimations* AnimationHost::GetElementAnimationsForLayerId( DCHECK(layer_id); auto iter = layer_to_element_animations_map_.find(layer_id); return iter == layer_to_element_animations_map_.end() ? nullptr - : iter->second; + : iter->second.get(); } void AnimationHost::SetSupportsScrollAnimations( diff --git a/cc/animation/animation_host.h b/cc/animation/animation_host.h index 1bec4ec0..2cddf6a 100644 --- a/cc/animation/animation_host.h +++ b/cc/animation/animation_host.h @@ -5,9 +5,9 @@ #ifndef CC_ANIMATION_ANIMATION_HOST_H_ #define CC_ANIMATION_ANIMATION_HOST_H_ +#include <unordered_map> #include <vector> -#include "base/containers/scoped_ptr_hash_map.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -167,8 +167,8 @@ class CC_EXPORT AnimationHost { // TODO(loyso): For now AnimationPlayers share LayerAnimationController object // if they are attached to the same element(layer). Note that Element can // contain many Layers. - typedef base::ScopedPtrHashMap<int, scoped_ptr<ElementAnimations>> - LayerToElementAnimationsMap; + using LayerToElementAnimationsMap = + std::unordered_map<int, scoped_ptr<ElementAnimations>>; LayerToElementAnimationsMap layer_to_element_animations_map_; AnimationTimelineList timelines_; diff --git a/cc/animation/animation_registrar.h b/cc/animation/animation_registrar.h index 45e49ef..bc14330 100644 --- a/cc/animation/animation_registrar.h +++ b/cc/animation/animation_registrar.h @@ -5,7 +5,8 @@ #ifndef CC_ANIMATION_ANIMATION_REGISTRAR_H_ #define CC_ANIMATION_ANIMATION_REGISTRAR_H_ -#include "base/containers/hash_tables.h" +#include <unordered_map> + #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -19,7 +20,8 @@ class LayerAnimationController; class CC_EXPORT AnimationRegistrar { public: - typedef base::hash_map<int, LayerAnimationController*> AnimationControllerMap; + using AnimationControllerMap = + std::unordered_map<int, LayerAnimationController*>; static scoped_ptr<AnimationRegistrar> Create() { return make_scoped_ptr(new AnimationRegistrar()); diff --git a/cc/animation/animation_timeline.h b/cc/animation/animation_timeline.h index 6100b44..64222d3 100644 --- a/cc/animation/animation_timeline.h +++ b/cc/animation/animation_timeline.h @@ -7,7 +7,6 @@ #include <vector> -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" diff --git a/cc/animation/layer_animation_controller.h b/cc/animation/layer_animation_controller.h index 9d92017..70c76d10 100644 --- a/cc/animation/layer_animation_controller.h +++ b/cc/animation/layer_animation_controller.h @@ -5,9 +5,9 @@ #ifndef CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ #define CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ +#include <unordered_set> #include <vector> -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -175,7 +175,7 @@ class CC_EXPORT LayerAnimationController virtual ~LayerAnimationController(); private: - typedef base::hash_set<int> TargetProperties; + using TargetProperties = std::unordered_set<int>; void PushNewAnimationsToImplThread( LayerAnimationController* controller_impl) const; diff --git a/cc/debug/frame_timing_tracker.h b/cc/debug/frame_timing_tracker.h index 5341b6a..117a1f9 100644 --- a/cc/debug/frame_timing_tracker.h +++ b/cc/debug/frame_timing_tracker.h @@ -7,10 +7,10 @@ #include <stdint.h> +#include <unordered_map> #include <utility> #include <vector> -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/time/time.h" @@ -35,7 +35,7 @@ class CC_EXPORT FrameTimingTracker { }; using CompositeTimingSet = - base::hash_map<int64_t, std::vector<CompositeTimingEvent>>; + std::unordered_map<int64_t, std::vector<CompositeTimingEvent>>; struct CC_EXPORT MainFrameTimingEvent { MainFrameTimingEvent(int frame_id, @@ -49,7 +49,7 @@ class CC_EXPORT FrameTimingTracker { }; using MainFrameTimingSet = - base::hash_map<int64_t, std::vector<MainFrameTimingEvent>>; + std::unordered_map<int64_t, std::vector<MainFrameTimingEvent>>; static scoped_ptr<FrameTimingTracker> Create( LayerTreeHostImpl* layer_tree_host_impl); diff --git a/cc/layers/delegated_frame_resource_collection.h b/cc/layers/delegated_frame_resource_collection.h index 0e38c68..e7b996b 100644 --- a/cc/layers/delegated_frame_resource_collection.h +++ b/cc/layers/delegated_frame_resource_collection.h @@ -5,7 +5,8 @@ #ifndef CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_ #define CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_ -#include "base/containers/hash_tables.h" +#include <unordered_map> + #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" @@ -56,7 +57,7 @@ class CC_EXPORT DelegatedFrameResourceCollection int refs_to_return; int refs_to_wait_for; }; - typedef base::hash_map<unsigned, RefCount> ResourceIdRefCountMap; + using ResourceIdRefCountMap = std::unordered_map<unsigned, RefCount>; ResourceIdRefCountMap resource_id_ref_count_map_; base::ThreadChecker main_thread_checker_; diff --git a/cc/layers/delegated_renderer_layer.h b/cc/layers/delegated_renderer_layer.h index b71b6ee..601cf4f 100644 --- a/cc/layers/delegated_renderer_layer.h +++ b/cc/layers/delegated_renderer_layer.h @@ -5,7 +5,6 @@ #ifndef CC_LAYERS_DELEGATED_RENDERER_LAYER_H_ #define CC_LAYERS_DELEGATED_RENDERER_LAYER_H_ -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" diff --git a/cc/layers/delegated_renderer_layer_impl.cc b/cc/layers/delegated_renderer_layer_impl.cc index 8158edcf..35806cc 100644 --- a/cc/layers/delegated_renderer_layer_impl.cc +++ b/cc/layers/delegated_renderer_layer_impl.cc @@ -11,7 +11,6 @@ #include <utility> #include "base/bind.h" -#include "base/containers/hash_tables.h" #include "cc/base/math_util.h" #include "cc/layers/append_quads_data.h" #include "cc/layers/render_pass_sink.h" diff --git a/cc/layers/delegated_renderer_layer_impl.h b/cc/layers/delegated_renderer_layer_impl.h index 0ca13eb..f5e4239 100644 --- a/cc/layers/delegated_renderer_layer_impl.h +++ b/cc/layers/delegated_renderer_layer_impl.h @@ -7,11 +7,13 @@ #include <stddef.h> -#include "base/containers/hash_tables.h" +#include <unordered_map> + #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "cc/base/cc_export.h" #include "cc/layers/layer_impl.h" +#include "cc/quads/render_pass_id.h" namespace cc { class DelegatedFrameData; @@ -90,7 +92,8 @@ class CC_EXPORT DelegatedRendererLayerImpl : public LayerImpl { float inverse_device_scale_factor_; RenderPassList render_passes_in_draw_order_; - using RenderPassToIndexMap = base::hash_map<RenderPassId, size_t>; + using RenderPassToIndexMap = + std::unordered_map<RenderPassId, size_t, RenderPassIdHash>; RenderPassToIndexMap render_passes_index_by_id_; ResourceProvider::ResourceIdSet resources_; diff --git a/cc/layers/layer.h b/cc/layers/layer.h index afc6dc3..eed959649 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -10,6 +10,7 @@ #include <set> #include <string> +#include <unordered_map> #include <vector> #include "base/callback.h" @@ -83,8 +84,8 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, public LayerAnimationValueObserver, public LayerAnimationValueProvider { public: - typedef LayerList LayerListType; - typedef base::hash_map<int, scoped_refptr<Layer>> LayerIdMap; + using LayerListType = LayerList; + using LayerIdMap = std::unordered_map<int, scoped_refptr<Layer>>; enum LayerIdLabels { INVALID_ID = -1, diff --git a/cc/layers/layer_proto_converter.h b/cc/layers/layer_proto_converter.h index f821a5d..94afcb9 100644 --- a/cc/layers/layer_proto_converter.h +++ b/cc/layers/layer_proto_converter.h @@ -5,6 +5,8 @@ #ifndef CC_LAYERS_LAYER_PROTO_CONVERTER_H_ #define CC_LAYERS_LAYER_PROTO_CONVERTER_H_ +#include <unordered_map> + #include "base/macros.h" #include "cc/base/cc_export.h" #include "cc/layers/layer.h" @@ -64,7 +66,7 @@ class CC_EXPORT LayerProtoConverter { Layer* root_layer, proto::LayerUpdate* layer_update); - using LayerIdMap = base::hash_map<int, scoped_refptr<Layer>>; + using LayerIdMap = std::unordered_map<int, scoped_refptr<Layer>>; // Start at |layer| and recursively add |layer| and all its children and // special layers to |layer_id_map|. static void RecursivelyFindAllLayers(const scoped_refptr<Layer>& layer, diff --git a/cc/layers/nine_patch_layer_impl_unittest.cc b/cc/layers/nine_patch_layer_impl_unittest.cc index 13c409e..2dbc6832 100644 --- a/cc/layers/nine_patch_layer_impl_unittest.cc +++ b/cc/layers/nine_patch_layer_impl_unittest.cc @@ -4,7 +4,6 @@ #include <stddef.h> -#include "base/containers/hash_tables.h" #include "cc/layers/append_quads_data.h" #include "cc/layers/nine_patch_layer_impl.h" #include "cc/quads/texture_draw_quad.h" diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc index 111bae75..eb885c0 100644 --- a/cc/layers/scrollbar_layer_unittest.cc +++ b/cc/layers/scrollbar_layer_unittest.cc @@ -4,7 +4,8 @@ #include <stddef.h> -#include "base/containers/hash_tables.h" +#include <unordered_map> + #include "base/thread_task_runner_handle.h" #include "cc/animation/scrollbar_animation_controller.h" #include "cc/layers/append_quads_data.h" @@ -109,7 +110,8 @@ class FakeResourceTrackingLayerTreeHost : public FakeLayerTreeHost { } private: - using UIResourceBitmapMap = base::hash_map<UIResourceId, UIResourceBitmap>; + using UIResourceBitmapMap = + std::unordered_map<UIResourceId, UIResourceBitmap>; UIResourceBitmapMap ui_resource_bitmap_map_; int next_id_; diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc index 55a4770..b075a3d 100644 --- a/cc/output/direct_renderer.cc +++ b/cc/output/direct_renderer.cc @@ -6,11 +6,10 @@ #include <stddef.h> +#include <unordered_map> #include <utility> #include <vector> -#include "base/containers/hash_tables.h" -#include "base/containers/scoped_ptr_hash_map.h" #include "base/metrics/histogram.h" #include "base/numerics/safe_conversions.h" #include "base/trace_event/trace_event.h" @@ -149,7 +148,8 @@ void DirectRenderer::SetEnlargePassTextureAmountForTesting( void DirectRenderer::DecideRenderPassAllocationsForFrame( const RenderPassList& render_passes_in_draw_order) { - base::hash_map<RenderPassId, gfx::Size> render_passes_in_frame; + std::unordered_map<RenderPassId, gfx::Size, RenderPassIdHash> + render_passes_in_frame; for (size_t i = 0; i < render_passes_in_draw_order.size(); ++i) render_passes_in_frame.insert(std::pair<RenderPassId, gfx::Size>( render_passes_in_draw_order[i]->id, @@ -158,15 +158,14 @@ void DirectRenderer::DecideRenderPassAllocationsForFrame( std::vector<RenderPassId> passes_to_delete; for (auto pass_iter = render_pass_textures_.begin(); pass_iter != render_pass_textures_.end(); ++pass_iter) { - base::hash_map<RenderPassId, gfx::Size>::const_iterator it = - render_passes_in_frame.find(pass_iter->first); + auto it = render_passes_in_frame.find(pass_iter->first); if (it == render_passes_in_frame.end()) { passes_to_delete.push_back(pass_iter->first); continue; } gfx::Size required_size = it->second; - ScopedResource* texture = pass_iter->second; + ScopedResource* texture = pass_iter->second.get(); DCHECK(texture); bool size_appropriate = texture->size().width() >= required_size.width() && @@ -181,11 +180,11 @@ void DirectRenderer::DecideRenderPassAllocationsForFrame( render_pass_textures_.erase(passes_to_delete[i]); for (size_t i = 0; i < render_passes_in_draw_order.size(); ++i) { - if (!render_pass_textures_.contains(render_passes_in_draw_order[i]->id)) { + if (render_pass_textures_.count(render_passes_in_draw_order[i]->id) == 0) { scoped_ptr<ScopedResource> texture = ScopedResource::Create(resource_provider_); - render_pass_textures_.set(render_passes_in_draw_order[i]->id, - std::move(texture)); + render_pass_textures_[render_passes_in_draw_order[i]->id] = + std::move(texture); } } } @@ -534,7 +533,7 @@ bool DirectRenderer::UseRenderPass(DrawingFrame* frame, return true; } - ScopedResource* texture = render_pass_textures_.get(render_pass->id); + ScopedResource* texture = render_pass_textures_[render_pass->id].get(); DCHECK(texture); gfx::Size size = RenderPassTextureSize(render_pass); @@ -558,8 +557,8 @@ bool DirectRenderer::UseRenderPass(DrawingFrame* frame, } bool DirectRenderer::HasAllocatedResourcesForTesting(RenderPassId id) const { - ScopedResource* texture = render_pass_textures_.get(id); - return texture && texture->id(); + auto iter = render_pass_textures_.find(id); + return iter != render_pass_textures_.end() && iter->second->id(); } // static diff --git a/cc/output/direct_renderer.h b/cc/output/direct_renderer.h index 2f6736f..0d032f1 100644 --- a/cc/output/direct_renderer.h +++ b/cc/output/direct_renderer.h @@ -5,8 +5,9 @@ #ifndef CC_OUTPUT_DIRECT_RENDERER_H_ #define CC_OUTPUT_DIRECT_RENDERER_H_ +#include <unordered_map> + #include "base/callback.h" -#include "base/containers/scoped_ptr_hash_map.h" #include "base/macros.h" #include "cc/base/cc_export.h" #include "cc/output/ca_layer_overlay.h" @@ -18,7 +19,6 @@ #include "ui/gfx/geometry/quad_f.h" namespace cc { - class DrawPolygon; class ResourceProvider; @@ -141,7 +141,7 @@ class CC_EXPORT DirectRenderer : public Renderer { scoped_ptr<CopyOutputRequest> request) = 0; // TODO(danakj): Just use a vector of pairs here? Hash map is way overkill. - base::ScopedPtrHashMap<RenderPassId, scoped_ptr<ScopedResource>> + std::unordered_map<RenderPassId, scoped_ptr<ScopedResource>, RenderPassIdHash> render_pass_textures_; OutputSurface* output_surface_; ResourceProvider* resource_provider_; diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 77b09c4..ba75b23 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -866,7 +866,7 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, const RenderPassDrawQuad* quad, const gfx::QuadF* clip_region) { ScopedResource* contents_texture = - render_pass_textures_.get(quad->render_pass_id); + render_pass_textures_[quad->render_pass_id].get(); DCHECK(contents_texture); DCHECK(contents_texture->id()); diff --git a/cc/output/software_renderer.cc b/cc/output/software_renderer.cc index f08aa08..8e23961 100644 --- a/cc/output/software_renderer.cc +++ b/cc/output/software_renderer.cc @@ -468,7 +468,7 @@ void SoftwareRenderer::DrawTileQuad(const DrawingFrame* frame, void SoftwareRenderer::DrawRenderPassQuad(const DrawingFrame* frame, const RenderPassDrawQuad* quad) { ScopedResource* content_texture = - render_pass_textures_.get(quad->render_pass_id); + render_pass_textures_[quad->render_pass_id].get(); DCHECK(content_texture); DCHECK(content_texture->id()); DCHECK(IsSoftwareResource(content_texture->id())); diff --git a/cc/quads/render_pass.h b/cc/quads/render_pass.h index 552643d..3f7775d 100644 --- a/cc/quads/render_pass.h +++ b/cc/quads/render_pass.h @@ -7,11 +7,11 @@ #include <stddef.h> +#include <unordered_map> #include <utility> #include <vector> #include "base/callback.h" -#include "base/containers/hash_tables.h" #include "base/hash.h" #include "base/macros.h" #include "cc/base/cc_export.h" @@ -134,20 +134,10 @@ class CC_EXPORT RenderPass { DISALLOW_COPY_AND_ASSIGN(RenderPass); }; -} // namespace cc +using RenderPassList = std::vector<scoped_ptr<RenderPass>>; +using RenderPassIdHashMap = + std::unordered_map<RenderPassId, RenderPass*, RenderPassIdHash>; -namespace BASE_HASH_NAMESPACE { -template <> -struct hash<cc::RenderPassId> { - size_t operator()(cc::RenderPassId key) const { - return base::HashInts(key.layer_id, static_cast<int>(key.index)); - } -}; -} // namespace BASE_HASH_NAMESPACE - -namespace cc { -typedef std::vector<scoped_ptr<RenderPass>> RenderPassList; -typedef base::hash_map<RenderPassId, RenderPass*> RenderPassIdHashMap; } // namespace cc #endif // CC_QUADS_RENDER_PASS_H_ diff --git a/cc/quads/render_pass_id.h b/cc/quads/render_pass_id.h index 5dff1e1..a0d48ea 100644 --- a/cc/quads/render_pass_id.h +++ b/cc/quads/render_pass_id.h @@ -9,6 +9,7 @@ #include <tuple> +#include "base/hash.h" #include "cc/base/cc_export.h" namespace cc { @@ -33,6 +34,12 @@ class CC_EXPORT RenderPassId { } }; +struct RenderPassIdHash { + size_t operator()(RenderPassId key) const { + return base::HashInts(key.layer_id, static_cast<int>(key.index)); + } +}; + } // namespace cc #endif // CC_QUADS_RENDER_PASS_ID_H_ diff --git a/cc/raster/task_graph_runner.cc b/cc/raster/task_graph_runner.cc index 4704e52..ad5aaff 100644 --- a/cc/raster/task_graph_runner.cc +++ b/cc/raster/task_graph_runner.cc @@ -8,7 +8,6 @@ #include <utility> #include "base/atomic_sequence_num.h" -#include "base/containers/hash_tables.h" #include "base/threading/thread_restrictions.h" #include "base/trace_event/trace_event.h" diff --git a/cc/raster/task_graph_work_queue.cc b/cc/raster/task_graph_work_queue.cc index 8780057..2947402 100644 --- a/cc/raster/task_graph_work_queue.cc +++ b/cc/raster/task_graph_work_queue.cc @@ -9,6 +9,7 @@ #include <algorithm> #include <map> +#include <unordered_map> #include <utility> #include "base/trace_event/trace_event.h" @@ -283,7 +284,7 @@ void TaskGraphWorkQueue::CollectCompletedTasks(NamespaceToken token, bool TaskGraphWorkQueue::DependencyMismatch(const TaskGraph* graph) { // Value storage will be 0-initialized. - base::hash_map<const Task*, size_t> dependents; + std::unordered_map<const Task*, size_t> dependents; for (const TaskGraph::Edge& edge : graph->edges) dependents[edge.dependent]++; diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index 66a68fa..a955e4cc 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -9,9 +9,9 @@ #include <algorithm> #include <limits> +#include <unordered_map> #include "base/atomic_sequence_num.h" -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/metrics/histogram.h" #include "base/numerics/safe_math.h" @@ -1281,7 +1281,7 @@ void ResourceProvider::ReceiveReturnsFromParent( DCHECK(thread_checker_.CalledOnValidThread()); GLES2Interface* gl = ContextGL(); - base::hash_map<int, ResourceIdArray> resources_for_child; + std::unordered_map<int, ResourceIdArray> resources_for_child; for (const ReturnedResource& returned : resources) { ResourceId local_id = returned.id; diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h index 1aed50f..5ba24e7 100644 --- a/cc/resources/resource_provider.h +++ b/cc/resources/resource_provider.h @@ -11,11 +11,12 @@ #include <deque> #include <set> #include <string> +#include <unordered_map> +#include <unordered_set> #include <utility> #include <vector> #include "base/callback.h" -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/linked_ptr.h" #include "base/memory/scoped_ptr.h" @@ -68,9 +69,9 @@ class CC_EXPORT ResourceProvider struct Resource; public: - typedef std::vector<ResourceId> ResourceIdArray; - typedef base::hash_set<ResourceId> ResourceIdSet; - typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap; + using ResourceIdArray = std::vector<ResourceId>; + using ResourceIdSet = std::unordered_set<ResourceId>; + using ResourceIdMap = std::unordered_map<ResourceId, ResourceId>; enum TextureHint { TEXTURE_HINT_DEFAULT = 0x0, TEXTURE_HINT_IMMUTABLE = 0x1, @@ -501,7 +502,7 @@ class CC_EXPORT ResourceProvider SharedBitmap* shared_bitmap; gfx::GpuMemoryBuffer* gpu_memory_buffer; }; - typedef base::hash_map<ResourceId, Resource> ResourceMap; + using ResourceMap = std::unordered_map<ResourceId, Resource>; struct Child { Child(); @@ -513,7 +514,7 @@ class CC_EXPORT ResourceProvider bool marked_for_deletion; bool needs_sync_tokens; }; - typedef base::hash_map<int, Child> ChildMap; + using ChildMap = std::unordered_map<int, Child>; bool ReadLockFenceHasPassed(const Resource* resource) { return !resource->read_lock_fence.get() || diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc index 5fa1baa..abee5c2 100644 --- a/cc/resources/resource_provider_unittest.cc +++ b/cc/resources/resource_provider_unittest.cc @@ -11,10 +11,10 @@ #include <deque> #include <map> #include <set> +#include <unordered_map> #include <vector> #include "base/bind.h" -#include "base/containers/hash_tables.h" #include "base/logging.h" #include "base/memory/ref_counted.h" #include "cc/output/output_surface.h" @@ -181,9 +181,9 @@ class ContextSharedData { uint64_t next_fence_sync_; unsigned next_mailbox_; - typedef base::hash_map<unsigned, scoped_refptr<TestTexture>> TextureMap; + using TextureMap = std::unordered_map<unsigned, scoped_refptr<TestTexture>>; TextureMap textures_; - base::hash_map<unsigned, uint32_t> sync_point_for_mailbox_; + std::unordered_map<unsigned, uint32_t> sync_point_for_mailbox_; }; class ResourceProviderContext : public TestWebGraphicsContext3D { diff --git a/cc/surfaces/surface.cc b/cc/surfaces/surface.cc index b60a64f..6a96230 100644 --- a/cc/surfaces/surface.cc +++ b/cc/surfaces/surface.cc @@ -166,8 +166,8 @@ void Surface::AddDestructionDependency(SurfaceSequence sequence) { } void Surface::SatisfyDestructionDependencies( - base::hash_set<SurfaceSequence>* sequences, - base::hash_set<uint32_t>* valid_id_namespaces) { + std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences, + std::unordered_set<uint32_t>* valid_id_namespaces) { destruction_dependencies_.erase( std::remove_if(destruction_dependencies_.begin(), destruction_dependencies_.end(), diff --git a/cc/surfaces/surface.h b/cc/surfaces/surface.h index a83aee3..97706eb 100644 --- a/cc/surfaces/surface.h +++ b/cc/surfaces/surface.h @@ -10,10 +10,10 @@ #include <map> #include <set> +#include <unordered_set> #include <vector> #include "base/callback.h" -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" @@ -71,8 +71,8 @@ class CC_SURFACES_EXPORT Surface { // Satisfy all destruction dependencies that are contained in sequences, and // remove them from sequences. void SatisfyDestructionDependencies( - base::hash_set<SurfaceSequence>* sequences, - base::hash_set<uint32_t>* valid_id_namespaces); + std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences, + std::unordered_set<uint32_t>* valid_id_namespaces); size_t GetDestructionDependencyCount() const { return destruction_dependencies_.size(); } diff --git a/cc/surfaces/surface_aggregator.cc b/cc/surfaces/surface_aggregator.cc index a25fdce..0ef30d8 100644 --- a/cc/surfaces/surface_aggregator.cc +++ b/cc/surfaces/surface_aggregator.cc @@ -9,7 +9,6 @@ #include <map> #include "base/bind.h" -#include "base/containers/hash_tables.h" #include "base/logging.h" #include "base/macros.h" #include "base/stl_util.h" @@ -107,7 +106,7 @@ class SurfaceAggregator::RenderPassIdAllocator { } private: - base::hash_map<RenderPassId, int> id_to_index_map_; + std::unordered_map<RenderPassId, int, RenderPassIdHash> id_to_index_map_; int* next_index_; DISALLOW_COPY_AND_ASSIGN(RenderPassIdAllocator); diff --git a/cc/surfaces/surface_aggregator.h b/cc/surfaces/surface_aggregator.h index c280758..b5a7fb9 100644 --- a/cc/surfaces/surface_aggregator.h +++ b/cc/surfaces/surface_aggregator.h @@ -9,8 +9,6 @@ #include <unordered_map> #include <unordered_set> -#include "base/containers/hash_tables.h" -#include "base/containers/scoped_ptr_hash_map.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "cc/quads/draw_quad.h" @@ -90,7 +88,7 @@ class CC_SURFACES_EXPORT SurfaceAggregator { void CopyQuadsToPass( const QuadList& source_quad_list, const SharedQuadStateList& source_shared_quad_state_list, - const base::hash_map<ResourceId, ResourceId>& resource_to_child_map, + const std::unordered_map<ResourceId, ResourceId>& resource_to_child_map, const gfx::Transform& target_transform, const ClipData& clip_rect, RenderPass* dest_pass, @@ -133,7 +131,7 @@ class CC_SURFACES_EXPORT SurfaceAggregator { // This is the set of surfaces referenced in the aggregation so far, used to // detect cycles. - typedef std::set<SurfaceId> SurfaceSet; + using SurfaceSet = std::set<SurfaceId>; SurfaceSet referenced_surfaces_; // For each Surface used in the last aggregation, gives the frame_index at diff --git a/cc/surfaces/surface_factory.cc b/cc/surfaces/surface_factory.cc index 79cb096..a45c809 100644 --- a/cc/surfaces/surface_factory.cc +++ b/cc/surfaces/surface_factory.cc @@ -4,6 +4,8 @@ #include "cc/surfaces/surface_factory.h" +#include <utility> + #include "base/trace_event/trace_event.h" #include "cc/output/compositor_frame.h" #include "cc/output/copy_output_request.h" diff --git a/cc/surfaces/surface_factory.h b/cc/surfaces/surface_factory.h index cd8a0e3..1fcb3f1 100644 --- a/cc/surfaces/surface_factory.h +++ b/cc/surfaces/surface_factory.h @@ -9,7 +9,6 @@ #include <unordered_map> #include "base/callback_forward.h" -#include "base/containers/scoped_ptr_hash_map.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" diff --git a/cc/surfaces/surface_id.h b/cc/surfaces/surface_id.h index 4472c69..c0c4410 100644 --- a/cc/surfaces/surface_id.h +++ b/cc/surfaces/surface_id.h @@ -10,8 +10,6 @@ #include <functional> -#include "base/containers/hash_tables.h" - namespace cc { struct SurfaceId { diff --git a/cc/surfaces/surface_manager.h b/cc/surfaces/surface_manager.h index d4fc144..a3f7b9b 100644 --- a/cc/surfaces/surface_manager.h +++ b/cc/surfaces/surface_manager.h @@ -9,9 +9,9 @@ #include <list> #include <unordered_map> +#include <unordered_set> #include <vector> -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/observer_list.h" #include "base/threading/thread_checker.h" @@ -73,12 +73,12 @@ class CC_SURFACES_EXPORT SurfaceManager { // Set of SurfaceSequences that have been satisfied by a frame but not yet // waited on. - base::hash_set<SurfaceSequence> satisfied_sequences_; + std::unordered_set<SurfaceSequence, SurfaceSequenceHash> satisfied_sequences_; // Set of valid surface ID namespaces. When a namespace is removed from // this set, any remaining sequences with that namespace are considered // satisfied. - base::hash_set<uint32_t> valid_surface_id_namespaces_; + std::unordered_set<uint32_t> valid_surface_id_namespaces_; DISALLOW_COPY_AND_ASSIGN(SurfaceManager); }; diff --git a/cc/surfaces/surface_resource_holder.h b/cc/surfaces/surface_resource_holder.h index 95cdb82..3cf5881 100644 --- a/cc/surfaces/surface_resource_holder.h +++ b/cc/surfaces/surface_resource_holder.h @@ -5,7 +5,8 @@ #ifndef CC_SURFACES_SURFACE_RESOURCE_HOLDER_H_ #define CC_SURFACES_SURFACE_RESOURCE_HOLDER_H_ -#include "base/containers/hash_tables.h" +#include <unordered_map> + #include "base/macros.h" #include "cc/base/resource_id.h" #include "cc/resources/returned_resource.h" @@ -40,7 +41,7 @@ class CC_SURFACES_EXPORT SurfaceResourceHolder { // Keeps track of the number of users currently in flight for each resource // ID we've received from the client. When this counter hits zero for a // particular resource, that ID is available to return to the client. - typedef base::hash_map<ResourceId, ResourceRefs> ResourceIdCountMap; + using ResourceIdCountMap = std::unordered_map<ResourceId, ResourceRefs>; ResourceIdCountMap resource_id_use_count_map_; DISALLOW_COPY_AND_ASSIGN(SurfaceResourceHolder); diff --git a/cc/surfaces/surface_sequence.h b/cc/surfaces/surface_sequence.h index b4ab8ef..9027ea1 100644 --- a/cc/surfaces/surface_sequence.h +++ b/cc/surfaces/surface_sequence.h @@ -10,7 +10,6 @@ #include <tuple> -#include "base/containers/hash_tables.h" #include "base/hash.h" namespace cc { @@ -41,15 +40,12 @@ inline bool operator<(const SurfaceSequence& a, const SurfaceSequence& b) { std::tie(b.id_namespace, b.sequence); } -} // namespace cc - -namespace BASE_HASH_NAMESPACE { -template <> -struct hash<cc::SurfaceSequence> { - size_t operator()(cc::SurfaceSequence key) const { +struct SurfaceSequenceHash { + size_t operator()(SurfaceSequence key) const { return base::HashInts(key.id_namespace, key.sequence); } }; -} // namespace BASE_HASH_NAMESPACE + +} // namespace cc #endif // CC_SURFACES_SURFACE_SEQUENCE_H_ diff --git a/cc/test/animation_timelines_test_common.cc b/cc/test/animation_timelines_test_common.cc index 46d9d53..d3b80f6 100644 --- a/cc/test/animation_timelines_test_common.cc +++ b/cc/test/animation_timelines_test_common.cc @@ -111,7 +111,7 @@ void TestHostClient::RegisterLayer(int layer_id, LayerTreeType tree_type) { ? layers_in_active_tree_ : layers_in_pending_tree_; DCHECK(layers_in_tree.find(layer_id) == layers_in_tree.end()); - layers_in_tree.add(layer_id, TestLayer::Create()); + layers_in_tree[layer_id] = TestLayer::Create(); DCHECK(host_); host_->RegisterLayer(layer_id, tree_type); @@ -171,7 +171,7 @@ TestLayer* TestHostClient::FindTestLayer(int layer_id, auto kv = layers_in_tree.find(layer_id); DCHECK(kv != layers_in_tree.end()); DCHECK(kv->second); - return kv->second; + return kv->second.get(); } TestAnimationDelegate::TestAnimationDelegate() diff --git a/cc/test/animation_timelines_test_common.h b/cc/test/animation_timelines_test_common.h index 1733ca8..2f1388e 100644 --- a/cc/test/animation_timelines_test_common.h +++ b/cc/test/animation_timelines_test_common.h @@ -5,7 +5,8 @@ #ifndef CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ #define CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_ -#include "base/containers/scoped_ptr_hash_map.h" +#include <unordered_map> + #include "base/memory/scoped_ptr.h" #include "cc/animation/animation.h" #include "cc/animation/animation_delegate.h" @@ -134,7 +135,7 @@ class TestHostClient : public MutatorHostClient { private: scoped_ptr<AnimationHost> host_; - typedef base::ScopedPtrHashMap<int, scoped_ptr<TestLayer>> LayerIdToTestLayer; + using LayerIdToTestLayer = std::unordered_map<int, scoped_ptr<TestLayer>>; LayerIdToTestLayer layers_in_active_tree_; LayerIdToTestLayer layers_in_pending_tree_; diff --git a/cc/test/fake_ui_resource_layer_tree_host_impl.h b/cc/test/fake_ui_resource_layer_tree_host_impl.h index 7db2ff0..be58cbd 100644 --- a/cc/test/fake_ui_resource_layer_tree_host_impl.h +++ b/cc/test/fake_ui_resource_layer_tree_host_impl.h @@ -5,7 +5,8 @@ #ifndef CC_TEST_FAKE_UI_RESOURCE_LAYER_TREE_HOST_IMPL_H_ #define CC_TEST_FAKE_UI_RESOURCE_LAYER_TREE_HOST_IMPL_H_ -#include "base/containers/hash_tables.h" +#include <unordered_map> + #include "cc/test/fake_layer_tree_host_impl.h" namespace cc { @@ -29,8 +30,8 @@ class FakeUIResourceLayerTreeHostImpl : public FakeLayerTreeHostImpl { bool IsUIResourceOpaque(UIResourceId uid) const override; private: - typedef base::hash_map<UIResourceId, LayerTreeHostImpl::UIResourceData> - UIResourceMap; + using UIResourceMap = + std::unordered_map<UIResourceId, LayerTreeHostImpl::UIResourceData>; UIResourceMap fake_ui_resource_map_; }; diff --git a/cc/test/ordered_texture_map.h b/cc/test/ordered_texture_map.h index 8b2a6ca..814c597 100644 --- a/cc/test/ordered_texture_map.h +++ b/cc/test/ordered_texture_map.h @@ -7,9 +7,9 @@ #include <stddef.h> +#include <unordered_map> #include <vector> -#include "base/containers/hash_tables.h" #include "base/memory/ref_counted.h" #include "third_party/khronos/GLES2/gl2.h" @@ -34,8 +34,8 @@ class OrderedTextureMap { GLuint IdAt(size_t index); private: - typedef base::hash_map<GLuint, scoped_refptr<TestTexture>> TextureMap; - typedef std::vector<GLuint> TextureList; + using TextureMap = std::unordered_map<GLuint, scoped_refptr<TestTexture>>; + using TextureList = std::vector<GLuint>; TextureMap textures_; TextureList ordered_textures_; diff --git a/cc/test/test_texture.h b/cc/test/test_texture.h index c5b6e21..6661aed 100644 --- a/cc/test/test_texture.h +++ b/cc/test/test_texture.h @@ -8,7 +8,8 @@ #include <stddef.h> #include <stdint.h> -#include "base/containers/hash_tables.h" +#include <unordered_map> + #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "cc/resources/resource_format.h" @@ -29,8 +30,7 @@ struct TestTexture : public base::RefCounted<TestTexture> { ResourceFormat format; scoped_ptr<uint8_t[]> data; - typedef base::hash_map<GLenum, GLint> - TextureParametersMap; + using TextureParametersMap = std::unordered_map<GLenum, GLint>; TextureParametersMap params; private: diff --git a/cc/test/test_web_graphics_context_3d.cc b/cc/test/test_web_graphics_context_3d.cc index 41f3eb0..6375492 100644 --- a/cc/test/test_web_graphics_context_3d.cc +++ b/cc/test/test_web_graphics_context_3d.cc @@ -526,12 +526,12 @@ void TestWebGraphicsContext3D::bindBuffer(GLenum target, DCHECK_LT(buffer_id, namespace_->next_buffer_id); DCHECK_EQ(context_id, context_id_); - base::ScopedPtrHashMap<unsigned, scoped_ptr<Buffer>>& buffers = + std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers = namespace_->buffers; if (buffers.count(bound_buffer_) == 0) - buffers.set(bound_buffer_, make_scoped_ptr(new Buffer)); + buffers[bound_buffer_] = make_scoped_ptr(new Buffer); - buffers.get(bound_buffer_)->target = target; + buffers[bound_buffer_]->target = target; } void TestWebGraphicsContext3D::bufferData(GLenum target, @@ -539,11 +539,11 @@ void TestWebGraphicsContext3D::bufferData(GLenum target, const void* data, GLenum usage) { base::AutoLock lock(namespace_->lock); - base::ScopedPtrHashMap<unsigned, scoped_ptr<Buffer>>& buffers = + std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers = namespace_->buffers; DCHECK_GT(buffers.count(bound_buffer_), 0u); - DCHECK_EQ(target, buffers.get(bound_buffer_)->target); - Buffer* buffer = buffers.get(bound_buffer_); + DCHECK_EQ(target, buffers[bound_buffer_]->target); + Buffer* buffer = buffers[bound_buffer_].get(); if (context_lost_) { buffer->pixels = nullptr; return; @@ -589,10 +589,10 @@ void TestWebGraphicsContext3D::pixelStorei(GLenum pname, GLint param) { void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target, GLenum access) { base::AutoLock lock(namespace_->lock); - base::ScopedPtrHashMap<unsigned, scoped_ptr<Buffer>>& buffers = + std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers = namespace_->buffers; DCHECK_GT(buffers.count(bound_buffer_), 0u); - DCHECK_EQ(target, buffers.get(bound_buffer_)->target); + DCHECK_EQ(target, buffers[bound_buffer_]->target); if (times_map_buffer_chromium_succeeds_ >= 0) { if (!times_map_buffer_chromium_succeeds_) { return NULL; @@ -600,17 +600,17 @@ void* TestWebGraphicsContext3D::mapBufferCHROMIUM(GLenum target, --times_map_buffer_chromium_succeeds_; } - return buffers.get(bound_buffer_)->pixels.get(); + return buffers[bound_buffer_]->pixels.get(); } GLboolean TestWebGraphicsContext3D::unmapBufferCHROMIUM( GLenum target) { base::AutoLock lock(namespace_->lock); - base::ScopedPtrHashMap<unsigned, scoped_ptr<Buffer>>& buffers = + std::unordered_map<unsigned, scoped_ptr<Buffer>>& buffers = namespace_->buffers; DCHECK_GT(buffers.count(bound_buffer_), 0u); - DCHECK_EQ(target, buffers.get(bound_buffer_)->target); - buffers.get(bound_buffer_)->pixels = nullptr; + DCHECK_EQ(target, buffers[bound_buffer_]->target); + buffers[bound_buffer_]->pixels = nullptr; return true; } @@ -621,7 +621,7 @@ GLuint TestWebGraphicsContext3D::createImageCHROMIUM(ClientBuffer buffer, DCHECK_EQ(GL_RGBA, static_cast<int>(internalformat)); GLuint image_id = NextImageId(); base::AutoLock lock(namespace_->lock); - base::hash_set<unsigned>& images = namespace_->images; + std::unordered_set<unsigned>& images = namespace_->images; images.insert(image_id); return image_id; } @@ -630,7 +630,7 @@ void TestWebGraphicsContext3D::destroyImageCHROMIUM( GLuint id) { RetireImageId(id); base::AutoLock lock(namespace_->lock); - base::hash_set<unsigned>& images = namespace_->images; + std::unordered_set<unsigned>& images = namespace_->images; if (!images.count(id)) ADD_FAILURE() << "destroyImageCHROMIUM called on unknown image " << id; images.erase(id); @@ -644,7 +644,7 @@ GLuint TestWebGraphicsContext3D::createGpuMemoryBufferImageCHROMIUM( DCHECK_EQ(GL_RGBA, static_cast<int>(internalformat)); GLuint image_id = NextImageId(); base::AutoLock lock(namespace_->lock); - base::hash_set<unsigned>& images = namespace_->images; + std::unordered_set<unsigned>& images = namespace_->images; images.insert(image_id); return image_id; } diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h index cb76604..03ddf3f 100644 --- a/cc/test/test_web_graphics_context_3d.h +++ b/cc/test/test_web_graphics_context_3d.h @@ -8,12 +8,12 @@ #include <stddef.h> #include <stdint.h> +#include <unordered_map> +#include <unordered_set> #include <vector> #include "base/callback.h" #include "base/compiler_specific.h" -#include "base/containers/hash_tables.h" -#include "base/containers/scoped_ptr_hash_map.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -404,7 +404,7 @@ class TestWebGraphicsContext3D { GLuint BoundTexture(GLenum target); private: - typedef base::hash_map<GLenum, GLuint> TargetTextureMap; + using TargetTextureMap = std::unordered_map<GLenum, GLuint>; TargetTextureMap bound_textures_; }; @@ -439,10 +439,10 @@ class TestWebGraphicsContext3D { unsigned next_image_id; unsigned next_texture_id; unsigned next_renderbuffer_id; - base::ScopedPtrHashMap<unsigned, scoped_ptr<Buffer>> buffers; - base::hash_set<unsigned> images; + std::unordered_map<unsigned, scoped_ptr<Buffer>> buffers; + std::unordered_set<unsigned> images; OrderedTextureMap textures; - base::hash_set<unsigned> renderbuffer_set; + std::unordered_set<unsigned> renderbuffer_set; private: friend class base::RefCountedThreadSafe<Namespace>; @@ -467,13 +467,13 @@ class TestWebGraphicsContext3D { int current_used_transfer_buffer_usage_bytes_; int max_used_transfer_buffer_usage_bytes_; base::Closure context_lost_callback_; - base::hash_set<unsigned> used_textures_; + std::unordered_set<unsigned> used_textures_; unsigned next_program_id_; - base::hash_set<unsigned> program_set_; + std::unordered_set<unsigned> program_set_; unsigned next_shader_id_; - base::hash_set<unsigned> shader_set_; + std::unordered_set<unsigned> shader_set_; unsigned next_framebuffer_id_; - base::hash_set<unsigned> framebuffer_set_; + std::unordered_set<unsigned> framebuffer_set_; unsigned current_framebuffer_; std::vector<TestWebGraphicsContext3D*> shared_contexts_; int max_texture_size_; diff --git a/cc/tiles/image_decode_controller.h b/cc/tiles/image_decode_controller.h index f814d21..a16f9282 100644 --- a/cc/tiles/image_decode_controller.h +++ b/cc/tiles/image_decode_controller.h @@ -7,7 +7,9 @@ #include <stdint.h> -#include "base/containers/hash_tables.h" +#include <unordered_map> +#include <unordered_set> + #include "base/hash.h" #include "base/memory/discardable_memory_allocator.h" #include "base/memory/ref_counted.h" @@ -18,7 +20,6 @@ #include "cc/playback/draw_image.h" #include "cc/raster/tile_task_runner.h" #include "skia/ext/refptr.h" - #include "ui/gfx/transform.h" namespace cc { @@ -70,13 +71,9 @@ class CC_EXPORT ImageDecodeControllerKey { SkFilterQuality filter_quality_; }; -} // namespace cc - // Hash function for the above ImageDecodeControllerKey. -namespace BASE_HASH_NAMESPACE { -template <> -struct hash<cc::ImageDecodeControllerKey> { - size_t operator()(const cc::ImageDecodeControllerKey& key) const { +struct ImageDecodeControllerKeyHash { + size_t operator()(const ImageDecodeControllerKey& key) const { // TODO(vmpstr): This is a mess. Maybe it's faster to just search the vector // always (forwards or backwards to account for LRU). uint64_t src_rect_hash = @@ -92,9 +89,6 @@ struct hash<cc::ImageDecodeControllerKey> { base::HashInts(key.image_id(), key.filter_quality())); } }; -} // namespace BASE_HASH_NAMESPACE - -namespace cc { // ImageDecodeController is responsible for generating decode tasks, decoding // images, storing images in cache, and being able to return the decoded images @@ -117,6 +111,7 @@ namespace cc { class CC_EXPORT ImageDecodeController { public: using ImageKey = ImageDecodeControllerKey; + using ImageKeyHash = ImageDecodeControllerKeyHash; ImageDecodeController(); ~ImageDecodeController(); @@ -236,22 +231,24 @@ class CC_EXPORT ImageDecodeController { bool is_using_gpu_rasterization_; - base::hash_map<ImageKey, scoped_refptr<ImageDecodeTask>> pending_image_tasks_; + std::unordered_map<ImageKey, scoped_refptr<ImageDecodeTask>, ImageKeyHash> + pending_image_tasks_; // The members below this comment can only be accessed if the lock is held to // ensure that they are safe to access on multiple threads. base::Lock lock_; std::deque<AnnotatedDecodedImage> decoded_images_; - base::hash_map<ImageKey, int> decoded_images_ref_counts_; + std::unordered_map<ImageKey, int, ImageKeyHash> decoded_images_ref_counts_; std::deque<AnnotatedDecodedImage> at_raster_decoded_images_; - base::hash_map<ImageKey, int> at_raster_decoded_images_ref_counts_; + std::unordered_map<ImageKey, int, ImageKeyHash> + at_raster_decoded_images_ref_counts_; MemoryBudget locked_images_budget_; // Note that this is used for cases where the only thing we do is preroll the // image the first time we see it. This mimics the previous behavior and // should over time change as the compositor starts to handle more cases. - base::hash_set<uint32_t> prerolled_images_; + std::unordered_set<uint32_t> prerolled_images_; }; } // namespace cc diff --git a/cc/tiles/picture_layer_tiling.cc b/cc/tiles/picture_layer_tiling.cc index 7390913..67d7096 100644 --- a/cc/tiles/picture_layer_tiling.cc +++ b/cc/tiles/picture_layer_tiling.cc @@ -11,7 +11,6 @@ #include <limits> #include <set> -#include "base/containers/hash_tables.h" #include "base/containers/small_map.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" @@ -117,7 +116,7 @@ Tile* PictureLayerTiling::CreateTile(const Tile::CreateInfo& info) { all_tiles_done_ = false; ScopedTilePtr tile = client_->CreateTile(info); Tile* raw_ptr = tile.get(); - tiles_.add(key, std::move(tile)); + tiles_[key] = std::move(tile); return raw_ptr; } @@ -186,8 +185,9 @@ void PictureLayerTiling::TakeTilesAndPropertiesFrom( all_tiles_done_ = pending_twin->all_tiles_done_; } else { while (!pending_twin->tiles_.empty()) { - TileMapKey key = pending_twin->tiles_.begin()->first; - tiles_.set(key, pending_twin->tiles_.take_and_erase(key)); + auto pending_iter = pending_twin->tiles_.begin(); + tiles_[pending_iter->first] = std::move(pending_iter->second); + pending_twin->tiles_.erase(pending_iter); } all_tiles_done_ &= pending_twin->all_tiles_done_; } @@ -296,11 +296,12 @@ void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation, // twin, so it's slated for removal in the future. if (live_tiles_rect_.IsEmpty()) return; - // Pick 16 for the size of the SmallMap before it promotes to a hash_map. + // Pick 16 for the size of the SmallMap before it promotes to a unordered_map. // 4x4 tiles should cover most small invalidations, and walking a vector of // 16 is fast enough. If an invalidation is huge we will fall back to a - // hash_map instead of a vector in the SmallMap. - base::SmallMap<base::hash_map<TileMapKey, gfx::Rect>, 16> remove_tiles; + // unordered_map instead of a vector in the SmallMap. + base::SmallMap<std::unordered_map<TileMapKey, gfx::Rect, TileMapKeyHash>, 16> + remove_tiles; gfx::Rect expanded_live_tiles_rect = tiling_data_.ExpandRectToTileBounds(live_tiles_rect_); for (Region::Iterator iter(layer_invalidation); iter.has_rect(); @@ -547,7 +548,9 @@ ScopedTilePtr PictureLayerTiling::TakeTileAt(int i, int j) { TileMap::iterator found = tiles_.find(TileMapKey(i, j)); if (found == tiles_.end()) return nullptr; - return tiles_.take_and_erase(found); + ScopedTilePtr result = std::move(found->second); + tiles_.erase(found); + return result; } bool PictureLayerTiling::RemoveTileAt(int i, int j) { @@ -934,7 +937,7 @@ std::map<const Tile*, PrioritizedTile> PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const { std::map<const Tile*, PrioritizedTile> result; for (const auto& key_tile_pair : tiles_) { - Tile* tile = key_tile_pair.second; + Tile* tile = key_tile_pair.second.get(); UpdateRequiredStatesOnTile(tile); PrioritizedTile prioritized_tile = MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile)); @@ -1005,7 +1008,7 @@ PictureLayerTiling::ComputePriorityRectTypeForTile(const Tile* tile) const { void PictureLayerTiling::GetAllPrioritizedTilesForTracing( std::vector<PrioritizedTile>* prioritized_tiles) const { for (const auto& tile_pair : tiles_) { - Tile* tile = tile_pair.second; + Tile* tile = tile_pair.second.get(); prioritized_tiles->push_back( MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile))); } @@ -1026,7 +1029,7 @@ void PictureLayerTiling::AsValueInto( size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { size_t amount = 0; for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { - const Tile* tile = it->second; + const Tile* tile = it->second.get(); amount += tile->GPUMemoryUsageInBytes(); } return amount; diff --git a/cc/tiles/picture_layer_tiling.h b/cc/tiles/picture_layer_tiling.h index 9185d5d..209251d 100644 --- a/cc/tiles/picture_layer_tiling.h +++ b/cc/tiles/picture_layer_tiling.h @@ -9,10 +9,10 @@ #include <stdint.h> #include <map> +#include <unordered_map> #include <utility> #include <vector> -#include "base/containers/scoped_ptr_hash_map.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "cc/base/cc_export.h" @@ -67,21 +67,14 @@ struct TileMapKey { int index_y; }; -} // namespace cc - -namespace BASE_HASH_NAMESPACE { -template <> -struct hash<cc::TileMapKey> { - size_t operator()(const cc::TileMapKey& key) const { +struct TileMapKeyHash { + size_t operator()(const TileMapKey& key) const { uint16_t value1 = static_cast<uint16_t>(key.index_x); uint16_t value2 = static_cast<uint16_t>(key.index_y); uint32_t value1_32 = value1; return (value1_32 << 16) | value2; } }; -} // namespace BASE_HASH_NAMESPACE - -namespace cc { class CC_EXPORT PictureLayerTiling { public: @@ -140,7 +133,7 @@ class CC_EXPORT PictureLayerTiling { Tile* TileAt(int i, int j) const { TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); - return iter == tiles_.end() ? nullptr : iter->second; + return iter == tiles_.end() ? nullptr : iter->second.get(); } bool has_tiles() const { return !tiles_.empty(); } @@ -152,9 +145,9 @@ class CC_EXPORT PictureLayerTiling { void VerifyNoTileNeedsRaster() const { #if DCHECK_IS_ON() - for (const auto tile_pair : tiles_) { + for (const auto& tile_pair : tiles_) { DCHECK(!tile_pair.second->draw_info().NeedsRaster() || - IsTileOccluded(tile_pair.second)); + IsTileOccluded(tile_pair.second.get())); } #endif // DCHECK_IS_ON() } @@ -167,13 +160,13 @@ class CC_EXPORT PictureLayerTiling { std::vector<Tile*> AllTilesForTesting() const { std::vector<Tile*> all_tiles; for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) - all_tiles.push_back(it->second); + all_tiles.push_back(it->second.get()); return all_tiles; } void UpdateAllRequiredStateForTesting() { for (const auto& key_tile_pair : tiles_) - UpdateRequiredStatesOnTile(key_tile_pair.second); + UpdateRequiredStatesOnTile(key_tile_pair.second.get()); } std::map<const Tile*, PrioritizedTile> UpdateAndGetAllPrioritizedTilesForTesting() const; @@ -274,7 +267,7 @@ class CC_EXPORT PictureLayerTiling { EVENTUALLY_RECT }; - using TileMap = base::ScopedPtrHashMap<TileMapKey, ScopedTilePtr>; + using TileMap = std::unordered_map<TileMapKey, ScopedTilePtr, TileMapKeyHash>; struct FrameVisibleRect { gfx::Rect visible_rect_in_content_space; @@ -413,7 +406,7 @@ class CC_EXPORT PictureLayerTiling { bool all_tiles_done_; private: - DISALLOW_ASSIGN(PictureLayerTiling); + DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling); }; } // namespace cc diff --git a/cc/tiles/tile_manager.h b/cc/tiles/tile_manager.h index d74d871..3310b19 100644 --- a/cc/tiles/tile_manager.h +++ b/cc/tiles/tile_manager.h @@ -9,10 +9,10 @@ #include <stdint.h> #include <set> +#include <unordered_map> #include <utility> #include <vector> -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" @@ -293,7 +293,7 @@ class CC_EXPORT TileManager { const bool use_partial_raster_; bool use_gpu_rasterization_; - typedef base::hash_map<Tile::Id, Tile*> TileMap; + using TileMap = std::unordered_map<Tile::Id, Tile*>; TileMap tiles_; bool all_tiles_that_need_to_be_rasterized_are_scheduled_; @@ -337,7 +337,7 @@ class CC_EXPORT TileManager { uint64_t prepare_tiles_count_; uint64_t next_tile_id_; - base::hash_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; + std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index e2a736b..bff00c0 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -10,6 +10,7 @@ #include <algorithm> #include <stack> #include <string> +#include <unordered_map> #include "base/atomic_sequence_num.h" #include "base/auto_reset.h" @@ -64,7 +65,7 @@ namespace { Layer* UpdateAndGetLayer(Layer* current_layer, int layer_id, - const base::hash_map<int, Layer*>& layer_id_map) { + const std::unordered_map<int, Layer*>& layer_id_map) { if (layer_id == Layer::INVALID_ID) { if (current_layer) current_layer->SetLayerTreeHost(nullptr); diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index d8eba8d..52d3321 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -11,10 +11,10 @@ #include <limits> #include <set> #include <string> +#include <unordered_map> #include <vector> #include "base/cancelable_callback.h" -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -439,12 +439,12 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient { gfx::Size size; }; - typedef base::hash_map<UIResourceId, UIResourceClientData> - UIResourceClientMap; + using UIResourceClientMap = + std::unordered_map<UIResourceId, UIResourceClientData>; UIResourceClientMap ui_resource_client_map_; int next_ui_resource_id_; - typedef std::vector<UIResourceRequest> UIResourceRequestQueue; + using UIResourceRequestQueue = std::vector<UIResourceRequest>; UIResourceRequestQueue ui_resource_request_queue_; void CalculateLCDTextMetricsCallback(Layer* layer); @@ -533,7 +533,7 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient { PropertyTrees property_trees_; - typedef base::hash_map<int, Layer*> LayerIdMap; + using LayerIdMap = std::unordered_map<int, Layer*>; LayerIdMap layer_id_map_; uint32_t surface_id_namespace_; diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 3ebc475..6653e94 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -11,9 +11,10 @@ #include <limits> #include <map> #include <set> +#include <unordered_map> +#include <utility> #include "base/auto_reset.h" -#include "base/containers/hash_tables.h" #include "base/containers/small_map.h" #include "base/json/json_writer.h" #include "base/metrics/histogram.h" @@ -1189,7 +1190,8 @@ void LayerTreeHostImpl::RemoveRenderPasses(FrameData* frame) { std::set<RenderPassId> pass_exists; // A set of RenderPassDrawQuads that we have seen (stored by the RenderPasses // they refer to). - base::SmallMap<base::hash_map<RenderPassId, int>> pass_references; + base::SmallMap<std::unordered_map<RenderPassId, int, RenderPassIdHash>> + pass_references; // Iterate RenderPasses in draw order, removing empty render passes (except // the root RenderPass). @@ -3404,9 +3406,8 @@ void LayerTreeHostImpl::RegisterScrollbarAnimationController( return; if (ScrollbarAnimationControllerForId(scroll_layer_id)) return; - scrollbar_animation_controllers_.add( - scroll_layer_id, - active_tree_->CreateScrollbarAnimationController(scroll_layer_id)); + scrollbar_animation_controllers_[scroll_layer_id] = + active_tree_->CreateScrollbarAnimationController(scroll_layer_id); } void LayerTreeHostImpl::UnregisterScrollbarAnimationController( @@ -3423,7 +3424,7 @@ LayerTreeHostImpl::ScrollbarAnimationControllerForId( auto i = scrollbar_animation_controllers_.find(scroll_layer_id); if (i == scrollbar_animation_controllers_.end()) return nullptr; - return i->second; + return i->second.get(); } void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask( diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 7dfaa16..660369c 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -9,9 +9,9 @@ #include <set> #include <string> +#include <unordered_map> #include <vector> -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/time/time.h" @@ -706,8 +706,7 @@ class CC_EXPORT LayerTreeHostImpl bool ScrollAnimationUpdateTarget(LayerImpl* layer_impl, const gfx::Vector2dF& scroll_delta); - typedef base::hash_map<UIResourceId, UIResourceData> - UIResourceMap; + using UIResourceMap = std::unordered_map<UIResourceId, UIResourceData>; UIResourceMap ui_resource_map_; // Resources that were evicted by EvictAllUIResources. Resources are removed @@ -809,7 +808,7 @@ class CC_EXPORT LayerTreeHostImpl // Map from scroll layer ID to scrollbar animation controller. // There is one animation controller per pair of overlay scrollbars. - base::ScopedPtrHashMap<int, scoped_ptr<ScrollbarAnimationController>> + std::unordered_map<int, scoped_ptr<ScrollbarAnimationController>> scrollbar_animation_controllers_; RenderingStatsInstrumentation* rendering_stats_instrumentation_; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 98b7c01..d6073c3 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -12,8 +12,6 @@ #include "base/bind.h" #include "base/command_line.h" -#include "base/containers/hash_tables.h" -#include "base/containers/scoped_ptr_hash_map.h" #include "base/location.h" #include "base/thread_task_runner_handle.h" #include "cc/animation/animation_events.h" diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index 91e34668..4e59132 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -8,9 +8,9 @@ #include <map> #include <set> #include <string> +#include <unordered_map> #include <vector> -#include "base/containers/hash_tables.h" #include "base/macros.h" #include "base/values.h" #include "cc/base/synced_property.h" @@ -482,15 +482,15 @@ class CC_EXPORT LayerTreeImpl { scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; - typedef base::hash_map<int, LayerImpl*> LayerIdMap; + using LayerIdMap = std::unordered_map<int, LayerImpl*>; LayerIdMap layer_id_map_; - base::hash_map<uint64_t, ElementLayers> element_layers_map_; + std::unordered_map<uint64_t, ElementLayers> element_layers_map_; // Maps from clip layer ids to scroll layer ids. Note that this only includes // the subset of clip layers that act as scrolling containers. (This is // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.) - base::hash_map<int, int> clip_scroll_map_; + std::unordered_map<int, int> clip_scroll_map_; // Maps scroll layer ids to scrollbar layer ids. For each scroll layer, there // may be 1 or 2 scrollbar layers (for vertical and horizontal). (This is diff --git a/cc/trees/tree_synchronizer.cc b/cc/trees/tree_synchronizer.cc index 72b6daa..a257c57 100644 --- a/cc/trees/tree_synchronizer.cc +++ b/cc/trees/tree_synchronizer.cc @@ -7,9 +7,8 @@ #include <stddef.h> #include <set> +#include <unordered_map> -#include "base/containers/hash_tables.h" -#include "base/containers/scoped_ptr_hash_map.h" #include "base/logging.h" #include "base/trace_event/trace_event.h" #include "cc/layers/layer.h" @@ -17,9 +16,8 @@ namespace cc { -typedef base::ScopedPtrHashMap<int, scoped_ptr<LayerImpl>> - ScopedPtrLayerImplMap; -typedef base::hash_map<int, LayerImpl*> RawPtrLayerImplMap; +using ScopedPtrLayerImplMap = std::unordered_map<int, scoped_ptr<LayerImpl>>; +using RawPtrLayerImplMap = std::unordered_map<int, LayerImpl*>; void CollectExistingLayerImplRecursive(ScopedPtrLayerImplMap* old_layers, scoped_ptr<LayerImpl> layer_impl) { @@ -34,7 +32,7 @@ void CollectExistingLayerImplRecursive(ScopedPtrLayerImplMap* old_layers, CollectExistingLayerImplRecursive(old_layers, layer_impl->TakeReplicaLayer()); int id = layer_impl->id(); - old_layers->set(id, std::move(layer_impl)); + (*old_layers)[id] = std::move(layer_impl); } template <typename LayerType> @@ -78,7 +76,7 @@ scoped_ptr<LayerImpl> ReuseOrCreateLayerImpl(RawPtrLayerImplMap* new_layers, ScopedPtrLayerImplMap* old_layers, LayerType* layer, LayerTreeImpl* tree_impl) { - scoped_ptr<LayerImpl> layer_impl = old_layers->take(layer->id()); + scoped_ptr<LayerImpl> layer_impl = std::move((*old_layers)[layer->id()]); if (!layer_impl) layer_impl = layer->CreateLayerImpl(tree_impl); |