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

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

Issue 2150633002: cc: Pass SurfaceId by const ref in more places (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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_manager.h ('k') | content/browser/renderer_host/delegated_frame_host.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_manager.h" 5 #include "cc/surfaces/surface_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 DCHECK_EQ(registered_sources_.size(), 0u); 44 DCHECK_EQ(registered_sources_.size(), 0u);
45 } 45 }
46 46
47 void SurfaceManager::RegisterSurface(Surface* surface) { 47 void SurfaceManager::RegisterSurface(Surface* surface) {
48 DCHECK(thread_checker_.CalledOnValidThread()); 48 DCHECK(thread_checker_.CalledOnValidThread());
49 DCHECK(surface); 49 DCHECK(surface);
50 DCHECK(!surface_map_.count(surface->surface_id())); 50 DCHECK(!surface_map_.count(surface->surface_id()));
51 surface_map_[surface->surface_id()] = surface; 51 surface_map_[surface->surface_id()] = surface;
52 } 52 }
53 53
54 void SurfaceManager::DeregisterSurface(SurfaceId surface_id) { 54 void SurfaceManager::DeregisterSurface(const SurfaceId& surface_id) {
55 DCHECK(thread_checker_.CalledOnValidThread()); 55 DCHECK(thread_checker_.CalledOnValidThread());
56 SurfaceMap::iterator it = surface_map_.find(surface_id); 56 SurfaceMap::iterator it = surface_map_.find(surface_id);
57 DCHECK(it != surface_map_.end()); 57 DCHECK(it != surface_map_.end());
58 surface_map_.erase(it); 58 surface_map_.erase(it);
59 } 59 }
60 60
61 void SurfaceManager::Destroy(std::unique_ptr<Surface> surface) { 61 void SurfaceManager::Destroy(std::unique_ptr<Surface> surface) {
62 DCHECK(thread_checker_.CalledOnValidThread()); 62 DCHECK(thread_checker_.CalledOnValidThread());
63 surface->set_destroyed(true); 63 surface->set_destroyed(true);
64 surfaces_to_destroy_.push_back(std::move(surface)); 64 surfaces_to_destroy_.push_back(std::move(surface));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 live_surfaces.push_back(map_entry.first); 105 live_surfaces.push_back(map_entry.first);
106 } 106 }
107 } 107 }
108 108
109 // Mark all surfaces reachable from live surfaces by adding them to 109 // Mark all surfaces reachable from live surfaces by adding them to
110 // live_surfaces and live_surfaces_set. 110 // live_surfaces and live_surfaces_set.
111 for (size_t i = 0; i < live_surfaces.size(); i++) { 111 for (size_t i = 0; i < live_surfaces.size(); i++) {
112 Surface* surf = surface_map_[live_surfaces[i]]; 112 Surface* surf = surface_map_[live_surfaces[i]];
113 DCHECK(surf); 113 DCHECK(surf);
114 114
115 for (SurfaceId id : surf->referenced_surfaces()) { 115 for (const SurfaceId& id : surf->referenced_surfaces()) {
116 if (live_surfaces_set.count(id)) 116 if (live_surfaces_set.count(id))
117 continue; 117 continue;
118 118
119 Surface* surf2 = GetSurfaceForId(id); 119 Surface* surf2 = GetSurfaceForId(id);
120 if (surf2) { 120 if (surf2) {
121 live_surfaces.push_back(id); 121 live_surfaces.push_back(id);
122 live_surfaces_set.insert(id); 122 live_surfaces_set.insert(id);
123 } 123 }
124 } 124 }
125 } 125 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 BeginFrameSource* parent_source = iter->second.source; 324 BeginFrameSource* parent_source = iter->second.source;
325 if (!parent_source) 325 if (!parent_source)
326 return; 326 return;
327 327
328 // TODO(enne): these walks could be done in one step. 328 // TODO(enne): these walks could be done in one step.
329 RecursivelyDetachBeginFrameSource(child_namespace, parent_source); 329 RecursivelyDetachBeginFrameSource(child_namespace, parent_source);
330 for (auto source_iter : registered_sources_) 330 for (auto source_iter : registered_sources_)
331 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first); 331 RecursivelyAttachBeginFrameSource(source_iter.second, source_iter.first);
332 } 332 }
333 333
334 Surface* SurfaceManager::GetSurfaceForId(SurfaceId surface_id) { 334 Surface* SurfaceManager::GetSurfaceForId(const SurfaceId& surface_id) {
335 DCHECK(thread_checker_.CalledOnValidThread()); 335 DCHECK(thread_checker_.CalledOnValidThread());
336 SurfaceMap::iterator it = surface_map_.find(surface_id); 336 SurfaceMap::iterator it = surface_map_.find(surface_id);
337 if (it == surface_map_.end()) 337 if (it == surface_map_.end())
338 return NULL; 338 return NULL;
339 return it->second; 339 return it->second;
340 } 340 }
341 341
342 bool SurfaceManager::SurfaceModified(SurfaceId surface_id) { 342 bool SurfaceManager::SurfaceModified(const SurfaceId& surface_id) {
343 CHECK(thread_checker_.CalledOnValidThread()); 343 CHECK(thread_checker_.CalledOnValidThread());
344 bool changed = false; 344 bool changed = false;
345 FOR_EACH_OBSERVER(SurfaceDamageObserver, observer_list_, 345 FOR_EACH_OBSERVER(SurfaceDamageObserver, observer_list_,
346 OnSurfaceDamaged(surface_id, &changed)); 346 OnSurfaceDamaged(surface_id, &changed));
347 return changed; 347 return changed;
348 } 348 }
349 349
350 } // namespace cc 350 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | content/browser/renderer_host/delegated_frame_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698