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/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 166ac22..c3eb1bc 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -635,6 +635,7 @@
hwcInfo.forceClientComposition = true;
} else {
auto transform = static_cast<HWC2::Transform>(orientation);
+ hwcInfo.transform = transform;
auto error = hwcLayer->setTransform(transform);
ALOGE_IF(error != HWC2::Error::None,
"[%s] Failed to set transform %s: "
@@ -1923,6 +1924,21 @@
layerInfo->set_app_id(state.appId);
}
+void Layer::writeToProto(LayerProto* layerInfo, int32_t hwcId) {
+ writeToProto(layerInfo, LayerVector::StateSet::Drawing);
+
+ const auto& hwcInfo = getBE().mHwcLayers.at(hwcId);
+
+ const Rect& frame = hwcInfo.displayFrame;
+ LayerProtoHelper::writeToProto(frame, layerInfo->mutable_hwc_frame());
+
+ const FloatRect& crop = hwcInfo.sourceCrop;
+ LayerProtoHelper::writeToProto(crop, layerInfo->mutable_hwc_crop());
+
+ const int32_t transform = static_cast<int32_t>(hwcInfo.transform);
+ layerInfo->set_hwc_transform(transform);
+}
+
// ---------------------------------------------------------------------------
}; // namespace android