// The default value of mBuf, used to indicate this doesn't correspond to a slot.
enum { INVALID_BUFFER_SLOT = -1 };
BufferItem();
+ BufferItem(const IGraphicBufferConsumer::BufferItem& item);
~BufferItem();
operator IGraphicBufferConsumer::BufferItem() const;
// mFrameNumber is the number of the queued frame for this slot.
uint64_t mFrameNumber;
- // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT).
- int mSlot;
+ union {
+ // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT).
+ int mSlot;
+
+ // mBuf is the former name for mSlot
+ int mBuf;
+ };
// mIsDroppable whether this buffer was queued with the
// property that it can be replaced by a new buffer for the purpose of
//
// If waitForFence is true, and the acquired BufferItem has a valid fence object,
// acquireBuffer will wait on the fence with no timeout before returning.
- status_t acquireBuffer(BufferItem *item, nsecs_t presentWhen,
- bool waitForFence = true);
+ status_t acquireBuffer(BufferQueue::BufferItem *item, nsecs_t presentWhen,
+ bool waitForFence = true);
+ status_t acquireBuffer(android::BufferItem* item, nsecs_t presentWhen,
+ bool waitForFence = true);
// Returns an acquired buffer to the queue, allowing it to be reused. Since
// only a fixed number of buffers may be acquired at a time, old buffers
// is CLOCK_MONOTONIC.
virtual status_t acquireBuffer(BufferItem* outBuffer,
nsecs_t expectedPresent);
+ virtual status_t acquireBuffer(android::BufferItem* outBuffer,
+ nsecs_t expectedPresent);
// See IGraphicBufferConsumer::detachBuffer
virtual status_t detachBuffer(int slot);
// initialization that must take place the first time a buffer is assigned
// to a slot. If it is overridden the derived class's implementation must
// call ConsumerBase::acquireBufferLocked.
- virtual status_t acquireBufferLocked(IGraphicBufferConsumer::BufferItem *item,
- nsecs_t presentWhen);
+ virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen);
+ virtual status_t acquireBufferLocked(BufferQueue::BufferItem *item, nsecs_t presentWhen);
// releaseBufferLocked relinquishes control over a buffer, returning that
// control to the BufferQueue.
// acquireBufferLocked overrides the ConsumerBase method to update the
// mEglSlots array in addition to the ConsumerBase behavior.
- virtual status_t acquireBufferLocked(BufferQueue::BufferItem *item,
- nsecs_t presentWhen);
+ virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen);
+ virtual status_t acquireBufferLocked(IGraphicBufferConsumer::BufferItem *item, nsecs_t presentWhen);
// releaseBufferLocked overrides the ConsumerBase method to update the
// mEglSlots array in addition to the ConsumerBase.
namespace android {
// ----------------------------------------------------------------------------
+class BufferItem;
class Fence;
class GraphicBuffer;
class IConsumerListener;
// Return of a negative value means an error has occurred:
// * INVALID_OPERATION - too many buffers have been acquired
virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen) = 0;
+ virtual status_t acquireBuffer(android::BufferItem* buffer, nsecs_t presentWhen) = 0;
// detachBuffer attempts to remove all ownership of the buffer in the given
// slot from the buffer queue. If this call succeeds, the slot will be
mCrop.makeInvalid();
}
+BufferItem::BufferItem(const IGraphicBufferConsumer::BufferItem& item) :
+ mGraphicBuffer(item.mGraphicBuffer),
+ mFence(item.mFence),
+ mCrop(item.mCrop),
+ mTransform(item.mTransform),
+ mScalingMode(item.mScalingMode),
+ mTimestamp(item.mTimestamp),
+ mIsAutoTimestamp(item.mIsAutoTimestamp),
+ mDataSpace(item.mDataSpace),
+ mFrameNumber(item.mFrameNumber),
+ mSlot(item.mBuf),
+ mIsDroppable(item.mIsDroppable),
+ mAcquireCalled(item.mAcquireCalled),
+ mTransformToDisplayInverse(item.mTransformToDisplayInverse) {}
+
BufferItem::~BufferItem() {}
BufferItem::operator IGraphicBufferConsumer::BufferItem() const {
//#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#include <utils/Log.h>
+#include <gui/BufferItem.h>
#include <gui/BufferItemConsumer.h>
//#define BI_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__)
mConsumer->setConsumerName(name);
}
-status_t BufferItemConsumer::acquireBuffer(BufferItem *item,
+status_t BufferItemConsumer::acquireBuffer(BufferQueue::BufferItem *item,
nsecs_t presentWhen, bool waitForFence) {
status_t err;
return OK;
}
+status_t BufferItemConsumer::acquireBuffer(android::BufferItem* outItem,
+ nsecs_t presentWhen, bool waitForFence) {
+ BufferQueue::BufferItem item;
+ status_t result = acquireBuffer(&item, presentWhen, waitForFence);
+ if (result != NO_ERROR) {
+ return result;
+ }
+ *outItem = item;
+ return NO_ERROR;
+}
+
status_t BufferItemConsumer::releaseBuffer(const BufferItem &item,
const sp<Fence>& releaseFence) {
status_t err;
return NO_ERROR;
}
+status_t BufferQueueConsumer::acquireBuffer(android::BufferItem* outBuffer,
+ nsecs_t expectedPresent) {
+ if (outBuffer == nullptr) {
+ return BAD_VALUE;
+ }
+
+ BufferItem item;
+ status_t result = acquireBuffer(&item, expectedPresent);
+ if (result != NO_ERROR) {
+ return result;
+ }
+
+ *outBuffer = item;
+ return NO_ERROR;
+}
+
status_t BufferQueueConsumer::detachBuffer(int slot) {
ATRACE_CALL();
ATRACE_BUFFER_INDEX(slot);
#include <hardware/hardware.h>
+#include <gui/BufferItem.h>
#include <gui/IGraphicBufferAlloc.h>
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
}
}
-status_t ConsumerBase::acquireBufferLocked(BufferQueue::BufferItem *item,
+status_t ConsumerBase::acquireBufferLocked(BufferItem *item,
nsecs_t presentWhen) {
status_t err = mConsumer->acquireBuffer(item, presentWhen);
if (err != NO_ERROR) {
return OK;
}
+status_t ConsumerBase::acquireBufferLocked(BufferQueue::BufferItem *outItem,
+ nsecs_t presentWhen) {
+ BufferItem item;
+ status_t result = acquireBufferLocked(&item, presentWhen);
+ if (result != NO_ERROR) {
+ return result;
+ }
+ *outItem = item;
+ return NO_ERROR;
+}
+
status_t ConsumerBase::addReleaseFence(int slot,
const sp<GraphicBuffer> graphicBuffer, const sp<Fence>& fence) {
Mutex::Autolock lock(mMutex);
#include <cutils/compiler.h>
#include <utils/Log.h>
+#include <gui/BufferItem.h>
#include <gui/CpuConsumer.h>
#define CC_LOGV(x, ...) ALOGV("[%s] " x, mName.string(), ##__VA_ARGS__)
return NOT_ENOUGH_DATA;
}
- BufferQueue::BufferItem b;
+ BufferItem b;
Mutex::Autolock _l(mMutex);
#include <hardware/hardware.h>
+#include <gui/BufferItem.h>
#include <gui/GLConsumer.h>
#include <gui/IGraphicBufferAlloc.h>
#include <gui/ISurfaceComposer.h>
return err;
}
- BufferQueue::BufferItem item;
+ BufferItem item;
// Acquire the next buffer.
// In asynchronous mode the list is guaranteed to be one buffer
return sReleasedTexImageBuffer;
}
-status_t GLConsumer::acquireBufferLocked(BufferQueue::BufferItem *item,
+status_t GLConsumer::acquireBufferLocked(BufferItem *item,
nsecs_t presentWhen) {
status_t err = ConsumerBase::acquireBufferLocked(item, presentWhen);
if (err != NO_ERROR) {
return NO_ERROR;
}
+status_t GLConsumer::acquireBufferLocked(BufferQueue::BufferItem *outItem,
+ nsecs_t presentWhen) {
+ BufferItem item;
+ status_t result = acquireBufferLocked(&item, presentWhen);
+ if (result != NO_ERROR) {
+ return result;
+ }
+ *outItem = item;
+ return NO_ERROR;
+}
+
status_t GLConsumer::releaseBufferLocked(int buf,
sp<GraphicBuffer> graphicBuffer,
EGLDisplay display, EGLSyncKHR eglFence) {
#include <binder/Parcel.h>
#include <binder/IInterface.h>
+#include <gui/BufferItem.h>
#include <gui/IConsumerListener.h>
#include <gui/IGraphicBufferConsumer.h>
return reply.readInt32();
}
+ virtual status_t acquireBuffer(android::BufferItem* buffer,
+ nsecs_t presentWhen) {
+ if (buffer == nullptr) {
+ return BAD_VALUE;
+ }
+
+ BufferItem item;
+ status_t result = acquireBuffer(&item, presentWhen);
+ if (result != NO_ERROR) {
+ return result;
+ }
+ *buffer = item;
+ return NO_ERROR;
+ }
+
virtual status_t detachBuffer(int slot) {
Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
//#define LOG_NDEBUG 0
+#include <gui/BufferItem.h>
#include <gui/IGraphicBufferConsumer.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/StreamSplitter.h>
++mOutstandingBuffers;
// Acquire and detach the buffer from the input
- IGraphicBufferConsumer::BufferItem bufferItem;
+ BufferItem bufferItem;
status_t status = mInput->acquireBuffer(&bufferItem, /* presentWhen */ 0);
LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
"acquiring buffer from input failed (%d)", status);
#define LOG_TAG "BufferQueue_test"
//#define LOG_NDEBUG 0
+#include <gui/BufferItem.h>
#include <gui/BufferQueue.h>
#include <gui/IProducerListener.h>
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
- IGraphicBufferConsumer::BufferItem item;
+ BufferItem item;
ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0));
uint32_t* dataOut;
IGraphicBufferProducer::QueueBufferInput qbi(0, false,
HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
- BufferQueue::BufferItem item;
+ BufferItem item;
for (int i = 0; i < 2; i++) {
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
ASSERT_EQ(OK, mProducer->queueBuffer(newSlot, input, &output));
- IGraphicBufferConsumer::BufferItem item;
+ BufferItem item;
ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, static_cast<nsecs_t>(0)));
uint32_t* dataOut;
BufferQueueDefs::NUM_BUFFER_SLOTS)); // Index too high
ASSERT_EQ(BAD_VALUE, mConsumer->detachBuffer(0)); // Not acquired
- IGraphicBufferConsumer::BufferItem item;
+ BufferItem item;
ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, static_cast<nsecs_t>(0)));
ASSERT_EQ(OK, mConsumer->detachBuffer(item.mBuf));
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
- IGraphicBufferConsumer::BufferItem item;
+ BufferItem item;
ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, static_cast<nsecs_t>(0)));
ASSERT_EQ(OK, mConsumer->detachBuffer(item.mBuf));
#define LOG_TAG "StreamSplitter_test"
//#define LOG_NDEBUG 0
+#include <gui/BufferItem.h>
#include <gui/BufferQueue.h>
#include <gui/IConsumerListener.h>
#include <gui/ISurfaceComposer.h>
Fence::NO_FENCE);
ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
- IGraphicBufferConsumer::BufferItem item;
+ BufferItem item;
ASSERT_EQ(OK, outputConsumer->acquireBuffer(&item, 0));
uint32_t* dataOut;
ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
for (int output = 0; output < NUM_OUTPUTS; ++output) {
- IGraphicBufferConsumer::BufferItem item;
+ BufferItem item;
ASSERT_EQ(OK, outputConsumers[output]->acquireBuffer(&item, 0));
uint32_t* dataOut;