0

Add option to hide invisible layers in PrintLayerHierarchy

This can reduce noise if you're interested in visible layers only.

Bug: None
Change-Id: I664d0aff8120a5f7bf76826a4dabfb435083666e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6254181
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Zoraiz Naeem <zoraiznaeem@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1418986}
This commit is contained in:
Mitsuru Oshima
2025-02-11 16:14:47 -08:00
committed by Chromium LUCI CQ
parent 1ea51eb3e6
commit 0844c70020
3 changed files with 18 additions and 7 deletions

@ -50,7 +50,7 @@ void PrintLayerHierarchy(std::ostringstream* out) {
ui::PrintLayerHierarchy(
layer,
RootWindowController::ForWindow(root)->GetLastMouseLocationInRoot(),
out, child_cb);
/*print_invisible=*/true, out, child_cb);
}
}
}

@ -32,8 +32,13 @@ namespace {
void PrintLayerHierarchyImp(const Layer* layer,
int indent,
const gfx::Point& mouse_location,
bool print_invisible,
std::ostringstream* out,
DebugLayerChildCallback child_cb) {
if (!print_invisible && !layer->visible()) {
return;
}
std::string indent_str(indent, ' ');
gfx::Point transformed_mouse_location = layer->transform()
@ -140,26 +145,30 @@ void PrintLayerHierarchyImp(const Layer* layer,
std::vector<raw_ptr<ui::Layer, VectorExperimental>> children =
child_cb ? child_cb.Run(layer) : layer->children();
for (ui::Layer* child : children) {
PrintLayerHierarchyImp(child, indent + 3, mouse_location_in_layer, out,
child_cb);
PrintLayerHierarchyImp(child, indent + 3, mouse_location_in_layer,
print_invisible, out, child_cb);
}
}
} // namespace
void PrintLayerHierarchy(const Layer* layer, const gfx::Point& mouse_location) {
void PrintLayerHierarchy(const Layer* layer,
const gfx::Point& mouse_location,
bool print_invisible) {
std::ostringstream out;
PrintLayerHierarchy(layer, mouse_location, &out);
PrintLayerHierarchy(layer, mouse_location, print_invisible, &out);
// Error so logs can be collected from end-users.
LOG(ERROR) << out.str();
}
void PrintLayerHierarchy(const Layer* layer,
const gfx::Point& mouse_location,
bool print_invisible,
std::ostringstream* out,
DebugLayerChildCallback child_cb) {
*out << "Layer hierarchy:\n";
PrintLayerHierarchyImp(layer, 0, mouse_location, out, child_cb);
PrintLayerHierarchyImp(layer, 0, mouse_location, print_invisible, out,
child_cb);
}
} // namespace ui

@ -26,13 +26,15 @@ using DebugLayerChildCallback =
// Log the layer hierarchy. Mark layers which contain |mouse_location| with '*'.
COMPOSITOR_EXPORT void PrintLayerHierarchy(const Layer* layer,
const gfx::Point& mouse_location);
const gfx::Point& mouse_location,
bool print_invisible = true);
// Print the layer hierarchy to |out|. Mark layers which contain
// |mouse_location| with '*'.
COMPOSITOR_EXPORT void PrintLayerHierarchy(
const Layer* layer,
const gfx::Point& mouse_location,
bool print_invisible,
std::ostringstream* out,
DebugLayerChildCallback child_cb = DebugLayerChildCallback());