summaryrefslogtreecommitdiff
path: root/libs/gui/BufferItemConsumer.cpp
diff options
context:
space:
mode:
author Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2025-03-11 16:19:44 -0700
committer Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2025-03-11 16:19:44 -0700
commitc2f7802cfa3094070ee44dc904ef2baedd20ee1f (patch)
treef00a08aab90303311c42e45e8bf80d5a5edadff6 /libs/gui/BufferItemConsumer.cpp
parenta07104434563d8a7ed9793076df233d68f65b036 (diff)
parent2e6071117a048dafe2eeb03d59d2b6adec371c35 (diff)
Snap for 13197820 from 2e6071117a048dafe2eeb03d59d2b6adec371c35 to 25Q2-release
Change-Id: Ibb999ef775ccef8a56f7793f8c5b6e44b6c4fb97
Diffstat (limited to 'libs/gui/BufferItemConsumer.cpp')
-rw-r--r--libs/gui/BufferItemConsumer.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/libs/gui/BufferItemConsumer.cpp b/libs/gui/BufferItemConsumer.cpp
index 1585aae45c..4926ceb619 100644
--- a/libs/gui/BufferItemConsumer.cpp
+++ b/libs/gui/BufferItemConsumer.cpp
@@ -17,6 +17,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "BufferItemConsumer"
//#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <utils/Errors.h>
#include <utils/Log.h>
#include <inttypes.h>
@@ -132,13 +133,36 @@ status_t BufferItemConsumer::acquireBuffer(BufferItem *item,
return OK;
}
+status_t BufferItemConsumer::attachBuffer(const sp<GraphicBuffer>& buffer) {
+ if (!buffer) {
+ BI_LOGE("BufferItemConsumer::attachBuffer no input buffer specified.");
+ return BAD_VALUE;
+ }
+
+ Mutex::Autolock _l(mMutex);
+
+ int slot = INVALID_BUFFER_SLOT;
+ status_t status = mConsumer->attachBuffer(&slot, buffer);
+ if (status != OK) {
+ BI_LOGE("BufferItemConsumer::attachBuffer unable to attach buffer %d", status);
+ return status;
+ }
+
+ mSlots[slot] = {
+ .mGraphicBuffer = buffer,
+ .mFence = nullptr,
+ .mFrameNumber = 0,
+ };
+
+ return OK;
+}
+
status_t BufferItemConsumer::releaseBuffer(const BufferItem &item,
const sp<Fence>& releaseFence) {
Mutex::Autolock _l(mMutex);
return releaseBufferSlotLocked(item.mSlot, item.mGraphicBuffer, releaseFence);
}
-#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
status_t BufferItemConsumer::releaseBuffer(const sp<GraphicBuffer>& buffer,
const sp<Fence>& releaseFence) {
Mutex::Autolock _l(mMutex);
@@ -154,7 +178,6 @@ status_t BufferItemConsumer::releaseBuffer(const sp<GraphicBuffer>& buffer,
return releaseBufferSlotLocked(slotIndex, buffer, releaseFence);
}
-#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
status_t BufferItemConsumer::releaseBufferSlotLocked(int slotIndex, const sp<GraphicBuffer>& buffer,
const sp<Fence>& releaseFence) {