diff options
author | 2020-09-22 19:33:40 -0700 | |
---|---|---|
committer | 2020-09-30 17:15:08 -0700 | |
commit | 22c7b5c7ee0fd3b5581e099e715826f0fbdcdc0f (patch) | |
tree | 68ab6180a3dfe97760fc8dd91c8c608009056bb7 /libs/gui/SurfaceComposerClient.cpp | |
parent | 384914ae21897bc2bdfaef8636984437311d44da (diff) |
SurfaceFlinger: add transactions to FrameTimeline
Allow transaction clients to specify the vsyncId that started the
transaction and plumb this data to FrameTimeline to be able
to track jank associated with transactions
Bug: 166302754
Test: manually see transactions in frame timeline
Change-Id: Id05e0d0a73039204943d93b666cb67e3e7515a69
Diffstat (limited to 'libs/gui/SurfaceComposerClient.cpp')
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 9b6272de43..d4a9cc183a 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -365,7 +365,8 @@ SurfaceComposerClient::Transaction::Transaction(const Transaction& other) mExplicitEarlyWakeupStart(other.mExplicitEarlyWakeupStart), mExplicitEarlyWakeupEnd(other.mExplicitEarlyWakeupEnd), mContainsBuffer(other.mContainsBuffer), - mDesiredPresentTime(other.mDesiredPresentTime) { + mDesiredPresentTime(other.mDesiredPresentTime), + mFrameTimelineVsyncId(other.mFrameTimelineVsyncId) { mDisplayStates = other.mDisplayStates; mComposerStates = other.mComposerStates; mInputWindowCommands = other.mInputWindowCommands; @@ -394,6 +395,7 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel const bool explicitEarlyWakeupEnd = parcel->readBool(); const bool containsBuffer = parcel->readBool(); const int64_t desiredPresentTime = parcel->readInt64(); + const int64_t frameTimelineVsyncId = parcel->readInt64(); size_t count = static_cast<size_t>(parcel->readUint32()); if (count > parcel->dataSize()) { @@ -464,6 +466,7 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel mExplicitEarlyWakeupEnd = explicitEarlyWakeupEnd; mContainsBuffer = containsBuffer; mDesiredPresentTime = desiredPresentTime; + mFrameTimelineVsyncId = frameTimelineVsyncId; mDisplayStates = displayStates; mListenerCallbacks = listenerCallbacks; mComposerStates = composerStates; @@ -493,6 +496,7 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const parcel->writeBool(mExplicitEarlyWakeupEnd); parcel->writeBool(mContainsBuffer); parcel->writeInt64(mDesiredPresentTime); + parcel->writeInt64(mFrameTimelineVsyncId); parcel->writeUint32(static_cast<uint32_t>(mDisplayStates.size())); for (auto const& displayState : mDisplayStates) { displayState.write(*parcel); @@ -568,6 +572,15 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr mEarlyWakeup = mEarlyWakeup || other.mEarlyWakeup; mExplicitEarlyWakeupStart = mExplicitEarlyWakeupStart || other.mExplicitEarlyWakeupStart; mExplicitEarlyWakeupEnd = mExplicitEarlyWakeupEnd || other.mExplicitEarlyWakeupEnd; + + // When merging vsync Ids we take the oldest one + if (mFrameTimelineVsyncId != ISurfaceComposer::INVALID_VSYNC_ID && + other.mFrameTimelineVsyncId != ISurfaceComposer::INVALID_VSYNC_ID) { + mFrameTimelineVsyncId = std::max(mFrameTimelineVsyncId, other.mFrameTimelineVsyncId); + } else if (mFrameTimelineVsyncId == ISurfaceComposer::INVALID_VSYNC_ID) { + mFrameTimelineVsyncId = other.mFrameTimelineVsyncId; + } + other.clear(); return *this; } @@ -585,6 +598,7 @@ void SurfaceComposerClient::Transaction::clear() { mExplicitEarlyWakeupStart = false; mExplicitEarlyWakeupEnd = false; mDesiredPresentTime = -1; + mFrameTimelineVsyncId = ISurfaceComposer::INVALID_VSYNC_ID; } void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) { @@ -595,8 +609,8 @@ void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) { uncacheBuffer.id = cacheId; sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance()); - sf->setTransactionState({}, {}, 0, applyToken, {}, -1, uncacheBuffer, false, {}, - 0 /* Undefined transactionId */); + sf->setTransactionState(ISurfaceComposer::INVALID_VSYNC_ID, {}, {}, 0, applyToken, {}, -1, + uncacheBuffer, false, {}, 0 /* Undefined transactionId */); } void SurfaceComposerClient::Transaction::cacheBuffers() { @@ -727,8 +741,8 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { mId = generateId(); sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance()); - sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands, - mDesiredPresentTime, + sf->setTransactionState(mFrameTimelineVsyncId, composerStates, displayStates, flags, applyToken, + mInputWindowCommands, mDesiredPresentTime, {} /*uncacheBuffer - only set in doUncacheBufferTransaction*/, hasListenerCallbacks, listenerCallbacks, transactionId); mInputWindowCommands.clear(); @@ -1517,6 +1531,12 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFixed return *this; } +SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameTimelineVsync( + int64_t frameTimelineVsyncId) { + mFrameTimelineVsyncId = frameTimelineVsyncId; + return *this; +} + // --------------------------------------------------------------------------- DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) { |