Prevent HDRLayerInfoListener traversal from running on every frame
We should only have to update the HDRLayerInfoListener in a few
scenarios.
1. A new listener appeared
2. A buffer changed colorspace
3. Surface geometry (visibility, parenting, display, etc) changed
We protect the traversal behind these flags to avoid the runtime in the
hot path of continuous buffer updates. A follow up fix could consider
directly recursively traversing and early returning if !Layer->isVisible.
Bug: 186200583
Test: Existing tests pass, simpleperf
Change-Id: I549fdf6ea228344f79f6989b86b8e73a6065158a
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index b9b26db..59fd218 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1240,11 +1240,19 @@
State mDrawingState{LayerVector::StateSet::Drawing};
bool mVisibleRegionsDirty = false;
+ // VisibleRegions dirty is already cleared by postComp, but we need to track it to prevent
+ // extra work in the HDR layer info listener.
+ bool mVisibleRegionsWereDirtyThisFrame = false;
+ // Used to ensure we omit a callback when HDR layer info listener is newly added but the
+ // scene hasn't changed
+ bool mAddingHDRLayerInfoListener = false;
+
// Set during transaction application stage to track if the input info or children
// for a layer has changed.
// TODO: Also move visibleRegions over to a boolean system.
bool mInputInfoChanged = false;
bool mSomeChildrenChanged;
+ bool mSomeDataspaceChanged = false;
bool mForceTransactionDisplayChange = false;
bool mGeometryInvalid = false;