From da1fd1508c914c7f0849e4e00a5fae5412433337 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Mon, 18 Oct 2021 09:36:33 -0700 Subject: SurfaceFlinger: Emit callbacks for non-buffer layer transactions Ensure we emit callbacks if the transaction contains only non-buffer layer state changes. Test: atest SurfaceFlinger_test Fixes: 205183085 Change-Id: I56bf0dcaff4312628fe2cd1d0b93db520518ec54 --- services/surfaceflinger/BufferStateLayer.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'services/surfaceflinger/BufferStateLayer.cpp') diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp index c213570c7f..3e09a40eba 100644 --- a/services/surfaceflinger/BufferStateLayer.cpp +++ b/services/surfaceflinger/BufferStateLayer.cpp @@ -549,13 +549,19 @@ bool BufferStateLayer::setSidebandStream(const sp& sidebandStream) } bool BufferStateLayer::setTransactionCompletedListeners( - const std::vector>& handles) { + const std::vector& listenerCallbacks, const sp& layerHandle) { // If there is no handle, we will not send a callback so reset mReleasePreviousBuffer and return - if (handles.empty()) { + if (listenerCallbacks.empty()) { mReleasePreviousBuffer = false; return false; } + std::vector> handles; + handles.reserve(listenerCallbacks.size()); + for (auto& [listener, callbackIds] : listenerCallbacks) { + handles.emplace_back(new CallbackHandle(listener, callbackIds, layerHandle)); + } + const bool willPresent = willPresentCurrentTransaction(); for (const auto& handle : handles) { @@ -571,9 +577,10 @@ bool BufferStateLayer::setTransactionCompletedListeners( // Store so latched time and release fence can be set mDrawingState.callbackHandles.push_back(handle); - } else { // If this layer will NOT need to be relatched and presented this frame + } else { + // If this layer will NOT need to be relatched and presented this frame // Notify the transaction completed thread this handle is done - mFlinger->getTransactionCallbackInvoker().registerUnpresentedCallbackHandle(handle); + mFlinger->getTransactionCallbackInvoker().addUnpresentedCallbackHandle(handle); } } -- cgit v1.2.3-59-g8ed1b