Loading libs/gui/BLASTBufferQueue.cpp +21 −10 Original line number Diff line number Diff line Loading @@ -213,12 +213,9 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { ATRACE_CALL(); BQA_LOGV("processNextBufferLocked useNextTransaction=%s", toString(useNextTransaction)); // Wait to acquire a buffer if there are no frames available or we have acquired the maximum // Wait to acquire a buffer if there are no frames available or we have acquired the max // number of buffers. // As a special case, we wait for the first callback before acquiring the second buffer so we // can ensure the first buffer is presented if multiple buffers are queued in succession. if (mNumFrameAvailable == 0 || mNumAcquired == MAX_ACQUIRED_BUFFERS + 1 || (!mInitialCallbackReceived && mNumAcquired == 1)) { if (mNumFrameAvailable == 0 || maxBuffersAcquired()) { BQA_LOGV("processNextBufferLocked waiting for frame available or callback"); return; } Loading @@ -241,6 +238,7 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { status_t status = mBufferItemConsumer->acquireBuffer(&bufferItem, -1, false); if (status != OK) { BQA_LOGE("Failed to acquire a buffer, err=%s", statusToString(status).c_str()); return; } auto buffer = bufferItem.mGraphicBuffer; Loading @@ -248,14 +246,15 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { if (buffer == nullptr) { mBufferItemConsumer->releaseBuffer(bufferItem, Fence::NO_FENCE); BQA_LOGE("Buffer was empty"); return; } if (rejectBuffer(bufferItem)) { BQA_LOGE("rejecting buffer:configured size=%dx%d, buffer{size=%dx%d transform=%d}", mWidth, mHeight, buffer->getWidth(), buffer->getHeight(), bufferItem.mTransform); mBufferItemConsumer->releaseBuffer(bufferItem, Fence::NO_FENCE); return; // TODO(b/168917217) temporarily don't reject buffers until we can synchronize buffer size // changes from ViewRootImpl. } mNumAcquired++; Loading Loading @@ -307,13 +306,16 @@ void BLASTBufferQueue::onFrameAvailable(const BufferItem& /*item*/) { std::unique_lock _lock{mMutex}; 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) { while (mNumFrameAvailable > 0 || mNumAcquired == MAX_ACQUIRED_BUFFERS + 1) { if (nextTransactionSet || mFlushShadowQueue) { while (mNumFrameAvailable > 0 || maxBuffersAcquired()) { BQA_LOGV("waiting in onFrameAvailable..."); mCallbackCV.wait(_lock); } } mFlushShadowQueue = false; // add to shadow queue mNumFrameAvailable++; processNextBufferLocked(true); Loading Loading @@ -341,4 +343,13 @@ bool BLASTBufferQueue::rejectBuffer(const BufferItem& item) const { // reject buffers if the buffer size doesn't match. return bufWidth != mWidth || bufHeight != mHeight; } // Check if we have acquired the maximum number of buffers. // As a special case, we wait for the first callback before acquiring the second buffer so we // can ensure the first buffer is presented if multiple buffers are queued in succession. bool BLASTBufferQueue::maxBuffersAcquired() const { return mNumAcquired == MAX_ACQUIRED_BUFFERS + 1 || (!mInitialCallbackReceived && mNumAcquired == 1); } } // namespace android libs/gui/include/gui/BLASTBufferQueue.h +7 −2 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ public: void setNextTransaction(SurfaceComposerClient::Transaction *t); void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height); void flushShadowQueue() { mFlushShadowQueue = true; } virtual ~BLASTBufferQueue() = default; Loading @@ -93,9 +94,10 @@ private: BLASTBufferQueue(const BLASTBufferQueue& rhs); void processNextBufferLocked(bool useNextTransaction) REQUIRES(mMutex); Rect computeCrop(const BufferItem& item); Rect computeCrop(const BufferItem& item) REQUIRES(mMutex); // Return true if we need to reject the buffer based on the scaling mode and the buffer size. bool rejectBuffer(const BufferItem& item) const; bool rejectBuffer(const BufferItem& item) const REQUIRES(mMutex); bool maxBuffersAcquired() const REQUIRES(mMutex); std::string mName; sp<SurfaceControl> mSurfaceControl; Loading Loading @@ -130,6 +132,9 @@ private: sp<BLASTBufferItemConsumer> mBufferItemConsumer; 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 Loading Loading
libs/gui/BLASTBufferQueue.cpp +21 −10 Original line number Diff line number Diff line Loading @@ -213,12 +213,9 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { ATRACE_CALL(); BQA_LOGV("processNextBufferLocked useNextTransaction=%s", toString(useNextTransaction)); // Wait to acquire a buffer if there are no frames available or we have acquired the maximum // Wait to acquire a buffer if there are no frames available or we have acquired the max // number of buffers. // As a special case, we wait for the first callback before acquiring the second buffer so we // can ensure the first buffer is presented if multiple buffers are queued in succession. if (mNumFrameAvailable == 0 || mNumAcquired == MAX_ACQUIRED_BUFFERS + 1 || (!mInitialCallbackReceived && mNumAcquired == 1)) { if (mNumFrameAvailable == 0 || maxBuffersAcquired()) { BQA_LOGV("processNextBufferLocked waiting for frame available or callback"); return; } Loading @@ -241,6 +238,7 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { status_t status = mBufferItemConsumer->acquireBuffer(&bufferItem, -1, false); if (status != OK) { BQA_LOGE("Failed to acquire a buffer, err=%s", statusToString(status).c_str()); return; } auto buffer = bufferItem.mGraphicBuffer; Loading @@ -248,14 +246,15 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { if (buffer == nullptr) { mBufferItemConsumer->releaseBuffer(bufferItem, Fence::NO_FENCE); BQA_LOGE("Buffer was empty"); return; } if (rejectBuffer(bufferItem)) { BQA_LOGE("rejecting buffer:configured size=%dx%d, buffer{size=%dx%d transform=%d}", mWidth, mHeight, buffer->getWidth(), buffer->getHeight(), bufferItem.mTransform); mBufferItemConsumer->releaseBuffer(bufferItem, Fence::NO_FENCE); return; // TODO(b/168917217) temporarily don't reject buffers until we can synchronize buffer size // changes from ViewRootImpl. } mNumAcquired++; Loading Loading @@ -307,13 +306,16 @@ void BLASTBufferQueue::onFrameAvailable(const BufferItem& /*item*/) { std::unique_lock _lock{mMutex}; 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) { while (mNumFrameAvailable > 0 || mNumAcquired == MAX_ACQUIRED_BUFFERS + 1) { if (nextTransactionSet || mFlushShadowQueue) { while (mNumFrameAvailable > 0 || maxBuffersAcquired()) { BQA_LOGV("waiting in onFrameAvailable..."); mCallbackCV.wait(_lock); } } mFlushShadowQueue = false; // add to shadow queue mNumFrameAvailable++; processNextBufferLocked(true); Loading Loading @@ -341,4 +343,13 @@ bool BLASTBufferQueue::rejectBuffer(const BufferItem& item) const { // reject buffers if the buffer size doesn't match. return bufWidth != mWidth || bufHeight != mHeight; } // Check if we have acquired the maximum number of buffers. // As a special case, we wait for the first callback before acquiring the second buffer so we // can ensure the first buffer is presented if multiple buffers are queued in succession. bool BLASTBufferQueue::maxBuffersAcquired() const { return mNumAcquired == MAX_ACQUIRED_BUFFERS + 1 || (!mInitialCallbackReceived && mNumAcquired == 1); } } // namespace android
libs/gui/include/gui/BLASTBufferQueue.h +7 −2 Original line number Diff line number Diff line Loading @@ -82,6 +82,7 @@ public: void setNextTransaction(SurfaceComposerClient::Transaction *t); void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height); void flushShadowQueue() { mFlushShadowQueue = true; } virtual ~BLASTBufferQueue() = default; Loading @@ -93,9 +94,10 @@ private: BLASTBufferQueue(const BLASTBufferQueue& rhs); void processNextBufferLocked(bool useNextTransaction) REQUIRES(mMutex); Rect computeCrop(const BufferItem& item); Rect computeCrop(const BufferItem& item) REQUIRES(mMutex); // Return true if we need to reject the buffer based on the scaling mode and the buffer size. bool rejectBuffer(const BufferItem& item) const; bool rejectBuffer(const BufferItem& item) const REQUIRES(mMutex); bool maxBuffersAcquired() const REQUIRES(mMutex); std::string mName; sp<SurfaceControl> mSurfaceControl; Loading Loading @@ -130,6 +132,9 @@ private: sp<BLASTBufferItemConsumer> mBufferItemConsumer; 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 Loading