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/tests/unittests/CompositionTest.cpp b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
index 3addd61..a09e97a 100644
--- a/services/surfaceflinger/tests/unittests/CompositionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
@@ -754,16 +754,16 @@
}
static void injectLayer(CompositionTest* test, sp<Layer> layer) {
- std::vector<std::unique_ptr<compositionengine::OutputLayer>> outputLayers;
- outputLayers.emplace_back(
- test->mDisplay->getCompositionDisplay()
- ->getOrCreateOutputLayer(layer->getCompositionLayer(), layer));
- test->mDisplay->getCompositionDisplay()->setOutputLayersOrderedByZ(std::move(outputLayers));
-
EXPECT_CALL(*test->mComposer, createLayer(HWC_DISPLAY, _))
.WillOnce(DoAll(SetArgPointee<1>(HWC_LAYER), Return(Error::NONE)));
- layer->createHwcLayer(&test->mFlinger.getHwComposer(), test->mDisplay);
+ std::vector<std::unique_ptr<compositionengine::OutputLayer>> outputLayers;
+ outputLayers.emplace_back(test->mDisplay->getCompositionDisplay()
+ ->getOrCreateOutputLayer(DEFAULT_DISPLAY_ID,
+ layer->getCompositionLayer(),
+ layer));
+
+ test->mDisplay->getCompositionDisplay()->setOutputLayersOrderedByZ(std::move(outputLayers));
Mock::VerifyAndClear(test->mComposer);
@@ -779,10 +779,6 @@
test->mDisplay->getCompositionDisplay()->setOutputLayersOrderedByZ(
std::vector<std::unique_ptr<compositionengine::OutputLayer>>());
-
- for (auto layer : test->mFlinger.mutableDrawingState().layersSortedByZ) {
- layer->destroyHwcLayer(test->mDisplay);
- }
test->mFlinger.mutableDrawingState().layersSortedByZ.clear();
}
};