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

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

Merge "SurfaceFlinger: Remove eSynchronous flag"

parents 7be3c9b2 1523dad8
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -95,7 +95,6 @@ public:


    // flags for setTransactionState()
    // flags for setTransactionState()
    enum {
    enum {
        eSynchronous = 0x01,
        eAnimation = 0x02,
        eAnimation = 0x02,


        // Explicit indication that this transaction and others to follow will likely result in a
        // Explicit indication that this transaction and others to follow will likely result in a
+1 −40
Original line number Original line Diff line number Diff line
@@ -3229,7 +3229,6 @@ void SurfaceFlinger::commitTransactionsLocked(uint32_t transactionFlags) {
    }
    }


    doCommitTransactions();
    doCommitTransactions();
    signalSynchronousTransactions(CountDownLatch::eSyncTransaction);
}
}


void SurfaceFlinger::updateInputFlinger() {
void SurfaceFlinger::updateInputFlinger() {
@@ -3826,10 +3825,6 @@ bool SurfaceFlinger::applyTransactions(std::vector<TransactionState>& transactio
                                      transaction.permissions, transaction.hasListenerCallbacks,
                                      transaction.permissions, transaction.hasListenerCallbacks,
                                      transaction.listenerCallbacks, transaction.originPid,
                                      transaction.listenerCallbacks, transaction.originPid,
                                      transaction.originUid, transaction.id);
                                      transaction.originUid, transaction.id);
        if (transaction.transactionCommittedSignal) {
            mTransactionCommittedSignals.emplace_back(
                    std::move(transaction.transactionCommittedSignal));
        }
    }
    }


    if (mTransactionTracing) {
    if (mTransactionTracing) {
@@ -4005,12 +4000,6 @@ auto SurfaceFlinger::transactionIsReadyToBeApplied(
}
}


void SurfaceFlinger::queueTransaction(TransactionState& state) {
void SurfaceFlinger::queueTransaction(TransactionState& state) {
    // Generate a CountDownLatch pending state if this is a synchronous transaction.
    if (state.flags & eSynchronous) {
        state.transactionCommittedSignal =
                std::make_shared<CountDownLatch>(CountDownLatch::eSyncTransaction);
    }

    mLocklessTransactionQueue.push(state);
    mLocklessTransactionQueue.push(state);
    mPendingTransactionCount++;
    mPendingTransactionCount++;
    ATRACE_INT("TransactionQueue", mPendingTransactionCount.load());
    ATRACE_INT("TransactionQueue", mPendingTransactionCount.load());
@@ -4026,28 +4015,6 @@ void SurfaceFlinger::queueTransaction(TransactionState& state) {
    setTransactionFlags(eTransactionFlushNeeded, schedule, state.applyToken, frameHint);
    setTransactionFlags(eTransactionFlushNeeded, schedule, state.applyToken, frameHint);
}
}


void SurfaceFlinger::waitForSynchronousTransaction(
        const CountDownLatch& transactionCommittedSignal) {
    // applyTransactionState is called on the main SF thread.  While a given process may wish
    // to wait on synchronous transactions, the main SF thread should apply the transaction and
    // set the value to notify this after committed.
    if (!transactionCommittedSignal.wait_until(
                std::chrono::nanoseconds(mAnimationTransactionTimeout))) {
        ALOGE("setTransactionState timed out!");
    }
}

void SurfaceFlinger::signalSynchronousTransactions(const uint32_t flag) {
    for (auto it = mTransactionCommittedSignals.begin();
         it != mTransactionCommittedSignals.end();) {
        if ((*it)->countDown(flag)) {
            it = mTransactionCommittedSignals.erase(it);
        } else {
            it++;
        }
    }
}

status_t SurfaceFlinger::setTransactionState(
status_t SurfaceFlinger::setTransactionState(
        const FrameTimelineInfo& frameTimelineInfo, const Vector<ComposerState>& states,
        const FrameTimelineInfo& frameTimelineInfo, const Vector<ComposerState>& states,
        const Vector<DisplayState>& displays, uint32_t flags, const sp<IBinder>& applyToken,
        const Vector<DisplayState>& displays, uint32_t flags, const sp<IBinder>& applyToken,
@@ -4100,11 +4067,6 @@ status_t SurfaceFlinger::setTransactionState(
    }
    }
    queueTransaction(state);
    queueTransaction(state);


    // Check the pending state to make sure the transaction is synchronous.
    if (state.transactionCommittedSignal) {
        waitForSynchronousTransaction(*state.transactionCommittedSignal);
    }

    return NO_ERROR;
    return NO_ERROR;
}
}


@@ -4161,8 +4123,7 @@ bool SurfaceFlinger::applyTransactionState(const FrameTimelineInfo& frameTimelin
    // anyway. This can be used as a flush mechanism for previous async transactions.
    // anyway. This can be used as a flush mechanism for previous async transactions.
    // Empty animation transaction can be used to simulate back-pressure, so also force a
    // Empty animation transaction can be used to simulate back-pressure, so also force a
    // transaction for empty animation transactions.
    // transaction for empty animation transactions.
    if (transactionFlags == 0 &&
    if (transactionFlags == 0 && (flags & eAnimation)) {
            ((flags & eSynchronous) || (flags & eAnimation))) {
        transactionFlags = eTransactionNeeded;
        transactionFlags = eTransactionNeeded;
    }
    }


+0 −5
Original line number Original line Diff line number Diff line
@@ -1095,8 +1095,6 @@ private:


    // Add transaction to the Transaction Queue
    // Add transaction to the Transaction Queue
    void queueTransaction(TransactionState& state);
    void queueTransaction(TransactionState& state);
    void waitForSynchronousTransaction(const CountDownLatch& transactionCommittedSignal);
    void signalSynchronousTransactions(const uint32_t flag);


    /*
    /*
     * Generic Layer Metadata
     * Generic Layer Metadata
@@ -1129,7 +1127,6 @@ private:
    mutable Mutex mStateLock;
    mutable Mutex mStateLock;
    State mCurrentState{LayerVector::StateSet::Current};
    State mCurrentState{LayerVector::StateSet::Current};
    std::atomic<int32_t> mTransactionFlags = 0;
    std::atomic<int32_t> mTransactionFlags = 0;
    std::vector<std::shared_ptr<CountDownLatch>> mTransactionCommittedSignals;
    std::atomic<uint32_t> mUniqueTransactionId = 1;
    std::atomic<uint32_t> mUniqueTransactionId = 1;
    SortedVector<sp<Layer>> mLayersPendingRemoval;
    SortedVector<sp<Layer>> mLayersPendingRemoval;


@@ -1418,8 +1415,6 @@ private:
        bool early = false;
        bool early = false;
    } mPowerHintSessionMode;
    } mPowerHintSessionMode;


    nsecs_t mAnimationTransactionTimeout = s2ns(5);

    friend class SurfaceComposerAIDL;
    friend class SurfaceComposerAIDL;
};
};


+0 −2
Original line number Original line Diff line number Diff line
@@ -127,7 +127,6 @@ void SurfaceInterceptor::addInitialSurfaceStateLocked(Increment* increment,
{
{
    Transaction* transaction(increment->mutable_transaction());
    Transaction* transaction(increment->mutable_transaction());
    const uint32_t layerFlags = layer->getTransactionFlags();
    const uint32_t layerFlags = layer->getTransactionFlags();
    transaction->set_synchronous(layerFlags & BnSurfaceComposer::eSynchronous);
    transaction->set_animation(layerFlags & BnSurfaceComposer::eAnimation);
    transaction->set_animation(layerFlags & BnSurfaceComposer::eAnimation);


    const int32_t layerId(getLayerId(layer));
    const int32_t layerId(getLayerId(layer));
@@ -495,7 +494,6 @@ void SurfaceInterceptor::addTransactionLocked(
        const Vector<DisplayState>& changedDisplays, uint32_t transactionFlags, int originPid,
        const Vector<DisplayState>& changedDisplays, uint32_t transactionFlags, int originPid,
        int originUid, uint64_t transactionId) {
        int originUid, uint64_t transactionId) {
    Transaction* transaction(increment->mutable_transaction());
    Transaction* transaction(increment->mutable_transaction());
    transaction->set_synchronous(transactionFlags & BnSurfaceComposer::eSynchronous);
    transaction->set_animation(transactionFlags & BnSurfaceComposer::eAnimation);
    transaction->set_animation(transactionFlags & BnSurfaceComposer::eAnimation);
    setTransactionOriginLocked(transaction, originPid, originUid);
    setTransactionOriginLocked(transaction, originPid, originUid);
    transaction->set_id(transactionId);
    transaction->set_id(transactionId);
+0 −44
Original line number Original line Diff line number Diff line
@@ -26,8 +26,6 @@


namespace android {
namespace android {


class CountDownLatch;

struct TransactionState {
struct TransactionState {
    TransactionState() = default;
    TransactionState() = default;


@@ -97,49 +95,7 @@ struct TransactionState {
    int originPid;
    int originPid;
    int originUid;
    int originUid;
    uint64_t id;
    uint64_t id;
    std::shared_ptr<CountDownLatch> transactionCommittedSignal;
    bool sentFenceTimeoutWarning = false;
    bool sentFenceTimeoutWarning = false;
};
};


class CountDownLatch {
public:
    enum {
        eSyncTransaction = 1 << 0,
    };
    explicit CountDownLatch(uint32_t flags) : mFlags(flags) {}

    // True if there is no waiting condition after count down.
    bool countDown(uint32_t flag) {
        std::unique_lock<std::mutex> lock(mMutex);
        if (mFlags == 0) {
            return true;
        }
        mFlags &= ~flag;
        if (mFlags == 0) {
            mCountDownComplete.notify_all();
            return true;
        }
        return false;
    }

    // Return true if triggered.
    bool wait_until(const std::chrono::nanoseconds& timeout) const {
        std::unique_lock<std::mutex> lock(mMutex);
        const auto untilTime = std::chrono::system_clock::now() + timeout;
        while (mFlags != 0) {
            // Conditional variables can be woken up sporadically, so we check count
            // to verify the wakeup was triggered by |countDown|.
            if (std::cv_status::timeout == mCountDownComplete.wait_until(lock, untilTime)) {
                return false;
            }
        }
        return true;
    }

private:
    uint32_t mFlags;
    mutable std::condition_variable mCountDownComplete;
    mutable std::mutex mMutex;
};

} // namespace android
} // namespace android
Loading