Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 722bbe81 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "blast: flush transaction wake ups"

parents a9e843ac e6e3c0d6
Loading
Loading
Loading
Loading
+21 −13
Original line number Diff line number Diff line
@@ -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() {
@@ -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;
@@ -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) {
@@ -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;
    }

+7 −3
Original line number Diff line number Diff line
@@ -139,7 +139,8 @@ enum {
    eTraversalNeeded = 0x02,
    eDisplayTransactionNeeded = 0x04,
    eDisplayLayerStackChanged = 0x08,
    eTransactionMask          = 0x0f,
    eTransactionFlushNeeded = 0x10,
    eTransactionMask = 0x1f,
};

enum class DisplayColorSetting : int32_t {
@@ -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