BQ: get rid of async in producer interface
- Get rid of the async flag in dequeueBuffer, allocateBuffers,
waitForFreeSlotThenRelock, and QueueBufferInput.
- Instead use the persistent flags mDequeueBufferCannotBlock and
mAsyncMode to determine whether to use the async behavior.
Bug 13174928
Change-Id: Ie6f7b9e46ee3844ee77b102003c84dddf1bcafdd
diff --git a/include/gui/BufferQueueCore.h b/include/gui/BufferQueueCore.h
index e824124..36cd238 100644
--- a/include/gui/BufferQueueCore.h
+++ b/include/gui/BufferQueueCore.h
@@ -85,25 +85,25 @@
// getMinUndequeuedBufferCountLocked returns the minimum number of buffers
// that must remain in a state other than DEQUEUED. The async parameter
// tells whether we're in asynchronous mode.
- int getMinUndequeuedBufferCountLocked(bool async) const;
+ int getMinUndequeuedBufferCountLocked() const;
// getMinMaxBufferCountLocked returns the minimum number of buffers allowed
// given the current BufferQueue state. The async parameter tells whether
// we're in asynchonous mode.
- int getMinMaxBufferCountLocked(bool async) const;
+ int getMinMaxBufferCountLocked() const;
// getMaxBufferCountLocked returns the maximum number of buffers that can be
// allocated at once. This value depends on the following member variables:
//
- // mDequeueBufferCannotBlock
+ // mMaxDequeuedBufferCount
// mMaxAcquiredBufferCount
- // mDefaultMaxBufferCount
- // mOverrideMaxBufferCount
- // async parameter
+ // mMaxBufferCount
+ // mAsyncMode
+ // mDequeueBufferCannotBlock
//
// Any time one of these member variables is changed while a producer is
// connected, mDequeueCondition must be broadcast.
- int getMaxBufferCountLocked(bool async) const;
+ int getMaxBufferCountLocked() const;
// freeBufferLocked frees the GraphicBuffer and sync resources for the
// given slot.
diff --git a/include/gui/BufferQueueProducer.h b/include/gui/BufferQueueProducer.h
index 267c50f..6e16a60 100644
--- a/include/gui/BufferQueueProducer.h
+++ b/include/gui/BufferQueueProducer.h
@@ -81,7 +81,7 @@
// In both cases, the producer will need to call requestBuffer to get a
// GraphicBuffer handle for the returned slot.
virtual status_t dequeueBuffer(int *outSlot, sp<Fence>* outFence,
- bool async, uint32_t width, uint32_t height, PixelFormat format,
+ uint32_t width, uint32_t height, PixelFormat format,
uint32_t usage);
// See IGraphicBufferProducer::detachBuffer
@@ -158,7 +158,7 @@
virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
// See IGraphicBufferProducer::allocateBuffers
- virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
+ virtual void allocateBuffers(uint32_t width, uint32_t height,
PixelFormat format, uint32_t usage);
// See IGraphicBufferProducer::allowAllocation
@@ -179,8 +179,8 @@
// mode (producer and consumer controlled by the application). If it blocks,
// it will release mCore->mMutex while blocked so that other operations on
// the BufferQueue may succeed.
- status_t waitForFreeSlotThenRelock(const char* caller, bool async,
- int* found, status_t* returnFlags) const;
+ status_t waitForFreeSlotThenRelock(const char* caller, int* found,
+ status_t* returnFlags) const;
sp<BufferQueueCore> mCore;
diff --git a/include/gui/IGraphicBufferProducer.h b/include/gui/IGraphicBufferProducer.h
index 6885eb0..be1874a 100644
--- a/include/gui/IGraphicBufferProducer.h
+++ b/include/gui/IGraphicBufferProducer.h
@@ -147,9 +147,6 @@
// fence signals. If the fence is Fence::NO_FENCE, the buffer may be written
// immediately.
//
- // The async parameter sets whether we're in asynchronous mode for this
- // dequeueBuffer() call.
- //
// The width and height parameters must be no greater than the minimum of
// GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv).
// An error due to invalid dimensions might not be reported until
@@ -187,8 +184,8 @@
//
// All other negative values are an unknown error returned downstream
// from the graphics allocator (typically errno).
- virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async,
- uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) = 0;
+ virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w,
+ uint32_t h, PixelFormat format, uint32_t usage) = 0;
// 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
@@ -297,23 +294,21 @@
// crop - a crop rectangle that's used as a hint to the consumer
// scalingMode - a set of flags from NATIVE_WINDOW_SCALING_* in <window.h>
// transform - a set of flags from NATIVE_WINDOW_TRANSFORM_* in <window.h>
- // async - if the buffer is queued in asynchronous mode
// fence - a fence that the consumer must wait on before reading the buffer,
// set this to Fence::NO_FENCE if the buffer is ready immediately
// sticky - the sticky transform set in Surface (only used by the LEGACY
// camera mode).
inline QueueBufferInput(int64_t timestamp, bool isAutoTimestamp,
android_dataspace dataSpace, const Rect& crop, int scalingMode,
- uint32_t transform, bool async, const sp<Fence>& fence,
- uint32_t sticky = 0)
+ uint32_t transform, const sp<Fence>& fence, uint32_t sticky = 0)
: timestamp(timestamp), isAutoTimestamp(isAutoTimestamp),
dataSpace(dataSpace), crop(crop), scalingMode(scalingMode),
- transform(transform), stickyTransform(sticky),
- async(async), fence(fence), surfaceDamage() { }
+ transform(transform), stickyTransform(sticky), fence(fence),
+ surfaceDamage() { }
inline void deflate(int64_t* outTimestamp, bool* outIsAutoTimestamp,
android_dataspace* outDataSpace,
Rect* outCrop, int* outScalingMode,
- uint32_t* outTransform, bool* outAsync, sp<Fence>* outFence,
+ uint32_t* outTransform, sp<Fence>* outFence,
uint32_t* outStickyTransform = NULL) const {
*outTimestamp = timestamp;
*outIsAutoTimestamp = bool(isAutoTimestamp);
@@ -321,7 +316,6 @@
*outCrop = crop;
*outScalingMode = scalingMode;
*outTransform = transform;
- *outAsync = bool(async);
*outFence = fence;
if (outStickyTransform != NULL) {
*outStickyTransform = stickyTransform;
@@ -345,7 +339,6 @@
int scalingMode;
uint32_t transform;
uint32_t stickyTransform;
- int async;
sp<Fence> fence;
Region surfaceDamage;
};
@@ -381,8 +374,8 @@
uint32_t numPendingBuffers;
};
- virtual status_t queueBuffer(int slot,
- const QueueBufferInput& input, QueueBufferOutput* output) = 0;
+ virtual status_t queueBuffer(int slot, const QueueBufferInput& input,
+ QueueBufferOutput* output) = 0;
// cancelBuffer indicates that the client does not wish to fill in the
// buffer associated with slot and transfers ownership of the slot back to
@@ -493,7 +486,7 @@
// allocated. This is most useful to avoid an allocation delay during
// dequeueBuffer. If there are already the maximum number of buffers
// allocated, this function has no effect.
- virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
+ virtual void allocateBuffers(uint32_t width, uint32_t height,
PixelFormat format, uint32_t usage) = 0;
// Sets whether dequeueBuffer is allowed to allocate new buffers.
diff --git a/libs/gui/BufferQueueConsumer.cpp b/libs/gui/BufferQueueConsumer.cpp
index 950a074..d52b47f 100644
--- a/libs/gui/BufferQueueConsumer.cpp
+++ b/libs/gui/BufferQueueConsumer.cpp
@@ -527,11 +527,13 @@
}
if ((maxAcquiredBuffers + mCore->mMaxDequeuedBufferCount +
- (mCore->mAsyncMode ? 1 : 0)) > mCore->mMaxBufferCount) {
+ (mCore->mAsyncMode || mCore->mDequeueBufferCannotBlock ? 1 : 0)) >
+ mCore->mMaxBufferCount) {
BQ_LOGE("setMaxAcquiredBufferCount: %d acquired buffers would exceed "
"the maxBufferCount (%d) (maxDequeued %d async %d)",
maxAcquiredBuffers, mCore->mMaxBufferCount,
- mCore->mMaxDequeuedBufferCount, mCore->mAsyncMode);
+ mCore->mMaxDequeuedBufferCount, mCore->mAsyncMode ||
+ mCore->mDequeueBufferCannotBlock);
return BAD_VALUE;
}
diff --git a/libs/gui/BufferQueueCore.cpp b/libs/gui/BufferQueueCore.cpp
index 8b97c2a..b1cbc86 100644
--- a/libs/gui/BufferQueueCore.cpp
+++ b/libs/gui/BufferQueueCore.cpp
@@ -101,12 +101,13 @@
}
result.appendFormat("%s-BufferQueue mMaxAcquiredBufferCount=%d, "
- "mMaxDequeuedBufferCount=%d, mDequeueBufferCannotBlock=%d, "
- "default-size=[%dx%d], default-format=%d, transform-hint=%02x, "
- "FIFO(%zu)={%s}\n",
- prefix, mMaxAcquiredBufferCount, mMaxDequeuedBufferCount,
- mDequeueBufferCannotBlock, mDefaultWidth, mDefaultHeight,
- mDefaultBufferFormat, mTransformHint, mQueue.size(), fifo.string());
+ "mMaxDequeuedBufferCount=%d, mDequeueBufferCannotBlock=%d "
+ "mAsyncMode=%d, default-size=[%dx%d], default-format=%d, "
+ "transform-hint=%02x, FIFO(%zu)={%s}\n", prefix,
+ mMaxAcquiredBufferCount, mMaxDequeuedBufferCount,
+ mDequeueBufferCannotBlock, mAsyncMode, mDefaultWidth,
+ mDefaultHeight, mDefaultBufferFormat, mTransformHint, mQueue.size(),
+ fifo.string());
// Trim the free buffers so as to not spam the dump
int maxBufferCount = 0;
@@ -137,23 +138,23 @@
}
}
-int BufferQueueCore::getMinUndequeuedBufferCountLocked(bool async) const {
+int BufferQueueCore::getMinUndequeuedBufferCountLocked() const {
// If dequeueBuffer is allowed to error out, we don't have to add an
// extra buffer.
- if (mDequeueBufferCannotBlock || async) {
+ if (mAsyncMode || mDequeueBufferCannotBlock) {
return mMaxAcquiredBufferCount + 1;
}
return mMaxAcquiredBufferCount;
}
-int BufferQueueCore::getMinMaxBufferCountLocked(bool async) const {
- return getMinUndequeuedBufferCountLocked(async) + 1;
+int BufferQueueCore::getMinMaxBufferCountLocked() const {
+ return getMinUndequeuedBufferCountLocked() + 1;
}
-int BufferQueueCore::getMaxBufferCountLocked(bool async) const {
+int BufferQueueCore::getMaxBufferCountLocked() const {
int maxBufferCount = mMaxAcquiredBufferCount + mMaxDequeuedBufferCount +
- (async ? 1 : 0);
+ (mAsyncMode || mDequeueBufferCannotBlock ? 1 : 0);
// limit maxBufferCount by mMaxBufferCount always
maxBufferCount = std::min(mMaxBufferCount, maxBufferCount);
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp
index 06cdeab..deec330 100644
--- a/libs/gui/BufferQueueProducer.cpp
+++ b/libs/gui/BufferQueueProducer.cpp
@@ -102,8 +102,7 @@
}
}
- int bufferCount = mCore->getMinUndequeuedBufferCountLocked(
- mCore->mAsyncMode);
+ int bufferCount = mCore->getMinUndequeuedBufferCountLocked();
bufferCount += maxDequeuedBuffers;
if (bufferCount > BufferQueueDefs::NUM_BUFFER_SLOTS) {
@@ -112,8 +111,7 @@
return BAD_VALUE;
}
- const int minBufferSlots = mCore->getMinMaxBufferCountLocked(
- mCore->mAsyncMode);
+ const int minBufferSlots = mCore->getMinMaxBufferCountLocked();
if (bufferCount < minBufferSlots) {
BQ_LOGE("setMaxDequeuedBufferCount: requested buffer count %d is "
"less than minimum %d", bufferCount, minBufferSlots);
@@ -122,9 +120,10 @@
if (bufferCount > mCore->mMaxBufferCount) {
BQ_LOGE("setMaxDequeuedBufferCount: %d dequeued buffers would "
- "exceed the maxBufferCount (%d) (maxAcquired %d async %d)",
- maxDequeuedBuffers, mCore->mMaxBufferCount,
- mCore->mMaxAcquiredBufferCount, mCore->mAsyncMode);
+ "exceed the maxBufferCount (%d) (maxAcquired %d async %d "
+ "mDequeuedBufferCannotBlock %d)", maxDequeuedBuffers,
+ mCore->mMaxBufferCount, mCore->mMaxAcquiredBufferCount,
+ mCore->mAsyncMode, mCore->mDequeueBufferCannotBlock);
return BAD_VALUE;
}
@@ -169,12 +168,14 @@
}
if ((mCore->mMaxAcquiredBufferCount + mCore->mMaxDequeuedBufferCount +
- (async ? 1 : 0)) > mCore->mMaxBufferCount) {
+ (async || mCore->mDequeueBufferCannotBlock ? 1 : 0)) >
+ mCore->mMaxBufferCount) {
BQ_LOGE("setAsyncMode(%d): this call would cause the "
"maxBufferCount (%d) to be exceeded (maxAcquired %d "
- "maxDequeued %d)", async,mCore->mMaxBufferCount,
- mCore->mMaxAcquiredBufferCount,
- mCore->mMaxDequeuedBufferCount);
+ "maxDequeued %d mDequeueBufferCannotBlock %d)", async,
+ mCore->mMaxBufferCount, mCore->mMaxAcquiredBufferCount,
+ mCore->mMaxDequeuedBufferCount,
+ mCore->mDequeueBufferCannotBlock);
return BAD_VALUE;
}
@@ -191,7 +192,7 @@
}
status_t BufferQueueProducer::waitForFreeSlotThenRelock(const char* caller,
- bool async, int* found, status_t* returnFlags) const {
+ int* found, status_t* returnFlags) const {
bool tryAgain = true;
while (tryAgain) {
if (mCore->mIsAbandoned) {
@@ -199,7 +200,7 @@
return NO_INIT;
}
- const int maxBufferCount = mCore->getMaxBufferCountLocked(async);
+ const int maxBufferCount = mCore->getMaxBufferCountLocked();
// Free up any buffers that are in slots beyond the max buffer count
for (int s = maxBufferCount; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
@@ -285,8 +286,8 @@
}
status_t BufferQueueProducer::dequeueBuffer(int *outSlot,
- sp<android::Fence> *outFence, bool async,
- uint32_t width, uint32_t height, PixelFormat format, uint32_t usage) {
+ sp<android::Fence> *outFence, uint32_t width, uint32_t height,
+ PixelFormat format, uint32_t usage) {
ATRACE_CALL();
{ // Autolock scope
Mutex::Autolock lock(mCore->mMutex);
@@ -303,8 +304,8 @@
}
} // Autolock scope
- BQ_LOGV("dequeueBuffer: async=%s w=%u h=%u format=%#x, usage=%#x",
- async ? "true" : "false", width, height, format, usage);
+ BQ_LOGV("dequeueBuffer: w=%u h=%u format=%#x, usage=%#x", width, height,
+ format, usage);
if ((width && !height) || (!width && height)) {
BQ_LOGE("dequeueBuffer: invalid size: w=%u h=%u", width, height);
@@ -335,8 +336,8 @@
int found = BufferItem::INVALID_BUFFER_SLOT;
while (found == BufferItem::INVALID_BUFFER_SLOT) {
- status_t status = waitForFreeSlotThenRelock("dequeueBuffer", async,
- &found, &returnFlags);
+ status_t status = waitForFreeSlotThenRelock("dequeueBuffer", &found,
+ &returnFlags);
if (status != NO_ERROR) {
return status;
}
@@ -572,11 +573,8 @@
status_t returnFlags = NO_ERROR;
int found;
- // TODO: Should we provide an async flag to attachBuffer? It seems
- // unlikely that buffers which we are attaching to a BufferQueue will
- // be asynchronous (droppable), but it may not be impossible.
- status_t status = waitForFreeSlotThenRelock("attachBuffer(P)", false,
- &found, &returnFlags);
+ status_t status = waitForFreeSlotThenRelock("attachBuffer(P)", &found,
+ &returnFlags);
if (status != NO_ERROR) {
return status;
}
@@ -615,10 +613,9 @@
int scalingMode;
uint32_t transform;
uint32_t stickyTransform;
- bool async;
sp<Fence> fence;
input.deflate(×tamp, &isAutoTimestamp, &dataSpace, &crop, &scalingMode,
- &transform, &async, &fence, &stickyTransform);
+ &transform, &fence, &stickyTransform);
Region surfaceDamage = input.getSurfaceDamage();
if (fence == NULL) {
@@ -654,7 +651,7 @@
return NO_INIT;
}
- const int maxBufferCount = mCore->getMaxBufferCountLocked(async);
+ const int maxBufferCount = mCore->getMaxBufferCountLocked();
if (slot < 0 || slot >= maxBufferCount) {
BQ_LOGE("queueBuffer: slot index %d out of range [0, %d)",
@@ -710,7 +707,8 @@
item.mFrameNumber = mCore->mFrameCounter;
item.mSlot = slot;
item.mFence = fence;
- item.mIsDroppable = mCore->mDequeueBufferCannotBlock || async;
+ item.mIsDroppable = mCore->mAsyncMode ||
+ mCore->mDequeueBufferCannotBlock;
item.mSurfaceDamage = surfaceDamage;
mStickyTransform = stickyTransform;
@@ -853,7 +851,7 @@
value = static_cast<int32_t>(mCore->mDefaultBufferFormat);
break;
case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
- value = mCore->getMinUndequeuedBufferCountLocked(false);
+ value = mCore->getMinUndequeuedBufferCountLocked();
break;
case NATIVE_WINDOW_STICKY_TRANSFORM:
value = static_cast<int32_t>(mStickyTransform);
@@ -943,8 +941,8 @@
}
mCore->mBufferHasBeenQueued = false;
- mCore->mDequeueBufferCannotBlock =
- mCore->mConsumerControlledByApp && producerControlledByApp;
+ mCore->mDequeueBufferCannotBlock = mCore->mConsumerControlledByApp &&
+ producerControlledByApp;
mCore->mAllowAllocation = true;
return status;
@@ -1023,8 +1021,8 @@
return NO_ERROR;
}
-void BufferQueueProducer::allocateBuffers(bool async, uint32_t width,
- uint32_t height, PixelFormat format, uint32_t usage) {
+void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height,
+ PixelFormat format, uint32_t usage) {
ATRACE_CALL();
while (true) {
Vector<int> freeSlots;
@@ -1058,7 +1056,7 @@
}
}
- int maxBufferCount = mCore->getMaxBufferCountLocked(async);
+ int maxBufferCount = mCore->getMaxBufferCountLocked();
BQ_LOGV("allocateBuffers: allocating from %d buffers up to %d buffers",
currentBufferCount, maxBufferCount);
if (maxBufferCount <= currentBufferCount)
diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp
index 86b6971..8ab963d 100644
--- a/libs/gui/IGraphicBufferProducer.cpp
+++ b/libs/gui/IGraphicBufferProducer.cpp
@@ -111,12 +111,10 @@
return result;
}
- virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, bool async,
- uint32_t width, uint32_t height, PixelFormat format,
- uint32_t usage) {
+ virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, uint32_t width,
+ uint32_t height, PixelFormat format, uint32_t usage) {
Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
- data.writeInt32(static_cast<int32_t>(async));
data.writeUint32(width);
data.writeUint32(height);
data.writeInt32(static_cast<int32_t>(format));
@@ -281,11 +279,10 @@
return result;
}
- virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
+ virtual void allocateBuffers(uint32_t width, uint32_t height,
PixelFormat format, uint32_t usage) {
Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
- data.writeInt32(static_cast<int32_t>(async));
data.writeUint32(width);
data.writeUint32(height);
data.writeInt32(static_cast<int32_t>(format));
@@ -371,15 +368,14 @@
}
case DEQUEUE_BUFFER: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
- bool async = static_cast<bool>(data.readInt32());
uint32_t width = data.readUint32();
uint32_t height = data.readUint32();
PixelFormat format = static_cast<PixelFormat>(data.readInt32());
uint32_t usage = data.readUint32();
int buf = 0;
sp<Fence> fence;
- int result = dequeueBuffer(&buf, &fence, async, width, height,
- format, usage);
+ int result = dequeueBuffer(&buf, &fence, width, height, format,
+ usage);
reply->writeInt32(buf);
reply->writeInt32(fence != NULL);
if (fence != NULL) {
@@ -486,12 +482,11 @@
}
case ALLOCATE_BUFFERS: {
CHECK_INTERFACE(IGraphicBufferProducer, data, reply);
- bool async = static_cast<bool>(data.readInt32());
uint32_t width = data.readUint32();
uint32_t height = data.readUint32();
PixelFormat format = static_cast<PixelFormat>(data.readInt32());
uint32_t usage = data.readUint32();
- allocateBuffers(async, width, height, format, usage);
+ allocateBuffers(width, height, format, usage);
return NO_ERROR;
}
case ALLOW_ALLOCATION: {
@@ -531,7 +526,6 @@
+ sizeof(scalingMode)
+ sizeof(transform)
+ sizeof(stickyTransform)
- + sizeof(async)
+ fence->getFlattenedSize()
+ surfaceDamage.getFlattenedSize();
}
@@ -553,7 +547,6 @@
FlattenableUtils::write(buffer, size, scalingMode);
FlattenableUtils::write(buffer, size, transform);
FlattenableUtils::write(buffer, size, stickyTransform);
- FlattenableUtils::write(buffer, size, async);
status_t result = fence->flatten(buffer, size, fds, count);
if (result != NO_ERROR) {
return result;
@@ -571,8 +564,7 @@
+ sizeof(crop)
+ sizeof(scalingMode)
+ sizeof(transform)
- + sizeof(stickyTransform)
- + sizeof(async);
+ + sizeof(stickyTransform);
if (size < minNeeded) {
return NO_MEMORY;
@@ -585,7 +577,6 @@
FlattenableUtils::read(buffer, size, scalingMode);
FlattenableUtils::read(buffer, size, transform);
FlattenableUtils::read(buffer, size, stickyTransform);
- FlattenableUtils::read(buffer, size, async);
fence = new Fence();
status_t result = fence->unflatten(buffer, size, fds, count);
diff --git a/libs/gui/StreamSplitter.cpp b/libs/gui/StreamSplitter.cpp
index dce0e87..bafe947 100644
--- a/libs/gui/StreamSplitter.cpp
+++ b/libs/gui/StreamSplitter.cpp
@@ -144,8 +144,7 @@
bufferItem.mTimestamp, bufferItem.mIsAutoTimestamp,
bufferItem.mDataSpace, bufferItem.mCrop,
static_cast<int32_t>(bufferItem.mScalingMode),
- bufferItem.mTransform, bufferItem.mIsDroppable,
- bufferItem.mFence);
+ bufferItem.mTransform, bufferItem.mFence);
// Attach and queue the buffer to each of the outputs
Vector<sp<IGraphicBufferProducer> >::iterator output = mOutputs.begin();
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index de5c275..a31876b 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -99,8 +99,8 @@
void Surface::allocateBuffers() {
uint32_t reqWidth = mReqWidth ? mReqWidth : mUserWidth;
uint32_t reqHeight = mReqHeight ? mReqHeight : mUserHeight;
- mGraphicBufferProducer->allocateBuffers(mSwapIntervalZero, reqWidth,
- reqHeight, mReqFormat, mReqUsage);
+ mGraphicBufferProducer->allocateBuffers(reqWidth, reqHeight,
+ mReqFormat, mReqUsage);
}
status_t Surface::setGenerationNumber(uint32_t generation) {
@@ -202,6 +202,7 @@
interval = maxSwapInterval;
mSwapIntervalZero = (interval == 0);
+ mGraphicBufferProducer->setAsyncMode(mSwapIntervalZero);
return NO_ERROR;
}
@@ -212,7 +213,6 @@
uint32_t reqWidth;
uint32_t reqHeight;
- bool swapIntervalZero;
PixelFormat reqFormat;
uint32_t reqUsage;
@@ -222,20 +222,19 @@
reqWidth = mReqWidth ? mReqWidth : mUserWidth;
reqHeight = mReqHeight ? mReqHeight : mUserHeight;
- swapIntervalZero = mSwapIntervalZero;
reqFormat = mReqFormat;
reqUsage = mReqUsage;
} // Drop the lock so that we can still touch the Surface while blocking in IGBP::dequeueBuffer
int buf = -1;
sp<Fence> fence;
- status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence, swapIntervalZero,
+ status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence,
reqWidth, reqHeight, reqFormat, reqUsage);
if (result < 0) {
- ALOGV("dequeueBuffer: IGraphicBufferProducer::dequeueBuffer(%d, %d, %d, %d, %d)"
- "failed: %d", swapIntervalZero, reqWidth, reqHeight, reqFormat,
- reqUsage, result);
+ ALOGV("dequeueBuffer: IGraphicBufferProducer::dequeueBuffer"
+ "(%d, %d, %d, %d) failed: %d", reqWidth, reqHeight, reqFormat,
+ reqUsage, result);
return result;
}
@@ -341,7 +340,7 @@
IGraphicBufferProducer::QueueBufferOutput output;
IGraphicBufferProducer::QueueBufferInput input(timestamp, isAutoTimestamp,
mDataSpace, crop, mScalingMode, mTransform ^ mStickyTransform,
- mSwapIntervalZero, fence, mStickyTransform);
+ fence, mStickyTransform);
if (mConnectedToCpu || mDirtyRegion.bounds() == Rect::INVALID_RECT) {
input.setSurfaceDamage(Region::INVALID_REGION);
diff --git a/libs/gui/tests/BufferQueue_test.cpp b/libs/gui/tests/BufferQueue_test.cpp
index 8a3be3d..5244d82 100644
--- a/libs/gui/tests/BufferQueue_test.cpp
+++ b/libs/gui/tests/BufferQueue_test.cpp
@@ -113,7 +113,7 @@
sp<Fence> fence;
sp<GraphicBuffer> buffer;
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+ mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
GRALLOC_USAGE_SW_WRITE_OFTEN));
ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
@@ -125,7 +125,7 @@
IGraphicBufferProducer::QueueBufferInput input(0, false,
HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
- NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
+ NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, Fence::NO_FENCE);
ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
BufferItem item;
@@ -152,12 +152,12 @@
sp<GraphicBuffer> buf;
IGraphicBufferProducer::QueueBufferInput qbi(0, false,
HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
- NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
+ NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, Fence::NO_FENCE);
BufferItem item;
for (int i = 0; i < 2; i++) {
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- mProducer->dequeueBuffer(&slot, &fence, false, 1, 1, 0,
+ mProducer->dequeueBuffer(&slot, &fence, 1, 1, 0,
GRALLOC_USAGE_SW_READ_OFTEN));
ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buf));
ASSERT_EQ(OK, mProducer->queueBuffer(slot, qbi, &qbo));
@@ -165,7 +165,7 @@
}
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- mProducer->dequeueBuffer(&slot, &fence, false, 1, 1, 0,
+ mProducer->dequeueBuffer(&slot, &fence, 1, 1, 0,
GRALLOC_USAGE_SW_READ_OFTEN));
ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buf));
ASSERT_EQ(OK, mProducer->queueBuffer(slot, qbi, &qbo));
@@ -248,7 +248,7 @@
sp<Fence> fence;
sp<GraphicBuffer> buffer;
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+ mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
GRALLOC_USAGE_SW_WRITE_OFTEN));
ASSERT_EQ(BAD_VALUE, mProducer->detachBuffer(slot)); // Not requested
ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
@@ -272,7 +272,7 @@
ASSERT_EQ(OK, mProducer->attachBuffer(&newSlot, buffer));
IGraphicBufferProducer::QueueBufferInput input(0, false,
HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
- NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
+ NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, Fence::NO_FENCE);
ASSERT_EQ(OK, mProducer->queueBuffer(newSlot, input, &output));
BufferItem item;
@@ -297,12 +297,12 @@
sp<Fence> fence;
sp<GraphicBuffer> buffer;
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+ mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
GRALLOC_USAGE_SW_WRITE_OFTEN));
ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
IGraphicBufferProducer::QueueBufferInput input(0, false,
HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
- NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
+ NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, Fence::NO_FENCE);
ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
ASSERT_EQ(BAD_VALUE, mConsumer->detachBuffer(-1)); // Index too low
@@ -333,7 +333,7 @@
EGL_NO_SYNC_KHR, Fence::NO_FENCE));
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+ mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
GRALLOC_USAGE_SW_WRITE_OFTEN));
ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
@@ -356,7 +356,7 @@
sp<Fence> fence;
sp<GraphicBuffer> buffer;
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+ mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
GRALLOC_USAGE_SW_WRITE_OFTEN));
ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
@@ -368,7 +368,7 @@
IGraphicBufferProducer::QueueBufferInput input(0, false,
HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
- NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE);
+ NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, Fence::NO_FENCE);
ASSERT_EQ(OK, mProducer->queueBuffer(slot, input, &output));
BufferItem item;
@@ -405,13 +405,13 @@
sp<GraphicBuffer> buffer;
// This should return an error since it would require an allocation
ASSERT_EQ(OK, mProducer->allowAllocation(false));
- ASSERT_EQ(WOULD_BLOCK, mProducer->dequeueBuffer(&slot, &fence, false, 0, 0,
+ ASSERT_EQ(WOULD_BLOCK, mProducer->dequeueBuffer(&slot, &fence, 0, 0,
0, GRALLOC_USAGE_SW_WRITE_OFTEN));
// This should succeed, now that we've lifted the prohibition
ASSERT_EQ(OK, mProducer->allowAllocation(true));
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+ mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
GRALLOC_USAGE_SW_WRITE_OFTEN));
// Release the previous buffer back to the BufferQueue
@@ -419,7 +419,7 @@
// This should fail since we're requesting a different size
ASSERT_EQ(OK, mProducer->allowAllocation(false));
- ASSERT_EQ(WOULD_BLOCK, mProducer->dequeueBuffer(&slot, &fence, false,
+ ASSERT_EQ(WOULD_BLOCK, mProducer->dequeueBuffer(&slot, &fence,
WIDTH * 2, HEIGHT * 2, 0, GRALLOC_USAGE_SW_WRITE_OFTEN));
}
@@ -437,7 +437,7 @@
int slot;
sp<Fence> fence;
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- mProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0, 0));
+ mProducer->dequeueBuffer(&slot, &fence, 0, 0, 0, 0));
sp<GraphicBuffer> buffer;
ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buffer));
diff --git a/libs/gui/tests/IGraphicBufferProducer_test.cpp b/libs/gui/tests/IGraphicBufferProducer_test.cpp
index 34fb998..7455cd9 100644
--- a/libs/gui/tests/IGraphicBufferProducer_test.cpp
+++ b/libs/gui/tests/IGraphicBufferProducer_test.cpp
@@ -61,7 +61,6 @@
const Rect QUEUE_BUFFER_INPUT_RECT = Rect(DEFAULT_WIDTH, DEFAULT_HEIGHT);
const int QUEUE_BUFFER_INPUT_SCALING_MODE = 0;
const int QUEUE_BUFFER_INPUT_TRANSFORM = 0;
- const bool QUEUE_BUFFER_INPUT_ASYNC = false;
const sp<Fence> QUEUE_BUFFER_INPUT_FENCE = Fence::NO_FENCE;
}; // namespace anonymous
@@ -131,7 +130,6 @@
crop = QUEUE_BUFFER_INPUT_RECT;
scalingMode = QUEUE_BUFFER_INPUT_SCALING_MODE;
transform = QUEUE_BUFFER_INPUT_TRANSFORM;
- async = QUEUE_BUFFER_INPUT_ASYNC;
fence = QUEUE_BUFFER_INPUT_FENCE;
}
@@ -143,7 +141,6 @@
crop,
scalingMode,
transform,
- async,
fence);
}
@@ -177,11 +174,6 @@
return *this;
}
- QueueBufferInputBuilder& setAsync(bool async) {
- this->async = async;
- return *this;
- }
-
QueueBufferInputBuilder& setFence(sp<Fence> fence) {
this->fence = fence;
return *this;
@@ -194,7 +186,6 @@
Rect crop;
int scalingMode;
uint32_t transform;
- int async;
sp<Fence> fence;
}; // struct QueueBufferInputBuilder
@@ -204,8 +195,8 @@
sp<Fence> fence;
};
- status_t dequeueBuffer(bool async, uint32_t w, uint32_t h, uint32_t format, uint32_t usage, DequeueBufferResult* result) {
- return mProducer->dequeueBuffer(&result->slot, &result->fence, async, w, h, format, usage);
+ status_t dequeueBuffer(uint32_t w, uint32_t h, uint32_t format, uint32_t usage, DequeueBufferResult* result) {
+ return mProducer->dequeueBuffer(&result->slot, &result->fence, w, h, format, usage);
}
void setupDequeueRequestBuffer(int *slot, sp<Fence> *fence,
@@ -218,9 +209,8 @@
ASSERT_NO_FATAL_FAILURE(ConnectProducer());
ASSERT_EQ(OK, ~IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION &
- (mProducer->dequeueBuffer(slot, fence,
- QUEUE_BUFFER_INPUT_ASYNC, DEFAULT_WIDTH, DEFAULT_HEIGHT,
- DEFAULT_FORMAT, TEST_PRODUCER_USAGE_BITS)));
+ (mProducer->dequeueBuffer(slot, fence, DEFAULT_WIDTH,
+ DEFAULT_HEIGHT, DEFAULT_FORMAT, TEST_PRODUCER_USAGE_BITS)));
EXPECT_LE(0, *slot);
EXPECT_GT(BufferQueue::NUM_BUFFER_SLOTS, *slot);
@@ -355,9 +345,9 @@
int dequeuedSlot = -1;
sp<Fence> dequeuedFence;
+
ASSERT_EQ(OK, ~IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION &
(mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
- QUEUE_BUFFER_INPUT_ASYNC,
DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
TEST_PRODUCER_USAGE_BITS)));
@@ -422,7 +412,6 @@
ASSERT_EQ(OK, ~IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION &
(mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
- QUEUE_BUFFER_INPUT_ASYNC,
DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
TEST_PRODUCER_USAGE_BITS)));
@@ -492,7 +481,6 @@
ASSERT_EQ(OK, ~IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION &
(mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
- QUEUE_BUFFER_INPUT_ASYNC,
DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
TEST_PRODUCER_USAGE_BITS)));
@@ -521,8 +509,7 @@
DequeueBufferResult result;
EXPECT_EQ(OK, ~IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION &
- (dequeueBuffer(QUEUE_BUFFER_INPUT_ASYNC,
- DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
+ (dequeueBuffer(DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
TEST_PRODUCER_USAGE_BITS, &result)))
<< "iteration: " << i << ", slot: " << result.slot;
@@ -543,7 +530,6 @@
EXPECT_EQ(OK, ~IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION &
(mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
- QUEUE_BUFFER_INPUT_ASYNC,
DEFAULT_WIDTH, DEFAULT_HEIGHT,
DEFAULT_FORMAT,
TEST_PRODUCER_USAGE_BITS)))
@@ -574,7 +560,6 @@
ASSERT_EQ(OK, ~IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION &
(mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
- QUEUE_BUFFER_INPUT_ASYNC,
DEFAULT_WIDTH, DEFAULT_HEIGHT,
DEFAULT_FORMAT,
TEST_PRODUCER_USAGE_BITS)))
@@ -602,10 +587,7 @@
int dequeuedSlot = -1;
sp<Fence> dequeuedFence;
- IGraphicBufferProducer::QueueBufferInput input(QUEUE_BUFFER_INPUT_TIMESTAMP,
- QUEUE_BUFFER_INPUT_IS_AUTO_TIMESTAMP, QUEUE_BUFFER_INPUT_DATASPACE,
- QUEUE_BUFFER_INPUT_RECT, QUEUE_BUFFER_INPUT_SCALING_MODE,
- QUEUE_BUFFER_INPUT_TRANSFORM, true, QUEUE_BUFFER_INPUT_FENCE);
+ IGraphicBufferProducer::QueueBufferInput input = CreateBufferInput();
IGraphicBufferProducer::QueueBufferOutput output;
sp<GraphicBuffer> dequeuedBuffer;
@@ -614,9 +596,8 @@
for (int i = 0; i < 5; ++i) {
ASSERT_EQ(OK, ~IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION &
(mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
- true, DEFAULT_WIDTH, DEFAULT_HEIGHT,
- DEFAULT_FORMAT, TEST_PRODUCER_USAGE_BITS))) << "slot : "
- << dequeuedSlot;
+ DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
+ TEST_PRODUCER_USAGE_BITS))) << "slot : " << dequeuedSlot;
ASSERT_OK(mProducer->requestBuffer(dequeuedSlot, &dequeuedBuffer));
ASSERT_OK(mProducer->queueBuffer(dequeuedSlot, input, &output));
}
@@ -631,9 +612,8 @@
ASSERT_EQ(OK, ~IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION &
(mProducer->dequeueBuffer(&dequeuedSlot, &dequeuedFence,
- QUEUE_BUFFER_INPUT_ASYNC, DEFAULT_WIDTH, DEFAULT_HEIGHT,
- DEFAULT_FORMAT, TEST_PRODUCER_USAGE_BITS))) << "slot: "
- << dequeuedSlot;
+ DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_FORMAT,
+ TEST_PRODUCER_USAGE_BITS))) << "slot: " << dequeuedSlot;
}
// Client has one or more buffers dequeued
@@ -653,9 +633,8 @@
int slot = -1;
sp<Fence> fence;
- ASSERT_EQ(NO_INIT, mProducer->dequeueBuffer(&slot, &fence,
- QUEUE_BUFFER_INPUT_ASYNC, DEFAULT_WIDTH, DEFAULT_HEIGHT,
- DEFAULT_FORMAT, TEST_PRODUCER_USAGE_BITS));
+ ASSERT_EQ(NO_INIT, mProducer->dequeueBuffer(&slot, &fence, DEFAULT_WIDTH,
+ DEFAULT_HEIGHT, DEFAULT_FORMAT, TEST_PRODUCER_USAGE_BITS));
}
TEST_F(IGraphicBufferProducerTest,
@@ -674,9 +653,8 @@
sp<Fence> fence;
ASSERT_EQ(OK, ~IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION &
- (mProducer->dequeueBuffer(&slot, &fence,
- QUEUE_BUFFER_INPUT_ASYNC, DEFAULT_WIDTH, DEFAULT_HEIGHT,
- DEFAULT_FORMAT, TEST_PRODUCER_USAGE_BITS)));
+ (mProducer->dequeueBuffer(&slot, &fence, DEFAULT_WIDTH,
+ DEFAULT_HEIGHT, DEFAULT_FORMAT, TEST_PRODUCER_USAGE_BITS)));
EXPECT_LE(0, slot);
EXPECT_GT(BufferQueue::NUM_BUFFER_SLOTS, slot);
diff --git a/libs/gui/tests/StreamSplitter_test.cpp b/libs/gui/tests/StreamSplitter_test.cpp
index afd149e..c7ce263 100644
--- a/libs/gui/tests/StreamSplitter_test.cpp
+++ b/libs/gui/tests/StreamSplitter_test.cpp
@@ -103,7 +103,7 @@
sp<Fence> fence;
sp<GraphicBuffer> buffer;
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+ inputProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
GRALLOC_USAGE_SW_WRITE_OFTEN));
ASSERT_EQ(OK, inputProducer->requestBuffer(slot, &buffer));
@@ -114,9 +114,8 @@
ASSERT_EQ(OK, buffer->unlock());
IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
- HAL_DATASPACE_UNKNOWN,
- Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
- Fence::NO_FENCE);
+ HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
+ NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, Fence::NO_FENCE);
ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
BufferItem item;
@@ -132,7 +131,7 @@
EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE));
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+ inputProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
GRALLOC_USAGE_SW_WRITE_OFTEN));
ASSERT_EQ(1, allocator->getAllocCount());
@@ -170,7 +169,7 @@
sp<Fence> fence;
sp<GraphicBuffer> buffer;
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+ inputProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
GRALLOC_USAGE_SW_WRITE_OFTEN));
ASSERT_EQ(OK, inputProducer->requestBuffer(slot, &buffer));
@@ -181,9 +180,8 @@
ASSERT_EQ(OK, buffer->unlock());
IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
- HAL_DATASPACE_UNKNOWN,
- Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
- Fence::NO_FENCE);
+ HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
+ NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, Fence::NO_FENCE);
ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
for (int output = 0; output < NUM_OUTPUTS; ++output) {
@@ -202,7 +200,7 @@
}
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+ inputProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
GRALLOC_USAGE_SW_WRITE_OFTEN));
ASSERT_EQ(1, allocator->getAllocCount());
@@ -231,7 +229,7 @@
sp<Fence> fence;
sp<GraphicBuffer> buffer;
ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION,
- inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0, 0,
+ inputProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
GRALLOC_USAGE_SW_WRITE_OFTEN));
ASSERT_EQ(OK, inputProducer->requestBuffer(slot, &buffer));
@@ -239,14 +237,13 @@
outputConsumer->consumerDisconnect();
IGraphicBufferProducer::QueueBufferInput qbInput(0, false,
- HAL_DATASPACE_UNKNOWN,
- Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false,
- Fence::NO_FENCE);
+ HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1),
+ NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, Fence::NO_FENCE);
ASSERT_EQ(OK, inputProducer->queueBuffer(slot, qbInput, &qbOutput));
// Input should be abandoned
- ASSERT_EQ(NO_INIT, inputProducer->dequeueBuffer(&slot, &fence, false, 0, 0,
- 0, GRALLOC_USAGE_SW_WRITE_OFTEN));
+ ASSERT_EQ(NO_INIT, inputProducer->dequeueBuffer(&slot, &fence, 0, 0, 0,
+ GRALLOC_USAGE_SW_WRITE_OFTEN));
}
} // namespace android
diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
index 0880a44..48971bc 100644
--- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
@@ -92,6 +92,7 @@
mConsumer->setConsumerName(ConsumerBase::mName);
mConsumer->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);
mConsumer->setDefaultBufferSize(sinkWidth, sinkHeight);
+ sink->setAsyncMode(true);
}
VirtualDisplaySurface::~VirtualDisplaySurface() {
@@ -238,7 +239,6 @@
HAL_DATASPACE_UNKNOWN,
Rect(mSinkBufferWidth, mSinkBufferHeight),
NATIVE_WINDOW_SCALING_MODE_FREEZE, 0 /* transform */,
- true /* async*/,
outFence),
&qbo);
if (result == NO_ERROR) {
@@ -293,10 +293,8 @@
status_t VirtualDisplaySurface::dequeueBuffer(Source source,
PixelFormat format, uint32_t usage, int* sslot, sp<Fence>* fence) {
LOG_FATAL_IF(mDisplayId < 0, "mDisplayId=%d but should not be < 0.", mDisplayId);
- // Don't let a slow consumer block us
- bool async = (source == SOURCE_SINK);
- status_t result = mSource[source]->dequeueBuffer(sslot, fence, async,
+ status_t result = mSource[source]->dequeueBuffer(sslot, fence,
mSinkBufferWidth, mSinkBufferHeight, format, usage);
if (result < 0)
return result;
@@ -335,16 +333,15 @@
return result;
}
-status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, bool async,
+status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence,
uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) {
if (mDisplayId < 0)
- return mSource[SOURCE_SINK]->dequeueBuffer(pslot, fence, async, w, h, format, usage);
+ return mSource[SOURCE_SINK]->dequeueBuffer(pslot, fence, w, h, format, usage);
VDS_LOGW_IF(mDbgState != DBG_STATE_PREPARED,
"Unexpected dequeueBuffer() in %s state", dbgStateStr());
mDbgState = DBG_STATE_GLES;
- VDS_LOGW_IF(!async, "EGL called dequeueBuffer with !async despite eglSwapInterval(0)");
VDS_LOGV("dequeueBuffer %dx%d fmt=%d usage=%#x", w, h, format, usage);
status_t result = NO_ERROR;
@@ -464,9 +461,8 @@
Rect crop;
int scalingMode;
uint32_t transform;
- bool async;
input.deflate(×tamp, &isAutoTimestamp, &dataSpace, &crop,
- &scalingMode, &transform, &async, &mFbFence);
+ &scalingMode, &transform, &mFbFence);
mFbProducerSlot = pslot;
mOutputFence = mFbFence;
@@ -525,9 +521,8 @@
return INVALID_OPERATION;
}
-void VirtualDisplaySurface::allocateBuffers(bool /* async */,
- uint32_t /* width */, uint32_t /* height */, PixelFormat /* format */,
- uint32_t /* usage */) {
+void VirtualDisplaySurface::allocateBuffers(uint32_t /* width */,
+ uint32_t /* height */, PixelFormat /* format */, uint32_t /* usage */) {
// TODO: Should we actually allocate buffers for a virtual display?
}
diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
index 91e94f1..d53d43c 100644
--- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
+++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.h
@@ -100,8 +100,8 @@
virtual status_t requestBuffer(int pslot, sp<GraphicBuffer>* outBuf);
virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers);
virtual status_t setAsyncMode(bool async);
- virtual status_t dequeueBuffer(int* pslot, sp<Fence>* fence, bool async,
- uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
+ virtual status_t dequeueBuffer(int* pslot, sp<Fence>* fence, uint32_t w,
+ uint32_t h, PixelFormat format, uint32_t usage);
virtual status_t detachBuffer(int slot);
virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
sp<Fence>* outFence);
@@ -114,7 +114,7 @@
int api, bool producerControlledByApp, QueueBufferOutput* output);
virtual status_t disconnect(int api);
virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
- virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
+ virtual void allocateBuffers(uint32_t width, uint32_t height,
PixelFormat format, uint32_t usage);
virtual status_t allowAllocation(bool allow);
virtual status_t setGenerationNumber(uint32_t generationNumber);
diff --git a/services/surfaceflinger/MonitoredProducer.cpp b/services/surfaceflinger/MonitoredProducer.cpp
index f16ad59..79ef92f 100644
--- a/services/surfaceflinger/MonitoredProducer.cpp
+++ b/services/surfaceflinger/MonitoredProducer.cpp
@@ -66,8 +66,8 @@
}
status_t MonitoredProducer::dequeueBuffer(int* slot, sp<Fence>* fence,
- bool async, uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) {
- return mProducer->dequeueBuffer(slot, fence, async, w, h, format, usage);
+ uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) {
+ return mProducer->dequeueBuffer(slot, fence, w, h, format, usage);
}
status_t MonitoredProducer::detachBuffer(int slot) {
@@ -110,9 +110,9 @@
return mProducer->setSidebandStream(stream);
}
-void MonitoredProducer::allocateBuffers(bool async, uint32_t width,
- uint32_t height, PixelFormat format, uint32_t usage) {
- mProducer->allocateBuffers(async, width, height, format, usage);
+void MonitoredProducer::allocateBuffers(uint32_t width, uint32_t height,
+ PixelFormat format, uint32_t usage) {
+ mProducer->allocateBuffers(width, height, format, usage);
}
status_t MonitoredProducer::allowAllocation(bool allow) {
diff --git a/services/surfaceflinger/MonitoredProducer.h b/services/surfaceflinger/MonitoredProducer.h
index 0bdc050..3df6f0f 100644
--- a/services/surfaceflinger/MonitoredProducer.h
+++ b/services/surfaceflinger/MonitoredProducer.h
@@ -37,8 +37,8 @@
virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers);
virtual status_t setAsyncMode(bool async);
- virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, bool async,
- uint32_t w, uint32_t h, PixelFormat format, uint32_t usage);
+ virtual status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w,
+ uint32_t h, PixelFormat format, uint32_t usage);
virtual status_t detachBuffer(int slot);
virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer,
sp<Fence>* outFence);
@@ -52,7 +52,7 @@
bool producerControlledByApp, QueueBufferOutput* output);
virtual status_t disconnect(int api);
virtual status_t setSidebandStream(const sp<NativeHandle>& stream);
- virtual void allocateBuffers(bool async, uint32_t width, uint32_t height,
+ virtual void allocateBuffers(uint32_t width, uint32_t height,
PixelFormat format, uint32_t usage);
virtual status_t allowAllocation(bool allow);
virtual status_t setGenerationNumber(uint32_t generationNumber);