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

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

Issue 2651283004: Reland of "Decouple GpuCompositorFrameSink from DisplayCompositor" (Closed)
Patch Set: Created 3 years, 10 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') | cc/surfaces/surface_reference_manager.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 <queue> 10 #include <queue>
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 parent_to_child_refs_[parent_id].count(child_id) == 0) { 212 parent_to_child_refs_[parent_id].count(child_id) == 0) {
213 DLOG(ERROR) << "No reference from " << parent_id.ToString() << " to " 213 DLOG(ERROR) << "No reference from " << parent_id.ToString() << " to "
214 << child_id.ToString(); 214 << child_id.ToString();
215 return; 215 return;
216 } 216 }
217 217
218 RemoveSurfaceReferenceImpl(parent_id, child_id); 218 RemoveSurfaceReferenceImpl(parent_id, child_id);
219 GarbageCollectSurfaces(); 219 GarbageCollectSurfaces();
220 } 220 }
221 221
222 void SurfaceManager::AddSurfaceReferences(
223 const std::vector<SurfaceReference>& references) {
224 DCHECK(thread_checker_.CalledOnValidThread());
225
226 for (const auto& reference : references)
227 AddSurfaceReference(reference.parent_id(), reference.child_id());
228 }
229
230 void SurfaceManager::RemoveSurfaceReferences(
231 const std::vector<SurfaceReference>& references) {
232 DCHECK(thread_checker_.CalledOnValidThread());
233
234 // TODO(kylechar): Each remove reference can trigger GC, it would be better if
235 // we GC only once if removing multiple references.
236 for (const auto& reference : references)
237 RemoveSurfaceReference(reference.parent_id(), reference.child_id());
238 }
239
222 size_t SurfaceManager::GetSurfaceReferenceCount( 240 size_t SurfaceManager::GetSurfaceReferenceCount(
223 const SurfaceId& surface_id) const { 241 const SurfaceId& surface_id) const {
224 auto iter = child_to_parent_refs_.find(surface_id); 242 auto iter = child_to_parent_refs_.find(surface_id);
225 if (iter == child_to_parent_refs_.end()) 243 if (iter == child_to_parent_refs_.end())
226 return 0; 244 return 0;
227 return iter->second.size(); 245 return iter->second.size();
228 } 246 }
229 247
230 size_t SurfaceManager::GetReferencedSurfaceCount( 248 size_t SurfaceManager::GetReferencedSurfaceCount(
231 const SurfaceId& surface_id) const { 249 const SurfaceId& surface_id) const {
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); 630 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end());
613 std::sort(children.begin(), children.end()); 631 std::sort(children.begin(), children.end());
614 632
615 for (const SurfaceId& child_id : children) 633 for (const SurfaceId& child_id : children)
616 SurfaceReferencesToStringImpl(child_id, indent + " ", str); 634 SurfaceReferencesToStringImpl(child_id, indent + " ", str);
617 } 635 }
618 } 636 }
619 #endif // DCHECK_IS_ON() 637 #endif // DCHECK_IS_ON()
620 638
621 } // namespace cc 639 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | cc/surfaces/surface_reference_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698