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

Commit 17b4e457 authored by Marissa Wall's avatar Marissa Wall
Browse files

blast: add desired present time

Add the option to set a desiredPresentTime for a transaction. This
lets the framework know approximately when the transaction should
be presented.

Test: Transaction_test
Bug: 80477568

Change-Id: Ic25617fb93f2c249b3b3c7a8f90f72ec358938f0
parent 5a68a779
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -66,7 +66,8 @@ public:
    virtual void setTransactionState(const Vector<ComposerState>& state,
                                     const Vector<DisplayState>& displays, uint32_t flags,
                                     const sp<IBinder>& applyToken,
                                     const InputWindowCommands& commands) {
                                     const InputWindowCommands& commands,
                                     int64_t desiredPresentTime) {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());

@@ -83,6 +84,7 @@ public:
        data.writeUint32(flags);
        data.writeStrongBinder(applyToken);
        commands.write(data);
        data.writeInt64(desiredPresentTime);
        remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
    }

@@ -748,7 +750,10 @@ status_t BnSurfaceComposer::onTransact(
            sp<IBinder> applyToken = data.readStrongBinder();
            InputWindowCommands inputWindowCommands;
            inputWindowCommands.read(data);
            setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands);

            int64_t desiredPresentTime = data.readInt64();
            setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
                                desiredPresentTime);
            return NO_ERROR;
        }
        case BOOT_FINISHED: {
+15 −7
Original line number Diff line number Diff line
@@ -159,11 +159,12 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener

// ---------------------------------------------------------------------------

SurfaceComposerClient::Transaction::Transaction(const Transaction& other) :
    mForceSynchronous(other.mForceSynchronous),
SurfaceComposerClient::Transaction::Transaction(const Transaction& other)
      : mForceSynchronous(other.mForceSynchronous),
        mTransactionNestCount(other.mTransactionNestCount),
        mAnimation(other.mAnimation),
    mEarlyWakeup(other.mEarlyWakeup) {
        mEarlyWakeup(other.mEarlyWakeup),
        mDesiredPresentTime(other.mDesiredPresentTime) {
    mDisplayStates = other.mDisplayStates;
    mComposerStates = other.mComposerStates;
    mInputWindowCommands = other.mInputWindowCommands;
@@ -218,7 +219,7 @@ void SurfaceComposerClient::doDropReferenceTransaction(const sp<IBinder>& handle
    s.state.parentHandleForChild = nullptr;

    composerStates.add(s);
    sf->setTransactionState(composerStates, displayStates, 0, nullptr, {});
    sf->setTransactionState(composerStates, displayStates, 0, nullptr, {}, -1);
}

status_t SurfaceComposerClient::Transaction::apply(bool synchronous) {
@@ -284,7 +285,8 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) {
    mEarlyWakeup = false;

    sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance());
    sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands);
    sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands,
                            mDesiredPresentTime);
    mInputWindowCommands.clear();
    mStatus = NO_ERROR;
    return NO_ERROR;
@@ -742,6 +744,12 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setSideb
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setDesiredPresentTime(
        nsecs_t desiredPresentTime) {
    mDesiredPresentTime = desiredPresentTime;
    return *this;
}

SurfaceComposerClient::Transaction&
SurfaceComposerClient::Transaction::addTransactionCompletedCallback(
        TransactionCompletedCallbackTakesContext callback, void* callbackContext) {
+2 −1
Original line number Diff line number Diff line
@@ -116,7 +116,8 @@ public:
    virtual void setTransactionState(const Vector<ComposerState>& state,
                                     const Vector<DisplayState>& displays, uint32_t flags,
                                     const sp<IBinder>& applyToken,
                                     const InputWindowCommands& inputWindowCommands) = 0;
                                     const InputWindowCommands& inputWindowCommands,
                                     int64_t desiredPresentTime) = 0;

    /* signal that we're done booting.
     * Requires ACCESS_SURFACE_FLINGER permission
+13 −0
Original line number Diff line number Diff line
@@ -237,6 +237,18 @@ public:
        bool                        mAnimation = false;
        bool                        mEarlyWakeup = false;

        // mDesiredPresentTime is the time in nanoseconds that the client would like the transaction
        // to be presented. When it is not possible to present at exactly that time, it will be
        // presented after the time has passed.
        //
        // Desired present times that are more than 1 second in the future may be ignored.
        // When a desired present time has already passed, the transaction will be presented as soon
        // as possible.
        //
        // Transactions from the same process are presented in the same order that they are applied.
        // The desired present time does not affect this ordering.
        int64_t mDesiredPresentTime = -1;

        InputWindowCommands mInputWindowCommands;
        int mStatus = NO_ERROR;

@@ -325,6 +337,7 @@ public:
        Transaction& setApi(const sp<SurfaceControl>& sc, int32_t api);
        Transaction& setSidebandStream(const sp<SurfaceControl>& sc,
                                       const sp<NativeHandle>& sidebandStream);
        Transaction& setDesiredPresentTime(nsecs_t desiredPresentTime);

        Transaction& addTransactionCompletedCallback(
                TransactionCompletedCallbackTakesContext callback, void* callbackContext);
+3 −1
Original line number Diff line number Diff line
@@ -556,7 +556,9 @@ public:
    void setTransactionState(const Vector<ComposerState>& /*state*/,
                             const Vector<DisplayState>& /*displays*/, uint32_t /*flags*/,
                             const sp<IBinder>& /*applyToken*/,
                             const InputWindowCommands& /*inputWindowCommands*/) override {}
                             const InputWindowCommands& /*inputWindowCommands*/,
                             int64_t /*desiredPresentTime*/) override {}

    void bootFinished() override {}
    bool authenticateSurfaceTexture(
            const sp<IGraphicBufferProducer>& /*surface*/) const override {
Loading