DO NOT MERGE libgui: Plumb attach/detach through Surface
Exposes the attachBuffer and detachNextBuffer calls from
IGraphicBufferProducer to the public Surface interface. Also moves
the version of connect that takes a producer callback from protected
to public.
Bug: 19628705
Change-Id: I9ebc3013c4d9c84c4e8ef150c00e03f8af80319e
(cherry picked from commit c14ecb9de2
)
This commit is contained in:
parent
23b204e1ee
commit
231832eb27
@ -158,7 +158,6 @@ protected:
|
|||||||
|
|
||||||
virtual int lockBuffer_DEPRECATED(ANativeWindowBuffer* buffer);
|
virtual int lockBuffer_DEPRECATED(ANativeWindowBuffer* buffer);
|
||||||
|
|
||||||
virtual int connect(int api, const sp<IProducerListener>& listener);
|
|
||||||
virtual int connect(int api);
|
virtual int connect(int api);
|
||||||
virtual int disconnect(int api);
|
virtual int disconnect(int api);
|
||||||
virtual int setBufferCount(int bufferCount);
|
virtual int setBufferCount(int bufferCount);
|
||||||
@ -177,6 +176,11 @@ public:
|
|||||||
virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds);
|
virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds);
|
||||||
virtual int unlockAndPost();
|
virtual int unlockAndPost();
|
||||||
|
|
||||||
|
virtual int connect(int api, const sp<IProducerListener>& listener);
|
||||||
|
virtual int detachNextBuffer(ANativeWindowBuffer** outBuffer,
|
||||||
|
sp<Fence>* outFence);
|
||||||
|
virtual int attachBuffer(ANativeWindowBuffer*);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum { NUM_BUFFER_SLOTS = BufferQueue::NUM_BUFFER_SLOTS };
|
enum { NUM_BUFFER_SLOTS = BufferQueue::NUM_BUFFER_SLOTS };
|
||||||
enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 };
|
enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 };
|
||||||
|
@ -610,6 +610,55 @@ int Surface::disconnect(int api) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Surface::detachNextBuffer(ANativeWindowBuffer** outBuffer,
|
||||||
|
sp<Fence>* outFence) {
|
||||||
|
ATRACE_CALL();
|
||||||
|
ALOGV("Surface::detachNextBuffer");
|
||||||
|
|
||||||
|
if (outBuffer == NULL || outFence == NULL) {
|
||||||
|
return BAD_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mutex::Autolock lock(mMutex);
|
||||||
|
|
||||||
|
sp<GraphicBuffer> buffer(NULL);
|
||||||
|
sp<Fence> fence(NULL);
|
||||||
|
status_t result = mGraphicBufferProducer->detachNextBuffer(
|
||||||
|
&buffer, &fence);
|
||||||
|
if (result != NO_ERROR) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
*outBuffer = buffer.get();
|
||||||
|
if (fence != NULL && fence->isValid()) {
|
||||||
|
*outFence = fence;
|
||||||
|
} else {
|
||||||
|
*outFence = Fence::NO_FENCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Surface::attachBuffer(ANativeWindowBuffer* buffer)
|
||||||
|
{
|
||||||
|
ATRACE_CALL();
|
||||||
|
ALOGV("Surface::attachBuffer");
|
||||||
|
|
||||||
|
Mutex::Autolock lock(mMutex);
|
||||||
|
|
||||||
|
sp<GraphicBuffer> graphicBuffer(static_cast<GraphicBuffer*>(buffer));
|
||||||
|
int32_t attachedSlot = -1;
|
||||||
|
status_t result = mGraphicBufferProducer->attachBuffer(
|
||||||
|
&attachedSlot, graphicBuffer);
|
||||||
|
if (result != NO_ERROR) {
|
||||||
|
ALOGE("attachBuffer: IGraphicBufferProducer call failed (%d)", result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
mSlots[attachedSlot].buffer = graphicBuffer;
|
||||||
|
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
int Surface::setUsage(uint32_t reqUsage)
|
int Surface::setUsage(uint32_t reqUsage)
|
||||||
{
|
{
|
||||||
ALOGV("Surface::setUsage");
|
ALOGV("Surface::setUsage");
|
||||||
|
Loading…
Reference in New Issue
Block a user