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

Commit bd0b4058 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "SF: Pass latch time for bufferless surface frames"

parents a8cafbfb 7fe69ede
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -770,7 +770,7 @@ void Layer::transferAvailableJankData(const std::deque<sp<CallbackHandle>>& hand
// transaction
// ----------------------------------------------------------------------------

uint32_t Layer::doTransaction(uint32_t flags) {
uint32_t Layer::doTransaction(uint32_t flags, nsecs_t latchTime) {
    ATRACE_CALL();

    // TODO: This is unfortunate.
@@ -798,23 +798,24 @@ uint32_t Layer::doTransaction(uint32_t flags) {
        mFlinger->mUpdateInputInfo = true;
    }

    commitTransaction(mDrawingState);
    commitTransaction(mDrawingState, latchTime);

    return flags;
}

void Layer::commitTransaction(State&) {
void Layer::commitTransaction(State&, nsecs_t currentLatchTime) {
    // Set the present state for all bufferlessSurfaceFramesTX to Presented. The
    // bufferSurfaceFrameTX will be presented in latchBuffer.
    for (auto& [token, surfaceFrame] : mDrawingState.bufferlessSurfaceFramesTX) {
        if (surfaceFrame->getPresentState() != PresentState::Presented) {
            // With applyPendingStates, we could end up having presented surfaceframes from previous
            // states
            surfaceFrame->setPresentState(PresentState::Presented);
            surfaceFrame->setPresentState(PresentState::Presented, mLastLatchTime);
            mFlinger->mFrameTimeline->addSurfaceFrame(surfaceFrame);
        }
    }
    mDrawingState.bufferlessSurfaceFramesTX.clear();
    mLastLatchTime = currentLatchTime;
}

uint32_t Layer::clearTransactionFlags(uint32_t mask) {
+2 −2
Original line number Diff line number Diff line
@@ -620,7 +620,7 @@ public:
     * doTransaction - process the transaction. This is a good place to figure
     * out which attributes of the surface have changed.
     */
    virtual uint32_t doTransaction(uint32_t transactionFlags);
    virtual uint32_t doTransaction(uint32_t transactionFlags, nsecs_t currentLatchTime);

    /*
     * Remove relative z for the layer if its relative parent is not part of the
@@ -857,7 +857,7 @@ protected:
    void preparePerFrameCompositionState();
    void preparePerFrameBufferCompositionState();
    void preparePerFrameEffectsCompositionState();
    virtual void commitTransaction(State& stateToCommit);
    virtual void commitTransaction(State& stateToCommit, nsecs_t currentLatchTime = 0);
    void gatherBufferInfo();
    void onSurfaceFrameCreated(const std::shared_ptr<frametimeline::SurfaceFrame>&);

+2 −2
Original line number Diff line number Diff line
@@ -3863,7 +3863,7 @@ void SurfaceFlinger::commitOffscreenLayers() {
    for (Layer* offscreenLayer : mOffscreenLayers) {
        offscreenLayer->traverse(LayerVector::StateSet::Drawing, [](Layer* layer) {
            if (layer->clearTransactionFlags(eTransactionNeeded)) {
                layer->doTransaction(0);
                layer->doTransaction(0, 0);
                layer->commitChildList();
            }
        });
@@ -3899,7 +3899,7 @@ bool SurfaceFlinger::latchBuffers() {
    // second frame. But layer 0's second frame could be waiting on display.
    mDrawingState.traverse([&](Layer* layer) {
        if (layer->clearTransactionFlags(eTransactionNeeded) || mForceTransactionDisplayChange) {
            const uint32_t flags = layer->doTransaction(0);
            const uint32_t flags = layer->doTransaction(0, latchTime);
            if (flags & Layer::eVisibleRegion) {
                mVisibleRegionsDirty = true;
            }