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

Unified Diff: cc/surfaces/surface_manager.cc

Issue 2625203004: Add debug method to print surface references. (Closed)
Patch Set: Little fixes. Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/surface_manager.cc
diff --git a/cc/surfaces/surface_manager.cc b/cc/surfaces/surface_manager.cc
index c4dcc5b46cf5eb58a3ee195ddbba829760429155..a1d2f62386403f15fcac064245abf8f94f634ca0 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,39 @@ 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()) {
+ // This provides the surface size from the root render pass.
+ const CompositorFrame& frame = surface->GetEligibleFrame();
+ *str << frame.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
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698