summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/Layer.cpp
diff options
context:
space:
mode:
author Patrick Williams <pdwilliams@google.com> 2024-08-21 13:30:38 -0500
committer Patrick Williams <pdwilliams@google.com> 2024-08-26 18:48:28 -0500
commit5ab65e9ef047bc802885396f0e1d960901e86a5c (patch)
tree0267978a2531eb65cb88d2ac755644c2d3d8bc6a /services/surfaceflinger/Layer.cpp
parentd78329b00872d65991e87887df16488e94582bf8 (diff)
Read from BufferReleaseChannel in background thread
Bug: 294133380 Flag: com.android.graphics.libgui.flags.buffer_release_channel Test: BLASTBufferQueueTest Change-Id: I18d2cf5457f615e832352ff9d03729ffe82cf4b9
Diffstat (limited to 'services/surfaceflinger/Layer.cpp')
-rw-r--r--services/surfaceflinger/Layer.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 636f7bdabf..5d6e5ba232 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2529,15 +2529,24 @@ void Layer::cloneDrawingState(const Layer* from) {
void Layer::callReleaseBufferCallback(const sp<ITransactionCompletedListener>& listener,
const sp<GraphicBuffer>& buffer, uint64_t framenumber,
const sp<Fence>& releaseFence) {
- if (!listener) {
+ if (!listener && !mBufferReleaseChannel) {
return;
}
+
SFTRACE_FORMAT_INSTANT("callReleaseBufferCallback %s - %" PRIu64, getDebugName(), framenumber);
+
+ ReleaseCallbackId callbackId{buffer->getId(), framenumber};
+ const sp<Fence>& fence = releaseFence ? releaseFence : Fence::NO_FENCE;
uint32_t currentMaxAcquiredBufferCount =
mFlinger->getMaxAcquiredBufferCountForCurrentRefreshRate(mOwnerUid);
- listener->onReleaseBuffer({buffer->getId(), framenumber},
- releaseFence ? releaseFence : Fence::NO_FENCE,
- currentMaxAcquiredBufferCount);
+
+ if (listener) {
+ listener->onReleaseBuffer(callbackId, fence, currentMaxAcquiredBufferCount);
+ }
+
+ if (mBufferReleaseChannel) {
+ mBufferReleaseChannel->writeReleaseFence(callbackId, fence, currentMaxAcquiredBufferCount);
+ }
}
sp<CallbackHandle> Layer::findCallbackHandle() {
@@ -2655,6 +2664,7 @@ void Layer::onLayerDisplayed(ftl::SharedFuture<FenceResult> futureFenceResult,
void Layer::releasePendingBuffer(nsecs_t dequeueReadyTime) {
for (const auto& handle : mDrawingState.callbackHandles) {
+ handle->bufferReleaseChannel = mBufferReleaseChannel;
handle->transformHint = mTransformHint;
handle->dequeueReadyTime = dequeueReadyTime;
handle->currentMaxAcquiredBufferCount =
@@ -4093,6 +4103,11 @@ bool Layer::setTrustedPresentationInfo(TrustedPresentationThresholds const& thre
return haveTrustedPresentationListener;
}
+void Layer::setBufferReleaseChannel(
+ const std::shared_ptr<gui::BufferReleaseChannel::ProducerEndpoint>& channel) {
+ mBufferReleaseChannel = channel;
+}
+
void Layer::updateLastLatchTime(nsecs_t latchTime) {
mLastLatchTime = latchTime;
}