Loading libs/gui/SurfaceComposerClient.cpp +89 −0 Original line number Diff line number Diff line Loading @@ -322,10 +322,99 @@ SurfaceComposerClient::Transaction::Transaction(const Transaction& other) mTransactionNestCount(other.mTransactionNestCount), mAnimation(other.mAnimation), mEarlyWakeup(other.mEarlyWakeup), mContainsBuffer(other.mContainsBuffer), mDesiredPresentTime(other.mDesiredPresentTime) { mDisplayStates = other.mDisplayStates; mComposerStates = other.mComposerStates; mInputWindowCommands = other.mInputWindowCommands; mListenerCallbacks = other.mListenerCallbacks; } std::unique_ptr<SurfaceComposerClient::Transaction> SurfaceComposerClient::Transaction::createFromParcel(const Parcel* parcel) { auto transaction = std::make_unique<Transaction>(); if (transaction->readFromParcel(parcel) == NO_ERROR) { return transaction; } return nullptr; } status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel) { const uint32_t forceSynchronous = parcel->readUint32(); const uint32_t transactionNestCount = parcel->readUint32(); const bool animation = parcel->readBool(); const bool earlyWakeup = parcel->readBool(); const bool containsBuffer = parcel->readBool(); const int64_t desiredPresentTime = parcel->readInt64(); size_t count = static_cast<size_t>(parcel->readUint32()); if (count > parcel->dataSize()) { return BAD_VALUE; } SortedVector<DisplayState> displayStates; displayStates.setCapacity(count); for (size_t i = 0; i < count; i++) { DisplayState displayState; if (displayState.read(*parcel) == BAD_VALUE) { return BAD_VALUE; } displayStates.add(displayState); } count = static_cast<size_t>(parcel->readUint32()); if (count > parcel->dataSize()) { return BAD_VALUE; } std::unordered_map<sp<SurfaceControl>, ComposerState, SCHash> composerStates; composerStates.reserve(count); for (size_t i = 0; i < count; i++) { sp<SurfaceControl> surfaceControl = SurfaceControl::readFromParcel(parcel); ComposerState composerState; if (composerState.read(*parcel) == BAD_VALUE) { return BAD_VALUE; } composerStates[surfaceControl] = composerState; } InputWindowCommands inputWindowCommands; inputWindowCommands.read(*parcel); // Parsing was successful. Update the object. mForceSynchronous = forceSynchronous; mTransactionNestCount = transactionNestCount; mAnimation = animation; mEarlyWakeup = earlyWakeup; mContainsBuffer = containsBuffer; mDesiredPresentTime = desiredPresentTime; mDisplayStates = displayStates; mComposerStates = composerStates; mInputWindowCommands = inputWindowCommands; // listener callbacks contain function pointer addresses and may not be safe to parcel. mListenerCallbacks.clear(); return NO_ERROR; } status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const { parcel->writeUint32(mForceSynchronous); parcel->writeUint32(mTransactionNestCount); parcel->writeBool(mAnimation); parcel->writeBool(mEarlyWakeup); parcel->writeBool(mContainsBuffer); parcel->writeInt64(mDesiredPresentTime); parcel->writeUint32(static_cast<uint32_t>(mDisplayStates.size())); for (auto const& displayState : mDisplayStates) { displayState.write(*parcel); } parcel->writeUint32(static_cast<uint32_t>(mComposerStates.size())); for (auto const& [surfaceControl, composerState] : mComposerStates) { surfaceControl->writeToParcel(parcel); composerState.write(*parcel); } mInputWindowCommands.write(*parcel); return NO_ERROR; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Transaction&& other) { Loading libs/gui/SurfaceControl.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -186,8 +186,7 @@ void SurfaceControl::writeToParcel(Parcel* parcel) parcel->writeStrongBinder(IGraphicBufferProducer::asBinder(mGraphicBufferProducer)); } sp<SurfaceControl> SurfaceControl::readFromParcel(Parcel* parcel) { sp<SurfaceControl> SurfaceControl::readFromParcel(const Parcel* parcel) { sp<IBinder> client = parcel->readStrongBinder(); sp<IBinder> handle = parcel->readStrongBinder(); if (client == nullptr || handle == nullptr) Loading libs/gui/include/gui/SurfaceComposerClient.h +7 −1 Original line number Diff line number Diff line Loading @@ -285,7 +285,7 @@ public: std::unordered_set<sp<SurfaceControl>, SCHash> surfaceControls; }; class Transaction { class Transaction : Parcelable { std::unordered_map<sp<SurfaceControl>, ComposerState, SCHash> mComposerStates; SortedVector<DisplayState > mDisplayStates; std::unordered_map<sp<ITransactionCompletedListener>, CallbackInfo, TCLHash> Loading Loading @@ -325,6 +325,12 @@ public: virtual ~Transaction() = default; Transaction(Transaction const& other); // Factory method that creates a new Transaction instance from the parcel. static std::unique_ptr<Transaction> createFromParcel(const Parcel* parcel); status_t writeToParcel(Parcel* parcel) const override; status_t readFromParcel(const Parcel* parcel) override; status_t apply(bool synchronous = false); // Merge another transaction in to this one, clearing other // as if it had been applied. Loading libs/gui/include/gui/SurfaceControl.h +2 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class SurfaceComposerClient; class SurfaceControl : public RefBase { public: static sp<SurfaceControl> readFromParcel(Parcel* parcel); static sp<SurfaceControl> readFromParcel(const Parcel* parcel); void writeToParcel(Parcel* parcel); static bool isValid(const sp<SurfaceControl>& surface) { Loading Loading
libs/gui/SurfaceComposerClient.cpp +89 −0 Original line number Diff line number Diff line Loading @@ -322,10 +322,99 @@ SurfaceComposerClient::Transaction::Transaction(const Transaction& other) mTransactionNestCount(other.mTransactionNestCount), mAnimation(other.mAnimation), mEarlyWakeup(other.mEarlyWakeup), mContainsBuffer(other.mContainsBuffer), mDesiredPresentTime(other.mDesiredPresentTime) { mDisplayStates = other.mDisplayStates; mComposerStates = other.mComposerStates; mInputWindowCommands = other.mInputWindowCommands; mListenerCallbacks = other.mListenerCallbacks; } std::unique_ptr<SurfaceComposerClient::Transaction> SurfaceComposerClient::Transaction::createFromParcel(const Parcel* parcel) { auto transaction = std::make_unique<Transaction>(); if (transaction->readFromParcel(parcel) == NO_ERROR) { return transaction; } return nullptr; } status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel) { const uint32_t forceSynchronous = parcel->readUint32(); const uint32_t transactionNestCount = parcel->readUint32(); const bool animation = parcel->readBool(); const bool earlyWakeup = parcel->readBool(); const bool containsBuffer = parcel->readBool(); const int64_t desiredPresentTime = parcel->readInt64(); size_t count = static_cast<size_t>(parcel->readUint32()); if (count > parcel->dataSize()) { return BAD_VALUE; } SortedVector<DisplayState> displayStates; displayStates.setCapacity(count); for (size_t i = 0; i < count; i++) { DisplayState displayState; if (displayState.read(*parcel) == BAD_VALUE) { return BAD_VALUE; } displayStates.add(displayState); } count = static_cast<size_t>(parcel->readUint32()); if (count > parcel->dataSize()) { return BAD_VALUE; } std::unordered_map<sp<SurfaceControl>, ComposerState, SCHash> composerStates; composerStates.reserve(count); for (size_t i = 0; i < count; i++) { sp<SurfaceControl> surfaceControl = SurfaceControl::readFromParcel(parcel); ComposerState composerState; if (composerState.read(*parcel) == BAD_VALUE) { return BAD_VALUE; } composerStates[surfaceControl] = composerState; } InputWindowCommands inputWindowCommands; inputWindowCommands.read(*parcel); // Parsing was successful. Update the object. mForceSynchronous = forceSynchronous; mTransactionNestCount = transactionNestCount; mAnimation = animation; mEarlyWakeup = earlyWakeup; mContainsBuffer = containsBuffer; mDesiredPresentTime = desiredPresentTime; mDisplayStates = displayStates; mComposerStates = composerStates; mInputWindowCommands = inputWindowCommands; // listener callbacks contain function pointer addresses and may not be safe to parcel. mListenerCallbacks.clear(); return NO_ERROR; } status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const { parcel->writeUint32(mForceSynchronous); parcel->writeUint32(mTransactionNestCount); parcel->writeBool(mAnimation); parcel->writeBool(mEarlyWakeup); parcel->writeBool(mContainsBuffer); parcel->writeInt64(mDesiredPresentTime); parcel->writeUint32(static_cast<uint32_t>(mDisplayStates.size())); for (auto const& displayState : mDisplayStates) { displayState.write(*parcel); } parcel->writeUint32(static_cast<uint32_t>(mComposerStates.size())); for (auto const& [surfaceControl, composerState] : mComposerStates) { surfaceControl->writeToParcel(parcel); composerState.write(*parcel); } mInputWindowCommands.write(*parcel); return NO_ERROR; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Transaction&& other) { Loading
libs/gui/SurfaceControl.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -186,8 +186,7 @@ void SurfaceControl::writeToParcel(Parcel* parcel) parcel->writeStrongBinder(IGraphicBufferProducer::asBinder(mGraphicBufferProducer)); } sp<SurfaceControl> SurfaceControl::readFromParcel(Parcel* parcel) { sp<SurfaceControl> SurfaceControl::readFromParcel(const Parcel* parcel) { sp<IBinder> client = parcel->readStrongBinder(); sp<IBinder> handle = parcel->readStrongBinder(); if (client == nullptr || handle == nullptr) Loading
libs/gui/include/gui/SurfaceComposerClient.h +7 −1 Original line number Diff line number Diff line Loading @@ -285,7 +285,7 @@ public: std::unordered_set<sp<SurfaceControl>, SCHash> surfaceControls; }; class Transaction { class Transaction : Parcelable { std::unordered_map<sp<SurfaceControl>, ComposerState, SCHash> mComposerStates; SortedVector<DisplayState > mDisplayStates; std::unordered_map<sp<ITransactionCompletedListener>, CallbackInfo, TCLHash> Loading Loading @@ -325,6 +325,12 @@ public: virtual ~Transaction() = default; Transaction(Transaction const& other); // Factory method that creates a new Transaction instance from the parcel. static std::unique_ptr<Transaction> createFromParcel(const Parcel* parcel); status_t writeToParcel(Parcel* parcel) const override; status_t readFromParcel(const Parcel* parcel) override; status_t apply(bool synchronous = false); // Merge another transaction in to this one, clearing other // as if it had been applied. Loading
libs/gui/include/gui/SurfaceControl.h +2 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ class SurfaceComposerClient; class SurfaceControl : public RefBase { public: static sp<SurfaceControl> readFromParcel(Parcel* parcel); static sp<SurfaceControl> readFromParcel(const Parcel* parcel); void writeToParcel(Parcel* parcel); static bool isValid(const sp<SurfaceControl>& surface) { Loading