Retrieve a list of composition settings from front end layer
Replace prepareClientComposition and prepareShadowClientComposition
calls with one that provides a list of composition settings in z-order
to handle layers that renders shadows wihtout any content.
If the EffectLayer is called with an invalid color, skip the color fill.
Test: atest libcompositionengine_test
Test: LayerTransactionTest.SetFlagsSecureEUidSystem
Test: go/wm-smoke
Change-Id: Iad16931341fc2e58247f4439a322c0ad1e8750f8
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h
index 912dffd..6cc90cb 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h
@@ -97,6 +97,21 @@
// Modified by each call to prepareClientComposition to indicate the
// region of the target buffer that should be cleared.
Region& clearRegion;
+
+ // Viewport of the target being rendered to. This is used to determine
+ // the shadow light position.
+ const Rect& viewport;
+
+ // Dataspace of the output so we can optimize how to render the shadow
+ // by avoiding unnecessary color space conversions.
+ const ui::Dataspace dataspace;
+
+ // True if the region excluding the shadow is visible.
+ const bool realContentIsVisible;
+
+ // If set to true, change the layer settings to render a clear output.
+ // This may be requested by the HWC
+ const bool clearContent;
};
// A superset of LayerSettings required by RenderEngine to compose a layer
@@ -109,18 +124,12 @@
uint64_t frameNumber = 0;
};
- // Returns the LayerSettings to pass to RenderEngine::drawLayers, or
- // nullopt_t if the layer does not render
- virtual std::optional<LayerSettings> prepareClientComposition(
+ // Returns the z-ordered list of LayerSettings to pass to RenderEngine::drawLayers. The list
+ // may contain shadows casted by the layer or the content of the layer itself. If the layer
+ // does not render then an empty list will be returned.
+ virtual std::vector<LayerSettings> prepareClientCompositionList(
ClientCompositionTargetSettings&) = 0;
- // Returns the LayerSettings used to draw shadows around a layer. It is passed
- // to RenderEngine::drawLayers. Returns nullopt_t if the layer does not render
- // shadows.
- virtual std::optional<LayerSettings> prepareShadowClientComposition(
- const LayerSettings& layerSettings, const Rect& displayViewport,
- ui::Dataspace outputDataspace) = 0;
-
// Called after the layer is displayed to update the presentation fence
virtual void onLayerDisplayed(const sp<Fence>&) = 0;
@@ -142,7 +151,10 @@
lhs.useIdentityTransform == rhs.useIdentityTransform &&
lhs.needsFiltering == rhs.needsFiltering && lhs.isSecure == rhs.isSecure &&
lhs.supportsProtectedContent == rhs.supportsProtectedContent &&
- lhs.clearRegion.hasSameRects(rhs.clearRegion);
+ lhs.clearRegion.hasSameRects(rhs.clearRegion) && lhs.viewport == rhs.viewport &&
+ lhs.dataspace == rhs.dataspace &&
+ lhs.realContentIsVisible == rhs.realContentIsVisible &&
+ lhs.clearContent == rhs.clearContent;
}
static inline bool operator==(const LayerFE::LayerSettings& lhs,
@@ -164,6 +176,12 @@
*os << "\n .supportsProtectedContent = " << settings.supportsProtectedContent;
*os << "\n .clearRegion = ";
PrintTo(settings.clearRegion, os);
+ *os << "\n .viewport = ";
+ PrintTo(settings.viewport, os);
+ *os << "\n .dataspace = ";
+ PrintTo(settings.dataspace, os);
+ *os << "\n .realContentIsVisible = " << settings.realContentIsVisible;
+ *os << "\n .clearContent = " << settings.clearContent;
*os << "\n}";
}
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h
index 5c2ad15..45891a7 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h
@@ -35,11 +35,9 @@
MOCK_METHOD1(onPreComposition, bool(nsecs_t));
MOCK_METHOD1(prepareCompositionState, void(compositionengine::LayerFE::StateSubset));
- MOCK_METHOD1(prepareClientComposition,
- std::optional<LayerSettings>(
+ MOCK_METHOD1(prepareClientCompositionList,
+ std::vector<compositionengine::LayerFE::LayerSettings>(
compositionengine::LayerFE::ClientCompositionTargetSettings&));
- MOCK_METHOD3(prepareShadowClientComposition,
- std::optional<LayerSettings>(const LayerSettings&, const Rect&, ui::Dataspace));
MOCK_METHOD1(onLayerDisplayed, void(const sp<Fence>&));
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index a389bf3..e792f45 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -963,11 +963,16 @@
// rectangle, as by definition the layer must blend with whatever is
// underneath. We also skip the first layer as the buffer target is
// guaranteed to start out cleared.
- bool clearClientComposition =
+ const bool clearClientComposition =
layerState.clearClientTarget && layerFEState->isOpaque && !firstLayer;
ALOGV(" Composition type: client %d clear %d", clientComposition, clearClientComposition);
+ // If the layer casts a shadow but the content casting the shadow is occluded, skip
+ // composing the non-shadow content and only draw the shadows.
+ const bool realContentIsVisible = clientComposition &&
+ !layerState.visibleRegion.subtract(layerState.shadowRegion).isEmpty();
+
if (clientComposition || clearClientComposition) {
compositionengine::LayerFE::ClientCompositionTargetSettings targetSettings{
clip,
@@ -976,35 +981,21 @@
outputState.isSecure,
supportsProtectedContent,
clientComposition ? clearRegion : dummyRegion,
+ outputState.viewport,
+ outputDataspace,
+ realContentIsVisible,
+ !clientComposition, /* clearContent */
};
- if (std::optional<LayerFE::LayerSettings> result =
- layerFE.prepareClientComposition(targetSettings)) {
- if (!clientComposition) {
- LayerFE::LayerSettings& layerSettings = *result;
- layerSettings.source.buffer.buffer = nullptr;
- layerSettings.source.solidColor = half3(0.0, 0.0, 0.0);
- layerSettings.alpha = half(0.0);
- layerSettings.disableBlending = true;
- layerSettings.frameNumber = 0;
- } else {
- std::optional<LayerFE::LayerSettings> shadowLayer =
- layerFE.prepareShadowClientComposition(*result, outputState.viewport,
- outputDataspace);
- if (shadowLayer) {
- clientCompositionLayers.push_back(*shadowLayer);
- }
- }
-
- // If the layer casts a shadow but the content casting the shadow is occluded, skip
- // composing the non-shadow content and only draw the shadows.
- const bool skipNonShadowContentComposition = clientComposition &&
- layerState.visibleRegion.subtract(layerState.shadowRegion).isEmpty();
-
- if (!skipNonShadowContentComposition) {
- layer->editState().clientCompositionTimestamp = systemTime();
- clientCompositionLayers.push_back(*result);
- }
+ std::vector<LayerFE::LayerSettings> results =
+ layerFE.prepareClientCompositionList(targetSettings);
+ if (realContentIsVisible && !results.empty()) {
+ layer->editState().clientCompositionTimestamp = systemTime();
}
+
+ clientCompositionLayers.insert(clientCompositionLayers.end(),
+ std::make_move_iterator(results.begin()),
+ std::make_move_iterator(results.end()));
+ results.clear();
}
firstLayer = false;
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
index 2b45046..be0e9e4 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
@@ -3425,19 +3425,13 @@
LayerFE::LayerSettings mShadowSettings;
mShadowSettings.source.solidColor = {0.1f, 0.1f, 0.1f};
- EXPECT_CALL(mLayers[0].mLayerFE, prepareClientComposition(_)).WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[1].mLayerFE, prepareClientComposition(_))
- .WillOnce(Return(mLayers[1].mLayerSettings));
- EXPECT_CALL(mLayers[1].mLayerFE,
- prepareShadowClientComposition(mLayers[1].mLayerSettings, kDisplayViewport,
- kDisplayDataspace))
- .WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareClientComposition(_))
- .WillOnce(Return(mLayers[2].mLayerSettings));
- EXPECT_CALL(mLayers[2].mLayerFE,
- prepareShadowClientComposition(mLayers[2].mLayerSettings, kDisplayViewport,
- kDisplayDataspace))
- .WillOnce(Return(mShadowSettings));
+ EXPECT_CALL(mLayers[0].mLayerFE, prepareClientCompositionList(_))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
+ EXPECT_CALL(mLayers[1].mLayerFE, prepareClientCompositionList(_))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>({mLayers[1].mLayerSettings})));
+ EXPECT_CALL(mLayers[2].mLayerFE, prepareClientCompositionList(_))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>(
+ {mShadowSettings, mLayers[2].mLayerSettings})));
Region accumClearRegion(Rect(10, 11, 12, 13));
auto requests = mOutput.generateClientCompositionRequests(false /* supportsProtectedContent */,
@@ -3469,10 +3463,8 @@
mLayers[1].mLayerFEState.isOpaque = true;
mLayers[2].mLayerFEState.isOpaque = true;
- EXPECT_CALL(mLayers[2].mLayerFE, prepareClientComposition(_))
- .WillOnce(Return(mLayers[2].mLayerSettings));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareShadowClientComposition(_, _, _))
- .WillOnce(Return(std::nullopt));
+ EXPECT_CALL(mLayers[2].mLayerFE, prepareClientCompositionList(_))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>({mLayers[2].mLayerSettings})));
Region accumClearRegion(Rect(10, 11, 12, 13));
auto requests = mOutput.generateClientCompositionRequests(false /* supportsProtectedContent */,
@@ -3497,10 +3489,8 @@
mLayers[1].mLayerFEState.isOpaque = false;
mLayers[2].mLayerFEState.isOpaque = false;
- EXPECT_CALL(mLayers[2].mLayerFE, prepareClientComposition(_))
- .WillOnce(Return(mLayers[2].mLayerSettings));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareShadowClientComposition(_, _, _))
- .WillOnce(Return(std::nullopt));
+ EXPECT_CALL(mLayers[2].mLayerFE, prepareClientCompositionList(_))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>({mLayers[2].mLayerSettings})));
Region accumClearRegion(Rect(10, 11, 12, 13));
auto requests = mOutput.generateClientCompositionRequests(false /* supportsProtectedContent */,
@@ -3529,25 +3519,51 @@
mLayers[0].mLayerFEState.isOpaque = true;
mLayers[1].mLayerFEState.isOpaque = true;
mLayers[2].mLayerFEState.isOpaque = true;
-
- EXPECT_CALL(mLayers[1].mLayerFE, prepareClientComposition(_))
- .WillOnce(Return(mLayers[1].mLayerSettings));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareClientComposition(_))
- .WillOnce(Return(mLayers[2].mLayerSettings));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareShadowClientComposition(_, _, _))
- .WillOnce(Return(std::nullopt));
-
Region accumClearRegion(Rect(10, 11, 12, 13));
+ Region dummyRegion;
+
+ compositionengine::LayerFE::ClientCompositionTargetSettings layer1TargetSettings{
+ Region(kDisplayFrame),
+ false, /* identity transform */
+ false, /* needs filtering */
+ false, /* secure */
+ false, /* supports protected content */
+ dummyRegion, /* clear region */
+ kDisplayViewport,
+ kDisplayDataspace,
+ false /* realContentIsVisible */,
+ true /* clearContent */,
+ };
+ compositionengine::LayerFE::ClientCompositionTargetSettings layer2TargetSettings{
+ Region(kDisplayFrame),
+ false, /* identity transform */
+ false, /* needs filtering */
+ false, /* secure */
+ false, /* supports protected content */
+ accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
+ };
+
+ LayerFE::LayerSettings mBlackoutSettings = mLayers[1].mLayerSettings;
+ mBlackoutSettings.source.buffer.buffer = nullptr;
+ mBlackoutSettings.source.solidColor = {0.1f, 0.1f, 0.1f};
+ mBlackoutSettings.alpha = 0.f;
+ mBlackoutSettings.disableBlending = true;
+
+ EXPECT_CALL(mLayers[1].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer1TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>({mBlackoutSettings})));
+ EXPECT_CALL(mLayers[2].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer2TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>({mLayers[2].mLayerSettings})));
+
auto requests = mOutput.generateClientCompositionRequests(false /* supportsProtectedContent */,
accumClearRegion, kDisplayDataspace);
ASSERT_EQ(2u, requests.size());
// The second layer is expected to be rendered as alpha=0 black with no blending
- EXPECT_EQ(mLayers[1].mLayerSettings.geometry.boundaries, requests[0].geometry.boundaries);
- EXPECT_FALSE(requests[0].source.buffer.buffer);
- EXPECT_EQ((half3{0.f, 0.f, 0.f}), requests[0].source.solidColor);
- EXPECT_EQ(0.f, static_cast<float>(requests[0].alpha));
- EXPECT_EQ(true, requests[0].disableBlending);
+ EXPECT_EQ(mBlackoutSettings, requests[0]);
EXPECT_EQ(mLayers[2].mLayerSettings, requests[1]);
@@ -3569,6 +3585,10 @@
false, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
compositionengine::LayerFE::ClientCompositionTargetSettings layer1TargetSettings{
Region(Rect(0, 0, 30, 30)),
@@ -3577,6 +3597,10 @@
false, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
compositionengine::LayerFE::ClientCompositionTargetSettings layer2TargetSettings{
Region(Rect(0, 0, 40, 201)),
@@ -3585,14 +3609,18 @@
false, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
- EXPECT_CALL(mLayers[0].mLayerFE, prepareClientComposition(Eq(ByRef(layer0TargetSettings))))
- .WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[1].mLayerFE, prepareClientComposition(Eq(ByRef(layer1TargetSettings))))
- .WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareClientComposition(Eq(ByRef(layer2TargetSettings))))
- .WillOnce(Return(std::nullopt));
+ EXPECT_CALL(mLayers[0].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer0TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
+ EXPECT_CALL(mLayers[1].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer1TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
+ EXPECT_CALL(mLayers[2].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer2TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
static_cast<void>(
mOutput.generateClientCompositionRequests(false /* supportsProtectedContent */,
@@ -3613,6 +3641,10 @@
false, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
compositionengine::LayerFE::ClientCompositionTargetSettings layer1TargetSettings{
Region(kDisplayFrame),
@@ -3621,6 +3653,10 @@
false, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
compositionengine::LayerFE::ClientCompositionTargetSettings layer2TargetSettings{
Region(kDisplayFrame),
@@ -3629,14 +3665,18 @@
false, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
- EXPECT_CALL(mLayers[0].mLayerFE, prepareClientComposition(Eq(ByRef(layer0TargetSettings))))
- .WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[1].mLayerFE, prepareClientComposition(Eq(ByRef(layer1TargetSettings))))
- .WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareClientComposition(Eq(ByRef(layer2TargetSettings))))
- .WillOnce(Return(std::nullopt));
+ EXPECT_CALL(mLayers[0].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer0TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
+ EXPECT_CALL(mLayers[1].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer1TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
+ EXPECT_CALL(mLayers[2].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer2TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
static_cast<void>(
mOutput.generateClientCompositionRequests(false /* supportsProtectedContent */,
@@ -3657,6 +3697,11 @@
false, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
+
};
compositionengine::LayerFE::ClientCompositionTargetSettings layer1TargetSettings{
Region(kDisplayFrame),
@@ -3665,6 +3710,10 @@
false, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
compositionengine::LayerFE::ClientCompositionTargetSettings layer2TargetSettings{
Region(kDisplayFrame),
@@ -3673,14 +3722,18 @@
false, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
- EXPECT_CALL(mLayers[0].mLayerFE, prepareClientComposition(Eq(ByRef(layer0TargetSettings))))
- .WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[1].mLayerFE, prepareClientComposition(Eq(ByRef(layer1TargetSettings))))
- .WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareClientComposition(Eq(ByRef(layer2TargetSettings))))
- .WillOnce(Return(std::nullopt));
+ EXPECT_CALL(mLayers[0].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer0TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
+ EXPECT_CALL(mLayers[1].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer1TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
+ EXPECT_CALL(mLayers[2].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer2TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
static_cast<void>(
mOutput.generateClientCompositionRequests(false /* supportsProtectedContent */,
@@ -3700,6 +3753,10 @@
true, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
compositionengine::LayerFE::ClientCompositionTargetSettings layer1TargetSettings{
Region(kDisplayFrame),
@@ -3708,6 +3765,10 @@
true, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
compositionengine::LayerFE::ClientCompositionTargetSettings layer2TargetSettings{
Region(kDisplayFrame),
@@ -3716,14 +3777,18 @@
true, /* secure */
false, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
- EXPECT_CALL(mLayers[0].mLayerFE, prepareClientComposition(Eq(ByRef(layer0TargetSettings))))
- .WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[1].mLayerFE, prepareClientComposition(Eq(ByRef(layer1TargetSettings))))
- .WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareClientComposition(Eq(ByRef(layer2TargetSettings))))
- .WillOnce(Return(std::nullopt));
+ EXPECT_CALL(mLayers[0].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer0TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
+ EXPECT_CALL(mLayers[1].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer1TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
+ EXPECT_CALL(mLayers[2].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer2TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
static_cast<void>(
mOutput.generateClientCompositionRequests(false /* supportsProtectedContent */,
@@ -3741,6 +3806,10 @@
false, /* secure */
true, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
compositionengine::LayerFE::ClientCompositionTargetSettings layer1TargetSettings{
Region(kDisplayFrame),
@@ -3749,6 +3818,10 @@
false, /* secure */
true, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
compositionengine::LayerFE::ClientCompositionTargetSettings layer2TargetSettings{
Region(kDisplayFrame),
@@ -3757,14 +3830,18 @@
false, /* secure */
true, /* supports protected content */
accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
- EXPECT_CALL(mLayers[0].mLayerFE, prepareClientComposition(Eq(ByRef(layer0TargetSettings))))
- .WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[1].mLayerFE, prepareClientComposition(Eq(ByRef(layer1TargetSettings))))
- .WillOnce(Return(std::nullopt));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareClientComposition(Eq(ByRef(layer2TargetSettings))))
- .WillOnce(Return(std::nullopt));
+ EXPECT_CALL(mLayers[0].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer0TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
+ EXPECT_CALL(mLayers[1].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer1TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
+ EXPECT_CALL(mLayers[2].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer2TargetSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>()));
static_cast<void>(mOutput.generateClientCompositionRequests(true /* supportsProtectedContent */,
accumClearRegion,
@@ -3847,16 +3924,16 @@
true, /* secure */
true, /* supports protected content */
accumClearRegion,
+ kPortraitViewport,
+ kOutputDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
EXPECT_CALL(leftLayer.mOutputLayer, requiresClientComposition()).WillRepeatedly(Return(true));
EXPECT_CALL(leftLayer.mOutputLayer, needsFiltering()).WillRepeatedly(Return(false));
- EXPECT_CALL(leftLayer.mLayerFE, prepareClientComposition(Eq(ByRef(leftLayerSettings))))
- .WillOnce(Return(leftLayer.mLayerSettings));
- EXPECT_CALL(leftLayer.mLayerFE,
- prepareShadowClientComposition(leftLayer.mLayerSettings, kPortraitViewport,
- kOutputDataspace))
- .WillOnce(Return(std::nullopt));
+ EXPECT_CALL(leftLayer.mLayerFE, prepareClientCompositionList(Eq(ByRef(leftLayerSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>({leftLayer.mLayerSettings})));
compositionengine::LayerFE::ClientCompositionTargetSettings rightLayerSettings{
Region(Rect(1000, 0, 2000, 1000)),
@@ -3865,16 +3942,16 @@
true, /* secure */
true, /* supports protected content */
accumClearRegion,
+ kPortraitViewport,
+ kOutputDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
};
EXPECT_CALL(rightLayer.mOutputLayer, requiresClientComposition()).WillRepeatedly(Return(true));
EXPECT_CALL(rightLayer.mOutputLayer, needsFiltering()).WillRepeatedly(Return(false));
- EXPECT_CALL(rightLayer.mLayerFE, prepareClientComposition(Eq(ByRef(rightLayerSettings))))
- .WillOnce(Return(rightLayer.mLayerSettings));
- EXPECT_CALL(rightLayer.mLayerFE,
- prepareShadowClientComposition(rightLayer.mLayerSettings, kPortraitViewport,
- kOutputDataspace))
- .WillOnce(Return(std::nullopt));
+ EXPECT_CALL(rightLayer.mLayerFE, prepareClientCompositionList(Eq(ByRef(rightLayerSettings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>({rightLayer.mLayerSettings})));
constexpr bool supportsProtectedContent = true;
auto requests = mOutput.generateClientCompositionRequests(supportsProtectedContent,
@@ -3891,6 +3968,20 @@
const Region kShadowRegion = Region(kContentWithShadow).subtract(kContent);
const Region kPartialShadowRegion = Region(kContentWithShadow).subtract(Rect(40, 40, 60, 80));
+ Region accumClearRegion(Rect(10, 11, 12, 13));
+ compositionengine::LayerFE::ClientCompositionTargetSettings layer2Settings{
+ Region(Rect(60, 40, 70, 80)).merge(Rect(40, 80, 70, 90)), /* visible region */
+ false, /* identity transform */
+ false, /* needs filtering */
+ false, /* secure */
+ false, /* supports protected content */
+ accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ false /* realContentIsVisible */,
+ false /* clearContent */,
+ };
+
LayerFE::LayerSettings mShadowSettings;
mShadowSettings.source.solidColor = {0.1f, 0.1f, 0.1f};
@@ -3899,14 +3990,9 @@
EXPECT_CALL(mLayers[0].mOutputLayer, requiresClientComposition()).WillOnce(Return(false));
EXPECT_CALL(mLayers[1].mOutputLayer, requiresClientComposition()).WillOnce(Return(false));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareClientComposition(_))
- .WillOnce(Return(mLayers[2].mLayerSettings));
- EXPECT_CALL(mLayers[2].mLayerFE,
- prepareShadowClientComposition(mLayers[2].mLayerSettings, kDisplayViewport,
- kDisplayDataspace))
- .WillOnce(Return(mShadowSettings));
+ EXPECT_CALL(mLayers[2].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer2Settings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>({mShadowSettings})));
- Region accumClearRegion(Rect(10, 11, 12, 13));
auto requests = mOutput.generateClientCompositionRequests(false /* supportsProtectedContent */,
accumClearRegion, kDisplayDataspace);
ASSERT_EQ(1u, requests.size());
@@ -3928,16 +4014,26 @@
mLayers[2].mOutputLayerState.visibleRegion = kPartialContentWithPartialShadowRegion;
mLayers[2].mOutputLayerState.shadowRegion = kShadowRegion;
+ Region accumClearRegion(Rect(10, 11, 12, 13));
+ compositionengine::LayerFE::ClientCompositionTargetSettings layer2Settings{
+ Region(Rect(50, 40, 70, 80)).merge(Rect(40, 80, 70, 90)), /* visible region */
+ false, /* identity transform */
+ false, /* needs filtering */
+ false, /* secure */
+ false, /* supports protected content */
+ accumClearRegion,
+ kDisplayViewport,
+ kDisplayDataspace,
+ true /* realContentIsVisible */,
+ false /* clearContent */,
+ };
+
EXPECT_CALL(mLayers[0].mOutputLayer, requiresClientComposition()).WillOnce(Return(false));
EXPECT_CALL(mLayers[1].mOutputLayer, requiresClientComposition()).WillOnce(Return(false));
- EXPECT_CALL(mLayers[2].mLayerFE, prepareClientComposition(_))
- .WillOnce(Return(mLayers[2].mLayerSettings));
- EXPECT_CALL(mLayers[2].mLayerFE,
- prepareShadowClientComposition(mLayers[2].mLayerSettings, kDisplayViewport,
- kDisplayDataspace))
- .WillOnce(Return(mShadowSettings));
+ EXPECT_CALL(mLayers[2].mLayerFE, prepareClientCompositionList(Eq(ByRef(layer2Settings))))
+ .WillOnce(Return(std::vector<LayerFE::LayerSettings>(
+ {mShadowSettings, mLayers[2].mLayerSettings})));
- Region accumClearRegion(Rect(10, 11, 12, 13));
auto requests = mOutput.generateClientCompositionRequests(false /* supportsProtectedContent */,
accumClearRegion, kDisplayDataspace);
ASSERT_EQ(2u, requests.size());