summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/LayerProtoHelper.cpp
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-08-28 20:15:37 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-08-28 20:15:37 +0000
commitd3ee7150d0719fb2f29529f5d20daba23f0ab0e5 (patch)
tree99ec44f4c56e85d72006a5e7de06608bef796419 /services/surfaceflinger/LayerProtoHelper.cpp
parenta5d13e05b412ab26b1ce7bc66713446d89078868 (diff)
parentb46e37c027e95c2b2b7ff48989af633e4780642e (diff)
Merge "Include offscreen layers in generated trace" into main
Diffstat (limited to 'services/surfaceflinger/LayerProtoHelper.cpp')
-rw-r--r--services/surfaceflinger/LayerProtoHelper.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/services/surfaceflinger/LayerProtoHelper.cpp b/services/surfaceflinger/LayerProtoHelper.cpp
index 0d2987c94a..885c3d3460 100644
--- a/services/surfaceflinger/LayerProtoHelper.cpp
+++ b/services/surfaceflinger/LayerProtoHelper.cpp
@@ -263,7 +263,7 @@ void LayerProtoHelper::readFromProto(const perfetto::protos::BlurRegion& proto,
outRegion.bottom = proto.bottom();
}
-perfetto::protos::LayersProto LayerProtoFromSnapshotGenerator::generate(
+LayerProtoFromSnapshotGenerator& LayerProtoFromSnapshotGenerator::with(
const frontend::LayerHierarchy& root) {
mLayersProto.clear_layers();
mVisitedLayers.clear();
@@ -305,9 +305,40 @@ perfetto::protos::LayersProto LayerProtoFromSnapshotGenerator::generate(
}
}
- mDefaultSnapshots.clear();
- mChildToRelativeParent.clear();
- return std::move(mLayersProto);
+ return *this;
+}
+
+LayerProtoFromSnapshotGenerator& LayerProtoFromSnapshotGenerator::withOffscreenLayers(
+ const frontend::LayerHierarchy& offscreenRoot) {
+ // Add a fake invisible root layer to the proto output and parent all the offscreen layers to
+ // it.
+ perfetto::protos::LayerProto* rootProto = mLayersProto.add_layers();
+ const int32_t offscreenRootLayerId = INT32_MAX - 2;
+ rootProto->set_id(offscreenRootLayerId);
+ rootProto->set_name("Offscreen Root");
+ rootProto->set_parent(-1);
+
+ perfetto::protos::LayersProto offscreenLayers =
+ LayerProtoFromSnapshotGenerator(mSnapshotBuilder, mDisplayInfos, mLegacyLayers,
+ mTraceFlags)
+ .with(offscreenRoot)
+ .generate();
+
+ for (int i = 0; i < offscreenLayers.layers_size(); i++) {
+ perfetto::protos::LayerProto* layerProto = offscreenLayers.mutable_layers()->Mutable(i);
+ if (layerProto->parent() == -1) {
+ layerProto->set_parent(offscreenRootLayerId);
+ // Add layer as child of the fake root
+ rootProto->add_children(layerProto->id());
+ }
+ }
+
+ mLayersProto.mutable_layers()->Reserve(mLayersProto.layers_size() +
+ offscreenLayers.layers_size());
+ std::copy(offscreenLayers.layers().begin(), offscreenLayers.layers().end(),
+ RepeatedFieldBackInserter(mLayersProto.mutable_layers()));
+
+ return *this;
}
frontend::LayerSnapshot* LayerProtoFromSnapshotGenerator::getSnapshot(