CE: Move knowledge of the OutputLayers out of Output

This separates knowledge of the type and management of OutputLayers from
the implementation of the Output class.

1) getOutputLayersOrderedByZ() is now a non-virtual function which
returns a helper object for iterating over all the layers in the Output,
with only minor code changes to the callers. Internally the helper
object uses a pair of virtual functions to get the count and access a
layer by index. The old interface fixed both the type of the layer and
the type of container it was stored in, which was problematic.

2) When rebuilding the layer stack, the implementation now uses
additional abstract interface functions that allow the layer stack to be
maniupluated without the caller having to own even temporarily instances
of the OutputLayer type.

3) The Output interface has been cleaned up to remove functions that
were no longer needed in the public interface, and to introduce a few
others such as injectOutputLayerForTest() and clearOutputLayers() for
performing special layer manipulations.

Test: atest libsurfaceflinger_unittest libcompositionengine_test
Test: go/wm-smoke
Bug: 121291683
Change-Id: I636cfaea7254c7e164837ef8b441932f364808f3
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a9632ec..f56e679 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1509,8 +1509,7 @@
     // any HWC layers are destroyed through that interface before it becomes
     // invalid.
     for (const auto& [token, displayDevice] : mDisplays) {
-        displayDevice->getCompositionDisplay()->setOutputLayersOrderedByZ(
-                compositionengine::Output::OutputLayers());
+        displayDevice->getCompositionDisplay()->clearOutputLayers();
     }
 
     // This DisplayDevice will no longer be relevant once resetDisplayState() is