[sf] Set visible regions change flag when layer starts drawing
If a layer state changes so it has a buffer or an effect like
color then, update the flags to indicate that visiblity of a
snapshot has changed. This will mark the visible regions
flag in CE args and force CE to rebuild its layer stack.
Without this flag, there was a scenario where CE
would get a null snapshot and crash.
Also crash early with traces if we ever pass a null snapshot to
CE.
Test: presubmit
Bug: 238781169, 295069311, 294889236
Change-Id: I355502fbe7f1be38c46a5ed25233b6b07c6b4eeb
diff --git a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
index a5d5563..8a39cd6 100644
--- a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
+++ b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
@@ -150,7 +150,7 @@
const bool hadSideStream = sidebandStream != nullptr;
const layer_state_t& clientState = resolvedComposerState.state;
- const bool hadBlur = hasBlur();
+ const bool hadSomethingToDraw = hasSomethingToDraw();
uint64_t clientChanges = what | layer_state_t::diff(clientState);
layer_state_t::merge(clientState);
what = clientChanges;
@@ -228,11 +228,10 @@
RequestedLayerState::Changes::VisibleRegion;
}
}
- if (what & (layer_state_t::eBackgroundBlurRadiusChanged | layer_state_t::eBlurRegionsChanged)) {
- if (hadBlur != hasBlur()) {
- changes |= RequestedLayerState::Changes::Visibility |
- RequestedLayerState::Changes::VisibleRegion;
- }
+
+ if (hadSomethingToDraw != hasSomethingToDraw()) {
+ changes |= RequestedLayerState::Changes::Visibility |
+ RequestedLayerState::Changes::VisibleRegion;
}
if (clientChanges & layer_state_t::HIERARCHY_CHANGES)
changes |= RequestedLayerState::Changes::Hierarchy;
@@ -579,6 +578,12 @@
return externalTexture && externalTexture->getUsage() & GRALLOC_USAGE_PROTECTED;
}
+bool RequestedLayerState::hasSomethingToDraw() const {
+ return externalTexture != nullptr || sidebandStream != nullptr || shadowRadius > 0.f ||
+ backgroundBlurRadius > 0 || blurRegions.size() > 0 ||
+ (color.r >= 0.0_hf && color.g >= 0.0_hf && color.b >= 0.0_hf);
+}
+
void RequestedLayerState::clearChanges() {
what = 0;
changes.clear();