DO NOT MERGE: Force input window updates when layer visibility changes

This should fix a latency regression introduced by delaying input window
visibility changes. See ag/22210759.

Bug: 270894765
Bug: 275562923
Test: v2/android-crystalball-eng/health/microbench/instr_metric/input_method
Change-Id: I0f64fa148eb4b02600eac9578d3d23ac00c78fa3
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 3a45229..a78144d 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1449,6 +1449,11 @@
     nsecs_t mAnimationTransactionTimeout = s2ns(5);
 
     friend class SurfaceComposerAIDL;
+
+    // Layers visible during the last commit. This set should only be used for testing set equality
+    // and membership. The pointers should not be dereferenced as it's possible the set contains
+    // pointers to freed layers.
+    std::unordered_set<Layer*> mVisibleLayers;
 };
 
 class SurfaceComposerAIDL : public gui::BnSurfaceComposer {