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

Commit 52846cd8 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Blast: Fix missing release callbacks for shared buffers

Fixes an issue where buffers were compared only using the buffer id.
In shared buffer mode, the client will queue up the same buffer id
multiple times so we need to distinguish using the frame number as
well.

Test: https://buganizer.corp.google.com/issues/195447981#comment18
Fixes: 195447981
Change-Id: I2a2d02a0d7e67ee9577857a210cb6157683e5598
parent cebf2e6c
Loading
Loading
Loading
Loading
+2 −17
Original line number Original line Diff line number Diff line
@@ -425,7 +425,8 @@ bool BufferStateLayer::setBuffer(const std::shared_ptr<renderengine::ExternalTex


    if (mDrawingState.buffer) {
    if (mDrawingState.buffer) {
        mReleasePreviousBuffer = true;
        mReleasePreviousBuffer = true;
        if (mDrawingState.buffer != mBufferInfo.mBuffer) {
        if (mDrawingState.buffer != mBufferInfo.mBuffer ||
            mDrawingState.frameNumber != mBufferInfo.mFrameNumber) {
            // If mDrawingState has a buffer, and we are about to update again
            // If mDrawingState has a buffer, and we are about to update again
            // before swapping to drawing state, then the first buffer will be
            // before swapping to drawing state, then the first buffer will be
            // dropped and we should decrement the pending buffer count and
            // dropped and we should decrement the pending buffer count and
@@ -963,22 +964,6 @@ void BufferStateLayer::tracePendingBufferCount(int32_t pendingBuffers) {
    ATRACE_INT(mBlastTransactionName.c_str(), pendingBuffers);
    ATRACE_INT(mBlastTransactionName.c_str(), pendingBuffers);
}
}


void BufferStateLayer::bufferMayChange(const sp<GraphicBuffer>& newBuffer) {
    if (mDrawingState.buffer != nullptr &&
        (!mBufferInfo.mBuffer ||
         mDrawingState.buffer->getBuffer() != mBufferInfo.mBuffer->getBuffer()) &&
        newBuffer != mDrawingState.buffer->getBuffer()) {
        // If we are about to update mDrawingState.buffer but it has not yet latched
        // then we will drop a buffer and should decrement the pending buffer count and
        // call any release buffer callbacks if set.
        callReleaseBufferCallback(mDrawingState.releaseBufferListener,
                                  mDrawingState.buffer->getBuffer(), mDrawingState.frameNumber,
                                  mDrawingState.acquireFence, mTransformHint,
                                  mFlinger->getMaxAcquiredBufferCountForCurrentRefreshRate(
                                          mOwnerUid));
        decrementPendingBufferCount();
    }
}


/*
/*
 * We don't want to send the layer's transform to input, but rather the
 * We don't want to send the layer's transform to input, but rather the
+0 −1
Original line number Original line Diff line number Diff line
@@ -97,7 +97,6 @@ public:


    // See mPendingBufferTransactions
    // See mPendingBufferTransactions
    void decrementPendingBufferCount();
    void decrementPendingBufferCount();
    void bufferMayChange(const sp<GraphicBuffer>& newBuffer) override;
    std::atomic<int32_t>* getPendingBufferCounter() override { return &mPendingBufferTransactions; }
    std::atomic<int32_t>* getPendingBufferCounter() override { return &mPendingBufferTransactions; }
    std::string getPendingBufferCounterName() override { return mBlastTransactionName; }
    std::string getPendingBufferCounterName() override { return mBlastTransactionName; }


+0 −6
Original line number Original line Diff line number Diff line
@@ -702,12 +702,6 @@ public:
     */
     */
    virtual uint32_t doTransaction(uint32_t transactionFlags);
    virtual uint32_t doTransaction(uint32_t transactionFlags);


    /*
     * Called before updating the drawing state buffer. Used by BufferStateLayer to release any
     * unlatched buffers in the drawing state.
     */
    virtual void bufferMayChange(const sp<GraphicBuffer>& /* newBuffer */){};

    /*
    /*
     * Remove relative z for the layer if its relative parent is not part of the
     * Remove relative z for the layer if its relative parent is not part of the
     * provided layer tree.
     * provided layer tree.