libgui: Prepare for IGBC::BufferItem removal
Switches some dependencies from IGraphicBufferConsumer::BufferItem to android::BufferItem and adds some methods to facilitate incrementally changing client code to do the same. Change-Id: I699ed0a6837076867ca756b28d1ffb2238f7a0d9
This commit is contained in:
parent
de7100ab23
commit
dd26416fe1
@ -76,8 +76,10 @@ class BufferItemConsumer: public ConsumerBase
|
||||
//
|
||||
// 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
|
||||
|
@ -153,8 +153,8 @@ protected:
|
||||
// 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.
|
||||
|
@ -241,8 +241,8 @@ protected:
|
||||
|
||||
// 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.
|
||||
|
@ -19,6 +19,7 @@
|
||||
//#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__)
|
||||
@ -52,7 +53,7 @@ void BufferItemConsumer::setName(const String8& name) {
|
||||
mConsumer->setConsumerName(name);
|
||||
}
|
||||
|
||||
status_t BufferItemConsumer::acquireBuffer(BufferItem *item,
|
||||
status_t BufferItemConsumer::acquireBuffer(BufferQueue::BufferItem *item,
|
||||
nsecs_t presentWhen, bool waitForFence) {
|
||||
status_t err;
|
||||
|
||||
@ -82,6 +83,17 @@ status_t BufferItemConsumer::acquireBuffer(BufferItem *item,
|
||||
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;
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
#include <gui/BufferItem.h>
|
||||
#include <gui/IGraphicBufferAlloc.h>
|
||||
#include <gui/ISurfaceComposer.h>
|
||||
#include <gui/SurfaceComposerClient.h>
|
||||
@ -179,7 +180,7 @@ void ConsumerBase::dumpLocked(String8& result, const char* prefix) const {
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -199,6 +200,17 @@ status_t ConsumerBase::acquireBufferLocked(BufferQueue::BufferItem *item,
|
||||
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);
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#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__)
|
||||
@ -110,7 +111,7 @@ status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
|
||||
return NOT_ENOUGH_DATA;
|
||||
}
|
||||
|
||||
BufferQueue::BufferItem b;
|
||||
BufferItem b;
|
||||
|
||||
Mutex::Autolock _l(mMutex);
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
#include <gui/BufferItem.h>
|
||||
#include <gui/GLConsumer.h>
|
||||
#include <gui/IGraphicBufferAlloc.h>
|
||||
#include <gui/ISurfaceComposer.h>
|
||||
@ -210,7 +211,7 @@ status_t GLConsumer::updateTexImage() {
|
||||
return err;
|
||||
}
|
||||
|
||||
BufferQueue::BufferItem item;
|
||||
BufferItem item;
|
||||
|
||||
// Acquire the next buffer.
|
||||
// In asynchronous mode the list is guaranteed to be one buffer
|
||||
@ -342,7 +343,7 @@ sp<GraphicBuffer> GLConsumer::getDebugTexImageBuffer() {
|
||||
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) {
|
||||
@ -360,6 +361,17 @@ status_t GLConsumer::acquireBufferLocked(BufferQueue::BufferItem *item,
|
||||
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) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#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>
|
||||
@ -123,7 +124,7 @@ void StreamSplitter::onFrameAvailable(const BufferItem& /* item */) {
|
||||
++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);
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define LOG_TAG "BufferQueue_test"
|
||||
//#define LOG_NDEBUG 0
|
||||
|
||||
#include <gui/BufferItem.h>
|
||||
#include <gui/BufferQueue.h>
|
||||
#include <gui/IProducerListener.h>
|
||||
|
||||
@ -129,7 +130,7 @@ TEST_F(BufferQueueTest, BufferQueueInAnotherProcess) {
|
||||
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;
|
||||
@ -154,7 +155,7 @@ TEST_F(BufferQueueTest, AcquireBuffer_ExceedsMaxAcquireCount_Fails) {
|
||||
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,
|
||||
@ -251,7 +252,7 @@ TEST_F(BufferQueueTest, DetachAndReattachOnProducerSide) {
|
||||
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;
|
||||
@ -286,7 +287,7 @@ TEST_F(BufferQueueTest, DetachAndReattachOnConsumerSide) {
|
||||
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));
|
||||
@ -347,7 +348,7 @@ TEST_F(BufferQueueTest, MoveFromConsumerToProducer) {
|
||||
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));
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#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>
|
||||
@ -116,7 +117,7 @@ TEST_F(StreamSplitterTest, OneInputOneOutput) {
|
||||
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;
|
||||
@ -184,7 +185,7 @@ TEST_F(StreamSplitterTest, OneInputMultipleOutputs) {
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user