diff options
author | 2020-08-05 10:57:05 +0000 | |
---|---|---|
committer | 2020-09-25 12:33:27 +0000 | |
commit | 7eb7ee7e16879e07c135bc89fee7a810064492af (patch) | |
tree | 459b8821c6384308d00f782cdbace704be170bed /libs/gui/SurfaceComposerClient.cpp | |
parent | fa2663e27f03f628414d7feefba557cef98fcbf0 (diff) |
Add ids to transactions and dump them in transaction trace
This is required for associating dumped transactions merges on the client side to dump transaction traces on the server side
Test: Make sure a transaction id is present in the dump
Change-Id: I8d3ad102bedb839901f0a818779c7d35519c669a
Diffstat (limited to 'libs/gui/SurfaceComposerClient.cpp')
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 8d2a7d9abc..9b6272de43 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -348,8 +348,17 @@ void removeDeadBufferCallback(void* /*context*/, uint64_t graphicBufferId) { // --------------------------------------------------------------------------- +// Initialize transaction id counter used to generate transaction ids +// Transactions will start counting at 1, 0 is used for invalid transactions +std::atomic<uint32_t> SurfaceComposerClient::Transaction::idCounter = 1; + +SurfaceComposerClient::Transaction::Transaction() { + mId = generateId(); +} + SurfaceComposerClient::Transaction::Transaction(const Transaction& other) - : mForceSynchronous(other.mForceSynchronous), + : mId(other.mId), + mForceSynchronous(other.mForceSynchronous), mTransactionNestCount(other.mTransactionNestCount), mAnimation(other.mAnimation), mEarlyWakeup(other.mEarlyWakeup), @@ -372,6 +381,10 @@ SurfaceComposerClient::Transaction::createFromParcel(const Parcel* parcel) { return nullptr; } +int64_t SurfaceComposerClient::Transaction::generateId() { + return (((int64_t)getpid()) << 32) | idCounter++; +} + status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel) { const uint32_t forceSynchronous = parcel->readUint32(); const uint32_t transactionNestCount = parcel->readUint32(); @@ -582,7 +595,8 @@ void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) { uncacheBuffer.id = cacheId; sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance()); - sf->setTransactionState({}, {}, 0, applyToken, {}, -1, uncacheBuffer, false, {}); + sf->setTransactionState({}, {}, 0, applyToken, {}, -1, uncacheBuffer, false, {}, + 0 /* Undefined transactionId */); } void SurfaceComposerClient::Transaction::cacheBuffers() { @@ -709,11 +723,14 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { mExplicitEarlyWakeupStart = false; mExplicitEarlyWakeupEnd = false; + uint64_t transactionId = mId; + mId = generateId(); + sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance()); sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands, mDesiredPresentTime, {} /*uncacheBuffer - only set in doUncacheBufferTransaction*/, - hasListenerCallbacks, listenerCallbacks); + hasListenerCallbacks, listenerCallbacks, transactionId); mInputWindowCommands.clear(); mStatus = NO_ERROR; return NO_ERROR; |