зеркало из https://github.com/mozilla/gecko-dev.git
Bug 839628 - Add MIN_UNDEQUEUED_BUFFERS check in GonkNativeWindow::dequeueBuffer(). r=kchen, r=mikeh, a=approval-mozilla-b2g18+
This commit is contained in:
Родитель
c071853065
Коммит
5779898c23
|
@ -263,6 +263,7 @@ int GonkNativeWindow::dequeueBuffer(android_native_buffer_t** buffer)
|
|||
|
||||
int found = -1;
|
||||
int dequeuedCount = 0;
|
||||
int renderingCount = 0;
|
||||
bool tryAgain = true;
|
||||
|
||||
CNW_LOGD("dequeueBuffer: E");
|
||||
|
@ -274,11 +275,15 @@ int GonkNativeWindow::dequeueBuffer(android_native_buffer_t** buffer)
|
|||
// look for a free buffer to give to the client
|
||||
found = INVALID_BUFFER_SLOT;
|
||||
dequeuedCount = 0;
|
||||
renderingCount = 0;
|
||||
for (int i = 0; i < mBufferCount; i++) {
|
||||
const int state = mSlots[i].mBufferState;
|
||||
if (state == BufferSlot::DEQUEUED) {
|
||||
dequeuedCount++;
|
||||
}
|
||||
else if (state == BufferSlot::RENDERING) {
|
||||
renderingCount++;
|
||||
}
|
||||
else if (state == BufferSlot::FREE) {
|
||||
/* We return the oldest of the free buffers to avoid
|
||||
* stalling the producer if possible. This is because
|
||||
|
@ -292,6 +297,22 @@ int GonkNativeWindow::dequeueBuffer(android_native_buffer_t** buffer)
|
|||
}
|
||||
}
|
||||
|
||||
// See whether a buffer has been in RENDERING state since the last
|
||||
// setBufferCount so we know whether to perform the
|
||||
// MIN_UNDEQUEUED_BUFFERS check below.
|
||||
if (renderingCount > 0) {
|
||||
// make sure the client is not trying to dequeue more buffers
|
||||
// than allowed.
|
||||
const int avail = mBufferCount - (dequeuedCount + 1);
|
||||
if (avail < MIN_UNDEQUEUED_BUFFERS) {
|
||||
CNW_LOGE("dequeueBuffer: MIN_UNDEQUEUED_BUFFERS=%d exceeded "
|
||||
"(dequeued=%d)",
|
||||
MIN_UNDEQUEUED_BUFFERS,
|
||||
dequeuedCount);
|
||||
return -EBUSY;
|
||||
}
|
||||
}
|
||||
|
||||
// we're in synchronous mode and didn't find a buffer, we need to
|
||||
// wait for some buffers to be consumed
|
||||
tryAgain = (found == INVALID_BUFFER_SLOT);
|
||||
|
|
Загрузка…
Ссылка в новой задаче