Introduce release buffer callback for BufferStateLayer
Currently BLAST clients use the TransactionCompleted callbacks to
determine when to release buffers. The TransactionCompleted callback
is overloaded. For transactions without buffers, the callback is
called when the transaction is applied on the server. If the
Transaction contains one or more buffers, the callback is called when
all the buffers are latched and ready to be presented. If we have
multiple buffers on multiple transactions, where one or more buffers
maybe dropped, the pending callbacks are called together. This may
delay signaling the client when a buffer can be released.
To fix this, we introduce a new buffer release callback that is
called as soon as a buffer is dropped by the server or when a new
buffer has been latched and the buffer will no longer be presented.
This new callback provides a graphic bufferid to identify the buffer
that can be released and a release fence to wait on.
BlastBufferQueue has been switched to use this new callback. Other
BLAST users continue to use the existing callback.
Test: go/wm-smoke
Test: atest ReleaseBufferCallbackTest
Bug: 178385281
Change-Id: Idd88e4994e543443198a5a8cfa0e3f5f67d5d482
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 0015bf2..cd3e8ad 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1048,6 +1048,9 @@
c.callbackHandles.push_back(handle);
}
+ // Allow BufferStateLayer to release any unlatched buffers in drawing state.
+ bufferMayChange(c.buffer);
+
// Commit the transaction
commitTransaction(c);
mPendingStatesSnapshot = mPendingStates;