Skip to content

Commit 0a1926e

Browse files
Carlos Martinez RomeroAndroid (Google) Code Review
authored andcommitted
Merge "Add addReleaseFence API to ConsumerBase." into main
2 parents e07d8df + 0c9ce84 commit 0a1926e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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)