diff options
| author | 2015-04-29 17:21:49 +0000 | |
|---|---|---|
| committer | 2015-04-29 17:21:51 +0000 | |
| commit | 8de71a2408f632407c25942a39c31f78c7f64ffd (patch) | |
| tree | 0cce3d9d5ed8c64b1b83f0394fc71ba8cd623561 /libs/gui | |
| parent | ca8c569598d79b4bbe4fc08a4ea97619df3b7262 (diff) | |
| parent | 81cde67a5528af6fbb7a3d49930fd3ca8ff49b34 (diff) | |
Merge "BufferQueue: Add NATIVE_WINDOW_BUFFER_AGE query"
Diffstat (limited to 'libs/gui')
| -rw-r--r-- | libs/gui/BufferQueueCore.cpp | 3 | ||||
| -rw-r--r-- | libs/gui/BufferQueueProducer.cpp | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/libs/gui/BufferQueueCore.cpp b/libs/gui/BufferQueueCore.cpp index bc75ca7539..887f2cbf06 100644 --- a/libs/gui/BufferQueueCore.cpp +++ b/libs/gui/BufferQueueCore.cpp @@ -70,7 +70,8 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) : mTransformHint(0), mIsAllocating(false), mIsAllocatingCondition(), - mAllowAllocation(true) + mAllowAllocation(true), + mBufferAge(0) { if (allocator == NULL) { sp<ISurfaceComposer> composer(ComposerService::getComposerService()); diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp index 86e45c8b00..7251d369ab 100644 --- a/libs/gui/BufferQueueProducer.cpp +++ b/libs/gui/BufferQueueProducer.cpp @@ -337,10 +337,19 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot, mSlots[found].mEglDisplay = EGL_NO_DISPLAY; mSlots[found].mEglFence = EGL_NO_SYNC_KHR; mSlots[found].mFence = Fence::NO_FENCE; + mCore->mBufferAge = 0; returnFlags |= BUFFER_NEEDS_REALLOCATION; + } else { + // We add 1 because that will be the frame number when this buffer + // is queued + mCore->mBufferAge = + mCore->mFrameCounter + 1 - mSlots[found].mFrameNumber; } + BQ_LOGV("dequeueBuffer: setting buffer age to %" PRIu64, + mCore->mBufferAge); + if (CC_UNLIKELY(mSlots[found].mFence == NULL)) { BQ_LOGE("dequeueBuffer: about to return a NULL fence - " "slot=%d w=%d h=%d format=%u", @@ -784,6 +793,13 @@ int BufferQueueProducer::query(int what, int *outValue) { case NATIVE_WINDOW_DEFAULT_DATASPACE: value = static_cast<int32_t>(mCore->mDefaultBufferDataSpace); break; + case NATIVE_WINDOW_BUFFER_AGE: + if (mCore->mBufferAge > INT32_MAX) { + value = 0; + } else { + value = static_cast<int32_t>(mCore->mBufferAge); + } + break; default: return BAD_VALUE; } |