From 9f3053de78630815d60cf48a2cf2348cc5867c45 Mon Sep 17 00:00:00 2001 From: Dan Stoza Date: Thu, 6 Mar 2014 15:14:33 -0800 Subject: BufferQueue: Allow detaching/reattaching buffers Adds detachBuffer and attachBuffer calls to both the producer and consumer sides of BufferQueue. Buffers may be detached while dequeued by the producer or acquired by the consumer, and when attached, enter the dequeued and acquired states, respectively. Bug: 13173343 Change-Id: Ic152692b0a94d99e0135b9bfa62747dab2a54220 --- libs/gui/BufferQueue.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'libs/gui/BufferQueue.cpp') diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index af857fd3ea..26e215b1d7 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -43,6 +43,19 @@ void BufferQueue::ProxyConsumerListener::onBuffersReleased() { } } +void BufferQueue::createBufferQueue(sp* outProducer, + sp* outConsumer, + const sp& allocator) { + LOG_ALWAYS_FATAL_IF(outProducer == NULL, + "BufferQueue: outProducer must not be NULL"); + LOG_ALWAYS_FATAL_IF(outConsumer == NULL, + "BufferQueue: outConsumer must not be NULL"); + + sp core(new BufferQueueCore(allocator)); + *outProducer = new BufferQueueProducer(core); + *outConsumer = new BufferQueueConsumer(core); +} + BufferQueue::BufferQueue(const sp& allocator) : mProducer(), mConsumer() @@ -75,6 +88,15 @@ status_t BufferQueue::dequeueBuffer(int *outBuf, sp* outFence, bool async return mProducer->dequeueBuffer(outBuf, outFence, async, w, h, format, usage); } +status_t BufferQueue::detachProducerBuffer(int slot) { + return mProducer->detachBuffer(slot); +} + +status_t BufferQueue::attachProducerBuffer(int* slot, + const sp& buffer) { + return mProducer->attachBuffer(slot, buffer); +} + status_t BufferQueue::queueBuffer(int buf, const QueueBufferInput& input, QueueBufferOutput* output) { return mProducer->queueBuffer(buf, input, output); @@ -97,6 +119,15 @@ status_t BufferQueue::acquireBuffer(BufferItem* buffer, nsecs_t presentWhen) { return mConsumer->acquireBuffer(buffer, presentWhen); } +status_t BufferQueue::detachConsumerBuffer(int slot) { + return mConsumer->detachBuffer(slot); +} + +status_t BufferQueue::attachConsumerBuffer(int* slot, + const sp& buffer) { + return mConsumer->attachBuffer(slot, buffer); +} + status_t BufferQueue::releaseBuffer( int buf, uint64_t frameNumber, EGLDisplay display, EGLSyncKHR eglFence, const sp& fence) { -- cgit v1.2.3-59-g8ed1b