Release buffers early after GL comp

When client comped a layers buffers are never really
acquired/released by HWC, since they are already composited
by the time they are sent there. This means we don't
need to wait on the release fence from the next
frame in order to release the buffer. As soon as
we receive a new buffer we can directly release with the previous
GL comp fence. We accomplish this by plumbing the GL comp fence
down to BufferStateLayer, and using it for early release
from setBuffer when applicable.

Bug: 200284594
Test: Existing tests pass
Change-Id: Ib76a8a02efd85ef2925d4fb32c3f096c55d383e1
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index f29ebde..d17c05b 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -623,6 +623,11 @@
     std::vector<compositionengine::LayerFE::LayerSettings> prepareClientCompositionList(
             compositionengine::LayerFE::ClientCompositionTargetSettings&) override;
     void onLayerDisplayed(const sp<Fence>& releaseFence) override;
+
+    void setWasClientComposed(const sp<Fence>& fence) override {
+        mLastClientCompositionFence = fence;
+    }
+
     const char* getDebugName() const override;
 
     bool setShadowRadius(float shadowRadius);
@@ -1028,6 +1033,8 @@
 
     mutable bool mDrawingStateModified = false;
 
+    sp<Fence> mLastClientCompositionFence;
+    bool mLastClientCompositionDisplayed = false;
 private:
     virtual void setTransformHint(ui::Transform::RotationFlags) {}