summaryrefslogtreecommitdiff
path: root/libs/gui/SurfaceComposerClient.cpp
diff options
context:
space:
mode:
author chaviw <chaviw@google.com> 2022-04-25 16:23:44 -0500
committer chaviw <chaviw@google.com> 2022-04-25 16:32:12 -0500
commit1a227f092ae5acc161eee58edd84cbc74356f05f (patch)
tree6163f2f406ee32522dcffef510336504713b3a2d /libs/gui/SurfaceComposerClient.cpp
parentc8c333259715252d81c3c4c28cdf64fd3c148b7b (diff)
Add transaction callback in SurfaceComposerClient::setBuffer
With the current infrastructure, a release callback will not be invoked if there's no transaction callback in the case when a buffer is latched and not released early. This is because the legacy implementation didn't have a release callback and sent releases in the transaction callback. Because of this, we need to make sure to have a transaction callback set up when a buffer is sent in a transaction to ensure the caller gets the release callback, regardless if they set up a transaction callback. Test: android.view.cts.SurfaceControlTest Bug: 230380821 Fixes: 226687688 Fixes: 226463500 Change-Id: Id4d5f4a79c85ae8df02018b3fa1cbdc8b6930931
Diffstat (limited to 'libs/gui/SurfaceComposerClient.cpp')
-rw-r--r--libs/gui/SurfaceComposerClient.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 7a63af0ed3..6642ec6337 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1495,6 +1495,18 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffe
s->bufferData = std::move(bufferData);
registerSurfaceControlForCallback(sc);
+ // With the current infrastructure, a release callback will not be invoked if there's no
+ // transaction callback in the case when a buffer is latched and not released early. This is
+ // because the legacy implementation didn't have a release callback and sent releases in the
+ // transaction callback. Because of this, we need to make sure to have a transaction callback
+ // set up when a buffer is sent in a transaction to ensure the caller gets the release
+ // callback, regardless if they set up a transaction callback.
+ //
+ // TODO (b/230380821): Remove when release callbacks are separated from transaction callbacks
+ addTransactionCompletedCallback([](void*, nsecs_t, const sp<Fence>&,
+ const std::vector<SurfaceControlStats>&) {},
+ nullptr);
+
mContainsBuffer = true;
return *this;
}