Loading libs/gui/BLASTBufferQueue.cpp +0 −30 Original line number Diff line number Diff line Loading @@ -319,9 +319,6 @@ static void transactionCallbackThunk(void* context, nsecs_t latchTime, void BLASTBufferQueue::transactionCallback(nsecs_t /*latchTime*/, const sp<Fence>& /*presentFence*/, const std::vector<SurfaceControlStats>& stats) { std::function<void(int64_t)> transactionCompleteCallback = nullptr; uint64_t currFrameNumber = 0; { std::unique_lock _lock{mMutex}; ATRACE_CALL(); Loading @@ -348,18 +345,6 @@ void BLASTBufferQueue::transactionCallback(nsecs_t /*latchTime*/, const sp<Fence stat.latchTime, stat.frameEventStats.dequeueReadyTime); } currFrameNumber = stat.frameEventStats.frameNumber; if (mTransactionCompleteCallback && currFrameNumber >= mTransactionCompleteFrameNumber) { if (currFrameNumber > mTransactionCompleteFrameNumber) { BQA_LOGE("transactionCallback received for a newer framenumber=%" PRIu64 " than expected=%" PRIu64, currFrameNumber, mTransactionCompleteFrameNumber); } transactionCompleteCallback = std::move(mTransactionCompleteCallback); mTransactionCompleteFrameNumber = 0; } } else { BQA_LOGE("Failed to find matching SurfaceControl in transaction callback"); } Loading @@ -370,10 +355,6 @@ void BLASTBufferQueue::transactionCallback(nsecs_t /*latchTime*/, const sp<Fence decStrong((void*)transactionCallbackThunk); } if (transactionCompleteCallback) { transactionCompleteCallback(currFrameNumber); } } // Unlike transactionCallbackThunk the release buffer callback does not extend the life of the Loading Loading @@ -698,17 +679,6 @@ bool BLASTBufferQueue::rejectBuffer(const BufferItem& item) { return mSize != bufferSize; } void BLASTBufferQueue::setTransactionCompleteCallback( uint64_t frameNumber, std::function<void(int64_t)>&& transactionCompleteCallback) { std::lock_guard _lock{mMutex}; if (transactionCompleteCallback == nullptr) { mTransactionCompleteCallback = nullptr; } else { mTransactionCompleteCallback = std::move(transactionCompleteCallback); mTransactionCompleteFrameNumber = frameNumber; } } // Check if we have acquired the maximum number of buffers. // Consumer can acquire an additional buffer if that buffer is not droppable. Set // includeExtraAcquire is true to include this buffer to the count. Since this depends on the state Loading libs/gui/include/gui/BLASTBufferQueue.h +2 −7 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public: void onFrameDequeued(const uint64_t) override; void onFrameCancelled(const uint64_t) override; void transactionCommittedCallback(nsecs_t latchTime, const sp<Fence>& presentFence, virtual void transactionCommittedCallback(nsecs_t latchTime, const sp<Fence>& presentFence, const std::vector<SurfaceControlStats>& stats); void transactionCallback(nsecs_t latchTime, const sp<Fence>& presentFence, const std::vector<SurfaceControlStats>& stats); Loading @@ -97,8 +97,6 @@ public: void setNextTransaction(SurfaceComposerClient::Transaction *t); void mergeWithNextTransaction(SurfaceComposerClient::Transaction* t, uint64_t frameNumber); void applyPendingTransactions(uint64_t frameNumber); void setTransactionCompleteCallback(uint64_t frameNumber, std::function<void(int64_t)>&& transactionCompleteCallback); void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height, int32_t format, SurfaceComposerClient::Transaction* outTransaction = nullptr); Loading Loading @@ -224,9 +222,6 @@ private: // Tracks the last acquired frame number uint64_t mLastAcquiredFrameNumber GUARDED_BY(mMutex) = 0; std::function<void(int64_t)> mTransactionCompleteCallback GUARDED_BY(mMutex) = nullptr; uint64_t mTransactionCompleteFrameNumber GUARDED_BY(mMutex){0}; // Queues up transactions using this token in SurfaceFlinger. This prevents queued up // transactions from other parts of the client from blocking this transaction. const sp<IBinder> mApplyToken GUARDED_BY(mMutex) = new BBinder(); Loading libs/gui/tests/BLASTBufferQueue_test.cpp +37 −23 Original line number Diff line number Diff line Loading @@ -66,11 +66,44 @@ private: int32_t mNumReleased GUARDED_BY(mMutex) = 0; }; class TestBLASTBufferQueue : public BLASTBufferQueue { public: TestBLASTBufferQueue(const std::string& name, const sp<SurfaceControl>& surface, int width, int height, int32_t format) : BLASTBufferQueue(name, surface, width, height, format) {} void transactionCommittedCallback(nsecs_t latchTime, const sp<Fence>& presentFence, const std::vector<SurfaceControlStats>& stats) override { BLASTBufferQueue::transactionCommittedCallback(latchTime, presentFence, stats); uint64_t frameNumber = stats[0].frameEventStats.frameNumber; { std::unique_lock lock{frameNumberMutex}; mLastTransactionCommittedFrameNumber = frameNumber; mCommittedCV.notify_all(); } } void waitForCallback(int64_t frameNumber) { std::unique_lock lock{frameNumberMutex}; // Wait until all but one of the submitted buffers have been released. while (mLastTransactionCommittedFrameNumber < frameNumber) { mCommittedCV.wait(lock); } } private: std::mutex frameNumberMutex; std::condition_variable mCommittedCV; int64_t mLastTransactionCommittedFrameNumber = -1; }; class BLASTBufferQueueHelper { public: BLASTBufferQueueHelper(const sp<SurfaceControl>& sc, int width, int height) { mBlastBufferQueueAdapter = new BLASTBufferQueue("TestBLASTBufferQueue", sc, width, height, PIXEL_FORMAT_RGBA_8888); mBlastBufferQueueAdapter = new TestBLASTBufferQueue("TestBLASTBufferQueue", sc, width, height, PIXEL_FORMAT_RGBA_8888); } void update(const sp<SurfaceControl>& sc, int width, int height) { Loading Loading @@ -107,28 +140,12 @@ public: } } void setTransactionCompleteCallback(int64_t frameNumber) { mBlastBufferQueueAdapter->setTransactionCompleteCallback(frameNumber, [&](int64_t frame) { std::unique_lock lock{mMutex}; mLastTransactionCompleteFrameNumber = frame; mCallbackCV.notify_all(); }); } void waitForCallback(int64_t frameNumber) { std::unique_lock lock{mMutex}; // Wait until all but one of the submitted buffers have been released. while (mLastTransactionCompleteFrameNumber < frameNumber) { mCallbackCV.wait(lock); } mBlastBufferQueueAdapter->waitForCallback(frameNumber); } private: sp<BLASTBufferQueue> mBlastBufferQueueAdapter; std::mutex mMutex; std::condition_variable mCallbackCV; int64_t mLastTransactionCompleteFrameNumber = -1; sp<TestBLASTBufferQueue> mBlastBufferQueueAdapter; }; class BLASTBufferQueueTest : public ::testing::Test { Loading Loading @@ -1366,7 +1383,6 @@ TEST_F(BLASTFrameEventHistoryTest, FrameEventHistory_Basic) { IGraphicBufferProducer::QueueBufferOutput qbOutput; nsecs_t requestedPresentTimeA = 0; nsecs_t postedTimeA = 0; adapter.setTransactionCompleteCallback(1); setUpAndQueueBuffer(igbProducer, &requestedPresentTimeA, &postedTimeA, &qbOutput, true); history.applyDelta(qbOutput.frameTimestamps); Loading Loading @@ -1435,7 +1451,6 @@ TEST_F(BLASTFrameEventHistoryTest, FrameEventHistory_DroppedFrame) { // queue another buffer so the first can be dropped nsecs_t requestedPresentTimeB = 0; nsecs_t postedTimeB = 0; adapter.setTransactionCompleteCallback(2); presentTime = systemTime() + std::chrono::nanoseconds(1ms).count(); setUpAndQueueBuffer(igbProducer, &requestedPresentTimeB, &postedTimeB, &qbOutput, true, presentTime); Loading Loading @@ -1501,7 +1516,6 @@ TEST_F(BLASTFrameEventHistoryTest, FrameEventHistory_CompositorTimings) { IGraphicBufferProducer::QueueBufferOutput qbOutput; nsecs_t requestedPresentTimeA = 0; nsecs_t postedTimeA = 0; adapter.setTransactionCompleteCallback(1); setUpAndQueueBuffer(igbProducer, &requestedPresentTimeA, &postedTimeA, &qbOutput, true); history.applyDelta(qbOutput.frameTimestamps); adapter.waitForCallback(1); Loading Loading
libs/gui/BLASTBufferQueue.cpp +0 −30 Original line number Diff line number Diff line Loading @@ -319,9 +319,6 @@ static void transactionCallbackThunk(void* context, nsecs_t latchTime, void BLASTBufferQueue::transactionCallback(nsecs_t /*latchTime*/, const sp<Fence>& /*presentFence*/, const std::vector<SurfaceControlStats>& stats) { std::function<void(int64_t)> transactionCompleteCallback = nullptr; uint64_t currFrameNumber = 0; { std::unique_lock _lock{mMutex}; ATRACE_CALL(); Loading @@ -348,18 +345,6 @@ void BLASTBufferQueue::transactionCallback(nsecs_t /*latchTime*/, const sp<Fence stat.latchTime, stat.frameEventStats.dequeueReadyTime); } currFrameNumber = stat.frameEventStats.frameNumber; if (mTransactionCompleteCallback && currFrameNumber >= mTransactionCompleteFrameNumber) { if (currFrameNumber > mTransactionCompleteFrameNumber) { BQA_LOGE("transactionCallback received for a newer framenumber=%" PRIu64 " than expected=%" PRIu64, currFrameNumber, mTransactionCompleteFrameNumber); } transactionCompleteCallback = std::move(mTransactionCompleteCallback); mTransactionCompleteFrameNumber = 0; } } else { BQA_LOGE("Failed to find matching SurfaceControl in transaction callback"); } Loading @@ -370,10 +355,6 @@ void BLASTBufferQueue::transactionCallback(nsecs_t /*latchTime*/, const sp<Fence decStrong((void*)transactionCallbackThunk); } if (transactionCompleteCallback) { transactionCompleteCallback(currFrameNumber); } } // Unlike transactionCallbackThunk the release buffer callback does not extend the life of the Loading Loading @@ -698,17 +679,6 @@ bool BLASTBufferQueue::rejectBuffer(const BufferItem& item) { return mSize != bufferSize; } void BLASTBufferQueue::setTransactionCompleteCallback( uint64_t frameNumber, std::function<void(int64_t)>&& transactionCompleteCallback) { std::lock_guard _lock{mMutex}; if (transactionCompleteCallback == nullptr) { mTransactionCompleteCallback = nullptr; } else { mTransactionCompleteCallback = std::move(transactionCompleteCallback); mTransactionCompleteFrameNumber = frameNumber; } } // Check if we have acquired the maximum number of buffers. // Consumer can acquire an additional buffer if that buffer is not droppable. Set // includeExtraAcquire is true to include this buffer to the count. Since this depends on the state Loading
libs/gui/include/gui/BLASTBufferQueue.h +2 −7 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public: void onFrameDequeued(const uint64_t) override; void onFrameCancelled(const uint64_t) override; void transactionCommittedCallback(nsecs_t latchTime, const sp<Fence>& presentFence, virtual void transactionCommittedCallback(nsecs_t latchTime, const sp<Fence>& presentFence, const std::vector<SurfaceControlStats>& stats); void transactionCallback(nsecs_t latchTime, const sp<Fence>& presentFence, const std::vector<SurfaceControlStats>& stats); Loading @@ -97,8 +97,6 @@ public: void setNextTransaction(SurfaceComposerClient::Transaction *t); void mergeWithNextTransaction(SurfaceComposerClient::Transaction* t, uint64_t frameNumber); void applyPendingTransactions(uint64_t frameNumber); void setTransactionCompleteCallback(uint64_t frameNumber, std::function<void(int64_t)>&& transactionCompleteCallback); void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height, int32_t format, SurfaceComposerClient::Transaction* outTransaction = nullptr); Loading Loading @@ -224,9 +222,6 @@ private: // Tracks the last acquired frame number uint64_t mLastAcquiredFrameNumber GUARDED_BY(mMutex) = 0; std::function<void(int64_t)> mTransactionCompleteCallback GUARDED_BY(mMutex) = nullptr; uint64_t mTransactionCompleteFrameNumber GUARDED_BY(mMutex){0}; // Queues up transactions using this token in SurfaceFlinger. This prevents queued up // transactions from other parts of the client from blocking this transaction. const sp<IBinder> mApplyToken GUARDED_BY(mMutex) = new BBinder(); Loading
libs/gui/tests/BLASTBufferQueue_test.cpp +37 −23 Original line number Diff line number Diff line Loading @@ -66,11 +66,44 @@ private: int32_t mNumReleased GUARDED_BY(mMutex) = 0; }; class TestBLASTBufferQueue : public BLASTBufferQueue { public: TestBLASTBufferQueue(const std::string& name, const sp<SurfaceControl>& surface, int width, int height, int32_t format) : BLASTBufferQueue(name, surface, width, height, format) {} void transactionCommittedCallback(nsecs_t latchTime, const sp<Fence>& presentFence, const std::vector<SurfaceControlStats>& stats) override { BLASTBufferQueue::transactionCommittedCallback(latchTime, presentFence, stats); uint64_t frameNumber = stats[0].frameEventStats.frameNumber; { std::unique_lock lock{frameNumberMutex}; mLastTransactionCommittedFrameNumber = frameNumber; mCommittedCV.notify_all(); } } void waitForCallback(int64_t frameNumber) { std::unique_lock lock{frameNumberMutex}; // Wait until all but one of the submitted buffers have been released. while (mLastTransactionCommittedFrameNumber < frameNumber) { mCommittedCV.wait(lock); } } private: std::mutex frameNumberMutex; std::condition_variable mCommittedCV; int64_t mLastTransactionCommittedFrameNumber = -1; }; class BLASTBufferQueueHelper { public: BLASTBufferQueueHelper(const sp<SurfaceControl>& sc, int width, int height) { mBlastBufferQueueAdapter = new BLASTBufferQueue("TestBLASTBufferQueue", sc, width, height, PIXEL_FORMAT_RGBA_8888); mBlastBufferQueueAdapter = new TestBLASTBufferQueue("TestBLASTBufferQueue", sc, width, height, PIXEL_FORMAT_RGBA_8888); } void update(const sp<SurfaceControl>& sc, int width, int height) { Loading Loading @@ -107,28 +140,12 @@ public: } } void setTransactionCompleteCallback(int64_t frameNumber) { mBlastBufferQueueAdapter->setTransactionCompleteCallback(frameNumber, [&](int64_t frame) { std::unique_lock lock{mMutex}; mLastTransactionCompleteFrameNumber = frame; mCallbackCV.notify_all(); }); } void waitForCallback(int64_t frameNumber) { std::unique_lock lock{mMutex}; // Wait until all but one of the submitted buffers have been released. while (mLastTransactionCompleteFrameNumber < frameNumber) { mCallbackCV.wait(lock); } mBlastBufferQueueAdapter->waitForCallback(frameNumber); } private: sp<BLASTBufferQueue> mBlastBufferQueueAdapter; std::mutex mMutex; std::condition_variable mCallbackCV; int64_t mLastTransactionCompleteFrameNumber = -1; sp<TestBLASTBufferQueue> mBlastBufferQueueAdapter; }; class BLASTBufferQueueTest : public ::testing::Test { Loading Loading @@ -1366,7 +1383,6 @@ TEST_F(BLASTFrameEventHistoryTest, FrameEventHistory_Basic) { IGraphicBufferProducer::QueueBufferOutput qbOutput; nsecs_t requestedPresentTimeA = 0; nsecs_t postedTimeA = 0; adapter.setTransactionCompleteCallback(1); setUpAndQueueBuffer(igbProducer, &requestedPresentTimeA, &postedTimeA, &qbOutput, true); history.applyDelta(qbOutput.frameTimestamps); Loading Loading @@ -1435,7 +1451,6 @@ TEST_F(BLASTFrameEventHistoryTest, FrameEventHistory_DroppedFrame) { // queue another buffer so the first can be dropped nsecs_t requestedPresentTimeB = 0; nsecs_t postedTimeB = 0; adapter.setTransactionCompleteCallback(2); presentTime = systemTime() + std::chrono::nanoseconds(1ms).count(); setUpAndQueueBuffer(igbProducer, &requestedPresentTimeB, &postedTimeB, &qbOutput, true, presentTime); Loading Loading @@ -1501,7 +1516,6 @@ TEST_F(BLASTFrameEventHistoryTest, FrameEventHistory_CompositorTimings) { IGraphicBufferProducer::QueueBufferOutput qbOutput; nsecs_t requestedPresentTimeA = 0; nsecs_t postedTimeA = 0; adapter.setTransactionCompleteCallback(1); setUpAndQueueBuffer(igbProducer, &requestedPresentTimeA, &postedTimeA, &qbOutput, true); history.applyDelta(qbOutput.frameTimestamps); adapter.waitForCallback(1); Loading