Mark empty EffectLayer as skipContentDraw
An effect layer that only draws a shadow or blurs shouldn't draw a
color. We should skip drawing its contents altogether.
Bug: 189207458
Test: manual
Change-Id: I01bb066d4a02f6111a6974dd241f9530c4979420
diff --git a/services/surfaceflinger/EffectLayer.cpp b/services/surfaceflinger/EffectLayer.cpp
index fd18c3b..0cc5f33 100644
--- a/services/surfaceflinger/EffectLayer.cpp
+++ b/services/surfaceflinger/EffectLayer.cpp
@@ -66,6 +66,7 @@
layerSettings->source.solidColor = getColor().rgb;
results.push_back(*layerSettings);
} else if (hasBlur() || drawShadows()) {
+ layerSettings->skipContentDraw = true;
results.push_back(*layerSettings);
}
@@ -126,7 +127,7 @@
bool EffectLayer::isOpaque(const Layer::State& s) const {
// Consider the layer to be opaque if its opaque flag is set or its effective
// alpha (considering the alpha of its parents as well) is 1.0;
- return (s.flags & layer_state_t::eLayerOpaque) != 0 || getAlpha() == 1.0_hf;
+ return (s.flags & layer_state_t::eLayerOpaque) != 0 || (fillsColor() && getAlpha() == 1.0_hf);
}
ui::Dataspace EffectLayer::getDataSpace() const {
@@ -147,7 +148,7 @@
}
bool EffectLayer::hasBlur() const {
- return getBackgroundBlurRadius() > 0;
+ return getBackgroundBlurRadius() > 0 || getDrawingState().blurRegions.size() > 0;
}
} // namespace android
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index a7c8704..690fda6 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -574,7 +574,8 @@
layerSettings.geometry.positionTransform = getTransform().asMatrix4();
// skip drawing content if the targetSettings indicate the content will be occluded
- layerSettings.skipContentDraw = !targetSettings.realContentIsVisible;
+ layerSettings.skipContentDraw =
+ layerSettings.skipContentDraw || !targetSettings.realContentIsVisible;
if (hasColorTransform()) {
layerSettings.colorTransform = getColorTransform();