Loading services/surfaceflinger/SurfaceFlinger.cpp +21 −13 Original line number Diff line number Diff line Loading @@ -1704,22 +1704,22 @@ bool SurfaceFlinger::handleMessageTransaction() { ATRACE_CALL(); uint32_t transactionFlags = peekTransactionFlags(); // Apply any ready transactions in the queues if there are still transactions that have not been // applied, wake up during the next vsync period and check again bool transactionNeeded = false; if (!flushTransactionQueues()) { transactionNeeded = true; } bool flushedATransaction = flushTransactionQueues(); if (transactionFlags) { handleTransaction(transactionFlags); bool runHandleTransaction = transactionFlags && ((transactionFlags != eTransactionFlushNeeded) || flushedATransaction); if (runHandleTransaction) { handleTransaction(eTransactionMask); } else { getTransactionFlags(eTransactionFlushNeeded); } if (transactionNeeded) { setTransactionFlags(eTransactionNeeded); if (transactionFlushNeeded()) { setTransactionFlags(eTransactionFlushNeeded); } return transactionFlags; return runHandleTransaction; } void SurfaceFlinger::handleMessageRefresh() { Loading Loading @@ -3518,6 +3518,8 @@ uint32_t SurfaceFlinger::setTransactionFlags(uint32_t flags, bool SurfaceFlinger::flushTransactionQueues() { Mutex::Autolock _l(mStateLock); bool flushedATransaction = false; auto it = mTransactionQueues.begin(); while (it != mTransactionQueues.end()) { auto& [applyToken, transactionQueue] = *it; Loading @@ -3527,17 +3529,23 @@ bool SurfaceFlinger::flushTransactionQueues() { [states, displays, flags, desiredPresentTime, uncacheBuffer, listenerCallbacks, postTime, privileged] = transactionQueue.front(); if (!transactionIsReadyToBeApplied(desiredPresentTime, states)) { setTransactionFlags(eTransactionFlushNeeded); break; } applyTransactionState(states, displays, flags, mPendingInputWindowCommands, desiredPresentTime, uncacheBuffer, listenerCallbacks, postTime, privileged, /*isMainThread*/ true); transactionQueue.pop(); flushedATransaction = true; } it = (transactionQueue.empty()) ? mTransactionQueues.erase(it) : std::next(it, 1); } return mTransactionQueues.empty(); return flushedATransaction; } bool SurfaceFlinger::transactionFlushNeeded() { return !mTransactionQueues.empty(); } bool SurfaceFlinger::containsAnyInvalidClientState(const Vector<ComposerState>& states) { Loading Loading @@ -3609,7 +3617,7 @@ void SurfaceFlinger::setTransactionState(const Vector<ComposerState>& states, mTransactionQueues[applyToken].emplace(states, displays, flags, desiredPresentTime, uncacheBuffer, listenerCallbacks, postTime, privileged); setTransactionFlags(eTransactionNeeded); setTransactionFlags(eTransactionFlushNeeded); return; } Loading services/surfaceflinger/SurfaceFlinger.h +7 −3 Original line number Diff line number Diff line Loading @@ -139,7 +139,8 @@ enum { eTraversalNeeded = 0x02, eDisplayTransactionNeeded = 0x04, eDisplayLayerStackChanged = 0x08, eTransactionMask = 0x0f, eTransactionFlushNeeded = 0x10, eTransactionMask = 0x1f, }; enum class DisplayColorSetting : int32_t { Loading Loading @@ -606,7 +607,10 @@ private: const std::vector<ListenerCallbacks>& listenerCallbacks, const int64_t postTime, bool privileged, 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 bool transactionFlushNeeded(); uint32_t getTransactionFlags(uint32_t flags); uint32_t peekTransactionFlags(); // Can only be called from the main thread or with mStateLock held Loading Loading
services/surfaceflinger/SurfaceFlinger.cpp +21 −13 Original line number Diff line number Diff line Loading @@ -1704,22 +1704,22 @@ bool SurfaceFlinger::handleMessageTransaction() { ATRACE_CALL(); uint32_t transactionFlags = peekTransactionFlags(); // Apply any ready transactions in the queues if there are still transactions that have not been // applied, wake up during the next vsync period and check again bool transactionNeeded = false; if (!flushTransactionQueues()) { transactionNeeded = true; } bool flushedATransaction = flushTransactionQueues(); if (transactionFlags) { handleTransaction(transactionFlags); bool runHandleTransaction = transactionFlags && ((transactionFlags != eTransactionFlushNeeded) || flushedATransaction); if (runHandleTransaction) { handleTransaction(eTransactionMask); } else { getTransactionFlags(eTransactionFlushNeeded); } if (transactionNeeded) { setTransactionFlags(eTransactionNeeded); if (transactionFlushNeeded()) { setTransactionFlags(eTransactionFlushNeeded); } return transactionFlags; return runHandleTransaction; } void SurfaceFlinger::handleMessageRefresh() { Loading Loading @@ -3518,6 +3518,8 @@ uint32_t SurfaceFlinger::setTransactionFlags(uint32_t flags, bool SurfaceFlinger::flushTransactionQueues() { Mutex::Autolock _l(mStateLock); bool flushedATransaction = false; auto it = mTransactionQueues.begin(); while (it != mTransactionQueues.end()) { auto& [applyToken, transactionQueue] = *it; Loading @@ -3527,17 +3529,23 @@ bool SurfaceFlinger::flushTransactionQueues() { [states, displays, flags, desiredPresentTime, uncacheBuffer, listenerCallbacks, postTime, privileged] = transactionQueue.front(); if (!transactionIsReadyToBeApplied(desiredPresentTime, states)) { setTransactionFlags(eTransactionFlushNeeded); break; } applyTransactionState(states, displays, flags, mPendingInputWindowCommands, desiredPresentTime, uncacheBuffer, listenerCallbacks, postTime, privileged, /*isMainThread*/ true); transactionQueue.pop(); flushedATransaction = true; } it = (transactionQueue.empty()) ? mTransactionQueues.erase(it) : std::next(it, 1); } return mTransactionQueues.empty(); return flushedATransaction; } bool SurfaceFlinger::transactionFlushNeeded() { return !mTransactionQueues.empty(); } bool SurfaceFlinger::containsAnyInvalidClientState(const Vector<ComposerState>& states) { Loading Loading @@ -3609,7 +3617,7 @@ void SurfaceFlinger::setTransactionState(const Vector<ComposerState>& states, mTransactionQueues[applyToken].emplace(states, displays, flags, desiredPresentTime, uncacheBuffer, listenerCallbacks, postTime, privileged); setTransactionFlags(eTransactionNeeded); setTransactionFlags(eTransactionFlushNeeded); return; } Loading
services/surfaceflinger/SurfaceFlinger.h +7 −3 Original line number Diff line number Diff line Loading @@ -139,7 +139,8 @@ enum { eTraversalNeeded = 0x02, eDisplayTransactionNeeded = 0x04, eDisplayLayerStackChanged = 0x08, eTransactionMask = 0x0f, eTransactionFlushNeeded = 0x10, eTransactionMask = 0x1f, }; enum class DisplayColorSetting : int32_t { Loading Loading @@ -606,7 +607,10 @@ private: const std::vector<ListenerCallbacks>& listenerCallbacks, const int64_t postTime, bool privileged, 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 bool transactionFlushNeeded(); uint32_t getTransactionFlags(uint32_t flags); uint32_t peekTransactionFlags(); // Can only be called from the main thread or with mStateLock held Loading