summaryrefslogtreecommitdiff
path: root/libs/gui/SurfaceComposerClient.cpp
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2021-01-13 10:28:00 -1000
committer Siarhei Vishniakou <svv@google.com> 2021-01-29 18:48:01 +0000
commitfc434acf530cbde198c8936bf1bc09fad5861031 (patch)
tree2f22c6a51fe8cd66f106004d9b438f52c8eeccf2 /libs/gui/SurfaceComposerClient.cpp
parent99599940f68158aeef735d8763980d0dbd397b51 (diff)
Add inputEventId to SurfaceFrame
SurfaceFrame will now be aware of the id of the input event that caused the current frame. The flow of input event id is inputflinger -> app -> surfaceflinger. Here, we are adding the 'inputEventId' parameter to the 'setFrameTimelineVsync' call. This call will now be responsible for setting two pieces of information: the vsync id, and the input event id. Since it will no longer be limited to the vsync id, we rename this call to "setFrameTimelineInfo". Once the inputEventId is stored in SurfaceFrame, we will add a binder call to send the frame timing information to inputflinger (separate, future CL). This will allow input to reconstruct the entire sequence of events (at what time was input event getting processed in system_server, app, and surfaceflinger) and will provide the ability to measure end-to-end touch latency. In a separate change, we will also add ATRACE calls to allow manual / script-based latency analysis for local debugging. We will now know which input event is being processed in surfaceflinger. Bug: 169866723 Bug: 129481165 Design doc: https://docs.google.com/document/d/1G3bLaZYSmbe6AKcL-6ZChvrw_B_LXEz29Z6Ed9QoYXY/edit# Test: atest WMShellUnitTests SurfaceParcelable_test libgui_test IPC_test SurfaceFlinger_test Change-Id: If7e0eee82603b38b396b53ad7ced660973efcb50 Merged-In: If7e0eee82603b38b396b53ad7ced660973efcb50
Diffstat (limited to 'libs/gui/SurfaceComposerClient.cpp')
-rw-r--r--libs/gui/SurfaceComposerClient.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 96c099be23..a1bdc033b0 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -396,7 +396,7 @@ SurfaceComposerClient::Transaction::Transaction(const Transaction& other)
mContainsBuffer(other.mContainsBuffer),
mDesiredPresentTime(other.mDesiredPresentTime),
mIsAutoTimestamp(other.mIsAutoTimestamp),
- mFrameTimelineVsyncId(other.mFrameTimelineVsyncId),
+ mFrameTimelineInfo(other.mFrameTimelineInfo),
mApplyToken(other.mApplyToken) {
mDisplayStates = other.mDisplayStates;
mComposerStates = other.mComposerStates;
@@ -427,7 +427,9 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
const bool containsBuffer = parcel->readBool();
const int64_t desiredPresentTime = parcel->readInt64();
const bool isAutoTimestamp = parcel->readBool();
- const int64_t frameTimelineVsyncId = parcel->readInt64();
+ FrameTimelineInfo frameTimelineInfo;
+ SAFE_PARCEL(frameTimelineInfo.read, *parcel);
+
sp<IBinder> applyToken;
parcel->readNullableStrongBinder(&applyToken);
size_t count = static_cast<size_t>(parcel->readUint32());
@@ -502,7 +504,7 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
mContainsBuffer = containsBuffer;
mDesiredPresentTime = desiredPresentTime;
mIsAutoTimestamp = isAutoTimestamp;
- mFrameTimelineVsyncId = frameTimelineVsyncId;
+ mFrameTimelineInfo = frameTimelineInfo;
mDisplayStates = displayStates;
mListenerCallbacks = listenerCallbacks;
mComposerStates = composerStates;
@@ -534,7 +536,7 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const
parcel->writeBool(mContainsBuffer);
parcel->writeInt64(mDesiredPresentTime);
parcel->writeBool(mIsAutoTimestamp);
- parcel->writeInt64(mFrameTimelineVsyncId);
+ SAFE_PARCEL(mFrameTimelineInfo.write, *parcel);
parcel->writeStrongBinder(mApplyToken);
parcel->writeUint32(static_cast<uint32_t>(mDisplayStates.size()));
for (auto const& displayState : mDisplayStates) {
@@ -613,13 +615,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr
mExplicitEarlyWakeupEnd = mExplicitEarlyWakeupEnd || other.mExplicitEarlyWakeupEnd;
mApplyToken = other.mApplyToken;
- // 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;
- }
+ mFrameTimelineInfo.merge(other.mFrameTimelineInfo);
other.clear();
return *this;
@@ -639,7 +635,7 @@ void SurfaceComposerClient::Transaction::clear() {
mExplicitEarlyWakeupEnd = false;
mDesiredPresentTime = 0;
mIsAutoTimestamp = true;
- mFrameTimelineVsyncId = ISurfaceComposer::INVALID_VSYNC_ID;
+ mFrameTimelineInfo.clear();
mApplyToken = nullptr;
}
@@ -651,9 +647,8 @@ void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) {
uncacheBuffer.id = cacheId;
sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance());
- sf->setTransactionState(ISurfaceComposer::INVALID_VSYNC_ID, {}, {}, 0, applyToken, {},
- systemTime(), true, uncacheBuffer, false, {},
- 0 /* Undefined transactionId */);
+ sf->setTransactionState(FrameTimelineInfo{}, {}, {}, 0, applyToken, {}, systemTime(), true,
+ uncacheBuffer, false, {}, 0 /* Undefined transactionId */);
}
void SurfaceComposerClient::Transaction::cacheBuffers() {
@@ -773,7 +768,7 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) {
? mApplyToken
: IInterface::asBinder(TransactionCompletedListener::getIInstance());
- sf->setTransactionState(mFrameTimelineVsyncId, composerStates, displayStates, flags, applyToken,
+ sf->setTransactionState(mFrameTimelineInfo, composerStates, displayStates, flags, applyToken,
mInputWindowCommands, mDesiredPresentTime, mIsAutoTimestamp,
{} /*uncacheBuffer - only set in doUncacheBufferTransaction*/,
hasListenerCallbacks, listenerCallbacks, mId);
@@ -1549,22 +1544,22 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFixed
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameTimelineVsync(
- int64_t frameTimelineVsyncId) {
- mFrameTimelineVsyncId = frameTimelineVsyncId;
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameTimelineInfo(
+ const FrameTimelineInfo& frameTimelineInfo) {
+ mFrameTimelineInfo = frameTimelineInfo;
return *this;
}
-SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameTimelineVsync(
- const sp<SurfaceControl>& sc, int64_t frameTimelineVsyncId) {
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameTimelineInfo(
+ const sp<SurfaceControl>& sc, const FrameTimelineInfo& frameTimelineInfo) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
return *this;
}
- s->what |= layer_state_t::eFrameTimelineVsyncChanged;
- s->frameTimelineVsyncId = frameTimelineVsyncId;
+ s->what |= layer_state_t::eFrameTimelineInfoChanged;
+ s->frameTimelineInfo = frameTimelineInfo;
return *this;
}