SF: Move management of HWC layers to compositionengine::OutputLayer

OutputLayer creates a HWC layer (if appropriate) on initialization, and
the HWC layer is destroyed with the OutputLayer.

Removes all explicit calls to create/destroy the HWC layers from the front-end
Layer code, and a few other places.

A call is also added to destroy all OutputLayers before switching in or
out of VrComposer mode. This change already marked the geometry as dirty
-- this just ensures all the HWC layers are recreated.

Test: atest libsurfaceflinger_unittest libcompositionengine_test
Test: atest dvr_display-test
Test: atest CtsViewTestCases
Bug: 121291683
Bug: 124537779
Change-Id: Ib7aec9e998ed5481d2753d19b061ba922e54bfe0
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index f97add4..ad4c7bf 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -217,13 +217,14 @@
 }
 
 std::unique_ptr<compositionengine::OutputLayer> Output::getOrCreateOutputLayer(
-        std::shared_ptr<compositionengine::Layer> layer, sp<compositionengine::LayerFE> layerFE) {
+        std::optional<DisplayId> displayId, std::shared_ptr<compositionengine::Layer> layer,
+        sp<compositionengine::LayerFE> layerFE) {
     for (auto& outputLayer : mOutputLayersOrderedByZ) {
         if (outputLayer && &outputLayer->getLayer() == layer.get()) {
             return std::move(outputLayer);
         }
     }
-    return createOutputLayer(*this, layer, layerFE);
+    return createOutputLayer(mCompositionEngine, displayId, *this, layer, layerFE);
 }
 
 void Output::setOutputLayersOrderedByZ(OutputLayers&& layers) {