summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
author Carlos Martinez Romero <carlosmr@google.com> 2025-01-17 09:50:07 -0800
committer Carlos Martinez Romero <carlosmr@google.com> 2025-02-10 13:25:59 -0800
commit0c9ce8436b65a98fec33b3f92bc1acf4481decec (patch)
treea2b9af116ff4868ee5d8274842e4f3d3439c2602 /libs
parent0499b3ecb14538a426104d4622b1c42fbdef106f (diff)
Add addReleaseFence API to ConsumerBase.
This API is used by classes that inherited from ConsumerBase. With the refactor to have an instance intead of inheriting from it this change makes the migration simpler. Although we might remove it later on. More information at go/warren-buffers. Bug: 342197847 Test: build and run Flag: EXEMPT - no behavior change Change-Id: I99da5b1bafae5b0042f8ac1ba5533ca6e5000fe6
Diffstat (limited to 'libs')
-rw-r--r--libs/gui/ConsumerBase.cpp20
-rw-r--r--libs/gui/include/gui/ConsumerBase.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp
index 3ad0e529a5..67de742161 100644
--- a/libs/gui/ConsumerBase.cpp
+++ b/libs/gui/ConsumerBase.cpp
@@ -385,6 +385,26 @@ status_t ConsumerBase::detachBuffer(const sp<GraphicBuffer>& buffer) {
}
#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+status_t ConsumerBase::addReleaseFence(const sp<GraphicBuffer> buffer, const sp<Fence>& fence) {
+ CB_LOGV("addReleaseFence");
+ Mutex::Autolock lock(mMutex);
+
+ if (mAbandoned) {
+ CB_LOGE("addReleaseFence: ConsumerBase is abandoned!");
+ return NO_INIT;
+ }
+ if (buffer == nullptr) {
+ return BAD_VALUE;
+ }
+
+ int slotIndex = getSlotForBufferLocked(buffer);
+ if (slotIndex == BufferQueue::INVALID_BUFFER_SLOT) {
+ return BAD_VALUE;
+ }
+
+ return addReleaseFenceLocked(slotIndex, buffer, fence);
+}
+
status_t ConsumerBase::setDefaultBufferSize(uint32_t width, uint32_t height) {
Mutex::Autolock _l(mMutex);
if (mAbandoned) {
diff --git a/libs/gui/include/gui/ConsumerBase.h b/libs/gui/include/gui/ConsumerBase.h
index acb0006754..2e347c94f5 100644
--- a/libs/gui/include/gui/ConsumerBase.h
+++ b/libs/gui/include/gui/ConsumerBase.h
@@ -98,6 +98,8 @@ public:
status_t detachBuffer(const sp<GraphicBuffer>& buffer);
#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
+ status_t addReleaseFence(const sp<GraphicBuffer> buffer, const sp<Fence>& fence);
+
// See IGraphicBufferConsumer::setDefaultBufferSize
status_t setDefaultBufferSize(uint32_t width, uint32_t height);