Merge "libgui: Add a BufferItem overload to IGBC::acquire"

This commit is contained in:
Dan Stoza 2015-03-13 17:19:44 +00:00 committed by Android (Google) Code Review
commit b08004f869
4 changed files with 36 additions and 0 deletions

View File

@ -48,6 +48,8 @@ public:
// is CLOCK_MONOTONIC. // is CLOCK_MONOTONIC.
virtual status_t acquireBuffer(BufferItem* outBuffer, virtual status_t acquireBuffer(BufferItem* outBuffer,
nsecs_t expectedPresent); nsecs_t expectedPresent);
virtual status_t acquireBuffer(android::BufferItem* outBuffer,
nsecs_t expectedPresent);
// See IGraphicBufferConsumer::detachBuffer // See IGraphicBufferConsumer::detachBuffer
virtual status_t detachBuffer(int slot); virtual status_t detachBuffer(int slot);

View File

@ -34,6 +34,7 @@
namespace android { namespace android {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class BufferItem;
class Fence; class Fence;
class GraphicBuffer; class GraphicBuffer;
class IConsumerListener; class IConsumerListener;
@ -147,6 +148,7 @@ public:
// Return of a negative value means an error has occurred: // Return of a negative value means an error has occurred:
// * INVALID_OPERATION - too many buffers have been acquired // * INVALID_OPERATION - too many buffers have been acquired
virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen) = 0; 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 // 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 // slot from the buffer queue. If this call succeeds, the slot will be

View File

@ -176,6 +176,22 @@ status_t BufferQueueConsumer::acquireBuffer(BufferItem* outBuffer,
return NO_ERROR; return NO_ERROR;
} }
status_t BufferQueueConsumer::acquireBuffer(android::BufferItem* outBuffer,
nsecs_t expectedPresent) {
if (outBuffer == nullptr) {
return BAD_VALUE;
}
android::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) { status_t BufferQueueConsumer::detachBuffer(int slot) {
ATRACE_CALL(); ATRACE_CALL();
ATRACE_BUFFER_INDEX(slot); ATRACE_BUFFER_INDEX(slot);

View File

@ -23,6 +23,7 @@
#include <binder/Parcel.h> #include <binder/Parcel.h>
#include <binder/IInterface.h> #include <binder/IInterface.h>
#include <gui/BufferItem.h>
#include <gui/IConsumerListener.h> #include <gui/IConsumerListener.h>
#include <gui/IGraphicBufferConsumer.h> #include <gui/IGraphicBufferConsumer.h>
@ -237,6 +238,21 @@ public:
return reply.readInt32(); 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) { virtual status_t detachBuffer(int slot) {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor()); data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());