[Shadows] Create a new composition layer for shadows [6/n]
When generating the list of composition layers, generate one to render
shadows based on the layer settings.
The function passes in the display view port to calculate shadow
position. When rendering a screenshot, use the layerstack of the
root layer to find the display and its viewport since the shadows
on the screenshot have to match how it was rendered on display.
Pass in display or target output dataspace so shadows do not have to
do any color conversion.
Bug: 136561771
Test: go/wm-smoke
Test: libcompositionengine_test
Change-Id: I89795707f054b6a08dabc278d80ed393a0da0a7e
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
index a9a735a..f0a29f0 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
@@ -2048,8 +2048,8 @@
// Sets up the helper functions called by composeSurfaces to use a mock
// implementations.
MOCK_CONST_METHOD0(getSkipColorTransform, bool());
- MOCK_METHOD2(generateClientCompositionRequests,
- std::vector<renderengine::LayerSettings>(bool, Region&));
+ MOCK_METHOD3(generateClientCompositionRequests,
+ std::vector<renderengine::LayerSettings>(bool, Region&, ui::Dataspace));
MOCK_METHOD2(appendRegionFlashRequests,
void(const Region&, std::vector<renderengine::LayerSettings>&));
MOCK_METHOD1(setExpensiveRenderingExpected, void(bool));
@@ -2127,7 +2127,7 @@
EXPECT_CALL(*mRenderSurface, dequeueBuffer(_)).WillOnce(Return(mOutputBuffer));
EXPECT_CALL(mOutput, getSkipColorTransform()).WillOnce(Return(false));
- EXPECT_CALL(mOutput, generateClientCompositionRequests(false, _)).Times(1);
+ EXPECT_CALL(mOutput, generateClientCompositionRequests(false, _, _)).Times(1);
EXPECT_CALL(mOutput, appendRegionFlashRequests(RegionEq(kDebugRegion), _)).Times(1);
EXPECT_CALL(mOutput, setExpensiveRenderingExpected(true)).Times(1);
EXPECT_CALL(mOutput, setExpensiveRenderingExpected(false)).Times(1);
@@ -2144,9 +2144,10 @@
struct OutputPartialMock : public OutputPartialMockBase {
// compositionengine::Output overrides
std::vector<renderengine::LayerSettings> generateClientCompositionRequests(
- bool supportsProtectedContent, Region& clearRegion) override {
+ bool supportsProtectedContent, Region& clearRegion,
+ ui::Dataspace dataspace) override {
return impl::Output::generateClientCompositionRequests(supportsProtectedContent,
- clearRegion);
+ clearRegion, dataspace);
}
};
@@ -2205,6 +2206,8 @@
EXPECT_CALL(leftOutputLayer, needsFiltering()).WillRepeatedly(Return(false));
EXPECT_CALL(leftLayer, getFEState()).WillRepeatedly(ReturnRef(leftLayerFEState));
EXPECT_CALL(leftLayerFE, prepareClientComposition(_)).WillOnce(Return(leftLayerRESettings));
+ EXPECT_CALL(leftLayerFE, prepareShadowClientComposition(_, _, _))
+ .WillOnce(Return(std::optional<renderengine::LayerSettings>()));
EXPECT_CALL(leftOutputLayer, editState()).WillRepeatedly(ReturnRef(leftOutputLayerState));
EXPECT_CALL(rightOutputLayer, getState()).WillRepeatedly(ReturnRef(rightOutputLayerState));
@@ -2214,6 +2217,8 @@
EXPECT_CALL(rightOutputLayer, needsFiltering()).WillRepeatedly(Return(false));
EXPECT_CALL(rightLayer, getFEState()).WillRepeatedly(ReturnRef(rightLayerFEState));
EXPECT_CALL(rightLayerFE, prepareClientComposition(_)).WillOnce(Return(rightLayerRESettings));
+ EXPECT_CALL(rightLayerFE, prepareShadowClientComposition(_, _, _))
+ .WillOnce(Return(std::optional<renderengine::LayerSettings>()));
EXPECT_CALL(rightOutputLayer, editState()).WillRepeatedly(ReturnRef(rightOutputLayerState));
EXPECT_CALL(mOutput, getOutputLayerCount()).WillRepeatedly(Return(2u));
@@ -2237,8 +2242,8 @@
constexpr bool supportsProtectedContent = false;
Region clearRegion;
- auto requests =
- mOutput.generateClientCompositionRequests(supportsProtectedContent, clearRegion);
+ auto requests = mOutput.generateClientCompositionRequests(supportsProtectedContent, clearRegion,
+ mOutput.getState().targetDataspace);
ASSERT_EQ(2u, requests.size());
EXPECT_EQ(leftLayerColor, requests[0].source.solidColor);
@@ -2287,8 +2292,8 @@
constexpr bool supportsProtectedContent = false;
Region clearRegion;
- auto requests =
- mOutput.generateClientCompositionRequests(supportsProtectedContent, clearRegion);
+ auto requests = mOutput.generateClientCompositionRequests(supportsProtectedContent, clearRegion,
+ mOutput.getState().targetDataspace);
EXPECT_EQ(0u, requests.size());
}
@@ -2365,8 +2370,8 @@
constexpr bool supportsProtectedContent = false;
Region clearRegion;
- auto requests =
- mOutput.generateClientCompositionRequests(supportsProtectedContent, clearRegion);
+ auto requests = mOutput.generateClientCompositionRequests(supportsProtectedContent, clearRegion,
+ mOutput.getState().targetDataspace);
const half3 clearColor{0.f, 0.f, 0.f};