From efb71afcbb5d8f57af6435391f5d4835696375cc Mon Sep 17 00:00:00 2001 From: Marissa Wall Date: Thu, 27 Jun 2019 14:45:53 -0700 Subject: blast: fix registering callbacks This is a better fix for b/134194071 than ag/7998544. The previous patch only protected the call to notify the binder thread to send a callback. This patch has both a start registration and end registration call. During that time, the transaction callback cannot be sent. This is closer to a long term fix for the bug. Bug: 134194071 Test: Switch between front and back cameras to make sure the app doesn't crash. Change-Id: I2d20c13cc1c8d13e5a1340dfaa8cbbaa4d3a30ab --- .../surfaceflinger/TransactionCompletedThread.cpp | 50 +++++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'services/surfaceflinger/TransactionCompletedThread.cpp') diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index 5cf8eb1a1d..0806f2aa93 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -75,14 +75,15 @@ void TransactionCompletedThread::run() { mThread = std::thread(&TransactionCompletedThread::threadMain, this); } -status_t TransactionCompletedThread::addCallback(const sp& listener, - const std::vector& callbackIds) { +status_t TransactionCompletedThread::startRegistration(const ListenerCallbacks& listenerCallbacks) { std::lock_guard lock(mMutex); if (!mRunning) { ALOGE("cannot add callback because the callback thread isn't running"); return BAD_VALUE; } + auto& [listener, callbackIds] = listenerCallbacks; + if (mCompletedTransactions.count(listener) == 0) { status_t err = IInterface::asBinder(listener)->linkToDeath(mDeathRecipient); if (err != NO_ERROR) { @@ -91,11 +92,41 @@ status_t TransactionCompletedThread::addCallback(const sp& transactionListener, + const std::vector& callbackIds) { + ListenerCallbacks listenerCallbacks(transactionListener, callbackIds); + + auto itr = mRegisteringTransactions.find(listenerCallbacks); + return itr != mRegisteringTransactions.end(); +} + status_t TransactionCompletedThread::registerPendingCallbackHandle( const sp& handle) { std::lock_guard lock(mMutex); @@ -105,7 +136,7 @@ status_t TransactionCompletedThread::registerPendingCallbackHandle( } // If we can't find the transaction stats something has gone wrong. The client should call - // addCallback before trying to register a pending callback handle. + // startRegistration before trying to register a pending callback handle. TransactionStats* transactionStats; status_t err = findTransactionStats(handle->listener, handle->callbackIds, &transactionStats); if (err != NO_ERROR) { @@ -117,7 +148,7 @@ status_t TransactionCompletedThread::registerPendingCallbackHandle( return NO_ERROR; } -status_t TransactionCompletedThread::addPresentedCallbackHandles( +status_t TransactionCompletedThread::finalizePendingCallbackHandles( const std::deque>& handles) { std::lock_guard lock(mMutex); if (!mRunning) { @@ -158,7 +189,7 @@ status_t TransactionCompletedThread::addPresentedCallbackHandles( return NO_ERROR; } -status_t TransactionCompletedThread::addUnpresentedCallbackHandle( +status_t TransactionCompletedThread::registerUnpresentedCallbackHandle( const sp& handle) { std::lock_guard lock(mMutex); if (!mRunning) { @@ -189,7 +220,7 @@ status_t TransactionCompletedThread::findTransactionStats( status_t TransactionCompletedThread::addCallbackHandle(const sp& handle) { // If we can't find the transaction stats something has gone wrong. The client should call - // addCallback before trying to add a presnted callback handle. + // startRegistration before trying to add a callback handle. TransactionStats* transactionStats; status_t err = findTransactionStats(handle->listener, handle->callbackIds, &transactionStats); if (err != NO_ERROR) { @@ -233,6 +264,13 @@ void TransactionCompletedThread::threadMain() { while (transactionStatsItr != transactionStatsDeque.end()) { auto& transactionStats = *transactionStatsItr; + // If this transaction is still registering, it is not safe to send a callback + // because there could be surface controls that haven't been added to + // transaction stats or mPendingTransactions. + if (isRegisteringTransaction(listener, transactionStats.callbackIds)) { + break; + } + // If we are still waiting on the callback handles for this transaction, stop // here because all transaction callbacks for the same listener must come in order auto pendingTransactions = mPendingTransactions.find(listener); -- cgit v1.2.3-59-g8ed1b From 5de3ad2cee2b5a30ab442dcc202d0799c5b4ac23 Mon Sep 17 00:00:00 2001 From: Valerie Hau Date: Tue, 20 Aug 2019 07:47:43 -0700 Subject: Switch from ITransactionCompletedListener to IBinder keys IBinder remains consistent across multiple transactions when passed cross-process to SF. However, interface_cast'ing it to an ITransactionCompletedListener results in different underlying objects. Switch to using IBinder as the keys for listener callbacks. Bug: 139731321 Test: build, boot, SurfaceFlinger_test Change-Id: I9bea76664087020eb43ceec258b5ecede0faaea5 --- libs/gui/ISurfaceComposer.cpp | 5 +-- libs/gui/ITransactionCompletedListener.cpp | 2 +- libs/gui/SurfaceComposerClient.cpp | 2 +- .../include/gui/ITransactionCompletedListener.h | 47 +++++++++++++++++--- services/surfaceflinger/SurfaceFlinger.h | 8 +--- .../surfaceflinger/TransactionCompletedThread.cpp | 28 +++++++----- .../surfaceflinger/TransactionCompletedThread.h | 51 ++++------------------ 7 files changed, 70 insertions(+), 73 deletions(-) (limited to 'services/surfaceflinger/TransactionCompletedThread.cpp') diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 12deaf0bd6..dc161b7222 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -93,7 +93,7 @@ public: if (data.writeVectorSize(listenerCallbacks) == NO_ERROR) { for (const auto& [listener, callbackIds] : listenerCallbacks) { - data.writeStrongBinder(IInterface::asBinder(listener)); + data.writeStrongBinder(listener); data.writeInt64Vector(callbackIds); } } @@ -1042,8 +1042,7 @@ status_t BnSurfaceComposer::onTransact( std::vector listenerCallbacks; int32_t listenersSize = data.readInt32(); for (int32_t i = 0; i < listenersSize; i++) { - auto listener = - interface_cast(data.readStrongBinder()); + auto listener = data.readStrongBinder(); std::vector callbackIds; data.readInt64Vector(&callbackIds); listenerCallbacks.emplace_back(listener, callbackIds); diff --git a/libs/gui/ITransactionCompletedListener.cpp b/libs/gui/ITransactionCompletedListener.cpp index 74cd4f1ede..acda6001cc 100644 --- a/libs/gui/ITransactionCompletedListener.cpp +++ b/libs/gui/ITransactionCompletedListener.cpp @@ -151,7 +151,7 @@ status_t ListenerStats::readFromParcel(const Parcel* input) { return NO_ERROR; } -ListenerStats ListenerStats::createEmpty(const sp& listener, +ListenerStats ListenerStats::createEmpty(const sp& listener, const std::unordered_set& callbackIds) { ListenerStats listenerStats; listenerStats.listener = listener; diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index e6b1beb2c4..3d074e1ef4 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -548,7 +548,7 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { continue; } - listenerCallbacks.emplace_back(listener, std::move(callbackIds)); + listenerCallbacks.emplace_back(IInterface::asBinder(listener), std::move(callbackIds)); // If the listener has any SurfaceControls set on this Transaction update the surface state for (const auto& surfaceControl : surfaceControls) { diff --git a/libs/gui/include/gui/ITransactionCompletedListener.h b/libs/gui/include/gui/ITransactionCompletedListener.h index cbfd365692..178ca2d7e2 100644 --- a/libs/gui/include/gui/ITransactionCompletedListener.h +++ b/libs/gui/include/gui/ITransactionCompletedListener.h @@ -31,6 +31,7 @@ namespace android { class ITransactionCompletedListener; +class ListenerCallbacks; using CallbackId = int64_t; @@ -72,10 +73,10 @@ public: status_t writeToParcel(Parcel* output) const override; status_t readFromParcel(const Parcel* input) override; - static ListenerStats createEmpty(const sp& listener, + static ListenerStats createEmpty(const sp& listener, const std::unordered_set& callbackIds); - sp listener; + sp listener; std::vector transactionStats; }; @@ -97,13 +98,11 @@ public: class ListenerCallbacks { public: - ListenerCallbacks(const sp& listener, - const std::unordered_set& callbacks) + ListenerCallbacks(const sp& listener, const std::unordered_set& callbacks) : transactionCompletedListener(listener), callbackIds(callbacks.begin(), callbacks.end()) {} - ListenerCallbacks(const sp& listener, - const std::vector& ids) + ListenerCallbacks(const sp& listener, const std::vector& ids) : transactionCompletedListener(listener), callbackIds(ids) {} bool operator==(const ListenerCallbacks& rhs) const { @@ -116,8 +115,42 @@ public: return callbackIds.front() == rhs.callbackIds.front(); } - sp transactionCompletedListener; + sp transactionCompletedListener; std::vector callbackIds; }; +struct IListenerHash { + std::size_t operator()(const sp& strongPointer) const { + return std::hash{}(strongPointer.get()); + } +}; + +struct CallbackIdsHash { + // CallbackId vectors have several properties that let us get away with this simple hash. + // 1) CallbackIds are never 0 so if something has gone wrong and our CallbackId vector is + // empty we can still hash 0. + // 2) CallbackId vectors for the same listener either are identical or contain none of the + // same members. It is sufficient to just check the first CallbackId in the vectors. If + // they match, they are the same. If they do not match, they are not the same. + std::size_t operator()(const std::vector& callbackIds) const { + return std::hash{}((callbackIds.empty()) ? 0 : callbackIds.front()); + } +}; + +struct ListenerCallbacksHash { + std::size_t HashCombine(size_t value1, size_t value2) const { + return value1 ^ (value2 + 0x9e3779b9 + (value1 << 6) + (value1 >> 2)); + } + + std::size_t operator()(const ListenerCallbacks& listenerCallbacks) const { + struct IListenerHash listenerHasher; + struct CallbackIdsHash callbackIdsHasher; + + std::size_t listenerHash = listenerHasher(listenerCallbacks.transactionCompletedListener); + std::size_t callbackIdsHash = callbackIdsHasher(listenerCallbacks.callbackIds); + + return HashCombine(listenerHash, callbackIdsHash); + } +}; + } // namespace android diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index e199ad55f8..5e263b2c9d 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -1025,11 +1026,6 @@ private: uint32_t mTexturePoolSize = 0; std::vector mTexturePool; - struct IBinderHash { - std::size_t operator()(const sp& strongPointer) const { - return std::hash{}(strongPointer.get()); - } - }; struct TransactionState { TransactionState(const Vector& composerStates, const Vector& displayStates, uint32_t transactionFlags, @@ -1054,7 +1050,7 @@ private: const int64_t postTime; bool privileged; }; - std::unordered_map, std::queue, IBinderHash> mTransactionQueues; + std::unordered_map, std::queue, IListenerHash> mTransactionQueues; /* ------------------------------------------------------------------------ * Feature prototyping diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index c519f8d647..1324f20e1c 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -24,7 +24,6 @@ #include #include -#include #include namespace android { @@ -58,7 +57,7 @@ TransactionCompletedThread::~TransactionCompletedThread() { { std::lock_guard lock(mMutex); for (const auto& [listener, transactionStats] : mCompletedTransactions) { - IInterface::asBinder(listener)->unlinkToDeath(mDeathRecipient); + listener->unlinkToDeath(mDeathRecipient); } } } @@ -85,7 +84,7 @@ status_t TransactionCompletedThread::startRegistration(const ListenerCallbacks& auto& [listener, callbackIds] = listenerCallbacks; if (mCompletedTransactions.count(listener) == 0) { - status_t err = IInterface::asBinder(listener)->linkToDeath(mDeathRecipient); + status_t err = listener->linkToDeath(mDeathRecipient); if (err != NO_ERROR) { ALOGE("cannot add callback because linkToDeath failed, err: %d", err); return err; @@ -119,8 +118,7 @@ status_t TransactionCompletedThread::endRegistration(const ListenerCallbacks& li } bool TransactionCompletedThread::isRegisteringTransaction( - const sp& transactionListener, - const std::vector& callbackIds) { + const sp& transactionListener, const std::vector& callbackIds) { ListenerCallbacks listenerCallbacks(transactionListener, callbackIds); auto itr = mRegisteringTransactions.find(listenerCallbacks); @@ -201,8 +199,8 @@ status_t TransactionCompletedThread::registerUnpresentedCallbackHandle( } status_t TransactionCompletedThread::findTransactionStats( - const sp& listener, - const std::vector& callbackIds, TransactionStats** outTransactionStats) { + const sp& listener, const std::vector& callbackIds, + TransactionStats** outTransactionStats) { auto& transactionStatsDeque = mCompletedTransactions[listener]; // Search back to front because the most recent transactions are at the back of the deque @@ -300,10 +298,16 @@ void TransactionCompletedThread::threadMain() { // If the listener has completed transactions if (!listenerStats.transactionStats.empty()) { // If the listener is still alive - if (IInterface::asBinder(listener)->isBinderAlive()) { - // Send callback - listenerStats.listener->onTransactionCompleted(listenerStats); - IInterface::asBinder(listener)->unlinkToDeath(mDeathRecipient); + if (listener->isBinderAlive()) { + // Send callback. The listener stored in listenerStats + // comes from the cross-process setTransactionState call to + // SF. This MUST be an ITransactionCompletedListener. We + // keep it as an IBinder due to consistency reasons: if we + // interface_cast at the IPC boundary when reading a Parcel, + // we get pointers that compare unequal in the SF process. + interface_cast(listenerStats.listener) + ->onTransactionCompleted(listenerStats); + listener->unlinkToDeath(mDeathRecipient); } completedTransactionsItr = mCompletedTransactions.erase(completedTransactionsItr); } else { @@ -335,7 +339,7 @@ void TransactionCompletedThread::threadMain() { // ----------------------------------------------------------------------- -CallbackHandle::CallbackHandle(const sp& transactionListener, +CallbackHandle::CallbackHandle(const sp& transactionListener, const std::vector& ids, const sp& sc) : listener(transactionListener), callbackIds(ids), surfaceControl(sc) {} diff --git a/services/surfaceflinger/TransactionCompletedThread.h b/services/surfaceflinger/TransactionCompletedThread.h index e255e5090e..a85ad1e63c 100644 --- a/services/surfaceflinger/TransactionCompletedThread.h +++ b/services/surfaceflinger/TransactionCompletedThread.h @@ -31,46 +31,12 @@ namespace android { -struct ITransactionCompletedListenerHash { - std::size_t operator()(const sp& listener) const { - return std::hash{}((listener) ? IInterface::asBinder(listener).get() : nullptr); - } -}; - -struct CallbackIdsHash { - // CallbackId vectors have several properties that let us get away with this simple hash. - // 1) CallbackIds are never 0 so if something has gone wrong and our CallbackId vector is - // empty we can still hash 0. - // 2) CallbackId vectors for the same listener either are identical or contain none of the - // same members. It is sufficient to just check the first CallbackId in the vectors. If - // they match, they are the same. If they do not match, they are not the same. - std::size_t operator()(const std::vector& callbackIds) const { - return std::hash{}((callbackIds.empty()) ? 0 : callbackIds.front()); - } -}; - -struct ListenerCallbacksHash { - std::size_t HashCombine(size_t value1, size_t value2) const { - return value1 ^ (value2 + 0x9e3779b9 + (value1 << 6) + (value1 >> 2)); - } - - std::size_t operator()(const ListenerCallbacks& listenerCallbacks) const { - struct ITransactionCompletedListenerHash listenerHasher; - struct CallbackIdsHash callbackIdsHasher; - - std::size_t listenerHash = listenerHasher(listenerCallbacks.transactionCompletedListener); - std::size_t callbackIdsHash = callbackIdsHasher(listenerCallbacks.callbackIds); - - return HashCombine(listenerHash, callbackIdsHash); - } -}; - class CallbackHandle : public RefBase { public: - CallbackHandle(const sp& transactionListener, - const std::vector& ids, const sp& sc); + CallbackHandle(const sp& transactionListener, const std::vector& ids, + const sp& sc); - sp listener; + sp listener; std::vector callbackIds; wp surfaceControl; @@ -114,10 +80,10 @@ public: private: void threadMain(); - bool isRegisteringTransaction(const sp& transactionListener, + bool isRegisteringTransaction(const sp& transactionListener, const std::vector& callbackIds) REQUIRES(mMutex); - status_t findTransactionStats(const sp& listener, + status_t findTransactionStats(const sp& listener, const std::vector& callbackIds, TransactionStats** outTransactionStats) REQUIRES(mMutex); @@ -146,13 +112,12 @@ private: GUARDED_BY(mMutex); std::unordered_map< - sp, + sp, std::unordered_map, uint32_t /*count*/, CallbackIdsHash>, - ITransactionCompletedListenerHash> + IListenerHash> mPendingTransactions GUARDED_BY(mMutex); - std::unordered_map, std::deque, - ITransactionCompletedListenerHash> + std::unordered_map, std::deque, IListenerHash> mCompletedTransactions GUARDED_BY(mMutex); bool mRunning GUARDED_BY(mMutex) = false; -- cgit v1.2.3-59-g8ed1b From 9dab9730c009b8f45b671c48c7c3fa0915298803 Mon Sep 17 00:00:00 2001 From: Valerie Hau Date: Tue, 20 Aug 2019 09:29:25 -0700 Subject: Only send surfaces to Listener that registered or applied transaction We must not leak surface controls to processes that shouldn't know about them. With this change, we limit the listeners that receive a callback for a surface control to those that 1) registered the surface control for callback or 2) received and merged a transaction containing that surface control to apply Bug: 139439952 Test: build, boot, IPC_test, SurfaceFlinger_test, libsurfaceflinger_unittest Change-Id: I4eccc3e72d60729c2f3aa7788db0c5c39fbf46b7 --- libs/gui/ISurfaceComposer.cpp | 9 +- libs/gui/LayerState.cpp | 27 +- libs/gui/SurfaceComposerClient.cpp | 81 ++++- libs/gui/include/gui/ISurfaceComposer.h | 2 +- libs/gui/include/gui/LayerState.h | 5 +- libs/gui/include/gui/SurfaceComposerClient.h | 1 + libs/gui/tests/Surface_test.cpp | 1 + services/surfaceflinger/SurfaceFlinger.cpp | 87 ++--- services/surfaceflinger/SurfaceFlinger.h | 27 +- .../surfaceflinger/TransactionCompletedThread.cpp | 22 +- services/surfaceflinger/tests/Android.bp | 41 +++ services/surfaceflinger/tests/IPC_test.cpp | 351 +++++++++++++++++++++ 12 files changed, 566 insertions(+), 88 deletions(-) create mode 100644 services/surfaceflinger/tests/IPC_test.cpp (limited to 'services/surfaceflinger/TransactionCompletedThread.cpp') diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index dc161b7222..580579759f 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -69,7 +69,7 @@ public: const sp& applyToken, const InputWindowCommands& commands, int64_t desiredPresentTime, - const client_cache_t& uncacheBuffer, + const client_cache_t& uncacheBuffer, bool hasListenerCallbacks, const std::vector& listenerCallbacks) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); @@ -90,6 +90,7 @@ public: data.writeInt64(desiredPresentTime); data.writeStrongBinder(uncacheBuffer.token.promote()); data.writeUint64(uncacheBuffer.id); + data.writeBool(hasListenerCallbacks); if (data.writeVectorSize(listenerCallbacks) == NO_ERROR) { for (const auto& [listener, callbackIds] : listenerCallbacks) { @@ -1039,6 +1040,8 @@ status_t BnSurfaceComposer::onTransact( uncachedBuffer.token = data.readStrongBinder(); uncachedBuffer.id = data.readUint64(); + bool hasListenerCallbacks = data.readBool(); + std::vector listenerCallbacks; int32_t listenersSize = data.readInt32(); for (int32_t i = 0; i < listenersSize; i++) { @@ -1047,9 +1050,9 @@ status_t BnSurfaceComposer::onTransact( data.readInt64Vector(&callbackIds); listenerCallbacks.emplace_back(listener, callbackIds); } - setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands, - desiredPresentTime, uncachedBuffer, listenerCallbacks); + desiredPresentTime, uncachedBuffer, hasListenerCallbacks, + listenerCallbacks); return NO_ERROR; } case BOOT_FINISHED: { diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp index 523ed1d2ce..e004e9584c 100644 --- a/libs/gui/LayerState.cpp +++ b/libs/gui/LayerState.cpp @@ -86,7 +86,6 @@ status_t layer_state_t::write(Parcel& output) const memcpy(output.writeInplace(16 * sizeof(float)), colorTransform.asArray(), 16 * sizeof(float)); output.writeFloat(cornerRadius); - output.writeBool(hasListenerCallbacks); output.writeStrongBinder(cachedBuffer.token.promote()); output.writeUint64(cachedBuffer.id); output.writeParcelable(metadata); @@ -95,6 +94,22 @@ status_t layer_state_t::write(Parcel& output) const output.writeUint32(static_cast(bgColorDataspace)); output.writeBool(colorSpaceAgnostic); + auto err = output.writeVectorSize(listeners); + if (err) { + return err; + } + + for (auto listener : listeners) { + err = output.writeStrongBinder(listener.transactionCompletedListener); + if (err) { + return err; + } + err = output.writeInt64Vector(listener.callbackIds); + if (err) { + return err; + } + } + return NO_ERROR; } @@ -156,7 +171,6 @@ status_t layer_state_t::read(const Parcel& input) colorTransform = mat4(static_cast(input.readInplace(16 * sizeof(float)))); cornerRadius = input.readFloat(); - hasListenerCallbacks = input.readBool(); cachedBuffer.token = input.readStrongBinder(); cachedBuffer.id = input.readUint64(); input.readParcelable(&metadata); @@ -165,6 +179,14 @@ status_t layer_state_t::read(const Parcel& input) bgColorDataspace = static_cast(input.readUint32()); colorSpaceAgnostic = input.readBool(); + int32_t numListeners = input.readInt32(); + listeners.clear(); + for (int i = 0; i < numListeners; i++) { + auto listener = input.readStrongBinder(); + std::vector callbackIds; + input.readInt64Vector(&callbackIds); + listeners.emplace_back(listener, callbackIds); + } return NO_ERROR; } @@ -361,7 +383,6 @@ void layer_state_t::merge(const layer_state_t& other) { } if (other.what & eHasListenerCallbacksChanged) { what |= eHasListenerCallbacksChanged; - hasListenerCallbacks = other.hasListenerCallbacks; } #ifndef NO_INPUT diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 67dd726eba..6b5021d1b4 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -362,6 +362,33 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel displayStates.add(displayState); } + count = static_cast(parcel->readUint32()); + if (count > parcel->dataSize()) { + return BAD_VALUE; + } + std::unordered_map, CallbackInfo, TCLHash> listenerCallbacks; + listenerCallbacks.reserve(count); + for (size_t i = 0; i < count; i++) { + sp listener = + interface_cast(parcel->readStrongBinder()); + size_t numCallbackIds = parcel->readUint32(); + if (numCallbackIds > parcel->dataSize()) { + return BAD_VALUE; + } + for (size_t j = 0; j < numCallbackIds; j++) { + listenerCallbacks[listener].callbackIds.insert(parcel->readInt64()); + } + size_t numSurfaces = parcel->readUint32(); + if (numSurfaces > parcel->dataSize()) { + return BAD_VALUE; + } + for (size_t j = 0; j < numSurfaces; j++) { + sp surface; + surface = SurfaceControl::readFromParcel(parcel); + listenerCallbacks[listener].surfaceControls.insert(surface); + } + } + count = static_cast(parcel->readUint32()); if (count > parcel->dataSize()) { return BAD_VALUE; @@ -389,10 +416,9 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel mContainsBuffer = containsBuffer; mDesiredPresentTime = desiredPresentTime; mDisplayStates = displayStates; + mListenerCallbacks = listenerCallbacks; mComposerStates = composerStates; mInputWindowCommands = inputWindowCommands; - // listener callbacks contain function pointer addresses and may not be safe to parcel. - mListenerCallbacks.clear(); return NO_ERROR; } @@ -408,6 +434,19 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const displayState.write(*parcel); } + parcel->writeUint32(static_cast(mListenerCallbacks.size())); + for (auto const& [listener, callbackInfo] : mListenerCallbacks) { + parcel->writeStrongBinder(ITransactionCompletedListener::asBinder(listener)); + parcel->writeUint32(static_cast(callbackInfo.callbackIds.size())); + for (auto callbackId : callbackInfo.callbackIds) { + parcel->writeInt64(callbackId); + } + parcel->writeUint32(static_cast(callbackInfo.surfaceControls.size())); + for (auto surfaceControl : callbackInfo.surfaceControls) { + surfaceControl->writeToParcel(parcel); + } + } + parcel->writeUint32(static_cast(mComposerStates.size())); for (auto const& [surfaceHandle, composerState] : mComposerStates) { parcel->writeStrongBinder(surfaceHandle); @@ -441,6 +480,11 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr mListenerCallbacks[listener].callbackIds.insert(std::make_move_iterator( callbackIds.begin()), std::make_move_iterator(callbackIds.end())); + // register surface controls for this listener that is merging + for (const auto& surfaceControl : surfaceControls) { + registerSurfaceControlForCallback(surfaceControl); + } + mListenerCallbacks[listener] .surfaceControls.insert(std::make_move_iterator(surfaceControls.begin()), std::make_move_iterator(surfaceControls.end())); @@ -479,7 +523,7 @@ void SurfaceComposerClient::doDropReferenceTransaction(const sp& handle composerStates.add(s); sp applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance()); - sf->setTransactionState(composerStates, displayStates, 0, applyToken, {}, -1, {}, {}); + sf->setTransactionState(composerStates, displayStates, 0, applyToken, {}, -1, {}, false, {}); } void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) { @@ -490,7 +534,7 @@ void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) { uncacheBuffer.id = cacheId; sp applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance()); - sf->setTransactionState({}, {}, 0, applyToken, {}, -1, uncacheBuffer, {}); + sf->setTransactionState({}, {}, 0, applyToken, {}, -1, uncacheBuffer, false, {}); } void SurfaceComposerClient::Transaction::cacheBuffers() { @@ -539,8 +583,8 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { sp sf(ComposerService::getComposerService()); + bool hasListenerCallbacks = !mListenerCallbacks.empty(); std::vector listenerCallbacks; - // For every listener with registered callbacks for (const auto& [listener, callbackInfo] : mListenerCallbacks) { auto& [callbackIds, surfaceControls] = callbackInfo; @@ -548,19 +592,24 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { continue; } - listenerCallbacks.emplace_back(IInterface::asBinder(listener), std::move(callbackIds)); - - // If the listener has any SurfaceControls set on this Transaction update the surface state - for (const auto& surfaceControl : surfaceControls) { - layer_state_t* s = getLayerState(surfaceControl); - if (!s) { - ALOGE("failed to get layer state"); - continue; + if (surfaceControls.empty()) { + listenerCallbacks.emplace_back(IInterface::asBinder(listener), std::move(callbackIds)); + } else { + // If the listener has any SurfaceControls set on this Transaction update the surface + // state + for (const auto& surfaceControl : surfaceControls) { + layer_state_t* s = getLayerState(surfaceControl); + if (!s) { + ALOGE("failed to get layer state"); + continue; + } + std::vector callbacks(callbackIds.begin(), callbackIds.end()); + s->what |= layer_state_t::eHasListenerCallbacksChanged; + s->listeners.emplace_back(IInterface::asBinder(listener), callbacks); } - s->what |= layer_state_t::eHasListenerCallbacksChanged; - s->hasListenerCallbacks = true; } } + mListenerCallbacks.clear(); cacheBuffers(); @@ -598,7 +647,7 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) { sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands, mDesiredPresentTime, {} /*uncacheBuffer - only set in doUncacheBufferTransaction*/, - listenerCallbacks); + hasListenerCallbacks, listenerCallbacks); mInputWindowCommands.clear(); mStatus = NO_ERROR; return NO_ERROR; diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h index c84910b6ec..06be1b36b2 100644 --- a/libs/gui/include/gui/ISurfaceComposer.h +++ b/libs/gui/include/gui/ISurfaceComposer.h @@ -140,7 +140,7 @@ public: const sp& applyToken, const InputWindowCommands& inputWindowCommands, int64_t desiredPresentTime, - const client_cache_t& uncacheBuffer, + const client_cache_t& uncacheBuffer, bool hasListenerCallbacks, const std::vector& listenerCallbacks) = 0; /* signal that we're done booting. diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h index 2eb5492558..a49ed525b6 100644 --- a/libs/gui/include/gui/LayerState.h +++ b/libs/gui/include/gui/LayerState.h @@ -23,6 +23,7 @@ #include #include +#include #include #ifndef NO_INPUT @@ -123,7 +124,6 @@ struct layer_state_t { surfaceDamageRegion(), api(-1), colorTransform(mat4()), - hasListenerCallbacks(false), bgColorAlpha(0), bgColorDataspace(ui::Dataspace::UNKNOWN), colorSpaceAgnostic(false) { @@ -186,7 +186,6 @@ struct layer_state_t { sp sidebandStream; mat4 colorTransform; - bool hasListenerCallbacks; #ifndef NO_INPUT InputWindowInfo inputInfo; #endif @@ -203,6 +202,8 @@ struct layer_state_t { // A color space agnostic layer means the color of this layer can be // interpreted in any color space. bool colorSpaceAgnostic; + + std::vector listeners; }; struct ComposerState { diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h index 8a6920c268..15287e2cb6 100644 --- a/libs/gui/include/gui/SurfaceComposerClient.h +++ b/libs/gui/include/gui/SurfaceComposerClient.h @@ -291,6 +291,7 @@ public: }; class Transaction : public Parcelable { + protected: std::unordered_map, ComposerState, IBinderHash> mComposerStates; SortedVector mDisplayStates; std::unordered_map, CallbackInfo, TCLHash> diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index 5a121d77ab..d75b1cace5 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -688,6 +688,7 @@ public: const sp& /*applyToken*/, const InputWindowCommands& /*inputWindowCommands*/, int64_t /*desiredPresentTime*/, const client_cache_t& /*cachedBuffer*/, + bool /*hasListenerCallbacks*/, const std::vector& /*listenerCallbacks*/) override { } diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 02690b0b6a..6576be2984 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3100,9 +3100,9 @@ bool SurfaceFlinger::flushTransactionQueues() { transactions.push_back(transaction); applyTransactionState(transaction.states, transaction.displays, transaction.flags, mPendingInputWindowCommands, transaction.desiredPresentTime, - transaction.buffer, transaction.callback, - transaction.postTime, transaction.privileged, - /*isMainThread*/ true); + transaction.buffer, transaction.postTime, + transaction.privileged, transaction.hasListenerCallbacks, + transaction.listenerCallbacks, /*isMainThread*/ true); transactionQueue.pop(); flushedATransaction = true; } @@ -3149,13 +3149,11 @@ bool SurfaceFlinger::transactionIsReadyToBeApplied(int64_t desiredPresentTime, return true; } -void SurfaceFlinger::setTransactionState(const Vector& states, - const Vector& displays, uint32_t flags, - const sp& applyToken, - const InputWindowCommands& inputWindowCommands, - int64_t desiredPresentTime, - const client_cache_t& uncacheBuffer, - const std::vector& listenerCallbacks) { +void SurfaceFlinger::setTransactionState( + const Vector& states, const Vector& displays, uint32_t flags, + const sp& applyToken, const InputWindowCommands& inputWindowCommands, + int64_t desiredPresentTime, const client_cache_t& uncacheBuffer, bool hasListenerCallbacks, + const std::vector& listenerCallbacks) { ATRACE_CALL(); const int64_t postTime = systemTime(); @@ -3185,24 +3183,23 @@ void SurfaceFlinger::setTransactionState(const Vector& states, if (itr != mTransactionQueues.end() || !transactionIsReadyToBeApplied( desiredPresentTime, false /* useCachedExpectedPresentTime */, states)) { mTransactionQueues[applyToken].emplace(states, displays, flags, desiredPresentTime, - uncacheBuffer, listenerCallbacks, postTime, - privileged); + uncacheBuffer, postTime, privileged, + hasListenerCallbacks, listenerCallbacks); setTransactionFlags(eTransactionFlushNeeded); return; } applyTransactionState(states, displays, flags, inputWindowCommands, desiredPresentTime, - uncacheBuffer, listenerCallbacks, postTime, privileged); + uncacheBuffer, postTime, privileged, hasListenerCallbacks, + listenerCallbacks); } -void SurfaceFlinger::applyTransactionState(const Vector& states, - const Vector& displays, uint32_t flags, - const InputWindowCommands& inputWindowCommands, - const int64_t desiredPresentTime, - const client_cache_t& uncacheBuffer, - const std::vector& listenerCallbacks, - const int64_t postTime, bool privileged, - bool isMainThread) { +void SurfaceFlinger::applyTransactionState( + const Vector& states, const Vector& displays, uint32_t flags, + const InputWindowCommands& inputWindowCommands, const int64_t desiredPresentTime, + const client_cache_t& uncacheBuffer, const int64_t postTime, bool privileged, + bool hasListenerCallbacks, const std::vector& listenerCallbacks, + bool isMainThread) { uint32_t transactionFlags = 0; if (flags & eAnimation) { @@ -3225,28 +3222,27 @@ void SurfaceFlinger::applyTransactionState(const Vector& states, transactionFlags |= setDisplayStateLocked(display); } - // In case the client has sent a Transaction that should receive callbacks but without any - // SurfaceControls that should be included in the callback, send the listener and callbackIds - // to the callback thread so it can send an empty callback - if (!listenerCallbacks.empty()) { - mTransactionCompletedThread.run(); - } - for (const auto& listenerCallback : listenerCallbacks) { - mTransactionCompletedThread.startRegistration(listenerCallback); + // start and end registration for listeners w/ no surface so they can get their callback. Note + // that listeners with SurfaceControls will start registration during setClientStateLocked + // below. + for (const auto& listener : listenerCallbacks) { + mTransactionCompletedThread.startRegistration(listener); + mTransactionCompletedThread.endRegistration(listener); } + std::unordered_set listenerCallbacksWithSurfaces; uint32_t clientStateFlags = 0; for (const ComposerState& state : states) { - clientStateFlags |= setClientStateLocked(state, desiredPresentTime, listenerCallbacks, - postTime, privileged); + clientStateFlags |= setClientStateLocked(state, desiredPresentTime, postTime, privileged, + listenerCallbacksWithSurfaces); } - for (const auto& listenerCallback : listenerCallbacks) { + for (const auto& listenerCallback : listenerCallbacksWithSurfaces) { mTransactionCompletedThread.endRegistration(listenerCallback); } // If the state doesn't require a traversal and there are callbacks, send them now - if (!(clientStateFlags & eTraversalNeeded) && !listenerCallbacks.empty()) { + if (!(clientStateFlags & eTraversalNeeded) && hasListenerCallbacks) { mTransactionCompletedThread.sendCallbacks(); } transactionFlags |= clientStateFlags; @@ -3374,17 +3370,23 @@ bool SurfaceFlinger::callingThreadHasUnscopedSurfaceFlingerAccess() { } uint32_t SurfaceFlinger::setClientStateLocked( - const ComposerState& composerState, int64_t desiredPresentTime, - const std::vector& listenerCallbacks, int64_t postTime, - bool privileged) { + const ComposerState& composerState, int64_t desiredPresentTime, int64_t postTime, + bool privileged, + std::unordered_set& listenerCallbacks) { const layer_state_t& s = composerState.state; + for (auto& listener : s.listeners) { + // note that startRegistration will not re-register if the listener has + // already be registered for a prior surface control + mTransactionCompletedThread.startRegistration(listener); + listenerCallbacks.insert(listener); + } + sp layer(fromHandle(s.surface)); if (layer == nullptr) { - for (auto& listenerCallback : listenerCallbacks) { + for (auto& [listener, callbackIds] : s.listeners) { mTransactionCompletedThread.registerUnpresentedCallbackHandle( - new CallbackHandle(listenerCallback.transactionCompletedListener, - listenerCallback.callbackIds, s.surface)); + new CallbackHandle(listener, callbackIds, s.surface)); } return 0; } @@ -3607,8 +3609,8 @@ uint32_t SurfaceFlinger::setClientStateLocked( } } std::vector> callbackHandles; - if ((what & layer_state_t::eHasListenerCallbacksChanged) && (!listenerCallbacks.empty())) { - for (const auto& [listener, callbackIds] : listenerCallbacks) { + if ((what & layer_state_t::eHasListenerCallbacksChanged) && (!s.listeners.empty())) { + for (auto& [listener, callbackIds] : s.listeners) { callbackHandles.emplace_back(new CallbackHandle(listener, callbackIds, s.surface)); } } @@ -3890,7 +3892,8 @@ void SurfaceFlinger::onInitializeDisplays() { d.width = 0; d.height = 0; displays.add(d); - setTransactionState(state, displays, 0, nullptr, mPendingInputWindowCommands, -1, {}, {}); + setTransactionState(state, displays, 0, nullptr, mPendingInputWindowCommands, -1, {}, false, + {}); setPowerModeInternal(display, HWC_POWER_MODE_NORMAL); diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index f220c26bdf..3467de2a51 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -400,6 +400,7 @@ private: const sp& applyToken, const InputWindowCommands& inputWindowCommands, int64_t desiredPresentTime, const client_cache_t& uncacheBuffer, + bool hasListenerCallbacks, const std::vector& listenerCallbacks) override; void bootFinished() override; bool authenticateSurfaceTexture( @@ -568,10 +569,10 @@ private: const Vector& displays, uint32_t flags, const InputWindowCommands& inputWindowCommands, const int64_t desiredPresentTime, - const client_cache_t& uncacheBuffer, + const client_cache_t& uncacheBuffer, const int64_t postTime, + bool privileged, bool hasListenerCallbacks, const std::vector& listenerCallbacks, - const int64_t postTime, bool privileged, bool isMainThread = false) - REQUIRES(mStateLock); + bool isMainThread = false) REQUIRES(mStateLock); // Returns true if at least one transaction was flushed bool flushTransactionQueues(); // Returns true if there is at least one transaction that needs to be flushed @@ -586,9 +587,11 @@ private: bool transactionIsReadyToBeApplied(int64_t desiredPresentTime, bool useCachedExpectedPresentTime, const Vector& states); - uint32_t setClientStateLocked(const ComposerState& composerState, int64_t desiredPresentTime, - const std::vector& listenerCallbacks, - int64_t postTime, bool privileged) REQUIRES(mStateLock); + uint32_t setClientStateLocked( + const ComposerState& composerState, int64_t desiredPresentTime, int64_t postTime, + bool privileged, + std::unordered_set& listenerCallbacks) + REQUIRES(mStateLock); uint32_t setDisplayStateLocked(const DisplayState& s) REQUIRES(mStateLock); uint32_t addInputWindowCommands(const InputWindowCommands& inputWindowCommands) REQUIRES(mStateLock); @@ -1024,25 +1027,27 @@ private: TransactionState(const Vector& composerStates, const Vector& displayStates, uint32_t transactionFlags, int64_t desiredPresentTime, const client_cache_t& uncacheBuffer, - const std::vector& listenerCallbacks, int64_t postTime, - bool privileged) + int64_t postTime, bool privileged, bool hasListenerCallbacks, + std::vector listenerCallbacks) : states(composerStates), displays(displayStates), flags(transactionFlags), desiredPresentTime(desiredPresentTime), buffer(uncacheBuffer), - callback(listenerCallbacks), postTime(postTime), - privileged(privileged) {} + privileged(privileged), + hasListenerCallbacks(hasListenerCallbacks), + listenerCallbacks(listenerCallbacks) {} Vector states; Vector displays; uint32_t flags; const int64_t desiredPresentTime; client_cache_t buffer; - std::vector callback; const int64_t postTime; bool privileged; + bool hasListenerCallbacks; + std::vector listenerCallbacks; }; std::unordered_map, std::queue, IListenerHash> mTransactionQueues; diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index 1324f20e1c..92e59d7745 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -75,27 +75,29 @@ void TransactionCompletedThread::run() { } status_t TransactionCompletedThread::startRegistration(const ListenerCallbacks& listenerCallbacks) { + // begin running if not already running + run(); std::lock_guard lock(mMutex); if (!mRunning) { ALOGE("cannot add callback because the callback thread isn't running"); return BAD_VALUE; } + auto [itr, inserted] = mRegisteringTransactions.insert(listenerCallbacks); auto& [listener, callbackIds] = listenerCallbacks; - if (mCompletedTransactions.count(listener) == 0) { - status_t err = listener->linkToDeath(mDeathRecipient); - if (err != NO_ERROR) { - ALOGE("cannot add callback because linkToDeath failed, err: %d", err); - return err; + if (inserted) { + if (mCompletedTransactions.count(listener) == 0) { + status_t err = listener->linkToDeath(mDeathRecipient); + if (err != NO_ERROR) { + ALOGE("cannot add callback because linkToDeath failed, err: %d", err); + return err; + } } + auto& transactionStatsDeque = mCompletedTransactions[listener]; + transactionStatsDeque.emplace_back(callbackIds); } - mRegisteringTransactions.insert(listenerCallbacks); - - auto& transactionStatsDeque = mCompletedTransactions[listener]; - transactionStatsDeque.emplace_back(callbackIds); - return NO_ERROR; } diff --git a/services/surfaceflinger/tests/Android.bp b/services/surfaceflinger/tests/Android.bp index 159c2a464a..7f960f302a 100644 --- a/services/surfaceflinger/tests/Android.bp +++ b/services/surfaceflinger/tests/Android.bp @@ -43,7 +43,48 @@ cc_test { "libui", "libutils", ] +} + +cc_defaults { + name: "ipc_defaults", + cflags: [ + "-Wall", + "-Werror", + ], +} +cc_test { + name: "IPC_test", + defaults: ["ipc_defaults"], + test_suites: ["device-tests"], + srcs: [ + "BufferGenerator.cpp", + "IPC_test.cpp", + ], + cppflags: [ + "-Wall", + "-Werror", + "-Wformat", + "-Wthread-safety", + "-Wunused", + "-Wunreachable-code", + ], + shared_libs: [ + "libandroid", + "libbinder", + "libcutils", + "libEGL", + "libGLESv2", + "libgui", + "liblayers_proto", + "liblog", + "libprotobuf-cpp-full", + "libtimestats_proto", + "libui", + "libutils", + ], + cpp_std: "experimental", + gnu_extensions: false, } subdirs = [ diff --git a/services/surfaceflinger/tests/IPC_test.cpp b/services/surfaceflinger/tests/IPC_test.cpp new file mode 100644 index 0000000000..8a756a668c --- /dev/null +++ b/services/surfaceflinger/tests/IPC_test.cpp @@ -0,0 +1,351 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include + +#include "BufferGenerator.h" +#include "utils/CallbackUtils.h" +#include "utils/ColorUtils.h" +#include "utils/TransactionUtils.h" + +namespace android { + +namespace test { + +using Transaction = SurfaceComposerClient::Transaction; +using CallbackInfo = SurfaceComposerClient::CallbackInfo; +using TCLHash = SurfaceComposerClient::TCLHash; +using android::hardware::graphics::common::V1_1::BufferUsage; + +class TransactionHelper : public Transaction { +public: + size_t getNumListeners() { return mListenerCallbacks.size(); } + + std::unordered_map, CallbackInfo, TCLHash> + getListenerCallbacks() { + return mListenerCallbacks; + } +}; + +class IPCTestUtils { +public: + static void waitForCallback(CallbackHelper& helper, const ExpectedResult& expectedResult, + bool finalState = false); + static status_t getBuffer(sp* outBuffer, sp* outFence); +}; + +class IIPCTest : public IInterface { +public: + DECLARE_META_INTERFACE(IPCTest) + enum class Tag : uint32_t { + SetDeathToken = IBinder::FIRST_CALL_TRANSACTION, + InitClient, + CreateTransaction, + MergeAndApply, + VerifyCallbacks, + CleanUp, + Last, + }; + + virtual status_t setDeathToken(sp& token) = 0; + + virtual status_t initClient() = 0; + + virtual status_t createTransaction(TransactionHelper* outTransaction, uint32_t width, + uint32_t height) = 0; + + virtual status_t mergeAndApply(TransactionHelper transaction) = 0; + + virtual status_t verifyCallbacks() = 0; + + virtual status_t cleanUp() = 0; +}; + +class BpIPCTest : public SafeBpInterface { +public: + explicit BpIPCTest(const sp& impl) : SafeBpInterface(impl, "BpIPCTest") {} + + status_t setDeathToken(sp& token) { + return callRemote(Tag::SetDeathToken, token); + } + + status_t initClient() { return callRemote(Tag::InitClient); } + + status_t createTransaction(TransactionHelper* transaction, uint32_t width, uint32_t height) { + return callRemote(Tag::CreateTransaction, + transaction, width, height); + } + + status_t mergeAndApply(TransactionHelper transaction) { + return callRemote(Tag::MergeAndApply, transaction); + } + + status_t verifyCallbacks() { + return callRemote(Tag::VerifyCallbacks); + } + + status_t cleanUp() { return callRemote(Tag::CleanUp); } +}; + +IMPLEMENT_META_INTERFACE(IPCTest, "android.gfx.tests.IIPCTest") + +class onTestDeath : public IBinder::DeathRecipient { +public: + void binderDied(const wp& /*who*/) override { + ALOGE("onTestDeath::binderDied, exiting"); + exit(0); + } +}; + +sp getDeathToken() { + static sp token = new onTestDeath; + return token; +} + +class BnIPCTest : public SafeBnInterface { +public: + BnIPCTest() : SafeBnInterface("BnIPCTest") {} + + status_t setDeathToken(sp& token) override { + return token->linkToDeath(getDeathToken()); + } + + status_t initClient() override { + mClient = new SurfaceComposerClient; + auto err = mClient->initCheck(); + return err; + } + + status_t createTransaction(TransactionHelper* transaction, uint32_t width, uint32_t height) { + if (transaction == nullptr) { + ALOGE("Error in createTransaction: transaction is nullptr"); + return BAD_VALUE; + } + mSurfaceControl = mClient->createSurface(String8("parentProcessSurface"), 0, 0, + PIXEL_FORMAT_RGBA_8888, + ISurfaceComposerClient::eFXSurfaceBufferState, + /*parent*/ nullptr); + sp gb; + sp fence; + int err = IPCTestUtils::getBuffer(&gb, &fence); + if (err != NO_ERROR) return err; + + TransactionUtils::fillGraphicBufferColor(gb, + {0, 0, static_cast(width), + static_cast(height)}, + Color::RED); + transaction->setLayerStack(mSurfaceControl, 0) + .setLayer(mSurfaceControl, std::numeric_limits::max()) + .setFrame(mSurfaceControl, Rect(0, 0, width, height)) + .setBuffer(mSurfaceControl, gb) + .setAcquireFence(mSurfaceControl, fence) + .show(mSurfaceControl) + .addTransactionCompletedCallback(mCallbackHelper.function, + mCallbackHelper.getContext()); + return NO_ERROR; + } + + status_t mergeAndApply(TransactionHelper /*transaction*/) { + // transaction.apply(); + return NO_ERROR; + } + + status_t verifyCallbacks() { + ExpectedResult expected; + expected.addSurface(ExpectedResult::Transaction::PRESENTED, mSurfaceControl); + EXPECT_NO_FATAL_FAILURE(IPCTestUtils::waitForCallback(mCallbackHelper, expected, true)); + return NO_ERROR; + } + + status_t cleanUp() { + if (mClient) mClient->dispose(); + mSurfaceControl = nullptr; + IPCThreadState::self()->stopProcess(); + return NO_ERROR; + } + + status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, + uint32_t /*flags*/) override { + EXPECT_GE(code, IBinder::FIRST_CALL_TRANSACTION); + EXPECT_LT(code, static_cast(IIPCTest::Tag::Last)); + switch (static_cast(code)) { + case IIPCTest::Tag::SetDeathToken: + return callLocal(data, reply, &IIPCTest::setDeathToken); + case IIPCTest::Tag::InitClient: + return callLocal(data, reply, &IIPCTest::initClient); + case IIPCTest::Tag::CreateTransaction: + return callLocal(data, reply, &IIPCTest::createTransaction); + case IIPCTest::Tag::MergeAndApply: + return callLocal(data, reply, &IIPCTest::mergeAndApply); + case IIPCTest::Tag::VerifyCallbacks: + return callLocal(data, reply, &IIPCTest::verifyCallbacks); + case IIPCTest::Tag::CleanUp: + return callLocal(data, reply, &IIPCTest::cleanUp); + default: + return UNKNOWN_ERROR; + } + } + +private: + sp mClient; + sp mSurfaceControl; + CallbackHelper mCallbackHelper; +}; + +class IPCTest : public ::testing::Test { +public: + IPCTest() : mDeathRecipient(new BBinder), mRemote(initRemoteService()) { + ProcessState::self()->startThreadPool(); + } + void SetUp() { + mClient = new SurfaceComposerClient; + ASSERT_EQ(NO_ERROR, mClient->initCheck()); + + mPrimaryDisplay = mClient->getInternalDisplayToken(); + DisplayInfo info; + mClient->getDisplayInfo(mPrimaryDisplay, &info); + mDisplayWidth = info.w; + mDisplayHeight = info.h; + + Transaction setupTransaction; + setupTransaction.setDisplayLayerStack(mPrimaryDisplay, 0); + setupTransaction.apply(); + } + +protected: + sp initRemoteService(); + + sp mDeathRecipient; + sp mRemote; + sp mClient; + sp mPrimaryDisplay; + uint32_t mDisplayWidth; + uint32_t mDisplayHeight; + sp sc; +}; + +status_t IPCTestUtils::getBuffer(sp* outBuffer, sp* outFence) { + static BufferGenerator bufferGenerator; + return bufferGenerator.get(outBuffer, outFence); +} + +void IPCTestUtils::waitForCallback(CallbackHelper& helper, const ExpectedResult& expectedResult, + bool finalState) { + CallbackData callbackData; + ASSERT_NO_FATAL_FAILURE(helper.getCallbackData(&callbackData)); + EXPECT_NO_FATAL_FAILURE(expectedResult.verifyCallbackData(callbackData)); + + if (finalState) { + ASSERT_NO_FATAL_FAILURE(helper.verifyFinalState()); + } +} + +sp IPCTest::initRemoteService() { + static std::mutex mMutex; + static sp remote; + const String16 serviceName("IPCTest"); + + std::unique_lock lock; + if (remote == nullptr) { + pid_t forkPid = fork(); + EXPECT_NE(forkPid, -1); + + if (forkPid == 0) { + sp nativeService = new BnIPCTest; + if (!nativeService) { + ALOGE("null service..."); + } + status_t err = defaultServiceManager()->addService(serviceName, + IInterface::asBinder(nativeService)); + if (err != NO_ERROR) { + ALOGE("failed to add service: %d", err); + } + ProcessState::self()->startThreadPool(); + IPCThreadState::self()->joinThreadPool(); + [&]() { exit(0); }(); + } + sp binder = defaultServiceManager()->getService(serviceName); + remote = interface_cast(binder); + remote->setDeathToken(mDeathRecipient); + } + return remote; +} + +TEST_F(IPCTest, MergeBasic) { + CallbackHelper helper1; + sc = mClient->createSurface(String8("parentProcessSurface"), 0, 0, PIXEL_FORMAT_RGBA_8888, + ISurfaceComposerClient::eFXSurfaceBufferState, + /*parent*/ nullptr); + sp gb; + sp fence; + int err = IPCTestUtils::getBuffer(&gb, &fence); + ASSERT_EQ(NO_ERROR, err); + TransactionUtils::fillGraphicBufferColor(gb, + {0, 0, static_cast(mDisplayWidth), + static_cast(mDisplayHeight)}, + Color::RED); + + Transaction transaction; + transaction.setLayerStack(sc, 0) + .setLayer(sc, std::numeric_limits::max() - 1) + .setBuffer(sc, gb) + .setAcquireFence(sc, fence) + .show(sc) + .addTransactionCompletedCallback(helper1.function, helper1.getContext()); + + TransactionHelper remote; + mRemote->initClient(); + mRemote->createTransaction(&remote, mDisplayWidth / 2, mDisplayHeight / 2); + ASSERT_EQ(1, remote.getNumListeners()); + auto remoteListenerCallbacks = remote.getListenerCallbacks(); + auto remoteCallback = remoteListenerCallbacks.begin(); + auto remoteCallbackInfo = remoteCallback->second; + auto remoteListenerScs = remoteCallbackInfo.surfaceControls; + ASSERT_EQ(1, remoteCallbackInfo.callbackIds.size()); + ASSERT_EQ(1, remoteListenerScs.size()); + + sp remoteSc = *(remoteListenerScs.begin()); + transaction.merge(std::move(remote)); + transaction.apply(); + + sleep(1); + ExpectedResult expected; + expected.addSurface(ExpectedResult::Transaction::PRESENTED, sc); + expected.addSurface(ExpectedResult::Transaction::PRESENTED, remoteSc); + EXPECT_NO_FATAL_FAILURE(IPCTestUtils::waitForCallback(helper1, expected, true)); + + mRemote->verifyCallbacks(); + mRemote->cleanUp(); +} + +} // namespace test +} // namespace android -- cgit v1.2.3-59-g8ed1b From 32cdc1f381977a9e980b81a2f15a575be9ab75b7 Mon Sep 17 00:00:00 2001 From: Valerie Hau Date: Mon, 21 Oct 2019 14:45:54 -0700 Subject: Adding transformHint for BufferStateLayers Adding transformHint to callbacks and passing back during Surface creation Bug: 133512804, 141939598 Test: build, boot, manual Change-Id: Ic3227b7d5991e342c017e789afc70cc6605d25f5 --- libs/gui/ITransactionCompletedListener.cpp | 4 +++- libs/gui/SurfaceComposerClient.cpp | 3 ++- libs/gui/include/gui/ITransactionCompletedListener.h | 9 +++++++-- libs/gui/include/gui/SurfaceComposerClient.h | 8 ++++++-- services/surfaceflinger/BufferStateLayer.cpp | 9 ++++++--- services/surfaceflinger/BufferStateLayer.h | 2 ++ services/surfaceflinger/TransactionCompletedThread.cpp | 3 ++- services/surfaceflinger/TransactionCompletedThread.h | 1 + services/surfaceflinger/tests/utils/CallbackUtils.h | 3 ++- 9 files changed, 31 insertions(+), 11 deletions(-) (limited to 'services/surfaceflinger/TransactionCompletedThread.cpp') diff --git a/libs/gui/ITransactionCompletedListener.cpp b/libs/gui/ITransactionCompletedListener.cpp index acda6001cc..e5e25aa50f 100644 --- a/libs/gui/ITransactionCompletedListener.cpp +++ b/libs/gui/ITransactionCompletedListener.cpp @@ -48,6 +48,7 @@ status_t SurfaceStats::writeToParcel(Parcel* output) const { } else { err = output->writeBool(false); } + err = output->writeUint32(transformHint); return err; } @@ -72,7 +73,8 @@ status_t SurfaceStats::readFromParcel(const Parcel* input) { return err; } } - return NO_ERROR; + err = input->readUint32(&transformHint); + return err; } status_t TransactionStats::writeToParcel(Parcel* output) const { diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 7b256f5c02..e9079efd29 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -222,7 +222,8 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener for (const auto& surfaceStats : transactionStats.surfaceStats) { surfaceControlStats.emplace_back(surfaceControls[surfaceStats.surfaceControl], surfaceStats.acquireTime, - surfaceStats.previousReleaseFence); + surfaceStats.previousReleaseFence, + surfaceStats.transformHint); } callbackFunction(transactionStats.latchTime, transactionStats.presentFence, diff --git a/libs/gui/include/gui/ITransactionCompletedListener.h b/libs/gui/include/gui/ITransactionCompletedListener.h index 178ca2d7e2..9c15225ac8 100644 --- a/libs/gui/include/gui/ITransactionCompletedListener.h +++ b/libs/gui/include/gui/ITransactionCompletedListener.h @@ -41,12 +41,17 @@ public: status_t readFromParcel(const Parcel* input) override; SurfaceStats() = default; - SurfaceStats(const sp& sc, nsecs_t time, const sp& prevReleaseFence) - : surfaceControl(sc), acquireTime(time), previousReleaseFence(prevReleaseFence) {} + SurfaceStats(const sp& sc, nsecs_t time, const sp& prevReleaseFence, + uint32_t hint) + : surfaceControl(sc), + acquireTime(time), + previousReleaseFence(prevReleaseFence), + transformHint(hint) {} sp surfaceControl; nsecs_t acquireTime = -1; sp previousReleaseFence; + uint32_t transformHint = 0; }; class TransactionStats : public Parcelable { diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h index 6676be4837..08f4e9e9d3 100644 --- a/libs/gui/include/gui/SurfaceComposerClient.h +++ b/libs/gui/include/gui/SurfaceComposerClient.h @@ -58,12 +58,16 @@ class Region; struct SurfaceControlStats { SurfaceControlStats(const sp& sc, nsecs_t time, - const sp& prevReleaseFence) - : surfaceControl(sc), acquireTime(time), previousReleaseFence(prevReleaseFence) {} + const sp& prevReleaseFence, uint32_t hint) + : surfaceControl(sc), + acquireTime(time), + previousReleaseFence(prevReleaseFence), + transformHint(hint) {} sp surfaceControl; nsecs_t acquireTime = -1; sp previousReleaseFence; + uint32_t transformHint = 0; }; using TransactionCompletedCallbackTakesContext = diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp index 75fc0e9c06..7b26b8a36d 100644 --- a/services/surfaceflinger/BufferStateLayer.cpp +++ b/services/surfaceflinger/BufferStateLayer.cpp @@ -103,12 +103,15 @@ void BufferStateLayer::onLayerDisplayed(const sp& releaseFence) { } } -void BufferStateLayer::setTransformHint(uint32_t /*orientation*/) const { - // TODO(marissaw): send the transform hint to buffer owner - return; +void BufferStateLayer::setTransformHint(uint32_t orientation) const { + mTransformHint = orientation; } void BufferStateLayer::releasePendingBuffer(nsecs_t /*dequeueReadyTime*/) { + for (const auto& handle : mDrawingState.callbackHandles) { + handle->transformHint = mTransformHint; + } + mFlinger->getTransactionCompletedThread().finalizePendingCallbackHandles( mDrawingState.callbackHandles); diff --git a/services/surfaceflinger/BufferStateLayer.h b/services/surfaceflinger/BufferStateLayer.h index 3dfe76cf9f..289bb1756f 100644 --- a/services/surfaceflinger/BufferStateLayer.h +++ b/services/surfaceflinger/BufferStateLayer.h @@ -149,6 +149,8 @@ private: bool mReleasePreviousBuffer = false; nsecs_t mCallbackHandleAcquireTime = -1; + mutable uint32_t mTransformHint = 0; + // TODO(marissaw): support sticky transform for LEGACY camera mode class HwcSlotGenerator : public ClientCache::ErasedRecipient { diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index 92e59d7745..8db03db7e8 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -234,7 +234,8 @@ status_t TransactionCompletedThread::addCallbackHandle(const sp& sp surfaceControl = handle->surfaceControl.promote(); if (surfaceControl) { transactionStats->surfaceStats.emplace_back(surfaceControl, handle->acquireTime, - handle->previousReleaseFence); + handle->previousReleaseFence, + handle->transformHint); } return NO_ERROR; } diff --git a/services/surfaceflinger/TransactionCompletedThread.h b/services/surfaceflinger/TransactionCompletedThread.h index a85ad1e63c..12ea8fe7d0 100644 --- a/services/surfaceflinger/TransactionCompletedThread.h +++ b/services/surfaceflinger/TransactionCompletedThread.h @@ -44,6 +44,7 @@ public: sp previousReleaseFence; nsecs_t acquireTime = -1; nsecs_t latchTime = -1; + uint32_t transformHint = 0; }; class TransactionCompletedThread { diff --git a/services/surfaceflinger/tests/utils/CallbackUtils.h b/services/surfaceflinger/tests/utils/CallbackUtils.h index 51ae8c4e94..4e2b7c3543 100644 --- a/services/surfaceflinger/tests/utils/CallbackUtils.h +++ b/services/surfaceflinger/tests/utils/CallbackUtils.h @@ -121,7 +121,8 @@ private: void verifySurfaceControlStats(const SurfaceControlStats& surfaceControlStats, nsecs_t latchTime) const { - const auto& [surfaceControl, acquireTime, previousReleaseFence] = surfaceControlStats; + const auto& [surfaceControl, acquireTime, previousReleaseFence, transformHint] = + surfaceControlStats; ASSERT_EQ(acquireTime > 0, mBufferResult == ExpectedResult::Buffer::ACQUIRED) << "bad acquire time"; -- cgit v1.2.3-59-g8ed1b From ac12ae73c2a2cc7d4fedcc1e187ff9984679df54 Mon Sep 17 00:00:00 2001 From: Valerie Hau Date: Tue, 19 Nov 2019 14:13:16 -0800 Subject: Clear all pending transactions on screen wakeup If an app sets a transaction that modifies layer state, but does not get committed by an SF composition cycle, we may end up dangling some callbacks. Temporary fix is to clear and send callbacks on wakeup Bug: 141111965 Test: build, boot, manual Change-Id: I781124c3f96174cefd5eb67e597c13f923df4fc1 --- services/surfaceflinger/SurfaceFlinger.cpp | 2 ++ services/surfaceflinger/TransactionCompletedThread.cpp | 9 +++++++++ services/surfaceflinger/TransactionCompletedThread.h | 2 ++ 3 files changed, 13 insertions(+) (limited to 'services/surfaceflinger/TransactionCompletedThread.cpp') diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 76fd51f8ea..7b4a972ad8 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3726,6 +3726,8 @@ void SurfaceFlinger::setPowerModeInternal(const sp& display, int if (currentMode == HWC_POWER_MODE_OFF) { // Turn on the display + // TODO: @vhau temp fix only! See b/141111965 + mTransactionCompletedThread.clearAllPending(); getHwComposer().setPowerMode(*displayId, mode); if (display->isPrimary() && mode != HWC_POWER_MODE_DOZE_SUSPEND) { setVsyncEnabledInHWC(*displayId, mHWCVsyncPendingState); diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index 8db03db7e8..c15355d338 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -189,6 +189,15 @@ status_t TransactionCompletedThread::finalizePendingCallbackHandles( return NO_ERROR; } +void TransactionCompletedThread::clearAllPending() { + std::lock_guard lock(mMutex); + if (!mRunning) { + return; + } + mPendingTransactions.clear(); + mConditionVariable.notify_all(); +} + status_t TransactionCompletedThread::registerUnpresentedCallbackHandle( const sp& handle) { std::lock_guard lock(mMutex); diff --git a/services/surfaceflinger/TransactionCompletedThread.h b/services/surfaceflinger/TransactionCompletedThread.h index 12ea8fe7d0..cd95bfb040 100644 --- a/services/surfaceflinger/TransactionCompletedThread.h +++ b/services/surfaceflinger/TransactionCompletedThread.h @@ -70,6 +70,8 @@ public: // Notifies the TransactionCompletedThread that a pending CallbackHandle has been presented. status_t finalizePendingCallbackHandles(const std::deque>& handles); + void clearAllPending(); + // Adds the Transaction CallbackHandle from a layer that does not need to be relatched and // presented this frame. status_t registerUnpresentedCallbackHandle(const sp& handle); -- cgit v1.2.3-59-g8ed1b From c5686802261e26e035889f047cf43016d890181f Mon Sep 17 00:00:00 2001 From: Valerie Hau Date: Fri, 22 Nov 2019 14:18:09 -0800 Subject: When destroying layer, add children to offscreen layers If a layer is destroyed, make sure all children are added to the offscreen layers. Otherwise, we may dangle a layer that is neither in current state nor in offscreen layers. Bug: 141111965 Test: build, boot, manual Change-Id: Iec6788f10a24cb63faa9b40f246cbde3770d24a7 --- services/surfaceflinger/Layer.h | 9 +++++++++ services/surfaceflinger/SurfaceFlinger.cpp | 17 ++++++++++++++--- services/surfaceflinger/SurfaceFlinger.h | 2 ++ services/surfaceflinger/TransactionCompletedThread.cpp | 9 --------- services/surfaceflinger/TransactionCompletedThread.h | 2 -- 5 files changed, 25 insertions(+), 14 deletions(-) (limited to 'services/surfaceflinger/TransactionCompletedThread.cpp') diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 286311b03f..475b584764 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -664,6 +664,15 @@ public: const LayerVector::Visitor& visitor); size_t getChildrenCount() const; + + // ONLY CALL THIS FROM THE LAYER DTOR! + // See b/141111965. We need to add current children to offscreen layers in + // the layer dtor so as not to dangle layers. Since the layer has not + // committed its transaction when the layer is destroyed, we must add + // current children. This is safe in the dtor as we will no longer update + // the current state, but should not be called anywhere else! + LayerVector& getCurrentChildren() { return mCurrentChildren; } + void addChild(const sp& layer); // Returns index if removed, or negative value otherwise // for symmetry with Vector::remove diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 14a2ab1b3e..09534468d8 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3717,9 +3717,6 @@ void SurfaceFlinger::setPowerModeInternal(const sp& display, int } if (currentMode == HWC_POWER_MODE_OFF) { - // Turn on the display - // TODO: @vhau temp fix only! See b/141111965 - mTransactionCompletedThread.clearAllPending(); getHwComposer().setPowerMode(*displayId, mode); if (display->isPrimary() && mode != HWC_POWER_MODE_DOZE_SUSPEND) { setVsyncEnabledInHWC(*displayId, mHWCVsyncPendingState); @@ -5500,6 +5497,20 @@ void SurfaceFlinger::onLayerFirstRef(Layer* layer) { void SurfaceFlinger::onLayerDestroyed(Layer* layer) { mNumLayers--; + removeFromOffscreenLayers(layer); +} + +// WARNING: ONLY CALL THIS FROM LAYER DTOR +// Here we add children in the current state to offscreen layers and remove the +// layer itself from the offscreen layer list. Since +// this is the dtor, it is safe to access the current state. This keeps us +// from dangling children layers such that they are not reachable from the +// Drawing state nor the offscreen layer list +// See b/141111965 +void SurfaceFlinger::removeFromOffscreenLayers(Layer* layer) { + for (auto& child : layer->getCurrentChildren()) { + mOffscreenLayers.emplace(child.get()); + } mOffscreenLayers.erase(layer); } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 50b3ae4ecd..2459cc3923 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -313,6 +313,8 @@ public: void onLayerFirstRef(Layer*); void onLayerDestroyed(Layer*); + void removeFromOffscreenLayers(Layer* layer); + TransactionCompletedThread& getTransactionCompletedThread() { return mTransactionCompletedThread; } diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index c15355d338..8db03db7e8 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -189,15 +189,6 @@ status_t TransactionCompletedThread::finalizePendingCallbackHandles( return NO_ERROR; } -void TransactionCompletedThread::clearAllPending() { - std::lock_guard lock(mMutex); - if (!mRunning) { - return; - } - mPendingTransactions.clear(); - mConditionVariable.notify_all(); -} - status_t TransactionCompletedThread::registerUnpresentedCallbackHandle( const sp& handle) { std::lock_guard lock(mMutex); diff --git a/services/surfaceflinger/TransactionCompletedThread.h b/services/surfaceflinger/TransactionCompletedThread.h index cd95bfb040..12ea8fe7d0 100644 --- a/services/surfaceflinger/TransactionCompletedThread.h +++ b/services/surfaceflinger/TransactionCompletedThread.h @@ -70,8 +70,6 @@ public: // Notifies the TransactionCompletedThread that a pending CallbackHandle has been presented. status_t finalizePendingCallbackHandles(const std::deque>& handles); - void clearAllPending(); - // Adds the Transaction CallbackHandle from a layer that does not need to be relatched and // presented this frame. status_t registerUnpresentedCallbackHandle(const sp& handle); -- cgit v1.2.3-59-g8ed1b From dfca3ecce2a0c045aa943fc4dfd6d2d33d43a1e0 Mon Sep 17 00:00:00 2001 From: Valerie Hau Date: Tue, 17 Dec 2019 08:50:33 -0800 Subject: Fix callback drop callbacks can be registered on any thread at any time. Do not clear mCompletedTransactions unless there are no associated stats Bug: 146345307, 141706317 Test: build, boot, libsurfaceflinger_unittest, SurfaceFlinger_test Change-Id: I659604c6be578417ebac7baf125510cddfbfd794 --- services/surfaceflinger/TransactionCompletedThread.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'services/surfaceflinger/TransactionCompletedThread.cpp') diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index c15355d338..1e0719159e 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -320,8 +320,16 @@ void TransactionCompletedThread::threadMain() { interface_cast(listenerStats.listener) ->onTransactionCompleted(listenerStats); listener->unlinkToDeath(mDeathRecipient); + if (transactionStatsDeque.empty()) { + completedTransactionsItr = + mCompletedTransactions.erase(completedTransactionsItr); + } else { + completedTransactionsItr++; + } + } else { + completedTransactionsItr = + mCompletedTransactions.erase(completedTransactionsItr); } - completedTransactionsItr = mCompletedTransactions.erase(completedTransactionsItr); } else { completedTransactionsItr++; } -- cgit v1.2.3-59-g8ed1b From 783ec6803ca246ff5ccdf9809588f063b3107bb1 Mon Sep 17 00:00:00 2001 From: Valerie Hau Date: Fri, 10 Jan 2020 08:41:15 -0800 Subject: unlinkToDeath only when the listener has no more callbacks Bug: N/A Test: build, boot, SurfaceFlinger_test Change-Id: I2bbca0f781897967a18731ade3a3b4724f16d361 --- services/surfaceflinger/TransactionCompletedThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'services/surfaceflinger/TransactionCompletedThread.cpp') diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index 4c1baafa3b..1475889cd9 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -310,8 +310,8 @@ void TransactionCompletedThread::threadMain() { // we get pointers that compare unequal in the SF process. interface_cast(listenerStats.listener) ->onTransactionCompleted(listenerStats); - listener->unlinkToDeath(mDeathRecipient); if (transactionStatsDeque.empty()) { + listener->unlinkToDeath(mDeathRecipient); completedTransactionsItr = mCompletedTransactions.erase(completedTransactionsItr); } else { -- cgit v1.2.3-59-g8ed1b From b0dbdaaf3b1a42ab072af9d111d56900b1197af4 Mon Sep 17 00:00:00 2001 From: Ady Abraham Date: Mon, 6 Jan 2020 16:19:42 -0800 Subject: SurfaceFlinger: Enable -WConversion in Android.bp Enable global -WConversion in Android.bp and turn it off in individual files. This is the first step to enable -WConversion in SurfaceFlinger. Test: boot Bug: 129481165 Change-Id: Ia752df39ef380bde71705a32582d618242c466f7 --- libs/renderengine/tests/RenderEngineTest.cpp | 7 +++++++ services/surfaceflinger/Android.bp | 1 + services/surfaceflinger/BufferLayer.cpp | 7 +++++++ services/surfaceflinger/BufferLayerConsumer.cpp | 7 +++++++ services/surfaceflinger/BufferQueueLayer.cpp | 7 +++++++ services/surfaceflinger/BufferStateLayer.cpp | 7 +++++++ services/surfaceflinger/Client.cpp | 7 +++++++ services/surfaceflinger/ColorLayer.cpp | 7 +++++++ .../CompositionEngine/mock/Display.cpp | 7 +++++++ .../CompositionEngine/mock/Layer.cpp | 7 +++++++ .../CompositionEngine/mock/LayerFE.cpp | 7 +++++++ .../CompositionEngine/mock/Output.cpp | 7 +++++++ .../CompositionEngine/mock/OutputLayer.cpp | 7 +++++++ .../CompositionEngine/src/CompositionEngine.cpp | 7 +++++++ .../CompositionEngine/src/Display.cpp | 7 +++++++ .../CompositionEngine/src/HwcBufferCache.cpp | 7 +++++++ .../surfaceflinger/CompositionEngine/src/Layer.cpp | 7 +++++++ .../src/LayerFECompositionState.cpp | 7 +++++++ .../CompositionEngine/src/Output.cpp | 7 +++++++ .../CompositionEngine/src/OutputLayer.cpp | 7 +++++++ .../src/OutputLayerCompositionState.cpp | 7 +++++++ .../CompositionEngine/src/RenderSurface.cpp | 7 +++++++ .../tests/CompositionEngineTest.cpp | 7 +++++++ .../CompositionEngine/tests/DisplayTest.cpp | 7 +++++++ .../CompositionEngine/tests/LayerTest.cpp | 7 +++++++ .../CompositionEngine/tests/OutputLayerTest.cpp | 7 +++++++ .../CompositionEngine/tests/OutputTest.cpp | 7 +++++++ .../CompositionEngine/tests/RenderSurfaceTest.cpp | 7 +++++++ services/surfaceflinger/ContainerLayer.cpp | 7 +++++++ services/surfaceflinger/DisplayDevice.cpp | 7 +++++++ .../surfaceflinger/DisplayHardware/ComposerHal.cpp | 7 +++++++ .../DisplayHardware/DisplayIdentification.cpp | 7 +++++++ .../DisplayHardware/FramebufferSurface.cpp | 7 +++++++ services/surfaceflinger/DisplayHardware/HWC2.cpp | 7 +++++++ .../surfaceflinger/DisplayHardware/HWComposer.cpp | 7 +++++++ .../DisplayHardware/VirtualDisplaySurface.cpp | 7 +++++++ services/surfaceflinger/Effects/Daltonizer.cpp | 7 +++++++ services/surfaceflinger/EventLog/EventLog.cpp | 7 +++++++ .../surfaceflinger/FrameTracer/FrameTracer.cpp | 7 +++++++ services/surfaceflinger/FrameTracker.cpp | 7 +++++++ services/surfaceflinger/Layer.cpp | 7 +++++++ services/surfaceflinger/LayerProtoHelper.cpp | 7 +++++++ services/surfaceflinger/LayerRejecter.cpp | 7 +++++++ services/surfaceflinger/LayerVector.cpp | 7 +++++++ services/surfaceflinger/MonitoredProducer.cpp | 7 +++++++ services/surfaceflinger/RefreshRateOverlay.cpp | 7 +++++++ services/surfaceflinger/RegionSamplingThread.cpp | 7 +++++++ services/surfaceflinger/RenderArea.cpp | 23 ++++++++++++++++++++++ services/surfaceflinger/Scheduler/DispSync.cpp | 7 +++++++ .../surfaceflinger/Scheduler/DispSyncSource.cpp | 7 +++++++ .../Scheduler/EventControlThread.cpp | 7 +++++++ services/surfaceflinger/Scheduler/EventThread.cpp | 7 +++++++ services/surfaceflinger/Scheduler/LayerHistory.cpp | 7 +++++++ services/surfaceflinger/Scheduler/MessageQueue.cpp | 7 +++++++ services/surfaceflinger/Scheduler/PhaseOffsets.cpp | 7 +++++++ .../Scheduler/RefreshRateConfigs.cpp | 6 ++++++ services/surfaceflinger/Scheduler/Scheduler.cpp | 7 +++++++ .../surfaceflinger/Scheduler/SchedulerUtils.cpp | 7 +++++++ .../surfaceflinger/Scheduler/VSyncModulator.cpp | 7 +++++++ .../surfaceflinger/Scheduler/VSyncPredictor.cpp | 7 +++++++ services/surfaceflinger/SurfaceFlinger.cpp | 7 +++++++ .../SurfaceFlingerDefaultFactory.cpp | 7 +++++++ services/surfaceflinger/SurfaceFlingerFactory.cpp | 7 +++++++ services/surfaceflinger/SurfaceInterceptor.cpp | 7 +++++++ services/surfaceflinger/SurfaceTracing.cpp | 7 +++++++ services/surfaceflinger/TimeStats/TimeStats.cpp | 7 +++++++ .../surfaceflinger/TransactionCompletedThread.cpp | 7 +++++++ services/surfaceflinger/main_surfaceflinger.cpp | 7 +++++++ services/surfaceflinger/tests/BufferGenerator.cpp | 7 +++++++ services/surfaceflinger/tests/Credentials_test.cpp | 7 +++++++ .../tests/DereferenceSurfaceControl_test.cpp | 7 +++++++ .../surfaceflinger/tests/DisplayConfigs_test.cpp | 7 +++++++ .../surfaceflinger/tests/LayerCallback_test.cpp | 7 +++++++ .../tests/LayerRenderTypeTransaction_test.cpp | 7 +++++++ .../surfaceflinger/tests/LayerTransaction_test.cpp | 7 +++++++ .../LayerTypeAndRenderTypeTransaction_test.cpp | 7 +++++++ .../tests/LayerTypeTransaction_test.cpp | 7 +++++++ services/surfaceflinger/tests/LayerUpdate_test.cpp | 7 +++++++ services/surfaceflinger/tests/MirrorLayer_test.cpp | 7 +++++++ .../tests/MultiDisplayLayerBounds_test.cpp | 7 +++++++ services/surfaceflinger/tests/RelativeZ_test.cpp | 7 +++++++ services/surfaceflinger/tests/SetGeometry_test.cpp | 7 +++++++ services/surfaceflinger/tests/Stress_test.cpp | 7 +++++++ .../tests/SurfaceInterceptor_test.cpp | 7 +++++++ .../tests/fakehwc/FakeComposerClient.cpp | 7 +++++++ .../tests/fakehwc/FakeComposerService.cpp | 7 +++++++ .../tests/fakehwc/FakeComposerUtils.cpp | 7 +++++++ .../tests/fakehwc/SFFakeHwc_test.cpp | 7 +++++++ services/surfaceflinger/tests/hwc2/Hwc2Test.cpp | 7 +++++++ .../surfaceflinger/tests/hwc2/Hwc2TestBuffer.cpp | 7 +++++++ .../surfaceflinger/tests/hwc2/Hwc2TestLayers.cpp | 7 +++++++ .../tests/hwc2/Hwc2TestPixelComparator.cpp | 7 +++++++ .../tests/hwc2/Hwc2TestProperties.cpp | 7 +++++++ .../surfaceflinger/tests/unittests/CachingTest.cpp | 7 +++++++ .../tests/unittests/CompositionTest.cpp | 7 +++++++ .../tests/unittests/DisplayTransactionTest.cpp | 7 +++++++ .../tests/unittests/FrameTracerTest.cpp | 7 +++++++ .../tests/unittests/LayerHistoryTest.cpp | 23 ++++++++++++++++++++++ .../tests/unittests/PhaseOffsetsTest.cpp | 7 +++++++ .../tests/unittests/RefreshRateConfigsTest.cpp | 8 ++++---- .../tests/unittests/RefreshRateStatsTest.cpp | 7 +++++++ .../tests/unittests/RegionSamplingTest.cpp | 7 +++++++ .../tests/unittests/SchedulerTest.cpp | 23 ++++++++++++++++++++++ .../tests/unittests/SchedulerUtilsTest.cpp | 8 +++++++- .../tests/unittests/TimeStatsTest.cpp | 7 +++++++ .../tests/unittests/TransactionApplicationTest.cpp | 7 +++++++ .../unittests/VSyncDispatchTimerQueueTest.cpp | 7 +++++++ .../tests/unittests/VSyncPredictorTest.cpp | 7 +++++++ .../mock/DisplayHardware/MockComposer.cpp | 7 +++++++ .../unittests/mock/MockSurfaceInterceptor.cpp | 7 +++++++ services/surfaceflinger/tests/vsync/vsync.cpp | 7 +++++++ 111 files changed, 815 insertions(+), 5 deletions(-) (limited to 'services/surfaceflinger/TransactionCompletedThread.cpp') diff --git a/libs/renderengine/tests/RenderEngineTest.cpp b/libs/renderengine/tests/RenderEngineTest.cpp index ba5a3f5550..7700b2e01f 100644 --- a/libs/renderengine/tests/RenderEngineTest.cpp +++ b/libs/renderengine/tests/RenderEngineTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -1339,3 +1343,6 @@ TEST_F(RenderEngineTest, drawLayers_fillShadow_translucentCasterWithAlpha) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Android.bp b/services/surfaceflinger/Android.bp index 4c5e5da36a..8fa35d83e7 100644 --- a/services/surfaceflinger/Android.bp +++ b/services/surfaceflinger/Android.bp @@ -7,6 +7,7 @@ cc_defaults { "-Wthread-safety", "-Wunused", "-Wunreachable-code", + "-Wconversion", ], } diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp index 3b1b796076..7845cab397 100644 --- a/services/surfaceflinger/BufferLayer.cpp +++ b/services/surfaceflinger/BufferLayer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + //#define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "BufferLayer" @@ -795,3 +799,6 @@ void BufferLayer::updateCloneBufferInfo() { #if defined(__gl2_h_) #error "don't include gl2/gl2.h in this file" #endif + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/BufferLayerConsumer.cpp b/services/surfaceflinger/BufferLayerConsumer.cpp index ea55795119..5e04d9597a 100644 --- a/services/surfaceflinger/BufferLayerConsumer.cpp +++ b/services/surfaceflinger/BufferLayerConsumer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "BufferLayerConsumer" #define ATRACE_TAG ATRACE_TAG_GRAPHICS @@ -519,3 +523,6 @@ BufferLayerConsumer::Image::~Image() { } } }; // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp index e4e4bc7db6..c1b87751a4 100644 --- a/services/surfaceflinger/BufferQueueLayer.cpp +++ b/services/surfaceflinger/BufferQueueLayer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "BufferQueueLayer" #define ATRACE_TAG ATRACE_TAG_GRAPHICS @@ -612,3 +616,6 @@ void BufferQueueLayer::ContentsChangedListener::abandon() { // ----------------------------------------------------------------------- } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp index 067aa46b71..c173c66b4e 100644 --- a/services/surfaceflinger/BufferStateLayer.cpp +++ b/services/surfaceflinger/BufferStateLayer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + //#define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "BufferStateLayer" @@ -681,3 +685,6 @@ sp BufferStateLayer::createClone() { return layer; } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Client.cpp b/services/surfaceflinger/Client.cpp index f3313645fa..fb72ab8065 100644 --- a/services/surfaceflinger/Client.cpp +++ b/services/surfaceflinger/Client.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -131,3 +135,6 @@ status_t Client::getLayerFrameStats(const sp& handle, FrameStats* outSt // --------------------------------------------------------------------------- }; // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/ColorLayer.cpp b/services/surfaceflinger/ColorLayer.cpp index 8bfa569eeb..6aea88abd6 100644 --- a/services/surfaceflinger/ColorLayer.cpp +++ b/services/surfaceflinger/ColorLayer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + // #define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "ColorLayer" @@ -116,3 +120,6 @@ sp ColorLayer::createClone() { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/mock/Display.cpp b/services/surfaceflinger/CompositionEngine/mock/Display.cpp index 01cf11278b..dc303d736f 100644 --- a/services/surfaceflinger/CompositionEngine/mock/Display.cpp +++ b/services/surfaceflinger/CompositionEngine/mock/Display.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include namespace android::compositionengine::mock { @@ -24,3 +28,6 @@ Display::Display() = default; Display::~Display() = default; } // namespace android::compositionengine::mock + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/mock/Layer.cpp b/services/surfaceflinger/CompositionEngine/mock/Layer.cpp index 08483cb301..a733bacee9 100644 --- a/services/surfaceflinger/CompositionEngine/mock/Layer.cpp +++ b/services/surfaceflinger/CompositionEngine/mock/Layer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include namespace android::compositionengine::mock { @@ -24,3 +28,6 @@ Layer::Layer() = default; Layer::~Layer() = default; } // namespace android::compositionengine::mock + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/mock/LayerFE.cpp b/services/surfaceflinger/CompositionEngine/mock/LayerFE.cpp index 607eaad826..232756f247 100644 --- a/services/surfaceflinger/CompositionEngine/mock/LayerFE.cpp +++ b/services/surfaceflinger/CompositionEngine/mock/LayerFE.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include namespace android::compositionengine::mock { @@ -24,3 +28,6 @@ LayerFE::LayerFE() = default; LayerFE::~LayerFE() = default; } // namespace android::compositionengine::mock + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/mock/Output.cpp b/services/surfaceflinger/CompositionEngine/mock/Output.cpp index 44df4c3da3..2608ef0cc0 100644 --- a/services/surfaceflinger/CompositionEngine/mock/Output.cpp +++ b/services/surfaceflinger/CompositionEngine/mock/Output.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include namespace android::compositionengine::mock { @@ -24,3 +28,6 @@ Output::Output() = default; Output::~Output() = default; } // namespace android::compositionengine::mock + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/mock/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/mock/OutputLayer.cpp index 4da9377123..c1153e3596 100644 --- a/services/surfaceflinger/CompositionEngine/mock/OutputLayer.cpp +++ b/services/surfaceflinger/CompositionEngine/mock/OutputLayer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include namespace android::compositionengine::mock { @@ -24,3 +28,6 @@ OutputLayer::OutputLayer() = default; OutputLayer::~OutputLayer() = default; } // namespace android::compositionengine::mock + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/src/CompositionEngine.cpp b/services/surfaceflinger/CompositionEngine/src/CompositionEngine.cpp index 5eabecd3ca..030c7039f7 100644 --- a/services/surfaceflinger/CompositionEngine/src/CompositionEngine.cpp +++ b/services/surfaceflinger/CompositionEngine/src/CompositionEngine.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -155,3 +159,6 @@ void CompositionEngine::updateLayerStateFromFE(CompositionRefreshArgs& args) { } // namespace impl } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/src/Display.cpp b/services/surfaceflinger/CompositionEngine/src/Display.cpp index e885629c4b..20f765c4a8 100644 --- a/services/surfaceflinger/CompositionEngine/src/Display.cpp +++ b/services/surfaceflinger/CompositionEngine/src/Display.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -337,3 +341,6 @@ void Display::finishFrame(const compositionengine::CompositionRefreshArgs& refre } } // namespace android::compositionengine::impl + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/src/HwcBufferCache.cpp b/services/surfaceflinger/CompositionEngine/src/HwcBufferCache.cpp index f72862be07..995a0ca71f 100644 --- a/services/surfaceflinger/CompositionEngine/src/HwcBufferCache.cpp +++ b/services/surfaceflinger/CompositionEngine/src/HwcBufferCache.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -48,3 +52,6 @@ void HwcBufferCache::getHwcBuffer(int slot, const sp& buffer, uin } } // namespace android::compositionengine::impl + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/src/Layer.cpp b/services/surfaceflinger/CompositionEngine/src/Layer.cpp index ecacaeee9c..22ecd33a2a 100644 --- a/services/surfaceflinger/CompositionEngine/src/Layer.cpp +++ b/services/surfaceflinger/CompositionEngine/src/Layer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -41,3 +45,6 @@ void Layer::dump(std::string& out) const { } // namespace impl } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/src/LayerFECompositionState.cpp b/services/surfaceflinger/CompositionEngine/src/LayerFECompositionState.cpp index e74052994a..085e83838e 100644 --- a/services/surfaceflinger/CompositionEngine/src/LayerFECompositionState.cpp +++ b/services/surfaceflinger/CompositionEngine/src/LayerFECompositionState.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -86,3 +90,6 @@ void LayerFECompositionState::dump(std::string& out) const { } } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp index 6e2816715f..01413b9478 100644 --- a/services/surfaceflinger/CompositionEngine/src/Output.cpp +++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -1058,3 +1062,6 @@ compositionengine::Output::FrameFences Output::presentAndGetFrameFences() { } // namespace impl } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp index 82d24222f1..ac66d8cbe3 100644 --- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp +++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -645,3 +649,6 @@ void OutputLayer::dump(std::string& out) const { } // namespace impl } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayerCompositionState.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayerCompositionState.cpp index cc3c54c8b1..20c8f9a112 100644 --- a/services/surfaceflinger/CompositionEngine/src/OutputLayerCompositionState.cpp +++ b/services/surfaceflinger/CompositionEngine/src/OutputLayerCompositionState.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -70,3 +74,6 @@ void OutputLayerCompositionState::dump(std::string& out) const { } } // namespace android::compositionengine::impl + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp b/services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp index 949feb4041..10512eb9e9 100644 --- a/services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp +++ b/services/surfaceflinger/CompositionEngine/src/RenderSurface.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include @@ -249,3 +253,6 @@ sp& RenderSurface::mutableGraphicBufferForTest() { } // namespace impl } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/tests/CompositionEngineTest.cpp b/services/surfaceflinger/CompositionEngine/tests/CompositionEngineTest.cpp index 989494d13f..ebcd0a0594 100644 --- a/services/surfaceflinger/CompositionEngine/tests/CompositionEngineTest.cpp +++ b/services/surfaceflinger/CompositionEngine/tests/CompositionEngineTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -298,3 +302,6 @@ TEST_F(CompositionTestPreComposition, } // namespace } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/tests/DisplayTest.cpp b/services/surfaceflinger/CompositionEngine/tests/DisplayTest.cpp index ae939693fa..0fe5843331 100644 --- a/services/surfaceflinger/CompositionEngine/tests/DisplayTest.cpp +++ b/services/surfaceflinger/CompositionEngine/tests/DisplayTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -833,3 +837,6 @@ TEST_F(DisplayFunctionalTest, postFramebufferCriticalCallsAreOrdered) { } // namespace } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/tests/LayerTest.cpp b/services/surfaceflinger/CompositionEngine/tests/LayerTest.cpp index 787f973215..44df2893d7 100644 --- a/services/surfaceflinger/CompositionEngine/tests/LayerTest.cpp +++ b/services/surfaceflinger/CompositionEngine/tests/LayerTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -59,3 +63,6 @@ TEST_F(LayerTest, canInstantiateLayer) {} } // namespace } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp index 0e579fa7e1..bd830be68c 100644 --- a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp +++ b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -1054,3 +1058,6 @@ TEST_F(OutputLayerTest, needsFilteringReturnsTrueIfDisplaySizeDifferentFromSourc } // namespace } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp index 80528e3cb9..24311c7e5b 100644 --- a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp +++ b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -3781,3 +3785,6 @@ TEST_F(GenerateClientCompositionRequestsTest_ThreeLayers, } // namespace } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/CompositionEngine/tests/RenderSurfaceTest.cpp b/services/surfaceflinger/CompositionEngine/tests/RenderSurfaceTest.cpp index fd47e453c8..4fba10bf66 100644 --- a/services/surfaceflinger/CompositionEngine/tests/RenderSurfaceTest.cpp +++ b/services/surfaceflinger/CompositionEngine/tests/RenderSurfaceTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -350,3 +354,6 @@ TEST_F(RenderSurfaceTest, flipForwardsSignal) { } // namespace } // namespace android::compositionengine + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/ContainerLayer.cpp b/services/surfaceflinger/ContainerLayer.cpp index ab664be5e2..841e79f8af 100644 --- a/services/surfaceflinger/ContainerLayer.cpp +++ b/services/surfaceflinger/ContainerLayer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + // #define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "ContainerLayer" @@ -39,3 +43,6 @@ sp ContainerLayer::createClone() { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index e0dc3e7751..e2122d1d30 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + // #define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "DisplayDevice" @@ -327,3 +331,6 @@ const HdrCapabilities& DisplayDevice::getHdrCapabilities() const { std::atomic DisplayDeviceState::sNextSequenceId(1); } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/DisplayHardware/ComposerHal.cpp b/services/surfaceflinger/DisplayHardware/ComposerHal.cpp index eb032f3fe8..6892dd8ed0 100644 --- a/services/surfaceflinger/DisplayHardware/ComposerHal.cpp +++ b/services/surfaceflinger/DisplayHardware/ComposerHal.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "HwcComposer" @@ -1622,3 +1626,6 @@ void CommandReader::takePresentOrValidateStage(Display display, uint32_t* state) } // namespace Hwc2 } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/DisplayHardware/DisplayIdentification.cpp b/services/surfaceflinger/DisplayHardware/DisplayIdentification.cpp index ba7818dd02..277081f230 100644 --- a/services/surfaceflinger/DisplayHardware/DisplayIdentification.cpp +++ b/services/surfaceflinger/DisplayHardware/DisplayIdentification.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "DisplayIdentification" @@ -204,3 +208,6 @@ DisplayId getVirtualDisplayId(uint32_t id) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp index 7370b0ccb2..36544b6653 100644 --- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp +++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp @@ -15,6 +15,10 @@ ** limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + // #define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "FramebufferSurface" @@ -193,3 +197,6 @@ const sp& FramebufferSurface::getClientTargetAcquireFence() const { // ---------------------------------------------------------------------------- }; // namespace android // ---------------------------------------------------------------------------- + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp index 12b0ddd26d..41e787980a 100644 --- a/services/surfaceflinger/DisplayHardware/HWC2.cpp +++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + // #define LOG_NDEBUG 0 #undef LOG_TAG @@ -977,3 +981,6 @@ Error Layer::setColorTransform(const android::mat4& matrix) { } // namespace impl } // namespace HWC2 + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index 1960f431a8..153cfe7f9d 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + // #define LOG_NDEBUG 0 #undef LOG_TAG @@ -948,3 +952,6 @@ uint32_t HWComposer::getMaxVirtualDisplayCount() const { } // namespace impl } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp index 56b0ea61e3..fba3261388 100644 --- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp +++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + // #define LOG_NDEBUG 0 #include "VirtualDisplaySurface.h" @@ -694,3 +698,6 @@ const char* VirtualDisplaySurface::dbgSourceStr(Source s) { // --------------------------------------------------------------------------- } // namespace android // --------------------------------------------------------------------------- + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Effects/Daltonizer.cpp b/services/surfaceflinger/Effects/Daltonizer.cpp index 01c9c0fc68..a7090c51f2 100644 --- a/services/surfaceflinger/Effects/Daltonizer.cpp +++ b/services/surfaceflinger/Effects/Daltonizer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "Daltonizer.h" #include @@ -171,3 +175,6 @@ void Daltonizer::update() { } } /* namespace android */ + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/EventLog/EventLog.cpp b/services/surfaceflinger/EventLog/EventLog.cpp index a532fc130f..3b609524e8 100644 --- a/services/surfaceflinger/EventLog/EventLog.cpp +++ b/services/surfaceflinger/EventLog/EventLog.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -124,3 +128,6 @@ void EventLog::TagBuffer::writeString(const std::string_view& value) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/FrameTracer/FrameTracer.cpp b/services/surfaceflinger/FrameTracer/FrameTracer.cpp index 441811646b..b986f3844a 100644 --- a/services/surfaceflinger/FrameTracer/FrameTracer.cpp +++ b/services/surfaceflinger/FrameTracer/FrameTracer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "FrameTracer" #define ATRACE_TAG ATRACE_TAG_GRAPHICS @@ -179,3 +183,6 @@ std::string FrameTracer::miniDump() { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/FrameTracker.cpp b/services/surfaceflinger/FrameTracker.cpp index a6e511e76e..8ad805b1d8 100644 --- a/services/surfaceflinger/FrameTracker.cpp +++ b/services/surfaceflinger/FrameTracker.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + // This is needed for stdint.h to define INT64_MAX in C++ #define __STDC_LIMIT_MACROS @@ -246,3 +250,6 @@ void FrameTracker::dumpStats(std::string& result) const { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 2593681b6b..b0c94a279e 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + //#define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "Layer" @@ -2304,3 +2308,6 @@ void Layer::addChildToDrawing(const sp& layer) { #if defined(__gl2_h_) #error "don't include gl2/gl2.h in this file" #endif + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/LayerProtoHelper.cpp b/services/surfaceflinger/LayerProtoHelper.cpp index b4022704d5..0fe1421926 100644 --- a/services/surfaceflinger/LayerProtoHelper.cpp +++ b/services/surfaceflinger/LayerProtoHelper.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "LayerProtoHelper.h" namespace android { @@ -165,3 +169,6 @@ void LayerProtoHelper::writeToProto(const mat4 matrix, ColorTransformProto* colo } // namespace surfaceflinger } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/LayerRejecter.cpp b/services/surfaceflinger/LayerRejecter.cpp index 412f9779c8..d3364a0929 100644 --- a/services/surfaceflinger/LayerRejecter.cpp +++ b/services/surfaceflinger/LayerRejecter.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "LayerRejecter.h" #include @@ -136,3 +140,6 @@ bool LayerRejecter::reject(const sp& buf, const BufferItem& item) } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/LayerVector.cpp b/services/surfaceflinger/LayerVector.cpp index 8271fd97ea..7c959b9e56 100644 --- a/services/surfaceflinger/LayerVector.cpp +++ b/services/surfaceflinger/LayerVector.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "LayerVector.h" #include "Layer.h" @@ -83,3 +87,6 @@ void LayerVector::traverseInReverseZOrder(StateSet stateSet, const Visitor& visi } } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/MonitoredProducer.cpp b/services/surfaceflinger/MonitoredProducer.cpp index 7a959f7b19..5009e10532 100644 --- a/services/surfaceflinger/MonitoredProducer.cpp +++ b/services/surfaceflinger/MonitoredProducer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "MonitoredProducer.h" #include "Layer.h" #include "SurfaceFlinger.h" @@ -168,3 +172,6 @@ sp MonitoredProducer::getLayer() const { // --------------------------------------------------------------------------- }; // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/RefreshRateOverlay.cpp b/services/surfaceflinger/RefreshRateOverlay.cpp index c69859e32a..33e5796e6f 100644 --- a/services/surfaceflinger/RefreshRateOverlay.cpp +++ b/services/surfaceflinger/RefreshRateOverlay.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "RefreshRateOverlay.h" #include "Client.h" #include "Layer.h" @@ -211,3 +215,6 @@ void RefreshRateOverlay::changeRefreshRate(const RefreshRate& refreshRate) { } }; // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp index 73de4f8b78..0031d70160 100644 --- a/services/surfaceflinger/RegionSamplingThread.cpp +++ b/services/surfaceflinger/RegionSamplingThread.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + //#define LOG_NDEBUG 0 #define ATRACE_TAG ATRACE_TAG_GRAPHICS #undef LOG_TAG @@ -472,3 +476,6 @@ void RegionSamplingThread::threadMain() NO_THREAD_SAFETY_ANALYSIS { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/RenderArea.cpp b/services/surfaceflinger/RenderArea.cpp index 93759e8ad7..9a6c8533ea 100644 --- a/services/surfaceflinger/RenderArea.cpp +++ b/services/surfaceflinger/RenderArea.cpp @@ -1,3 +1,23 @@ +/* + * Copyright 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "RenderArea.h" namespace android { @@ -13,3 +33,6 @@ float RenderArea::getCaptureFillValue(CaptureFill captureFill) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/DispSync.cpp b/services/surfaceflinger/Scheduler/DispSync.cpp index 4bdfad94eb..ca41608c1c 100644 --- a/services/surfaceflinger/Scheduler/DispSync.cpp +++ b/services/surfaceflinger/Scheduler/DispSync.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #define ATRACE_TAG ATRACE_TAG_GRAPHICS //#define LOG_NDEBUG 0 @@ -847,3 +851,6 @@ nsecs_t DispSync::expectedPresentTime() { } // namespace impl } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/DispSyncSource.cpp b/services/surfaceflinger/Scheduler/DispSyncSource.cpp index bd4b0ec0d1..776e98463f 100644 --- a/services/surfaceflinger/Scheduler/DispSyncSource.cpp +++ b/services/surfaceflinger/Scheduler/DispSyncSource.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include "DispSyncSource.h" @@ -104,3 +108,6 @@ void DispSyncSource::onDispSyncEvent(nsecs_t when) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/EventControlThread.cpp b/services/surfaceflinger/Scheduler/EventControlThread.cpp index 85a7f82a3c..7f9db9ca2d 100644 --- a/services/surfaceflinger/Scheduler/EventControlThread.cpp +++ b/services/surfaceflinger/Scheduler/EventControlThread.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -73,3 +77,6 @@ void EventControlThread::threadMain() NO_THREAD_SAFETY_ANALYSIS { } // namespace impl } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp index 5bdef5807f..14e3ec6ead 100644 --- a/services/surfaceflinger/Scheduler/EventThread.cpp +++ b/services/surfaceflinger/Scheduler/EventThread.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include @@ -517,3 +521,6 @@ const char* EventThread::toCString(State state) { } // namespace impl } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/LayerHistory.cpp b/services/surfaceflinger/Scheduler/LayerHistory.cpp index cf79d9fcf7..db16f8df1f 100644 --- a/services/surfaceflinger/Scheduler/LayerHistory.cpp +++ b/services/surfaceflinger/Scheduler/LayerHistory.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "LayerHistory" #define ATRACE_TAG ATRACE_TAG_GRAPHICS @@ -158,3 +162,6 @@ void LayerHistory::clear() { } } // namespace android::scheduler::impl + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/MessageQueue.cpp b/services/surfaceflinger/Scheduler/MessageQueue.cpp index 5318b00983..005d157fd5 100644 --- a/services/surfaceflinger/Scheduler/MessageQueue.cpp +++ b/services/surfaceflinger/Scheduler/MessageQueue.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -159,3 +163,6 @@ int MessageQueue::eventReceiver(int /*fd*/, int /*events*/) { } // namespace impl } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/PhaseOffsets.cpp b/services/surfaceflinger/Scheduler/PhaseOffsets.cpp index 13014c789b..106aa9bccb 100644 --- a/services/surfaceflinger/Scheduler/PhaseOffsets.cpp +++ b/services/surfaceflinger/Scheduler/PhaseOffsets.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "PhaseOffsets.h" #include @@ -330,3 +334,6 @@ void PhaseDurations::dump(std::string& result) const { } // namespace impl } // namespace android::scheduler + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp index 692ded928d..45d1f23029 100644 --- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + // #define LOG_NDEBUG 0 #include "RefreshRateConfigs.h" @@ -217,3 +221,5 @@ void RefreshRateConfigs::init(const std::vector& configs, } } // namespace android::scheduler +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp index 73dc753c7e..c96eba40fd 100644 --- a/services/surfaceflinger/Scheduler/Scheduler.cpp +++ b/services/surfaceflinger/Scheduler/Scheduler.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "Scheduler" #define ATRACE_TAG ATRACE_TAG_GRAPHICS @@ -595,3 +599,6 @@ void Scheduler::onDisplayRefreshed(nsecs_t timestamp) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/SchedulerUtils.cpp b/services/surfaceflinger/Scheduler/SchedulerUtils.cpp index fb5414fd4b..27120be272 100644 --- a/services/surfaceflinger/Scheduler/SchedulerUtils.cpp +++ b/services/surfaceflinger/Scheduler/SchedulerUtils.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "SchedulerUtils.h" #include @@ -36,3 +40,6 @@ int64_t calculate_median(std::vector* v) { } // namespace scheduler } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/VSyncModulator.cpp b/services/surfaceflinger/Scheduler/VSyncModulator.cpp index 8de35b1c2f..40a992cf01 100644 --- a/services/surfaceflinger/Scheduler/VSyncModulator.cpp +++ b/services/surfaceflinger/Scheduler/VSyncModulator.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include "VSyncModulator.h" @@ -144,3 +148,6 @@ void VSyncModulator::updateOffsetsLocked() { } } // namespace android::scheduler + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp index 3b99a58838..915419154f 100644 --- a/services/surfaceflinger/Scheduler/VSyncPredictor.cpp +++ b/services/surfaceflinger/Scheduler/VSyncPredictor.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #define ATRACE_TAG ATRACE_TAG_GRAPHICS //#define LOG_NDEBUG 0 #include "VSyncPredictor.h" @@ -224,3 +228,6 @@ bool VSyncPredictor::needsMoreSamples(nsecs_t now) const { } } // namespace android::scheduler + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index b7a2c760e6..3dcf7d1665 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + //#define LOG_NDEBUG 0 #define ATRACE_TAG ATRACE_TAG_GRAPHICS @@ -5772,3 +5776,6 @@ status_t SurfaceFlinger::setGlobalShadowSettings(const half4& ambientColor, cons #if defined(__gl2_h_) #error "don't include gl2/gl2.h in this file" #endif + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/SurfaceFlingerDefaultFactory.cpp b/services/surfaceflinger/SurfaceFlingerDefaultFactory.cpp index d5c2306e1f..e12d31a99a 100644 --- a/services/surfaceflinger/SurfaceFlingerDefaultFactory.cpp +++ b/services/surfaceflinger/SurfaceFlingerDefaultFactory.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -138,3 +142,6 @@ sp DefaultFactory::createColorLayer(const LayerCreationArgs& args) { } } // namespace android::surfaceflinger + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/SurfaceFlingerFactory.cpp b/services/surfaceflinger/SurfaceFlingerFactory.cpp index 9b1f658661..3997b04f5f 100644 --- a/services/surfaceflinger/SurfaceFlingerFactory.cpp +++ b/services/surfaceflinger/SurfaceFlingerFactory.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "SurfaceFlinger.h" #include "SurfaceFlingerDefaultFactory.h" @@ -26,3 +30,6 @@ sp createSurfaceFlinger() { } } // namespace android::surfaceflinger + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/SurfaceInterceptor.cpp b/services/surfaceflinger/SurfaceInterceptor.cpp index 8e0462ab52..79123f979b 100644 --- a/services/surfaceflinger/SurfaceInterceptor.cpp +++ b/services/surfaceflinger/SurfaceInterceptor.cpp @@ -13,6 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" #undef LOG_TAG #define LOG_TAG "SurfaceInterceptor" #define ATRACE_TAG ATRACE_TAG_GRAPHICS @@ -677,3 +681,6 @@ void SurfaceInterceptor::savePowerModeUpdate(int32_t sequenceId, int32_t mode) { } // namespace impl } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/SurfaceTracing.cpp b/services/surfaceflinger/SurfaceTracing.cpp index eb26cd0379..6fd4e46c73 100644 --- a/services/surfaceflinger/SurfaceTracing.cpp +++ b/services/surfaceflinger/SurfaceTracing.cpp @@ -13,6 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" #undef LOG_TAG #define LOG_TAG "SurfaceTracing" #define ATRACE_TAG ATRACE_TAG_GRAPHICS @@ -202,3 +206,6 @@ void SurfaceTracing::dump(std::string& result) const { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/TimeStats/TimeStats.cpp b/services/surfaceflinger/TimeStats/TimeStats.cpp index a5fabf2c16..0939fa4f9b 100644 --- a/services/surfaceflinger/TimeStats/TimeStats.cpp +++ b/services/surfaceflinger/TimeStats/TimeStats.cpp @@ -13,6 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" #undef LOG_TAG #define LOG_TAG "TimeStats" #define ATRACE_TAG ATRACE_TAG_GRAPHICS @@ -657,3 +661,6 @@ void TimeStats::dump(bool asProto, std::optional maxLayers, std::strin } // namespace impl } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index 1475889cd9..daa67ae043 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + //#define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "TransactionCompletedThread" @@ -355,3 +359,6 @@ CallbackHandle::CallbackHandle(const sp& transactionListener, : listener(transactionListener), callbackIds(ids), surfaceControl(sc) {} } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/main_surfaceflinger.cpp b/services/surfaceflinger/main_surfaceflinger.cpp index e7986d3344..d7ad9deb03 100644 --- a/services/surfaceflinger/main_surfaceflinger.cpp +++ b/services/surfaceflinger/main_surfaceflinger.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -121,3 +125,6 @@ int main(int, char**) { return 0; } + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/BufferGenerator.cpp b/services/surfaceflinger/tests/BufferGenerator.cpp index 8ddda60cd2..293738cfcb 100644 --- a/services/surfaceflinger/tests/BufferGenerator.cpp +++ b/services/surfaceflinger/tests/BufferGenerator.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -379,3 +383,6 @@ void BufferGenerator::setBuffer(const sp& buffer, int32_t fence, } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/Credentials_test.cpp b/services/surfaceflinger/tests/Credentials_test.cpp index f6188738b2..a7c095d327 100644 --- a/services/surfaceflinger/tests/Credentials_test.cpp +++ b/services/surfaceflinger/tests/Credentials_test.cpp @@ -31,6 +31,10 @@ const float FRAME_SCALE = 1.0f; * Methods like EnableVsyncInjections and InjectVsync are not tested since they do not * return anything meaningful. */ + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" class CredentialsTest : public ::testing::Test { protected: void SetUp() override { @@ -362,3 +366,6 @@ TEST_F(CredentialsTest, GetActiveColorModeBasicCorrectness) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/DereferenceSurfaceControl_test.cpp b/services/surfaceflinger/tests/DereferenceSurfaceControl_test.cpp index 0cef0d1c87..46b98f9193 100644 --- a/services/surfaceflinger/tests/DereferenceSurfaceControl_test.cpp +++ b/services/surfaceflinger/tests/DereferenceSurfaceControl_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "LayerTransactionTest.h" namespace android { @@ -67,3 +71,6 @@ TEST_F(DereferenceSurfaceControlTest, LayerInTransaction) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/DisplayConfigs_test.cpp b/services/surfaceflinger/tests/DisplayConfigs_test.cpp index d51b9a146f..3aa4474b6b 100644 --- a/services/surfaceflinger/tests/DisplayConfigs_test.cpp +++ b/services/surfaceflinger/tests/DisplayConfigs_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include "LayerTransactionTest.h" namespace android { @@ -68,3 +72,6 @@ TEST_F(RefreshRateRangeTest, setAllConfigs) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" \ No newline at end of file diff --git a/services/surfaceflinger/tests/LayerCallback_test.cpp b/services/surfaceflinger/tests/LayerCallback_test.cpp index 7a5ed484d1..6d28e621ac 100644 --- a/services/surfaceflinger/tests/LayerCallback_test.cpp +++ b/services/surfaceflinger/tests/LayerCallback_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "LayerTransactionTest.h" #include "utils/CallbackUtils.h" @@ -870,3 +874,6 @@ TEST_F(LayerCallbackTest, DesiredPresentTime_Past) { EXPECT_NO_FATAL_FAILURE(waitForCallback(callback, expected, true)); } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp b/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp index 92698f0142..24874b010b 100644 --- a/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp +++ b/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -1841,3 +1845,6 @@ TEST_P(LayerRenderTypeTransactionTest, SetColorTransformOnChildAndParent) { } } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/LayerTransaction_test.cpp b/services/surfaceflinger/tests/LayerTransaction_test.cpp index 7816c667bb..97cba63192 100644 --- a/services/surfaceflinger/tests/LayerTransaction_test.cpp +++ b/services/surfaceflinger/tests/LayerTransaction_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include "LayerTransactionTest.h" @@ -190,3 +194,6 @@ TEST_F(LayerTransactionTest, DISABLED_BufferQueueLayerMergeDamageRegionWhenDropp ASSERT_EQ(OK, producer->disconnect(NATIVE_WINDOW_API_CPU)); } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp b/services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp index daeff17ea3..71f01b0c1d 100644 --- a/services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp +++ b/services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include "TransactionTestHarnesses.h" @@ -267,3 +271,6 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetLayerStackBasic) { } } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp b/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp index 42ec34a129..7e9202bb82 100644 --- a/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp +++ b/services/surfaceflinger/tests/LayerTypeTransaction_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include "TransactionTestHarnesses.h" @@ -186,3 +190,6 @@ TEST_P(LayerTypeTransactionTest, RefreshRateIsInitialized) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/LayerUpdate_test.cpp b/services/surfaceflinger/tests/LayerUpdate_test.cpp index 0ad122b5ed..0459386936 100644 --- a/services/surfaceflinger/tests/LayerUpdate_test.cpp +++ b/services/surfaceflinger/tests/LayerUpdate_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "LayerTransactionTest.h" namespace android { @@ -1708,3 +1712,6 @@ TEST_F(ScreenCaptureTest, CaptureInvalidLayer) { ASSERT_EQ(NAME_NOT_FOUND, sf->captureLayers(redLayerHandle, &outBuffer, Rect::EMPTY_RECT, 1.0)); } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/MirrorLayer_test.cpp b/services/surfaceflinger/tests/MirrorLayer_test.cpp index 0bcac1a880..b49bd54599 100644 --- a/services/surfaceflinger/tests/MirrorLayer_test.cpp +++ b/services/surfaceflinger/tests/MirrorLayer_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "LayerTransactionTest.h" namespace android { @@ -224,3 +228,6 @@ TEST_F(MirrorLayerTest, MirrorBufferLayer) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp b/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp index 066c9aa3ce..e525e2af9b 100644 --- a/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp +++ b/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "LayerTransactionTest.h" namespace android { @@ -122,3 +126,6 @@ TEST_F(MultiDisplayLayerBoundsTest, RenderLayerInMirroredVirtualDisplay) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/RelativeZ_test.cpp b/services/surfaceflinger/tests/RelativeZ_test.cpp index 8c56d27e8a..1180cacf7f 100644 --- a/services/surfaceflinger/tests/RelativeZ_test.cpp +++ b/services/surfaceflinger/tests/RelativeZ_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "LayerTransactionTest.h" namespace android { @@ -204,3 +208,6 @@ TEST_F(RelativeZTest, LayerAndRelativeRemoved) { } } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/SetGeometry_test.cpp b/services/surfaceflinger/tests/SetGeometry_test.cpp index dca06ec8d4..5fe2513bb3 100644 --- a/services/surfaceflinger/tests/SetGeometry_test.cpp +++ b/services/surfaceflinger/tests/SetGeometry_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "LayerTransactionTest.h" namespace android { @@ -97,3 +101,6 @@ TEST_F(SetGeometryTest, Scale) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/Stress_test.cpp b/services/surfaceflinger/tests/Stress_test.cpp index ee857b01f2..e9b6ba0f64 100644 --- a/services/surfaceflinger/tests/Stress_test.cpp +++ b/services/surfaceflinger/tests/Stress_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -107,3 +111,6 @@ TEST(LayerProtoStress, mem_info) { } } + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp b/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp index 1fa426d14e..75d0761907 100644 --- a/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp +++ b/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -1011,3 +1015,6 @@ TEST_F(SurfaceInterceptorTest, InterceptSimultaneousUpdatesWorks) { ASSERT_TRUE(singleIncrementFound(capturedTrace, Increment::IncrementCase::kSurfaceCreation)); } } + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/fakehwc/FakeComposerClient.cpp b/services/surfaceflinger/tests/fakehwc/FakeComposerClient.cpp index 0c370a6fdb..5824e589d1 100644 --- a/services/surfaceflinger/tests/fakehwc/FakeComposerClient.cpp +++ b/services/surfaceflinger/tests/fakehwc/FakeComposerClient.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + //#define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "FakeComposer" @@ -896,3 +900,6 @@ Layer FakeComposerClient::getLayer(size_t index) const { // this might get more involving. return static_cast(index); } + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/fakehwc/FakeComposerService.cpp b/services/surfaceflinger/tests/fakehwc/FakeComposerService.cpp index f727bc4079..c656eed0fb 100644 --- a/services/surfaceflinger/tests/fakehwc/FakeComposerService.cpp +++ b/services/surfaceflinger/tests/fakehwc/FakeComposerService.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "FakeHwcService" @@ -170,3 +174,6 @@ Return FakeComposerService_2_4::createClient_2_4(createClient_2_4_cb hidl_ } } // namespace sftest + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/fakehwc/FakeComposerUtils.cpp b/services/surfaceflinger/tests/fakehwc/FakeComposerUtils.cpp index 4d2146810b..2f89696e8e 100644 --- a/services/surfaceflinger/tests/fakehwc/FakeComposerUtils.cpp +++ b/services/surfaceflinger/tests/fakehwc/FakeComposerUtils.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "FakeHwcUtil" @@ -183,3 +187,6 @@ void FakeHwcEnvironment::TearDown() { } } // namespace sftest + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp b/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp index 09fdbdf114..18572064b6 100644 --- a/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp +++ b/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + // #define LOG_NDEBUG 0 #undef LOG_TAG #define LOG_TAG "FakeHwcTest" @@ -1970,3 +1974,6 @@ int main(int argc, char** argv) { ::testing::InitGoogleMock(&argc, argv); return RUN_ALL_TESTS(); } + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/hwc2/Hwc2Test.cpp b/services/surfaceflinger/tests/hwc2/Hwc2Test.cpp index 13774b4ed3..f9a1fe9a73 100644 --- a/services/surfaceflinger/tests/hwc2/Hwc2Test.cpp +++ b/services/surfaceflinger/tests/hwc2/Hwc2Test.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -4770,3 +4774,6 @@ TEST_F(Hwc2Test, PRESENT_VIRTUAL_DISPLAY_default_5) ASSERT_NO_FATAL_FAILURE(createAndPresentVirtualDisplay(layerCnt, coverage, virtualDisplayExceptions)); } + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/hwc2/Hwc2TestBuffer.cpp b/services/surfaceflinger/tests/hwc2/Hwc2TestBuffer.cpp index 648456295d..fcd0d31078 100644 --- a/services/surfaceflinger/tests/hwc2/Hwc2TestBuffer.cpp +++ b/services/surfaceflinger/tests/hwc2/Hwc2TestBuffer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -789,3 +793,6 @@ int Hwc2TestOutputBuffer::getOutputBuffer(buffer_handle_t* outHandle, return 0; } + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/hwc2/Hwc2TestLayers.cpp b/services/surfaceflinger/tests/hwc2/Hwc2TestLayers.cpp index 90127a1302..b76ace8752 100644 --- a/services/surfaceflinger/tests/hwc2/Hwc2TestLayers.cpp +++ b/services/surfaceflinger/tests/hwc2/Hwc2TestLayers.cpp @@ -13,6 +13,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -279,3 +283,6 @@ bool Hwc2TestLayers::setVisibleRegions() return optimized; } + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/hwc2/Hwc2TestPixelComparator.cpp b/services/surfaceflinger/tests/hwc2/Hwc2TestPixelComparator.cpp index 904b927abf..8ca88150e9 100644 --- a/services/surfaceflinger/tests/hwc2/Hwc2TestPixelComparator.cpp +++ b/services/surfaceflinger/tests/hwc2/Hwc2TestPixelComparator.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include @@ -111,3 +115,6 @@ std::string ComparatorResult::dumpComparison() const } return stream.str(); } + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.cpp b/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.cpp index c5b92d0664..1efb21e639 100644 --- a/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.cpp +++ b/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -780,3 +784,6 @@ const std::array Hwc2TestSurfaceDamage::mCompositionSupport = {{ const std::array Hwc2TestTransform::mCompositionSupport = {{ false, true, true, false, true, true, }}; + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/CachingTest.cpp b/services/surfaceflinger/tests/unittests/CachingTest.cpp index 74ce540626..1b8c76d1b9 100644 --- a/services/surfaceflinger/tests/unittests/CachingTest.cpp +++ b/services/surfaceflinger/tests/unittests/CachingTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "CachingTest" @@ -91,3 +95,6 @@ TEST_F(SlotGenerationTest, getHwcCacheSlot_Reuse) { } } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/CompositionTest.cpp b/services/surfaceflinger/tests/unittests/CompositionTest.cpp index cce21ceddb..8a762d4030 100644 --- a/services/surfaceflinger/tests/unittests/CompositionTest.cpp +++ b/services/surfaceflinger/tests/unittests/CompositionTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "CompositionTest" @@ -1423,3 +1427,6 @@ TEST_F(CompositionTest, DebugOptionForcingClientCompositionOfBufferLayerWithDirt } // namespace } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp index 55c3ab8b22..33563eaed6 100644 --- a/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp +++ b/services/surfaceflinger/tests/unittests/DisplayTransactionTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "LibSurfaceFlingerUnittests" @@ -3239,3 +3243,6 @@ TEST_F(SetPowerModeInternalTest, transitionsDisplayFromOnToUnknownExternalDispla } // namespace } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/FrameTracerTest.cpp b/services/surfaceflinger/tests/unittests/FrameTracerTest.cpp index c334bcf85d..68cb52fe87 100644 --- a/services/surfaceflinger/tests/unittests/FrameTracerTest.cpp +++ b/services/surfaceflinger/tests/unittests/FrameTracerTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "LibSurfaceFlingerUnittests" @@ -394,3 +398,6 @@ TEST_F(FrameTracerTest, traceFenceWithValidStartTime_ShouldHaveCorrectDuration) } // namespace } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp b/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp index f055fe72ac..c9af057ae5 100644 --- a/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp +++ b/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp @@ -1,3 +1,23 @@ +/* + * Copyright 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "LayerHistoryTest" @@ -241,3 +261,6 @@ TEST_F(LayerHistoryTest, multipleLayers) { } // namespace } // namespace android::scheduler + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/PhaseOffsetsTest.cpp b/services/surfaceflinger/tests/unittests/PhaseOffsetsTest.cpp index 6360ec14cd..910e73baf2 100644 --- a/services/surfaceflinger/tests/unittests/PhaseOffsetsTest.cpp +++ b/services/surfaceflinger/tests/unittests/PhaseOffsetsTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "SchedulerUnittests" @@ -124,3 +128,6 @@ TEST_F(PhaseOffsetsTest, getOffsetsForRefreshRate_DefaultOffsets) { } // namespace } // namespace scheduler } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" \ No newline at end of file diff --git a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp index cc3c985aa1..86aa8fb22b 100644 --- a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +++ b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp @@ -242,11 +242,11 @@ TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_getRefreshRateForContent) { TEST_F(RefreshRateConfigsTest, testInPolicy) { RefreshRate expectedDefaultConfig = {HWC_CONFIG_ID_60, VSYNC_60_POINT_4, HWC_GROUP_ID_0, "60fps", 60}; - ASSERT_TRUE(expectedDefaultConfig.inPolicy(60.000004, 60.000004)); + ASSERT_TRUE(expectedDefaultConfig.inPolicy(60.000004f, 60.000004f)); ASSERT_TRUE(expectedDefaultConfig.inPolicy(59.0f, 60.1f)); - ASSERT_FALSE(expectedDefaultConfig.inPolicy(75.0, 90.0)); - ASSERT_FALSE(expectedDefaultConfig.inPolicy(60.0011, 90.0)); - ASSERT_FALSE(expectedDefaultConfig.inPolicy(50.0, 59.998)); + ASSERT_FALSE(expectedDefaultConfig.inPolicy(75.0f, 90.0f)); + ASSERT_FALSE(expectedDefaultConfig.inPolicy(60.0011f, 90.0f)); + ASSERT_FALSE(expectedDefaultConfig.inPolicy(50.0f, 59.998f)); } } // namespace diff --git a/services/surfaceflinger/tests/unittests/RefreshRateStatsTest.cpp b/services/surfaceflinger/tests/unittests/RefreshRateStatsTest.cpp index ef4699f628..8e07c79656 100644 --- a/services/surfaceflinger/tests/unittests/RefreshRateStatsTest.cpp +++ b/services/surfaceflinger/tests/unittests/RefreshRateStatsTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "SchedulerUnittests" @@ -195,3 +199,6 @@ TEST_F(RefreshRateStatsTest, twoConfigsTest) { } // namespace } // namespace scheduler } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/RegionSamplingTest.cpp b/services/surfaceflinger/tests/unittests/RegionSamplingTest.cpp index d8de804ad8..f19e55409c 100644 --- a/services/surfaceflinger/tests/unittests/RegionSamplingTest.cpp +++ b/services/surfaceflinger/tests/unittests/RegionSamplingTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "RegionSamplingTest" @@ -137,3 +141,6 @@ TEST_F(RegionSamplingTest, orientation_90) { } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp index 40536abc5d..b1ecf4da6e 100644 --- a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp +++ b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp @@ -1,3 +1,23 @@ +/* + * Copyright 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "SchedulerUnittests" @@ -144,3 +164,6 @@ TEST_F(SchedulerTest, validConnectionHandle) { } // namespace } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/SchedulerUtilsTest.cpp b/services/surfaceflinger/tests/unittests/SchedulerUtilsTest.cpp index 5865579641..5f6a7150d6 100644 --- a/services/surfaceflinger/tests/unittests/SchedulerUtilsTest.cpp +++ b/services/surfaceflinger/tests/unittests/SchedulerUtilsTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "SchedulerUnittests" @@ -128,4 +132,6 @@ TEST_F(SchedulerUtilsTest, calculate_mode) { } // namespace } // namespace scheduler -} // namespace android \ No newline at end of file +} // namespace android +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/TimeStatsTest.cpp b/services/surfaceflinger/tests/unittests/TimeStatsTest.cpp index 3e808c0abb..bcf3ba8856 100644 --- a/services/surfaceflinger/tests/unittests/TimeStatsTest.cpp +++ b/services/surfaceflinger/tests/unittests/TimeStatsTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "LibSurfaceFlingerUnittests" @@ -656,3 +660,6 @@ TEST_F(TimeStatsTest, canSurviveMonkey) { } // namespace } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp b/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp index 994a509e4f..f1739e5e8a 100644 --- a/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp +++ b/services/surfaceflinger/tests/unittests/TransactionApplicationTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "CompositionTest" @@ -321,3 +325,6 @@ TEST_F(TransactionApplicationTest, FromHandle) { EXPECT_EQ(nullptr, ret.get()); } } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/VSyncDispatchTimerQueueTest.cpp b/services/surfaceflinger/tests/unittests/VSyncDispatchTimerQueueTest.cpp index 5aff4296f9..82919abe03 100644 --- a/services/surfaceflinger/tests/unittests/VSyncDispatchTimerQueueTest.cpp +++ b/services/surfaceflinger/tests/unittests/VSyncDispatchTimerQueueTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "LibSurfaceFlingerUnittests" #define LOG_NDEBUG 0 @@ -803,3 +807,6 @@ TEST_F(VSyncDispatchTimerQueueEntryTest, reportsScheduledIfStillTime) { } } // namespace android::scheduler + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/VSyncPredictorTest.cpp b/services/surfaceflinger/tests/unittests/VSyncPredictorTest.cpp index 4cb6a38217..00d3cc6e0b 100644 --- a/services/surfaceflinger/tests/unittests/VSyncPredictorTest.cpp +++ b/services/surfaceflinger/tests/unittests/VSyncPredictorTest.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #undef LOG_TAG #define LOG_TAG "LibSurfaceFlingerUnittests" #define LOG_NDEBUG 0 @@ -352,3 +356,6 @@ TEST_F(VSyncPredictorTest, doesNotPredictBeforeTimePointWithHigherIntercept) { } } // namespace android::scheduler + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.cpp b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.cpp index 7ed57b9d96..0780af1f26 100644 --- a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.cpp +++ b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "mock/DisplayHardware/MockComposer.h" namespace android { @@ -27,3 +31,6 @@ Composer::~Composer() = default; } // namespace mock } // namespace Hwc2 } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/unittests/mock/MockSurfaceInterceptor.cpp b/services/surfaceflinger/tests/unittests/mock/MockSurfaceInterceptor.cpp index 4129328ba9..7e925b94ee 100644 --- a/services/surfaceflinger/tests/unittests/mock/MockSurfaceInterceptor.cpp +++ b/services/surfaceflinger/tests/unittests/mock/MockSurfaceInterceptor.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include "mock/MockSurfaceInterceptor.h" namespace android { @@ -25,3 +29,6 @@ SurfaceInterceptor::~SurfaceInterceptor() = default; } // namespace mock } // namespace android + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" diff --git a/services/surfaceflinger/tests/vsync/vsync.cpp b/services/surfaceflinger/tests/vsync/vsync.cpp index a1b45e6adb..667dfb92d5 100644 --- a/services/surfaceflinger/tests/vsync/vsync.cpp +++ b/services/surfaceflinger/tests/vsync/vsync.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" + #include #include #include @@ -82,3 +86,6 @@ int main(int /*argc*/, char** /*argv*/) return 0; } + +// TODO(b/129481165): remove the #pragma below and fix conversion issues +#pragma clang diagnostic pop // ignored "-Wconversion" -- cgit v1.2.3-59-g8ed1b From 871d635736f502e67e6b41a162d4c77826cf6523 Mon Sep 17 00:00:00 2001 From: Valerie Hau Date: Wed, 29 Jan 2020 08:44:02 -0800 Subject: Plumb FrameEventHistory to client Bug: 141939081 Test: build, boot, libgui_test, SurfaceFlinger_test Change-Id: I7294c5357bc28cf0336eef583264c5d0544ec7d4 --- libs/gui/BLASTBufferQueue.cpp | 88 +++++++++++++++++++++- libs/gui/ITransactionCompletedListener.cpp | 70 +++++++++++++++++ libs/gui/SurfaceComposerClient.cpp | 18 ++++- libs/gui/include/gui/BLASTBufferQueue.h | 31 +++++++- libs/gui/include/gui/FrameTimestamps.h | 1 - .../include/gui/ITransactionCompletedListener.h | 28 ++++++- libs/gui/include/gui/LayerState.h | 1 + libs/gui/include/gui/SurfaceComposerClient.h | 18 ++++- libs/gui/tests/BLASTBufferQueue_test.cpp | 76 +++++++++++++++++++ services/surfaceflinger/BufferStateLayer.cpp | 28 +++++-- services/surfaceflinger/BufferStateLayer.h | 6 ++ services/surfaceflinger/Layer.h | 6 ++ services/surfaceflinger/SurfaceFlinger.cpp | 7 +- .../surfaceflinger/TransactionCompletedThread.cpp | 6 +- .../surfaceflinger/TransactionCompletedThread.h | 5 ++ .../surfaceflinger/tests/utils/CallbackUtils.h | 6 +- 16 files changed, 371 insertions(+), 24 deletions(-) (limited to 'services/surfaceflinger/TransactionCompletedThread.cpp') diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index 4e62da79ea..e2f5d31d00 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -31,6 +31,68 @@ using namespace std::chrono_literals; namespace android { +void BLASTBufferItemConsumer::onDisconnect() { + Mutex::Autolock lock(mFrameEventHistoryMutex); + mPreviouslyConnected = mCurrentlyConnected; + mCurrentlyConnected = false; + if (mPreviouslyConnected) { + mDisconnectEvents.push(mCurrentFrameNumber); + } + mFrameEventHistory.onDisconnect(); +} + +void BLASTBufferItemConsumer::addAndGetFrameTimestamps(const NewFrameEventsEntry* newTimestamps, + FrameEventHistoryDelta* outDelta) { + Mutex::Autolock lock(mFrameEventHistoryMutex); + if (newTimestamps) { + // BufferQueueProducer only adds a new timestamp on + // queueBuffer + mCurrentFrameNumber = newTimestamps->frameNumber; + mFrameEventHistory.addQueue(*newTimestamps); + } + if (outDelta) { + // frame event histories will be processed + // only after the producer connects and requests + // deltas for the first time. Forward this intent + // to SF-side to turn event processing back on + mPreviouslyConnected = mCurrentlyConnected; + mCurrentlyConnected = true; + mFrameEventHistory.getAndResetDelta(outDelta); + } +} + +void BLASTBufferItemConsumer::updateFrameTimestamps(uint64_t frameNumber, nsecs_t refreshStartTime, + const sp& glDoneFence, + const sp& presentFence, + const sp& prevReleaseFence, + CompositorTiming compositorTiming, + nsecs_t latchTime, nsecs_t dequeueReadyTime) { + Mutex::Autolock lock(mFrameEventHistoryMutex); + + // if the producer is not connected, don't bother updating, + // the next producer that connects won't access this frame event + if (!mCurrentlyConnected) return; + std::shared_ptr glDoneFenceTime = std::make_shared(glDoneFence); + std::shared_ptr presentFenceTime = std::make_shared(presentFence); + std::shared_ptr releaseFenceTime = std::make_shared(prevReleaseFence); + + mFrameEventHistory.addLatch(frameNumber, latchTime); + mFrameEventHistory.addRelease(frameNumber, dequeueReadyTime, std::move(releaseFenceTime)); + mFrameEventHistory.addPreComposition(frameNumber, refreshStartTime); + mFrameEventHistory.addPostComposition(frameNumber, glDoneFenceTime, presentFenceTime, + compositorTiming); +} + +void BLASTBufferItemConsumer::getConnectionEvents(uint64_t frameNumber, bool* needsDisconnect) { + bool disconnect = false; + Mutex::Autolock lock(mFrameEventHistoryMutex); + while (!mDisconnectEvents.empty() && mDisconnectEvents.front() <= frameNumber) { + disconnect = true; + mDisconnectEvents.pop(); + } + if (needsDisconnect != nullptr) *needsDisconnect = disconnect; +} + BLASTBufferQueue::BLASTBufferQueue(const sp& surface, int width, int height) : mSurfaceControl(surface), mWidth(width), @@ -39,7 +101,7 @@ BLASTBufferQueue::BLASTBufferQueue(const sp& surface, int width, BufferQueue::createBufferQueue(&mProducer, &mConsumer); mConsumer->setMaxAcquiredBufferCount(MAX_ACQUIRED_BUFFERS); mBufferItemConsumer = - new BufferItemConsumer(mConsumer, AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER, 1, true); + new BLASTBufferItemConsumer(mConsumer, AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER, 1, true); static int32_t id = 0; auto name = std::string("BLAST Consumer") + std::to_string(id); id++; @@ -79,11 +141,21 @@ void BLASTBufferQueue::transactionCallback(nsecs_t /*latchTime*/, const spsetTransformHint(mTransformHint); + mBufferItemConsumer->updateFrameTimestamps(stats[0].frameEventStats.frameNumber, + stats[0].frameEventStats.refreshStartTime, + stats[0].frameEventStats.gpuCompositionDoneFence, + stats[0].presentFence, + stats[0].previousReleaseFence, + stats[0].frameEventStats.compositorTiming, + stats[0].latchTime, + stats[0].frameEventStats.dequeueReadyTime); + } if (mPendingReleaseItem.item.mGraphicBuffer != nullptr) { - if (stats.size() > 0) { + if (!stats.empty()) { mPendingReleaseItem.releaseFence = stats[0].previousReleaseFence; - mTransformHint = stats[0].transformHint; - mBufferItemConsumer->setTransformHint(mTransformHint); } else { ALOGE("Warning: no SurfaceControlStats returned in BLASTBufferQueue callback"); mPendingReleaseItem.releaseFence = nullptr; @@ -144,6 +216,14 @@ void BLASTBufferQueue::processNextBufferLocked() { mNumAcquired++; mSubmitted.push(bufferItem); + bool needsDisconnect = false; + mBufferItemConsumer->getConnectionEvents(bufferItem.mFrameNumber, &needsDisconnect); + + // if producer disconnected before, notify SurfaceFlinger + if (needsDisconnect) { + t->notifyProducerDisconnect(mSurfaceControl); + } + // Ensure BLASTBufferQueue stays alive until we receive the transaction complete callback. incStrong((void*)transactionCallbackThunk); diff --git a/libs/gui/ITransactionCompletedListener.cpp b/libs/gui/ITransactionCompletedListener.cpp index e5e25aa50f..69f7894d07 100644 --- a/libs/gui/ITransactionCompletedListener.cpp +++ b/libs/gui/ITransactionCompletedListener.cpp @@ -30,6 +30,66 @@ enum class Tag : uint32_t { } // Anonymous namespace +status_t FrameEventHistoryStats::writeToParcel(Parcel* output) const { + status_t err = output->writeUint64(frameNumber); + if (err != NO_ERROR) return err; + + if (gpuCompositionDoneFence) { + err = output->writeBool(true); + if (err != NO_ERROR) return err; + + err = output->write(*gpuCompositionDoneFence); + } else { + err = output->writeBool(false); + } + if (err != NO_ERROR) return err; + + err = output->writeInt64(compositorTiming.deadline); + if (err != NO_ERROR) return err; + + err = output->writeInt64(compositorTiming.interval); + if (err != NO_ERROR) return err; + + err = output->writeInt64(compositorTiming.presentLatency); + if (err != NO_ERROR) return err; + + err = output->writeInt64(refreshStartTime); + if (err != NO_ERROR) return err; + + err = output->writeInt64(dequeueReadyTime); + return err; +} + +status_t FrameEventHistoryStats::readFromParcel(const Parcel* input) { + status_t err = input->readUint64(&frameNumber); + if (err != NO_ERROR) return err; + + bool hasFence = false; + err = input->readBool(&hasFence); + if (err != NO_ERROR) return err; + + if (hasFence) { + gpuCompositionDoneFence = new Fence(); + err = input->read(*gpuCompositionDoneFence); + if (err != NO_ERROR) return err; + } + + err = input->readInt64(&(compositorTiming.deadline)); + if (err != NO_ERROR) return err; + + err = input->readInt64(&(compositorTiming.interval)); + if (err != NO_ERROR) return err; + + err = input->readInt64(&(compositorTiming.presentLatency)); + if (err != NO_ERROR) return err; + + err = input->readInt64(&refreshStartTime); + if (err != NO_ERROR) return err; + + err = input->readInt64(&dequeueReadyTime); + return err; +} + status_t SurfaceStats::writeToParcel(Parcel* output) const { status_t err = output->writeStrongBinder(surfaceControl); if (err != NO_ERROR) { @@ -49,6 +109,11 @@ status_t SurfaceStats::writeToParcel(Parcel* output) const { err = output->writeBool(false); } err = output->writeUint32(transformHint); + if (err != NO_ERROR) { + return err; + } + + err = output->writeParcelable(eventStats); return err; } @@ -74,6 +139,11 @@ status_t SurfaceStats::readFromParcel(const Parcel* input) { } } err = input->readUint32(&transformHint); + if (err != NO_ERROR) { + return err; + } + + err = input->readParcelable(&eventStats); return err; } diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 43bccf6c04..7017b7c8f3 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -222,8 +222,10 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener surfaceControlStats .emplace_back(callbacksMap[callbackId] .surfaceControls[surfaceStats.surfaceControl], - surfaceStats.acquireTime, surfaceStats.previousReleaseFence, - surfaceStats.transformHint); + transactionStats.latchTime, surfaceStats.acquireTime, + transactionStats.presentFence, + surfaceStats.previousReleaseFence, surfaceStats.transformHint, + surfaceStats.eventStats); if (callbacksMap[callbackId].surfaceControls[surfaceStats.surfaceControl]) { callbacksMap[callbackId] .surfaceControls[surfaceStats.surfaceControl] @@ -1235,6 +1237,18 @@ SurfaceComposerClient::Transaction::addTransactionCompletedCallback( return *this; } +SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::notifyProducerDisconnect( + const sp& sc) { + layer_state_t* s = getLayerState(sc); + if (!s) { + mStatus = BAD_INDEX; + return *this; + } + + s->what |= layer_state_t::eProducerDisconnect; + return *this; +} + SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::detachChildren( const sp& sc) { layer_state_t* s = getLayerState(sc); diff --git a/libs/gui/include/gui/BLASTBufferQueue.h b/libs/gui/include/gui/BLASTBufferQueue.h index be429feade..d72eb5a632 100644 --- a/libs/gui/include/gui/BLASTBufferQueue.h +++ b/libs/gui/include/gui/BLASTBufferQueue.h @@ -33,6 +33,35 @@ namespace android { class BufferItemConsumer; +class BLASTBufferItemConsumer : public BufferItemConsumer { +public: + BLASTBufferItemConsumer(const sp& consumer, uint64_t consumerUsage, + int bufferCount, bool controlledByApp) + : BufferItemConsumer(consumer, consumerUsage, bufferCount, controlledByApp), + mCurrentlyConnected(false), + mPreviouslyConnected(false) {} + + void onDisconnect() override; + void addAndGetFrameTimestamps(const NewFrameEventsEntry* newTimestamps, + FrameEventHistoryDelta* outDelta) override + REQUIRES(mFrameEventHistoryMutex); + void updateFrameTimestamps(uint64_t frameNumber, nsecs_t refreshStartTime, + const sp& gpuCompositionDoneFence, + const sp& presentFence, const sp& prevReleaseFence, + CompositorTiming compositorTiming, nsecs_t latchTime, + nsecs_t dequeueReadyTime) REQUIRES(mFrameEventHistoryMutex); + void getConnectionEvents(uint64_t frameNumber, bool* needsDisconnect); + +private: + uint64_t mCurrentFrameNumber = 0; + + Mutex mFrameEventHistoryMutex; + ConsumerFrameEventHistory mFrameEventHistory GUARDED_BY(mFrameEventHistoryMutex); + std::queue mDisconnectEvents GUARDED_BY(mFrameEventHistoryMutex); + bool mCurrentlyConnected GUARDED_BY(mFrameEventHistoryMutex); + bool mPreviouslyConnected GUARDED_BY(mFrameEventHistoryMutex); +}; + class BLASTBufferQueue : public ConsumerBase::FrameAvailableListener, public BufferItemConsumer::BufferFreedListener { @@ -89,7 +118,7 @@ private: sp mConsumer; sp mProducer; - sp mBufferItemConsumer; + sp mBufferItemConsumer; SurfaceComposerClient::Transaction* mNextTransaction GUARDED_BY(mMutex); }; diff --git a/libs/gui/include/gui/FrameTimestamps.h b/libs/gui/include/gui/FrameTimestamps.h index 816dd2b176..4af86594fc 100644 --- a/libs/gui/include/gui/FrameTimestamps.h +++ b/libs/gui/include/gui/FrameTimestamps.h @@ -174,7 +174,6 @@ struct NewFrameEventsEntry { std::shared_ptr acquireFence{FenceTime::NO_FENCE}; }; - // Used by the consumer to keep track of which fields it already sent to // the producer. class FrameEventDirtyFields { diff --git a/libs/gui/include/gui/ITransactionCompletedListener.h b/libs/gui/include/gui/ITransactionCompletedListener.h index 9c15225ac8..c58634b8a2 100644 --- a/libs/gui/include/gui/ITransactionCompletedListener.h +++ b/libs/gui/include/gui/ITransactionCompletedListener.h @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -35,6 +36,27 @@ class ListenerCallbacks; using CallbackId = int64_t; +class FrameEventHistoryStats : public Parcelable { +public: + status_t writeToParcel(Parcel* output) const override; + status_t readFromParcel(const Parcel* input) override; + + FrameEventHistoryStats() = default; + FrameEventHistoryStats(uint64_t fn, const sp& gpuCompFence, CompositorTiming compTiming, + nsecs_t refreshTime, nsecs_t dequeueReadyTime) + : frameNumber(fn), + gpuCompositionDoneFence(gpuCompFence), + compositorTiming(compTiming), + refreshStartTime(refreshTime), + dequeueReadyTime(dequeueReadyTime) {} + + uint64_t frameNumber; + sp gpuCompositionDoneFence; + CompositorTiming compositorTiming; + nsecs_t refreshStartTime; + nsecs_t dequeueReadyTime; +}; + class SurfaceStats : public Parcelable { public: status_t writeToParcel(Parcel* output) const override; @@ -42,16 +64,18 @@ public: SurfaceStats() = default; SurfaceStats(const sp& sc, nsecs_t time, const sp& prevReleaseFence, - uint32_t hint) + uint32_t hint, FrameEventHistoryStats frameEventStats) : surfaceControl(sc), acquireTime(time), previousReleaseFence(prevReleaseFence), - transformHint(hint) {} + transformHint(hint), + eventStats(frameEventStats) {} sp surfaceControl; nsecs_t acquireTime = -1; sp previousReleaseFence; uint32_t transformHint = 0; + FrameEventHistoryStats eventStats; }; class TransactionStats : public Parcelable { diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h index c256a09c40..2d53b48475 100644 --- a/libs/gui/include/gui/LayerState.h +++ b/libs/gui/include/gui/LayerState.h @@ -102,6 +102,7 @@ struct layer_state_t { eFrameRateSelectionPriority = 0x20'00000000, eFrameRateChanged = 0x40'00000000, eBackgroundBlurRadiusChanged = 0x80'00000000, + eProducerDisconnect = 0x100'00000000, }; layer_state_t() diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h index 6eec2b7a91..d0bb6a39ec 100644 --- a/libs/gui/include/gui/SurfaceComposerClient.h +++ b/libs/gui/include/gui/SurfaceComposerClient.h @@ -52,17 +52,24 @@ class IRegionSamplingListener; class Region; struct SurfaceControlStats { - SurfaceControlStats(const sp& sc, nsecs_t time, - const sp& prevReleaseFence, uint32_t hint) + SurfaceControlStats(const sp& sc, nsecs_t latchTime, nsecs_t acquireTime, + const sp& presentFence, const sp& prevReleaseFence, + uint32_t hint, FrameEventHistoryStats eventStats) : surfaceControl(sc), - acquireTime(time), + latchTime(latchTime), + acquireTime(acquireTime), + presentFence(presentFence), previousReleaseFence(prevReleaseFence), - transformHint(hint) {} + transformHint(hint), + frameEventStats(eventStats) {} sp surfaceControl; + nsecs_t latchTime = -1; nsecs_t acquireTime = -1; + sp presentFence; sp previousReleaseFence; uint32_t transformHint = 0; + FrameEventHistoryStats frameEventStats; }; using TransactionCompletedCallbackTakesContext = @@ -484,6 +491,9 @@ public: Transaction& addTransactionCompletedCallback( TransactionCompletedCallbackTakesContext callback, void* callbackContext); + // ONLY FOR BLAST ADAPTER + Transaction& notifyProducerDisconnect(const sp& sc); + // Detaches all child surfaces (and their children recursively) // from their SurfaceControl. // The child SurfaceControls will not throw exceptions or return errors, diff --git a/libs/gui/tests/BLASTBufferQueue_test.cpp b/libs/gui/tests/BLASTBufferQueue_test.cpp index a273914caf..b40eb14093 100644 --- a/libs/gui/tests/BLASTBufferQueue_test.cpp +++ b/libs/gui/tests/BLASTBufferQueue_test.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -647,4 +648,79 @@ TEST_F(BLASTBufferQueueTransformTest, setTransform_ROT_180) { TEST_F(BLASTBufferQueueTransformTest, setTransform_ROT_270) { test(ui::Transform::ROT_270); } + +class BLASTFrameEventHistoryTest : public BLASTBufferQueueTest { +public: + void setUpAndQueueBuffer(const sp& igbProducer, + nsecs_t* requestedPresentTime, nsecs_t* postedTime, + IGraphicBufferProducer::QueueBufferOutput* qbOutput, + bool getFrameTimestamps) { + int slot; + sp fence; + sp buf; + auto ret = igbProducer->dequeueBuffer(&slot, &fence, mDisplayWidth, mDisplayHeight, + PIXEL_FORMAT_RGBA_8888, GRALLOC_USAGE_SW_WRITE_OFTEN, + nullptr, nullptr); + ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION, ret); + ASSERT_EQ(OK, igbProducer->requestBuffer(slot, &buf)); + + nsecs_t requestedTime = systemTime(); + if (requestedPresentTime) *requestedPresentTime = requestedTime; + IGraphicBufferProducer::QueueBufferInput input(requestedTime, false, HAL_DATASPACE_UNKNOWN, + Rect(mDisplayWidth, mDisplayHeight), + NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, + Fence::NO_FENCE, /*sticky*/ 0, + getFrameTimestamps); + if (postedTime) *postedTime = systemTime(); + igbProducer->queueBuffer(slot, input, qbOutput); + } +}; + +TEST_F(BLASTFrameEventHistoryTest, FrameEventHistory_Basic) { + BLASTBufferQueueHelper adapter(mSurfaceControl, mDisplayWidth, mDisplayHeight); + sp igbProducer; + ProducerFrameEventHistory history; + setUpProducer(adapter, igbProducer); + + IGraphicBufferProducer::QueueBufferOutput qbOutput; + nsecs_t requestedPresentTimeA = 0; + nsecs_t postedTimeA = 0; + setUpAndQueueBuffer(igbProducer, &requestedPresentTimeA, &postedTimeA, &qbOutput, true); + history.applyDelta(qbOutput.frameTimestamps); + + FrameEvents* events = nullptr; + events = history.getFrame(1); + ASSERT_NE(nullptr, events); + ASSERT_EQ(1, events->frameNumber); + ASSERT_EQ(requestedPresentTimeA, events->requestedPresentTime); + ASSERT_GE(events->postedTime, postedTimeA); + + adapter.waitForCallbacks(); + + // queue another buffer so we query for frame event deltas + nsecs_t requestedPresentTimeB = 0; + nsecs_t postedTimeB = 0; + setUpAndQueueBuffer(igbProducer, &requestedPresentTimeB, &postedTimeB, &qbOutput, true); + history.applyDelta(qbOutput.frameTimestamps); + events = history.getFrame(1); + ASSERT_NE(nullptr, events); + + // frame number, requestedPresentTime, and postTime should not have changed + ASSERT_EQ(1, events->frameNumber); + ASSERT_EQ(requestedPresentTimeA, events->requestedPresentTime); + ASSERT_GE(events->postedTime, postedTimeA); + + ASSERT_GE(events->latchTime, postedTimeA); + ASSERT_GE(events->dequeueReadyTime, events->latchTime); + ASSERT_NE(nullptr, events->gpuCompositionDoneFence); + ASSERT_NE(nullptr, events->displayPresentFence); + ASSERT_NE(nullptr, events->releaseFence); + + // we should also have gotten the initial values for the next frame + events = history.getFrame(2); + ASSERT_NE(nullptr, events); + ASSERT_EQ(2, events->frameNumber); + ASSERT_EQ(requestedPresentTimeB, events->requestedPresentTime); + ASSERT_GE(events->postedTime, postedTimeB); +} } // namespace android diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp index 29688dac63..f8769c0614 100644 --- a/services/surfaceflinger/BufferStateLayer.cpp +++ b/services/surfaceflinger/BufferStateLayer.cpp @@ -115,6 +115,7 @@ void BufferStateLayer::setTransformHint(uint32_t orientation) const { void BufferStateLayer::releasePendingBuffer(nsecs_t dequeueReadyTime) { for (const auto& handle : mDrawingState.callbackHandles) { handle->transformHint = mTransformHint; + handle->dequeueReadyTime = dequeueReadyTime; } mFlinger->getTransactionCompletedThread().finalizePendingCallbackHandles( @@ -133,6 +134,14 @@ void BufferStateLayer::releasePendingBuffer(nsecs_t dequeueReadyTime) { } } +void BufferStateLayer::finalizeFrameEventHistory(const std::shared_ptr& glDoneFence, + const CompositorTiming& compositorTiming) { + for (const auto& handle : mDrawingState.callbackHandles) { + handle->gpuCompositionDoneFence = glDoneFence; + handle->compositorTiming = compositorTiming; + } +} + bool BufferStateLayer::shouldPresentNow(nsecs_t /*expectedPresentTime*/) const { if (getSidebandStreamChanged() || getAutoRefresh()) { return true; @@ -244,14 +253,15 @@ bool BufferStateLayer::setFrame(const Rect& frame) { return true; } -bool BufferStateLayer::updateFrameEventHistory(const sp& acquireFence, nsecs_t postedTime, - nsecs_t desiredPresentTime) { +bool BufferStateLayer::addFrameEvent(const sp& acquireFence, nsecs_t postedTime, + nsecs_t desiredPresentTime) { Mutex::Autolock lock(mFrameEventHistoryMutex); mAcquireTimeline.updateSignalTimes(); std::shared_ptr acquireFenceTime = std::make_shared((acquireFence ? acquireFence : Fence::NO_FENCE)); NewFrameEventsEntry newTimestamps = {mCurrentState.frameNumber, postedTime, desiredPresentTime, acquireFenceTime}; + mFrameEventHistory.setProducerWantsEvents(); mFrameEventHistory.addQueue(newTimestamps); return true; } @@ -276,12 +286,12 @@ bool BufferStateLayer::setBuffer(const sp& buffer, const spmFrameTracer->traceNewLayer(layerId, getName().c_str()); mFlinger->mFrameTracer->traceTimestamp(layerId, buffer->getId(), mCurrentState.frameNumber, postTime, FrameTracer::FrameEvent::POST); + desiredPresentTime = desiredPresentTime <= 0 ? 0 : desiredPresentTime; mCurrentState.desiredPresentTime = desiredPresentTime; - mFlinger->mScheduler->recordLayerHistory(this, - desiredPresentTime <= 0 ? 0 : desiredPresentTime); + mFlinger->mScheduler->recordLayerHistory(this, desiredPresentTime); - updateFrameEventHistory(acquireFence, postTime, desiredPresentTime); + addFrameEvent(acquireFence, postTime, desiredPresentTime); return true; } @@ -446,6 +456,13 @@ bool BufferStateLayer::framePresentTimeIsCurrent(nsecs_t expectedPresentTime) co return mCurrentState.desiredPresentTime <= expectedPresentTime; } +bool BufferStateLayer::onPreComposition(nsecs_t refreshStartTime) { + for (const auto& handle : mDrawingState.callbackHandles) { + handle->refreshStartTime = refreshStartTime; + } + return BufferLayer::onPreComposition(refreshStartTime); +} + uint64_t BufferStateLayer::getFrameNumber(nsecs_t /*expectedPresentTime*/) const { return mDrawingState.frameNumber; } @@ -529,6 +546,7 @@ status_t BufferStateLayer::updateTexImage(bool& /*recomputeVisibleRegions*/, nse for (auto& handle : mDrawingState.callbackHandles) { handle->latchTime = latchTime; + handle->frameNumber = mDrawingState.frameNumber; } if (!SyncFeatures::getInstance().useNativeFenceSync()) { diff --git a/services/surfaceflinger/BufferStateLayer.h b/services/surfaceflinger/BufferStateLayer.h index 57ff8bc00d..8e22215b4a 100644 --- a/services/surfaceflinger/BufferStateLayer.h +++ b/services/surfaceflinger/BufferStateLayer.h @@ -45,6 +45,9 @@ public: void setTransformHint(uint32_t orientation) const override; void releasePendingBuffer(nsecs_t dequeueReadyTime) override; + void finalizeFrameEventHistory(const std::shared_ptr& glDoneFence, + const CompositorTiming& compositorTiming) override; + bool shouldPresentNow(nsecs_t expectedPresentTime) const override; uint32_t doTransactionResize(uint32_t flags, Layer::State* /*stateToCommit*/) override { @@ -78,6 +81,8 @@ public: bool setSidebandStream(const sp& sidebandStream) override; bool setTransactionCompletedListeners(const std::vector>& handles) override; void forceSendCallbacks() override; + bool addFrameEvent(const sp& acquireFence, nsecs_t postedTime, + nsecs_t requestedPresentTime) override; // Override to ignore legacy layer state properties that are not used by BufferStateLayer bool setSize(uint32_t /*w*/, uint32_t /*h*/) override { return false; } @@ -104,6 +109,7 @@ public: // ----------------------------------------------------------------------- bool fenceHasSignaled() const override; bool framePresentTimeIsCurrent(nsecs_t expectedPresentTime) const override; + bool onPreComposition(nsecs_t refreshStartTime) override; protected: void gatherBufferInfo() override; diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 810e0af47f..de4a08070c 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -372,6 +372,10 @@ public: return false; }; virtual void forceSendCallbacks() {} + virtual bool addFrameEvent(const sp& /*acquireFence*/, nsecs_t /*postedTime*/, + nsecs_t /*requestedPresentTime*/) { + return false; + } virtual bool setBackgroundColor(const half3& color, float alpha, ui::Dataspace dataspace); virtual bool setColorSpaceAgnostic(const bool agnostic); bool setShadowRadius(float shadowRadius); @@ -596,6 +600,8 @@ public: // If a buffer was replaced this frame, release the former buffer virtual void releasePendingBuffer(nsecs_t /*dequeueReadyTime*/) { } + virtual void finalizeFrameEventHistory(const std::shared_ptr& /*glDoneFence*/, + const CompositorTiming& /*compositorTiming*/) {} /* * doTransaction - process the transaction. This is a good place to figure * out which attributes of the surface have changed. diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 33d85cb420..c125b2c75b 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2037,12 +2037,10 @@ void SurfaceFlinger::postComposition() ATRACE_CALL(); ALOGV("postComposition"); - // Release any buffers which were replaced this frame nsecs_t dequeueReadyTime = systemTime(); for (auto& layer : mLayersWithQueuedFrames) { layer->releasePendingBuffer(dequeueReadyTime); } - // |mStateLock| not needed as we are on the main thread const auto displayDevice = getDefaultDisplayDeviceLocked(); @@ -3349,6 +3347,11 @@ uint32_t SurfaceFlinger::setClientStateLocked( layer->pushPendingState(); } + // Only set by BLAST adapter layers + if (what & layer_state_t::eProducerDisconnect) { + layer->onDisconnect(); + } + if (what & layer_state_t::ePositionChanged) { if (layer->setPosition(s.x, s.y)) { flags |= eTraversalNeeded; diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index daa67ae043..0cdff8f380 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -237,9 +237,13 @@ status_t TransactionCompletedThread::addCallbackHandle(const sp& // destroyed the client side is dead and there won't be anyone to send the callback to. sp surfaceControl = handle->surfaceControl.promote(); if (surfaceControl) { + FrameEventHistoryStats eventStats(handle->frameNumber, + handle->gpuCompositionDoneFence->getSnapshot().fence, + handle->compositorTiming, handle->refreshStartTime, + handle->dequeueReadyTime); transactionStats->surfaceStats.emplace_back(surfaceControl, handle->acquireTime, handle->previousReleaseFence, - handle->transformHint); + handle->transformHint, eventStats); } return NO_ERROR; } diff --git a/services/surfaceflinger/TransactionCompletedThread.h b/services/surfaceflinger/TransactionCompletedThread.h index 12ea8fe7d0..f50147a1e9 100644 --- a/services/surfaceflinger/TransactionCompletedThread.h +++ b/services/surfaceflinger/TransactionCompletedThread.h @@ -45,6 +45,11 @@ public: nsecs_t acquireTime = -1; nsecs_t latchTime = -1; uint32_t transformHint = 0; + std::shared_ptr gpuCompositionDoneFence{FenceTime::NO_FENCE}; + CompositorTiming compositorTiming; + nsecs_t refreshStartTime = 0; + nsecs_t dequeueReadyTime = 0; + uint64_t frameNumber = 0; }; class TransactionCompletedThread { diff --git a/services/surfaceflinger/tests/utils/CallbackUtils.h b/services/surfaceflinger/tests/utils/CallbackUtils.h index 4e2b7c3543..1318debbba 100644 --- a/services/surfaceflinger/tests/utils/CallbackUtils.h +++ b/services/surfaceflinger/tests/utils/CallbackUtils.h @@ -121,8 +121,10 @@ private: void verifySurfaceControlStats(const SurfaceControlStats& surfaceControlStats, nsecs_t latchTime) const { - const auto& [surfaceControl, acquireTime, previousReleaseFence, transformHint] = - surfaceControlStats; + const auto& + [surfaceControl, latch, acquireTime, presentFence, previousReleaseFence, + transformHint, + frameEvents] = surfaceControlStats; ASSERT_EQ(acquireTime > 0, mBufferResult == ExpectedResult::Buffer::ACQUIRED) << "bad acquire time"; -- cgit v1.2.3-59-g8ed1b From 109ad7156997f031717183664ac51a03110bc2b3 Mon Sep 17 00:00:00 2001 From: Valerie Hau Date: Thu, 18 Jun 2020 17:00:58 -0700 Subject: Only force send callbacks if they are registered Some clients of ASurfaceControl may not set callbacks. We do not want to call finalizePendingCallbacks in this case. Bug: 159231312 Test: build, boot, SurfaceFlinger_test, libsurfaceflinger_unittest Change-Id: I62dc270302a60274d8d1192d0e35ce3f48721e6c --- services/surfaceflinger/TransactionCompletedThread.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'services/surfaceflinger/TransactionCompletedThread.cpp') diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index 0cdff8f380..ca244934e4 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -154,6 +154,9 @@ status_t TransactionCompletedThread::registerPendingCallbackHandle( status_t TransactionCompletedThread::finalizePendingCallbackHandles( const std::deque>& handles) { + if (handles.empty()) { + return NO_ERROR; + } std::lock_guard lock(mMutex); if (!mRunning) { ALOGE("cannot add presented callback handle because the callback thread isn't running"); -- cgit v1.2.3-59-g8ed1b