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
Bug: b/74071380
Change-Id: Ie08aa85d34db2c2c767b8e27eb5aad6f7c3fb975
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index bebd6a5..d6aa142 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -56,6 +56,7 @@
#include "DisplayDevice.h"
#include "DispSync.h"
#include "FrameTracker.h"
+#include "LayerStats.h"
#include "LayerVector.h"
#include "MessageQueue.h"
#include "SurfaceInterceptor.h"
@@ -631,6 +632,7 @@
void doComposition();
void doDebugFlashRegions();
void doTracing(const char* where);
+ void logLayerStats();
void doDisplayComposition(const sp<const DisplayDevice>& displayDevice, const Region& dirtyRegion);
// compose surfaces for display hw. this fails if using GL and the surface
@@ -693,6 +695,7 @@
void dumpBufferingStats(String8& result) const;
void dumpWideColorInfo(String8& result) const;
LayersProto dumpProtoInfo(LayerVector::StateSet stateSet) const;
+ LayersProto dumpVisibleLayersProtoInfo(int32_t hwcId) const;
bool isLayerTripleBufferingDisabled() const {
return this->mLayerTripleBufferingDisabled;
@@ -777,6 +780,7 @@
bool mPropagateBackpressure = true;
SurfaceInterceptor mInterceptor;
SurfaceTracing mTracing;
+ LayerStats mLayerStats;
bool mUseHwcVirtualDisplays = false;
// Restrict layers to use two buffers in their bufferqueues.