Set blockingRegion for DISPLAY_DECORATION layers
Devices that have support for DISPLAY_DECORATION layers may also have
support for a blockingRegion, which will allow the DPU to skip regions
that are known to be transparent, in order to save power.
Use the transparentRegionHint to compute the blockingRegion. It may not
be accurate for all layers, which is why it is only used for
DISPLAY_DECORATION layers.
Add tests.
Bug: 212736475
Test: libcompositionengine_test
Change-Id: I6c5d29614dc8d65d8481150ce717a440192083a0
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
index 132ac02..0b123b1 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
@@ -846,7 +846,8 @@
ui::Dataspace dataspace = kDataspace,
const Region& visibleRegion = kOutputSpaceVisibleRegion,
const Region& surfaceDamage = kSurfaceDamage,
- float whitePointNits = kWhitePointNits) {
+ float whitePointNits = kWhitePointNits,
+ const Region& blockingRegion = Region()) {
EXPECT_CALL(*mHwcLayer, setVisibleRegion(RegionEq(visibleRegion))).WillOnce(Return(kError));
EXPECT_CALL(*mHwcLayer, setDataspace(dataspace)).WillOnce(Return(kError));
EXPECT_CALL(*mHwcLayer, setWhitePointNits(whitePointNits)).WillOnce(Return(kError));
@@ -855,6 +856,8 @@
? hal::Error::UNSUPPORTED
: hal::Error::NONE));
EXPECT_CALL(*mHwcLayer, setSurfaceDamage(RegionEq(surfaceDamage))).WillOnce(Return(kError));
+ EXPECT_CALL(*mHwcLayer, setBlockingRegion(RegionEq(blockingRegion)))
+ .WillOnce(Return(kError));
}
void expectSetCompositionTypeCall(Composition compositionType) {
@@ -1278,6 +1281,23 @@
EXPECT_EQ(Composition::DEVICE, mOutputLayer.getState().hwc->hwcCompositionType);
}
+TEST_F(OutputLayerWriteStateToHWCTest, setBlockingRegion) {
+ mLayerFEState.compositionType = Composition::DISPLAY_DECORATION;
+ const auto blockingRegion = Region(Rect(0, 0, 1000, 1000));
+ mOutputLayer.editState().outputSpaceBlockingRegionHint = blockingRegion;
+
+ expectGeometryCommonCalls();
+ expectPerFrameCommonCalls(SimulateUnsupported::None, kDataspace, kOutputSpaceVisibleRegion,
+ kSurfaceDamage, kWhitePointNits, blockingRegion);
+ expectSetHdrMetadataAndBufferCalls();
+ EXPECT_CALL(*mLayerFE, hasRoundedCorners()).WillRepeatedly(Return(false));
+ expectSetCompositionTypeCall(Composition::DISPLAY_DECORATION);
+
+ mOutputLayer.writeStateToHWC(/*includeGeometry*/ true, /*skipLayer*/ false, 0,
+ /*zIsOverridden*/ false, /*isPeekingThrough*/
+ false);
+}
+
/*
* OutputLayer::writeCursorPositionToHWC()
*/