From 80da86b8ae51da0c936450bf8c16355be14e943c Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Thu, 11 Aug 2022 16:32:58 -0700 Subject: SurfaceComposerClient: Expose default apply token The default apply token specifies which transaction queue transactions from a process is sent to in surfaceflinger. This queue is used to ensure transactions from a process are applied in order. If a transaction from multiple processes need to be applied in order, we can use a commit callback to act as a barrier or pass transactions across processes to be applied on a single process. In some cases where operations are intertwined it may be advantageous to set a single transaction queue for multiple processes. In this case this api can be used to set a single queue to apply transactions by setting the same apply token on both processes. Note this api if misused can result in surprising out of order transactions. Test: manually set the same applytoken on multiple processes and verify they go into the same queue. Bug: 242193885 Bug: 242193885 Change-Id: I106fa701cc844d675e2ff2a05b5edcfed8cf85ff --- libs/gui/SurfaceComposerClient.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'libs/gui/SurfaceComposerClient.cpp') diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index d16ddb91a5..e7c1d7f1c4 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -1038,9 +1038,7 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous, bool oneWay flags |= ISurfaceComposer::eEarlyWakeupEnd; } - sp applyToken = mApplyToken - ? mApplyToken - : IInterface::asBinder(TransactionCompletedListener::getIInstance()); + sp applyToken = mApplyToken ? mApplyToken : sApplyToken; sf->setTransactionState(mFrameTimelineInfo, composerStates, displayStates, flags, applyToken, mInputWindowCommands, mDesiredPresentTime, mIsAutoTimestamp, @@ -1055,6 +1053,15 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous, bool oneWay return NO_ERROR; } +sp SurfaceComposerClient::Transaction::sApplyToken = new BBinder(); + +sp SurfaceComposerClient::Transaction::getDefaultApplyToken() { + return sApplyToken; +} + +void SurfaceComposerClient::Transaction::setDefaultApplyToken(sp applyToken) { + sApplyToken = applyToken; +} // --------------------------------------------------------------------------- sp SurfaceComposerClient::createDisplay(const String8& displayName, bool secure) { -- cgit v1.2.3-59-g8ed1b