Skip to content

Commit 5ce9acd

Browse files
nairvis-beepAndroid (Google) Code Review
authored andcommitted
Merge "Consolidate flags in Transaction" into main
2 parents 679e2d3 + b580827 commit 5ce9acd

2 files changed

Lines changed: 14 additions & 34 deletions

File tree

libs/gui/SurfaceComposerClient.cpp

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -829,9 +829,7 @@ SurfaceComposerClient::Transaction::Transaction() {
829829

830830
SurfaceComposerClient::Transaction::Transaction(const Transaction& other)
831831
: mId(other.mId),
832-
mAnimation(other.mAnimation),
833-
mEarlyWakeupStart(other.mEarlyWakeupStart),
834-
mEarlyWakeupEnd(other.mEarlyWakeupEnd),
832+
mFlags(other.mFlags),
835833
mMayContainBuffer(other.mMayContainBuffer),
836834
mDesiredPresentTime(other.mDesiredPresentTime),
837835
mIsAutoTimestamp(other.mIsAutoTimestamp),
@@ -868,9 +866,7 @@ SurfaceComposerClient::Transaction::createFromParcel(const Parcel* parcel) {
868866

869867
status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel) {
870868
const uint64_t transactionId = parcel->readUint64();
871-
const bool animation = parcel->readBool();
872-
const bool earlyWakeupStart = parcel->readBool();
873-
const bool earlyWakeupEnd = parcel->readBool();
869+
const uint32_t flags = parcel->readUint32();
874870
const int64_t desiredPresentTime = parcel->readInt64();
875871
const bool isAutoTimestamp = parcel->readBool();
876872
const bool logCallPoints = parcel->readBool();
@@ -965,9 +961,7 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
965961

966962
// Parsing was successful. Update the object.
967963
mId = transactionId;
968-
mAnimation = animation;
969-
mEarlyWakeupStart = earlyWakeupStart;
970-
mEarlyWakeupEnd = earlyWakeupEnd;
964+
mFlags = flags;
971965
mDesiredPresentTime = desiredPresentTime;
972966
mIsAutoTimestamp = isAutoTimestamp;
973967
mFrameTimelineInfo = frameTimelineInfo;
@@ -996,9 +990,7 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const
996990
const_cast<SurfaceComposerClient::Transaction*>(this)->cacheBuffers();
997991

998992
parcel->writeUint64(mId);
999-
parcel->writeBool(mAnimation);
1000-
parcel->writeBool(mEarlyWakeupStart);
1001-
parcel->writeBool(mEarlyWakeupEnd);
993+
parcel->writeUint32(mFlags);
1002994
parcel->writeInt64(mDesiredPresentTime);
1003995
parcel->writeBool(mIsAutoTimestamp);
1004996
parcel->writeBool(mLogCallPoints);
@@ -1131,8 +1123,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr
11311123
mInputWindowCommands.merge(other.mInputWindowCommands);
11321124

11331125
mMayContainBuffer |= other.mMayContainBuffer;
1134-
mEarlyWakeupStart = mEarlyWakeupStart || other.mEarlyWakeupStart;
1135-
mEarlyWakeupEnd = mEarlyWakeupEnd || other.mEarlyWakeupEnd;
1126+
mFlags |= other.mFlags;
11361127
mApplyToken = other.mApplyToken;
11371128

11381129
mergeFrameTimelineInfo(mFrameTimelineInfo, other.mFrameTimelineInfo);
@@ -1154,15 +1145,13 @@ void SurfaceComposerClient::Transaction::clear() {
11541145
mInputWindowCommands.clear();
11551146
mUncacheBuffers.clear();
11561147
mMayContainBuffer = false;
1157-
mAnimation = false;
1158-
mEarlyWakeupStart = false;
1159-
mEarlyWakeupEnd = false;
11601148
mDesiredPresentTime = 0;
11611149
mIsAutoTimestamp = true;
11621150
mFrameTimelineInfo = {};
11631151
mApplyToken = nullptr;
11641152
mMergedTransactionIds.clear();
11651153
mLogCallPoints = false;
1154+
mFlags = 0;
11661155
}
11671156

11681157
uint64_t SurfaceComposerClient::Transaction::getId() {
@@ -1333,9 +1322,6 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous, bool oneWay
13331322

13341323
displayStates = std::move(mDisplayStates);
13351324

1336-
if (mAnimation) {
1337-
flags |= ISurfaceComposer::eAnimation;
1338-
}
13391325
if (oneWay) {
13401326
if (synchronous) {
13411327
ALOGE("Transaction attempted to set synchronous and one way at the same time"
@@ -1345,15 +1331,12 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous, bool oneWay
13451331
}
13461332
}
13471333

1348-
// If both mEarlyWakeupStart and mEarlyWakeupEnd are set
1334+
// If both ISurfaceComposer::eEarlyWakeupStart and ISurfaceComposer::eEarlyWakeupEnd are set
13491335
// it is equivalent for none
1350-
if (mEarlyWakeupStart && !mEarlyWakeupEnd) {
1351-
flags |= ISurfaceComposer::eEarlyWakeupStart;
1352-
}
1353-
if (mEarlyWakeupEnd && !mEarlyWakeupStart) {
1354-
flags |= ISurfaceComposer::eEarlyWakeupEnd;
1336+
uint32_t wakeupFlags = ISurfaceComposer::eEarlyWakeupStart | ISurfaceComposer::eEarlyWakeupEnd;
1337+
if ((flags & wakeupFlags) == wakeupFlags) {
1338+
flags &= ~(wakeupFlags);
13551339
}
1356-
13571340
sp<IBinder> applyToken = mApplyToken ? mApplyToken : getDefaultApplyToken();
13581341

13591342
sp<ISurfaceComposer> sf(ComposerService::getComposerService());
@@ -1461,15 +1444,15 @@ std::optional<gui::StalledTransactionInfo> SurfaceComposerClient::getStalledTran
14611444
}
14621445

14631446
void SurfaceComposerClient::Transaction::setAnimationTransaction() {
1464-
mAnimation = true;
1447+
mFlags |= ISurfaceComposer::eAnimation;
14651448
}
14661449

14671450
void SurfaceComposerClient::Transaction::setEarlyWakeupStart() {
1468-
mEarlyWakeupStart = true;
1451+
mFlags |= ISurfaceComposer::eEarlyWakeupStart;
14691452
}
14701453

14711454
void SurfaceComposerClient::Transaction::setEarlyWakeupEnd() {
1472-
mEarlyWakeupEnd = true;
1455+
mFlags |= ISurfaceComposer::eEarlyWakeupEnd;
14731456
}
14741457

14751458
layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<SurfaceControl>& sc) {

libs/gui/include/gui/SurfaceComposerClient.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,7 @@ class SurfaceComposerClient : public RefBase
467467
std::vector<uint64_t> mMergedTransactionIds;
468468

469469
uint64_t mId;
470-
471-
bool mAnimation = false;
472-
bool mEarlyWakeupStart = false;
473-
bool mEarlyWakeupEnd = false;
470+
uint32_t mFlags;
474471

475472
// Indicates that the Transaction may contain buffers that should be cached. The reason this
476473
// is only a guess is that buffers can be removed before cache is called. This is only a

0 commit comments

Comments
 (0)