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/tests/Stress_test.cpp b/services/surfaceflinger/tests/Stress_test.cpp
index 4577153..3e1be8e 100644
--- a/services/surfaceflinger/tests/Stress_test.cpp
+++ b/services/surfaceflinger/tests/Stress_test.cpp
@@ -101,10 +101,7 @@
     for (int i = 0; i < 100000; i++) {
         surfaceflinger::LayersProto layersProto = generateLayerProto();
         auto layerTree = surfaceflinger::LayerProtoParser::generateLayerTree(layersProto);
-        // Allow some layerTrees to just fall out of scope (instead of std::move)
-        if (i % 2) {
-            surfaceflinger::LayerProtoParser::layersToString(std::move(layerTree));
-        }
+        surfaceflinger::LayerProtoParser::layerTreeToString(layerTree);
     }
     system(cmd.c_str());
 }