Chromium Code Reviews| Index: cc/surfaces/surface_manager.cc |
| diff --git a/cc/surfaces/surface_manager.cc b/cc/surfaces/surface_manager.cc |
| index c4dcc5b46cf5eb58a3ee195ddbba829760429155..09b606adac9f8c837c07c03e516b3e5ee4a43232 100644 |
| --- a/cc/surfaces/surface_manager.cc |
| +++ b/cc/surfaces/surface_manager.cc |
| @@ -16,6 +16,10 @@ |
| #include "cc/surfaces/surface_factory_client.h" |
| #include "cc/surfaces/surface_id_allocator.h" |
| +#if DCHECK_IS_ON() |
| +#include <sstream> |
| +#endif |
| + |
| namespace cc { |
| SurfaceManager::FrameSinkSourceMapping::FrameSinkSourceMapping() |
| @@ -54,6 +58,14 @@ SurfaceManager::~SurfaceManager() { |
| DCHECK_EQ(registered_sources_.size(), 0u); |
| } |
| +#if DCHECK_IS_ON() |
| +std::string SurfaceManager::SurfaceReferencesToString() { |
| + std::stringstream str; |
| + SurfaceReferencesToStringImpl(root_surface_id_, "", &str); |
| + return str.str(); |
| +} |
| +#endif |
| + |
| void SurfaceManager::RegisterSurface(Surface* surface) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| DCHECK(surface); |
| @@ -170,7 +182,7 @@ void SurfaceManager::GarbageCollectSurfacesFromRoot() { |
| if (surfaces_to_destroy_.empty()) |
| return; |
| - std::unordered_set<SurfaceId, SurfaceIdHash> reachable_surfaces; |
| + SurfaceIdSet reachable_surfaces; |
| // Walk down from the root and mark each SurfaceId we encounter as reachable. |
| std::queue<SurfaceId> surface_queue; |
| @@ -508,4 +520,40 @@ void SurfaceManager::SurfaceCreated(const SurfaceInfo& surface_info) { |
| observer.OnSurfaceCreated(surface_info); |
| } |
| +#if DCHECK_IS_ON() |
| +void SurfaceManager::SurfaceReferencesToStringImpl(const SurfaceId& surface_id, |
| + std::string indent, |
| + std::stringstream* str) { |
| + *str << indent; |
| + |
| + // Print the current line for |surface_id|. |
| + Surface* surface = GetSurfaceForId(surface_id); |
| + if (surface) { |
| + *str << surface->surface_id().ToString(); |
| + *str << (surface->destroyed() ? " destroyed " : " live "); |
| + |
| + if (surface->HasFrame()) { |
| + *str << surface->GetEligibleFrame() |
|
danakj
2017/01/18 16:57:11
can you try using a temp var to split this into tw
kylechar
2017/01/18 18:04:58
Done.
|
| + .render_pass_list.back() |
| + ->output_rect.size() |
| + .ToString(); |
| + } |
| + } else { |
| + *str << surface_id; |
| + } |
| + *str << "\n"; |
| + |
| + // If the current surface has references to children, sort children and print |
| + // references for each child. |
| + auto iter = parent_to_child_refs_.find(surface_id); |
| + if (iter != parent_to_child_refs_.end()) { |
| + std::vector<SurfaceId> children(iter->second.begin(), iter->second.end()); |
| + std::sort(children.begin(), children.end()); |
| + |
| + for (const SurfaceId& child_id : children) |
| + SurfaceReferencesToStringImpl(child_id, indent + " ", str); |
| + } |
| +} |
| +#endif // DCHECK_IS_ON() |
| + |
| } // namespace cc |