Skip to content

Commit 0c9ce84

Browse files
author
Carlos Martinez Romero
committed
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
1 parent 0499b3e commit 0c9ce84

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

libs/gui/ConsumerBase.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,26 @@ status_t ConsumerBase::detachBuffer(const sp<GraphicBuffer>& buffer) {
385385
}
386386
#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
387387

388+
status_t ConsumerBase::addReleaseFence(const sp<GraphicBuffer> buffer, const sp<Fence>& fence) {
389+
CB_LOGV("addReleaseFence");
390+
Mutex::Autolock lock(mMutex);
391+
392+
if (mAbandoned) {
393+
CB_LOGE("addReleaseFence: ConsumerBase is abandoned!");
394+
return NO_INIT;
395+
}
396+
if (buffer == nullptr) {
397+
return BAD_VALUE;
398+
}
399+
400+
int slotIndex = getSlotForBufferLocked(buffer);
401+
if (slotIndex == BufferQueue::INVALID_BUFFER_SLOT) {
402+
return BAD_VALUE;
403+
}
404+
405+
return addReleaseFenceLocked(slotIndex, buffer, fence);
406+
}
407+
388408
status_t ConsumerBase::setDefaultBufferSize(uint32_t width, uint32_t height) {
389409
Mutex::Autolock _l(mMutex);
390410
if (mAbandoned) {

libs/gui/include/gui/ConsumerBase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ class ConsumerBase : public virtual RefBase,
9898
status_t detachBuffer(const sp<GraphicBuffer>& buffer);
9999
#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
100100

101+
status_t addReleaseFence(const sp<GraphicBuffer> buffer, const sp<Fence>& fence);
102+
101103
// See IGraphicBufferConsumer::setDefaultBufferSize
102104
status_t setDefaultBufferSize(uint32_t width, uint32_t height);
103105

0 commit comments

Comments
 (0)