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

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

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 | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_id.h » ('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 #include "cc/surfaces/surface_factory.h" 5 #include "cc/surfaces/surface_factory.h"
6 6
7 #include "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/copy_output_request.h" 9 #include "cc/output/copy_output_request.h"
10 #include "cc/surfaces/surface.h" 10 #include "cc/surfaces/surface.h"
(...skipping 13 matching lines...) Expand all
24 SurfaceFactory::~SurfaceFactory() { 24 SurfaceFactory::~SurfaceFactory() {
25 if (!surface_map_.empty()) { 25 if (!surface_map_.empty()) {
26 LOG(ERROR) << "SurfaceFactory has " << surface_map_.size() 26 LOG(ERROR) << "SurfaceFactory has " << surface_map_.size()
27 << " entries in map on destruction."; 27 << " entries in map on destruction.";
28 } 28 }
29 DestroyAll(); 29 DestroyAll();
30 client_->SetBeginFrameSource(SurfaceId(), nullptr); 30 client_->SetBeginFrameSource(SurfaceId(), nullptr);
31 } 31 }
32 32
33 void SurfaceFactory::DestroyAll() { 33 void SurfaceFactory::DestroyAll() {
34 for (auto it = surface_map_.begin(); it != surface_map_.end(); ++it) 34 for (auto& pair : surface_map_)
35 manager_->Destroy(surface_map_.take(it)); 35 manager_->Destroy(std::move(pair.second));
36 surface_map_.clear(); 36 surface_map_.clear();
37 } 37 }
38 38
39 void SurfaceFactory::Create(SurfaceId surface_id) { 39 void SurfaceFactory::Create(SurfaceId surface_id) {
40 scoped_ptr<Surface> surface(new Surface(surface_id, this)); 40 scoped_ptr<Surface> surface(new Surface(surface_id, this));
41 manager_->RegisterSurface(surface.get()); 41 manager_->RegisterSurface(surface.get());
42 DCHECK(!surface_map_.count(surface_id)); 42 DCHECK(!surface_map_.count(surface_id));
43 surface_map_.add(surface_id, std::move(surface)); 43 surface_map_[surface_id] = std::move(surface);
44 } 44 }
45 45
46 void SurfaceFactory::Destroy(SurfaceId surface_id) { 46 void SurfaceFactory::Destroy(SurfaceId surface_id) {
47 OwningSurfaceMap::iterator it = surface_map_.find(surface_id); 47 OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
48 DCHECK(it != surface_map_.end()); 48 DCHECK(it != surface_map_.end());
49 DCHECK(it->second->factory().get() == this); 49 DCHECK(it->second->factory().get() == this);
50 manager_->Destroy(surface_map_.take_and_erase(it)); 50 scoped_ptr<Surface> surface(std::move(it->second));
51 surface_map_.erase(it);
52 manager_->Destroy(std::move(surface));
51 } 53 }
52 54
53 void SurfaceFactory::SetBeginFrameSource(SurfaceId surface_id, 55 void SurfaceFactory::SetBeginFrameSource(SurfaceId surface_id,
54 BeginFrameSource* begin_frame_source) { 56 BeginFrameSource* begin_frame_source) {
55 client_->SetBeginFrameSource(surface_id, begin_frame_source); 57 client_->SetBeginFrameSource(surface_id, begin_frame_source);
56 } 58 }
57 59
58 void SurfaceFactory::SubmitCompositorFrame(SurfaceId surface_id, 60 void SurfaceFactory::SubmitCompositorFrame(SurfaceId surface_id,
59 scoped_ptr<CompositorFrame> frame, 61 scoped_ptr<CompositorFrame> frame,
60 const DrawCallback& callback) { 62 const DrawCallback& callback) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 96
95 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) { 97 void SurfaceFactory::RefResources(const TransferableResourceArray& resources) {
96 holder_.RefResources(resources); 98 holder_.RefResources(resources);
97 } 99 }
98 100
99 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) { 101 void SurfaceFactory::UnrefResources(const ReturnedResourceArray& resources) {
100 holder_.UnrefResources(resources); 102 holder_.UnrefResources(resources);
101 } 103 }
102 104
103 } // namespace cc 105 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory.h ('k') | cc/surfaces/surface_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698