| OLD | NEW |
| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 parent_to_child_refs_[parent_id].count(child_id) == 0) { | 217 parent_to_child_refs_[parent_id].count(child_id) == 0) { |
| 218 DLOG(ERROR) << "No reference from " << parent_id.ToString() << " to " | 218 DLOG(ERROR) << "No reference from " << parent_id.ToString() << " to " |
| 219 << child_id.ToString(); | 219 << child_id.ToString(); |
| 220 return; | 220 return; |
| 221 } | 221 } |
| 222 | 222 |
| 223 RemoveSurfaceReferenceImpl(parent_id, child_id); | 223 RemoveSurfaceReferenceImpl(parent_id, child_id); |
| 224 GarbageCollectSurfaces(); | 224 GarbageCollectSurfaces(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void SurfaceManager::AddSurfaceReferences( |
| 228 const std::vector<SurfaceReference>& references) { |
| 229 DCHECK(thread_checker_.CalledOnValidThread()); |
| 230 |
| 231 for (const auto& reference : references) |
| 232 AddSurfaceReference(reference.parent_id(), reference.child_id()); |
| 233 } |
| 234 |
| 235 void SurfaceManager::RemoveSurfaceReferences( |
| 236 const std::vector<SurfaceReference>& references) { |
| 237 DCHECK(thread_checker_.CalledOnValidThread()); |
| 238 |
| 239 // TODO(kylechar): Each remove reference can trigger GC, it would be better if |
| 240 // we GC only once if removing multiple references. |
| 241 for (const auto& reference : references) |
| 242 RemoveSurfaceReference(reference.parent_id(), reference.child_id()); |
| 243 } |
| 244 |
| 227 size_t SurfaceManager::GetSurfaceReferenceCount( | 245 size_t SurfaceManager::GetSurfaceReferenceCount( |
| 228 const SurfaceId& surface_id) const { | 246 const SurfaceId& surface_id) const { |
| 229 auto iter = child_to_parent_refs_.find(surface_id); | 247 auto iter = child_to_parent_refs_.find(surface_id); |
| 230 if (iter == child_to_parent_refs_.end()) | 248 if (iter == child_to_parent_refs_.end()) |
| 231 return 0; | 249 return 0; |
| 232 return iter->second.size(); | 250 return iter->second.size(); |
| 233 } | 251 } |
| 234 | 252 |
| 235 size_t SurfaceManager::GetReferencedSurfaceCount( | 253 size_t SurfaceManager::GetReferencedSurfaceCount( |
| 236 const SurfaceId& surface_id) const { | 254 const SurfaceId& surface_id) const { |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); | 644 std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); |
| 627 std::sort(children.begin(), children.end()); | 645 std::sort(children.begin(), children.end()); |
| 628 | 646 |
| 629 for (const SurfaceId& child_id : children) | 647 for (const SurfaceId& child_id : children) |
| 630 SurfaceReferencesToStringImpl(child_id, indent + " ", str); | 648 SurfaceReferencesToStringImpl(child_id, indent + " ", str); |
| 631 } | 649 } |
| 632 } | 650 } |
| 633 #endif // DCHECK_IS_ON() | 651 #endif // DCHECK_IS_ON() |
| 634 | 652 |
| 635 } // namespace cc | 653 } // namespace cc |
| OLD | NEW |