Skip to content

Commit 52683c6

Browse files
Melody HsuAndroid (Google) Code Review
authored andcommitted
Merge "Support SurfaceControlRegistry logs in native" into main
2 parents 24bae18 + c034fbf commit 52683c6

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

libs/gui/SurfaceComposerClient.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ int64_t generateId() {
9292
}
9393

9494
constexpr int64_t INVALID_VSYNC = -1;
95+
const constexpr char* LOG_SURFACE_CONTROL_REGISTRY = "SurfaceControlRegistry";
9596

9697
} // namespace
9798

@@ -873,6 +874,7 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
873874
const bool earlyWakeupEnd = parcel->readBool();
874875
const int64_t desiredPresentTime = parcel->readInt64();
875876
const bool isAutoTimestamp = parcel->readBool();
877+
const bool logCallPoints = parcel->readBool();
876878
FrameTimelineInfo frameTimelineInfo;
877879
frameTimelineInfo.readFromParcel(parcel);
878880

@@ -1000,6 +1002,7 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const
10001002
parcel->writeBool(mEarlyWakeupEnd);
10011003
parcel->writeInt64(mDesiredPresentTime);
10021004
parcel->writeBool(mIsAutoTimestamp);
1005+
parcel->writeBool(mLogCallPoints);
10031006
mFrameTimelineInfo.writeToParcel(parcel);
10041007
parcel->writeStrongBinder(mApplyToken);
10051008
parcel->writeUint32(static_cast<uint32_t>(mDisplayStates.size()));
@@ -1135,6 +1138,12 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr
11351138

11361139
mergeFrameTimelineInfo(mFrameTimelineInfo, other.mFrameTimelineInfo);
11371140

1141+
mLogCallPoints |= other.mLogCallPoints;
1142+
if (mLogCallPoints) {
1143+
ALOG(LOG_DEBUG, LOG_SURFACE_CONTROL_REGISTRY,
1144+
"Transaction %" PRIu64 " merged with transaction %" PRIu64, other.getId(), mId);
1145+
}
1146+
11381147
other.clear();
11391148
return *this;
11401149
}
@@ -1154,6 +1163,7 @@ void SurfaceComposerClient::Transaction::clear() {
11541163
mFrameTimelineInfo = {};
11551164
mApplyToken = nullptr;
11561165
mMergedTransactionIds.clear();
1166+
mLogCallPoints = false;
11571167
}
11581168

11591169
uint64_t SurfaceComposerClient::Transaction::getId() {
@@ -1362,6 +1372,10 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous, bool oneWay
13621372
syncCallback->wait();
13631373
}
13641374

1375+
if (mLogCallPoints) {
1376+
ALOG(LOG_DEBUG, LOG_SURFACE_CONTROL_REGISTRY, "Transaction %" PRIu64 " applied", mId);
1377+
}
1378+
13651379
mStatus = NO_ERROR;
13661380
return binderStatus;
13671381
}
@@ -1392,6 +1406,11 @@ status_t SurfaceComposerClient::Transaction::sendSurfaceFlushJankDataTransaction
13921406
t.registerSurfaceControlForCallback(sc);
13931407
return t.apply(/*sync=*/false, /* oneWay=*/true);
13941408
}
1409+
1410+
void SurfaceComposerClient::Transaction::enableDebugLogCallPoints() {
1411+
mLogCallPoints = true;
1412+
}
1413+
13951414
// ---------------------------------------------------------------------------
13961415

13971416
sp<IBinder> SurfaceComposerClient::createVirtualDisplay(const std::string& displayName,

libs/gui/include/gui/SurfaceComposerClient.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ class SurfaceComposerClient : public RefBase
437437
static void mergeFrameTimelineInfo(FrameTimelineInfo& t, const FrameTimelineInfo& other);
438438
// Tracks registered callbacks
439439
sp<TransactionCompletedListener> mTransactionCompletedListener = nullptr;
440+
// Prints debug logs when enabled.
441+
bool mLogCallPoints = false;
440442

441443
protected:
442444
std::unordered_map<sp<IBinder>, ComposerState, IBinderHash> mComposerStates;
@@ -809,6 +811,7 @@ class SurfaceComposerClient : public RefBase
809811
static void setDefaultApplyToken(sp<IBinder> applyToken);
810812

811813
static status_t sendSurfaceFlushJankDataTransaction(const sp<SurfaceControl>& sc);
814+
void enableDebugLogCallPoints();
812815
};
813816

814817
status_t clearLayerFrameStats(const sp<IBinder>& token) const;

0 commit comments

Comments
 (0)