surfaceflinger: simplify memory management for layerproto
Use std::vector<Layer> instead of a tree of std::unique_ptr<Layer>
to manage layers. This significantly reduces the number of
allocations, and more importantly, we can get rid of "new" in
generateLayer. Because there is no "new", it is easier to reason
that there is no leaked layer.
We still keep the pointers to top-level layers in
LayerTree::topLevelLayers. But AFAICT, we probably don't need it
after all.
Test: dumpsys, winscope trace
Change-Id: I302c9115ab025b69e9ea05f4bcd759ed3ee4a8eb
diff --git a/services/surfaceflinger/LayerStats.h b/services/surfaceflinger/LayerStats.h
index 7a190fd..944073b 100644
--- a/services/surfaceflinger/LayerStats.h
+++ b/services/surfaceflinger/LayerStats.h
@@ -38,7 +38,7 @@
private:
// Traverse layer tree to get all visible layers' stats
void traverseLayerTreeStatsLocked(
- const std::vector<std::unique_ptr<LayerProtoParser::Layer>>& layerTree,
+ const std::vector<LayerProtoParser::Layer*>& layerTree,
const LayerProtoParser::LayerGlobal& layerGlobal,
std::vector<std::string>* const outLayerShapeVec);
// Convert layer's top-left position into 8x8 percentage of the display