diff options
author | 2016-10-21 15:23:44 -0700 | |
---|---|---|
committer | 2016-11-11 11:35:06 -0800 | |
commit | 6ebc46a7c01b22bc19d3c00b493f8d930b15b43a (patch) | |
tree | 6f68e8f1cf2ccde71eece4a037c8e32b4f0cd0b2 /libs/gui/BufferQueueProducer.cpp | |
parent | cd7dedbe69f8c90d351b97b1acea2bb3635b68ca (diff) |
Add layered buffer support to libui and libgui.
Bug: 31686534
Test: manual
Change-Id: Ia40270701467f4b785660324cad883e7da08989a
Diffstat (limited to 'libs/gui/BufferQueueProducer.cpp')
-rw-r--r-- | libs/gui/BufferQueueProducer.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp index 90b4b9df3d..9241c7c63d 100644 --- a/libs/gui/BufferQueueProducer.cpp +++ b/libs/gui/BufferQueueProducer.cpp @@ -42,6 +42,8 @@ namespace android { +static constexpr uint32_t BQ_LAYER_COUNT = 1; + BufferQueueProducer::BufferQueueProducer(const sp<BufferQueueCore>& core, bool consumerIsSurfaceFlinger) : mCore(core), @@ -414,7 +416,8 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot, // buffer. If this buffer would require reallocation to meet the // requested attributes, we free it and attempt to get another one. if (!mCore->mAllowAllocation) { - if (buffer->needsReallocation(width, height, format, usage)) { + if (buffer->needsReallocation(width, height, format, + BQ_LAYER_COUNT, usage)) { if (mCore->mSharedBufferSlot == found) { BQ_LOGE("dequeueBuffer: cannot re-allocate a shared" "buffer"); @@ -430,7 +433,8 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot, const sp<GraphicBuffer>& buffer(mSlots[found].mGraphicBuffer); if (mCore->mSharedBufferSlot == found && - buffer->needsReallocation(width, height, format, usage)) { + buffer->needsReallocation(width, height, format, + BQ_LAYER_COUNT, usage)) { BQ_LOGE("dequeueBuffer: cannot re-allocate a shared" "buffer"); @@ -449,7 +453,8 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot, mSlots[found].mBufferState.dequeue(); if ((buffer == NULL) || - buffer->needsReallocation(width, height, format, usage)) + buffer->needsReallocation(width, height, format, BQ_LAYER_COUNT, + usage)) { mSlots[found].mAcquireCalled = false; mSlots[found].mGraphicBuffer = NULL; @@ -500,7 +505,7 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot, status_t error; BQ_LOGV("dequeueBuffer: allocating a new buffer for slot %d", *outSlot); sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer( - width, height, format, usage, + width, height, format, BQ_LAYER_COUNT, usage, {mConsumerName.string(), mConsumerName.size()}, &error)); { // Autolock scope Mutex::Autolock lock(mCore->mMutex); @@ -1039,6 +1044,10 @@ int BufferQueueProducer::query(int what, int *outValue) { case NATIVE_WINDOW_FORMAT: value = static_cast<int32_t>(mCore->mDefaultBufferFormat); break; + case NATIVE_WINDOW_LAYER_COUNT: + // All BufferQueue buffers have a single layer. + value = BQ_LAYER_COUNT; + break; case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS: value = mCore->getMinUndequeuedBufferCountLocked(); break; @@ -1287,8 +1296,9 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height, for (size_t i = 0; i < newBufferCount; ++i) { status_t result = NO_ERROR; sp<GraphicBuffer> graphicBuffer(mCore->mAllocator->createGraphicBuffer( - allocWidth, allocHeight, allocFormat, allocUsage, - {mConsumerName.string(), mConsumerName.size()}, &result)); + allocWidth, allocHeight, allocFormat, BQ_LAYER_COUNT, + allocUsage, {mConsumerName.string(), mConsumerName.size()}, + &result)); if (result != NO_ERROR) { BQ_LOGE("allocateBuffers: failed to allocate buffer (%u x %u, format" " %u, usage %u)", width, height, format, usage); |