Call release buffer if the buffer is overwritten in the client

Clients can overwrite the buffer in a transaction before it's applied.
When this happens, the buffer is then replaced, but the client doesn't
get a callback that the buffer was released. This could cause the client
to run out of buffers since the dropped ones become lost.

This can happen in two situations:
1. Merging two transactions where each has a buffer for the same
SurfaceControl
2. Transaction.setBuffer is called multiple times before an apply

In both cases, call the release callback so the client can properly
handle the dropped buffers.

It's also possible that the merging occurs in a different process than
the one that set the buffer. Because of that, we need to ensure we call
the correct releaseBufferListener that's associated with the one that
set the buffer.

The transformHint is removed from the releaseCallback since it's already
provided in the transaction callback. It was originally added in the
release callback to give it to BBQ early so it can know the new
transform hint before rendering a new frame. However, the transform hint
is now provided by VRI to BBQ so it no longer needs to be sent back via
release callback.

Test: ReleaseBufferCallbackTest
Change-Id: I9df0c713bf841f53e1a3d092f33179573a680dc4
Bug: 200285149
diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp
index 4eeaba1..099b85b 100644
--- a/services/surfaceflinger/BufferStateLayer.cpp
+++ b/services/surfaceflinger/BufferStateLayer.cpp
@@ -40,13 +40,13 @@
 namespace {
 void callReleaseBufferCallback(const sp<ITransactionCompletedListener>& listener,
                                const sp<GraphicBuffer>& buffer, uint64_t framenumber,
-                               const sp<Fence>& releaseFence, uint32_t transformHint,
+                               const sp<Fence>& releaseFence,
                                uint32_t currentMaxAcquiredBufferCount) {
     if (!listener) {
         return;
     }
     listener->onReleaseBuffer({buffer->getId(), framenumber},
-                              releaseFence ? releaseFence : Fence::NO_FENCE, transformHint,
+                              releaseFence ? releaseFence : Fence::NO_FENCE,
                               currentMaxAcquiredBufferCount);
 }
 } // namespace
@@ -64,7 +64,7 @@
     if (mBufferInfo.mBuffer != nullptr && !isClone()) {
         callReleaseBufferCallback(mDrawingState.releaseBufferListener,
                                   mBufferInfo.mBuffer->getBuffer(), mBufferInfo.mFrameNumber,
-                                  mBufferInfo.mFence, mTransformHint,
+                                  mBufferInfo.mFence,
                                   mFlinger->getMaxAcquiredBufferCountForCurrentRefreshRate(
                                           mOwnerUid));
     }
@@ -479,7 +479,7 @@
             // call any release buffer callbacks if set.
             callReleaseBufferCallback(mDrawingState.releaseBufferListener,
                                       mDrawingState.buffer->getBuffer(), mDrawingState.frameNumber,
-                                      mDrawingState.acquireFence, mTransformHint,
+                                      mDrawingState.acquireFence,
                                       mFlinger->getMaxAcquiredBufferCountForCurrentRefreshRate(
                                               mOwnerUid));
             decrementPendingBufferCount();
@@ -491,9 +491,9 @@
         } else if (mLastClientCompositionFence != nullptr) {
             callReleaseBufferCallback(mDrawingState.releaseBufferListener,
                                       mDrawingState.buffer->getBuffer(), mDrawingState.frameNumber,
-                                      mLastClientCompositionFence, mTransformHint,
+                                      mLastClientCompositionFence,
                                       mFlinger->getMaxAcquiredBufferCountForCurrentRefreshRate(
-                                          mOwnerUid));
+                                              mOwnerUid));
             mLastClientCompositionFence = nullptr;
         }
     }