Merge "SF: add a solid background when hole punching a cached set" into sc-dev am: 4d56aeed59 am: 6415f031b0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/15375775
Change-Id: Ic21c72c4405c1e775228c946967c1b015bbef731
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp b/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp
index 56bb39a..ccacdfb 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp
@@ -216,6 +216,7 @@
}
renderengine::LayerSettings holePunchSettings;
+ renderengine::LayerSettings holePunchBackgroundSettings;
if (mHolePunchLayer) {
auto clientCompositionList =
mHolePunchLayer->getOutputLayer()->getLayerFE().prepareClientCompositionList(
@@ -230,6 +231,15 @@
holePunchSettings.alpha = 0.0f;
holePunchSettings.name = std::string("hole punch layer");
layerSettingsPointers.push_back(&holePunchSettings);
+
+ // Add a solid background as the first layer in case there is no opaque
+ // buffer behind the punch hole
+ holePunchBackgroundSettings.alpha = 1.0f;
+ holePunchBackgroundSettings.name = std::string("holePunchBackground");
+ holePunchBackgroundSettings.geometry.boundaries = holePunchSettings.geometry.boundaries;
+ holePunchBackgroundSettings.geometry.positionTransform =
+ holePunchSettings.geometry.positionTransform;
+ layerSettingsPointers.insert(layerSettingsPointers.begin(), &holePunchBackgroundSettings);
}
if (sDebugHighlighLayers) {
diff --git a/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp b/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp
index b765337..ec81322 100644
--- a/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp
@@ -656,12 +656,22 @@
base::unique_fd&&, base::unique_fd*) -> size_t {
// If the highlight layer is enabled, it will increase the size by 1.
// We're interested in the third layer either way.
- EXPECT_GE(layers.size(), 3u);
- const auto* holePunchSettings = layers[2];
- EXPECT_EQ(nullptr, holePunchSettings->source.buffer.buffer);
- EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), holePunchSettings->source.solidColor);
- EXPECT_TRUE(holePunchSettings->disableBlending);
- EXPECT_EQ(0.0f, holePunchSettings->alpha);
+ EXPECT_GE(layers.size(), 4u);
+ {
+ const auto* holePunchSettings = layers[3];
+ EXPECT_EQ(nullptr, holePunchSettings->source.buffer.buffer);
+ EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), holePunchSettings->source.solidColor);
+ EXPECT_TRUE(holePunchSettings->disableBlending);
+ EXPECT_EQ(0.0f, holePunchSettings->alpha);
+ }
+
+ {
+ const auto* holePunchBackgroundSettings = layers[0];
+ EXPECT_EQ(nullptr, holePunchBackgroundSettings->source.buffer.buffer);
+ EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), holePunchBackgroundSettings->source.solidColor);
+ EXPECT_FALSE(holePunchBackgroundSettings->disableBlending);
+ EXPECT_EQ(1.0f, holePunchBackgroundSettings->alpha);
+ }
return NO_ERROR;
};
@@ -706,12 +716,23 @@
base::unique_fd&&, base::unique_fd*) -> size_t {
// If the highlight layer is enabled, it will increase the size by 1.
// We're interested in the third layer either way.
- EXPECT_GE(layers.size(), 3u);
- const auto* holePunchSettings = layers[2];
- EXPECT_EQ(nullptr, holePunchSettings->source.buffer.buffer);
- EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), holePunchSettings->source.solidColor);
- EXPECT_TRUE(holePunchSettings->disableBlending);
- EXPECT_EQ(0.0f, holePunchSettings->alpha);
+ EXPECT_GE(layers.size(), 4u);
+
+ {
+ const auto* holePunchSettings = layers[3];
+ EXPECT_EQ(nullptr, holePunchSettings->source.buffer.buffer);
+ EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), holePunchSettings->source.solidColor);
+ EXPECT_TRUE(holePunchSettings->disableBlending);
+ EXPECT_EQ(0.0f, holePunchSettings->alpha);
+ }
+
+ {
+ const auto* holePunchBackgroundSettings = layers[0];
+ EXPECT_EQ(nullptr, holePunchBackgroundSettings->source.buffer.buffer);
+ EXPECT_EQ(half3(0.0f, 0.0f, 0.0f), holePunchBackgroundSettings->source.solidColor);
+ EXPECT_FALSE(holePunchBackgroundSettings->disableBlending);
+ EXPECT_EQ(1.0f, holePunchBackgroundSettings->alpha);
+ }
return NO_ERROR;
};