Implement Display Layer Stats
Try to collect data for analyzing how many display controller layers we
need and what we use them for. Also part of a bug fixing for potential
memory leak of existing layer tracing work of winscope.
Test: adb shell dumpsys SurfaceFlinger --enable-layer-stats
Test: adb shell dumpsys SurfaceFlinger --disable-layer-stats
Test: adb shell dumpsys SurfaceFlinger --clear-layer-stats
Test: adb shell dumpsys SurfaceFlinger --dump-layer-stats
Bug: b/73668062
Change-Id: Ie08aa85d34db2c2c767b8e27eb5aad6f7c3fb975
Merged-In: Ie08aa85d34db2c2c767b8e27eb5aad6f7c3fb975
diff --git a/services/surfaceflinger/layerproto/LayerProtoParser.cpp b/services/surfaceflinger/layerproto/LayerProtoParser.cpp
index 1383d28..cef6c21 100644
--- a/services/surfaceflinger/layerproto/LayerProtoParser.cpp
+++ b/services/surfaceflinger/layerproto/LayerProtoParser.cpp
@@ -42,6 +42,11 @@
return sortLayers(lhs.get(), rhs.get());
}
+const LayerProtoParser::LayerGlobal LayerProtoParser::generateLayerGlobalInfo(
+ const LayersProto& layersProto) {
+ return {{layersProto.resolution().w(), layersProto.resolution().h()}};
+}
+
std::vector<std::unique_ptr<LayerProtoParser::Layer>> LayerProtoParser::generateLayerTree(
const LayersProto& layersProto) {
std::unordered_map<int32_t, LayerProtoParser::Layer*> layerMap = generateMap(layersProto);
@@ -106,6 +111,9 @@
layer->activeBuffer = generateActiveBuffer(layerProto.active_buffer());
layer->queuedFrames = layerProto.queued_frames();
layer->refreshPending = layerProto.refresh_pending();
+ layer->hwcFrame = generateRect(layerProto.hwc_frame());
+ layer->hwcCrop = generateFloatRect(layerProto.hwc_crop());
+ layer->hwcTransform = layerProto.hwc_transform();
layer->windowType = layerProto.window_type();
layer->appId = layerProto.app_id();
@@ -133,6 +141,16 @@
return rect;
}
+LayerProtoParser::FloatRect LayerProtoParser::generateFloatRect(const FloatRectProto& rectProto) {
+ LayerProtoParser::FloatRect rect;
+ rect.left = rectProto.left();
+ rect.top = rectProto.top();
+ rect.right = rectProto.right();
+ rect.bottom = rectProto.bottom();
+
+ return rect;
+}
+
LayerProtoParser::Transform LayerProtoParser::generateTransform(
const TransformProto& transformProto) {
LayerProtoParser::Transform transform;
@@ -246,6 +264,10 @@
return StringPrintf("[%3d, %3d, %3d, %3d]", left, top, right, bottom);
}
+std::string LayerProtoParser::FloatRect::to_string() const {
+ return StringPrintf("[%.2f, %.2f, %.2f, %.2f]", left, top, right, bottom);
+}
+
std::string LayerProtoParser::Region::to_string(const char* what) const {
std::string result =
StringPrintf(" Region %s (this=%lx count=%d)\n", what, static_cast<unsigned long>(id),