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

Commit 7eb670ae authored by Vishnu Nair's avatar Vishnu Nair
Browse files

BlastBufferQueue: Add a function to flush the shadow queue

If the function is called, the next queue buffer will wait until the
the adapter processes the previously queued buffers.

Test: enable blast and test split screen resize
Change-Id: Ica9b3be9459dd174a7e80311abddb691976e83e3
parent b71253ec
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -254,8 +254,8 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) {
    if (rejectBuffer(bufferItem)) {
    if (rejectBuffer(bufferItem)) {
        BQA_LOGE("rejecting buffer:configured size=%dx%d, buffer{size=%dx%d transform=%d}", mWidth,
        BQA_LOGE("rejecting buffer:configured size=%dx%d, buffer{size=%dx%d transform=%d}", mWidth,
                 mHeight, buffer->getWidth(), buffer->getHeight(), bufferItem.mTransform);
                 mHeight, buffer->getWidth(), buffer->getHeight(), bufferItem.mTransform);
        mBufferItemConsumer->releaseBuffer(bufferItem, Fence::NO_FENCE);
        // TODO(b/168917217) temporarily don't reject buffers until we can synchronize buffer size
        return;
        // changes from ViewRootImpl.
    }
    }


    mNumAcquired++;
    mNumAcquired++;
@@ -307,13 +307,16 @@ void BLASTBufferQueue::onFrameAvailable(const BufferItem& /*item*/) {
    std::unique_lock _lock{mMutex};
    std::unique_lock _lock{mMutex};


    const bool nextTransactionSet = mNextTransaction != nullptr;
    const bool nextTransactionSet = mNextTransaction != nullptr;
    BQA_LOGV("onFrameAvailable nextTransactionSet=%s", toString(nextTransactionSet));
    BQA_LOGV("onFrameAvailable nextTransactionSet=%s mFlushShadowQueue=%s",
             toString(nextTransactionSet), toString(mFlushShadowQueue));


    if (nextTransactionSet) {
    if (nextTransactionSet || mFlushShadowQueue) {
        while (mNumFrameAvailable > 0 || mNumAcquired == MAX_ACQUIRED_BUFFERS + 1) {
        while (mNumFrameAvailable > 0 || mNumAcquired == MAX_ACQUIRED_BUFFERS + 1) {
            BQA_LOGV("waiting in onFrameAvailable...");
            mCallbackCV.wait(_lock);
            mCallbackCV.wait(_lock);
        }
        }
    }
    }
    mFlushShadowQueue = false;
    // add to shadow queue
    // add to shadow queue
    mNumFrameAvailable++;
    mNumFrameAvailable++;
    processNextBufferLocked(true);
    processNextBufferLocked(true);
+4 −0
Original line number Original line Diff line number Diff line
@@ -82,6 +82,7 @@ public:
    void setNextTransaction(SurfaceComposerClient::Transaction *t);
    void setNextTransaction(SurfaceComposerClient::Transaction *t);


    void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height);
    void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height);
    void flushShadowQueue() { mFlushShadowQueue = true; }


    virtual ~BLASTBufferQueue() = default;
    virtual ~BLASTBufferQueue() = default;


@@ -130,6 +131,9 @@ private:
    sp<BLASTBufferItemConsumer> mBufferItemConsumer;
    sp<BLASTBufferItemConsumer> mBufferItemConsumer;


    SurfaceComposerClient::Transaction* mNextTransaction GUARDED_BY(mMutex);
    SurfaceComposerClient::Transaction* mNextTransaction GUARDED_BY(mMutex);
    // If set to true, the next queue buffer will wait until the shadow queue has been processed by
    // the adapter.
    bool mFlushShadowQueue = false;
};
};


} // namespace android
} // namespace android