SurfaceFlinger: Rip out Input caching scheme.

A few weeks ago we implemented a scheme where we won't update
InputWindowInfo if no windows with InputChannels are updated.
However in preparation for an occlusion detection fix we will be
sending input windows for all buffered surfaces (regardless of whether
they have an InputChannel) to InputDispatcher. This means the caching
scheme is effectively useless.

Bug: 152064592
Test: Existing tests pass
Change-Id: I49d0afa9ef6bd620c7632338a5dacca724bd46b8
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index 54cd04f..5b28384 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -497,10 +497,6 @@
         }
     }
 
-    if (recomputeVisibleRegions == true) {
-        maybeDirtyInput();
-    }
-
     return true;
 }
 
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index f9dff12..8452957 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -220,9 +220,6 @@
     }
 
     mFlinger->markLayerPendingRemovalLocked(this);
-    if (hasInput()) {
-        mFlinger->dirtyInput();
-    }
 }
 
 void Layer::onRemovedFromCurrentState() {
@@ -998,8 +995,6 @@
     mPendingStatesSnapshot = mPendingStates;
     mCurrentState.callbackHandles = {};
 
-    maybeDirtyInput();
-
     return flags;
 }
 
@@ -2548,32 +2543,6 @@
     }
 }
 
-bool Layer::maybeDirtyInput() {
-    // No sense redirtying input.
-    if (mFlinger->inputDirty()) return true;
-
-    if (hasInput()) {
-        mFlinger->dirtyInput();
-        return true;
-    }
-
-    // If a child or relative dirties the input, no sense continuing to traverse
-    // so we return early and halt the recursion. We traverse ourselves instead
-    // of using traverse() so we can implement this early halt.
-    for (const sp<Layer>& child : mDrawingChildren) {
-        if (child->maybeDirtyInput()) {
-            return true;
-        }
-    }
-    for (const wp<Layer>& weakRelative : mDrawingState.zOrderRelatives) {
-        sp<Layer> relative = weakRelative.promote();
-        if (relative && relative->maybeDirtyInput()) {
-            return true;
-        }
-    }
-    return false;
-}
-
 // ---------------------------------------------------------------------------
 
 }; // namespace android
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 92ac015..6636b5e 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -1015,10 +1015,6 @@
     // Window types from WindowManager.LayoutParams
     const int mWindowType;
 
-    // Called when mDrawingState has changed. If we or one of our children/relatives hasInput()
-    // then we will dirty the setInputWindows cache.
-    bool maybeDirtyInput();
-
 private:
     /**
      * Returns an unsorted vector of all layers that are part of this tree.
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a86e8f0..422d270 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2897,19 +2897,6 @@
 void SurfaceFlinger::updateInputWindowInfo() {
     std::vector<InputWindowInfo> inputHandles;
 
-    // We use a simple caching algorithm here. mInputDirty begins as true,
-    // after we call setInputWindows we set it to false, so
-    // in the future we wont call it again.. We set input dirty to true again
-    // when any layer that hasInput() has a transaction performed on it
-    // or when any parent or relative parent of such a layer has a transaction
-    // performed on it. Not all of these transactions will really result in
-    // input changes but all input changes will spring from these transactions
-    // so the cache is safe but not optimal. It seems like it might be annoyingly
-    // costly to cache and comapre the actual InputWindowHandle vector though.
-    if (!mInputDirty && !mInputWindowCommands.syncInputWindows) {
-        return;
-    }
-
     mDrawingState.traverseInReverseZOrder([&](Layer* layer) {
         if (layer->hasInput()) {
             // When calculating the screen bounds we ignore the transparent region since it may
@@ -2921,8 +2908,6 @@
     mInputFlinger->setInputWindows(inputHandles,
                                    mInputWindowCommands.syncInputWindows ? mSetInputWindowsListener
                                                                          : nullptr);
-
-    mInputDirty = false;
 }
 
 void SurfaceFlinger::commitInputWindowCommands() {
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index dd7d887..8ac064d 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1255,11 +1255,6 @@
     nsecs_t mMissedFrameJankStart = 0;
     int32_t mMissedFrameJankCount = 0;
 
-    // See updateInputWindowInfo() for details
-    std::atomic<bool> mInputDirty = true;
-    void dirtyInput() { mInputDirty = true; }
-    bool inputDirty() { return mInputDirty; }
-
     int mFrameRateFlexibilityTokenCount = 0;
 
     sp<IBinder> mDebugFrameRateFlexibilityToken;