Loading include/gui/BufferQueueCore.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -270,6 +270,10 @@ private: // mAllowAllocation determines whether dequeueBuffer is allowed to allocate // mAllowAllocation determines whether dequeueBuffer is allowed to allocate // new buffers // new buffers bool mAllowAllocation; bool mAllowAllocation; // mBufferAge tracks the age of the contents of the most recently dequeued // buffer as the number of frames that have elapsed since it was last queued uint64_t mBufferAge; }; // class BufferQueueCore }; // class BufferQueueCore } // namespace android } // namespace android Loading libs/gui/BufferQueueCore.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -70,7 +70,8 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) : mTransformHint(0), mTransformHint(0), mIsAllocating(false), mIsAllocating(false), mIsAllocatingCondition(), mIsAllocatingCondition(), mAllowAllocation(true) mAllowAllocation(true), mBufferAge(0) { { if (allocator == NULL) { if (allocator == NULL) { sp<ISurfaceComposer> composer(ComposerService::getComposerService()); sp<ISurfaceComposer> composer(ComposerService::getComposerService()); Loading libs/gui/BufferQueueProducer.cpp +16 −0 Original line number Original line Diff line number Diff line Loading @@ -337,10 +337,19 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot, mSlots[found].mEglDisplay = EGL_NO_DISPLAY; mSlots[found].mEglDisplay = EGL_NO_DISPLAY; mSlots[found].mEglFence = EGL_NO_SYNC_KHR; mSlots[found].mEglFence = EGL_NO_SYNC_KHR; mSlots[found].mFence = Fence::NO_FENCE; mSlots[found].mFence = Fence::NO_FENCE; mCore->mBufferAge = 0; returnFlags |= BUFFER_NEEDS_REALLOCATION; 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)) { if (CC_UNLIKELY(mSlots[found].mFence == NULL)) { BQ_LOGE("dequeueBuffer: about to return a NULL fence - " BQ_LOGE("dequeueBuffer: about to return a NULL fence - " "slot=%d w=%d h=%d format=%u", "slot=%d w=%d h=%d format=%u", Loading Loading @@ -784,6 +793,13 @@ int BufferQueueProducer::query(int what, int *outValue) { case NATIVE_WINDOW_DEFAULT_DATASPACE: case NATIVE_WINDOW_DEFAULT_DATASPACE: value = static_cast<int32_t>(mCore->mDefaultBufferDataSpace); value = static_cast<int32_t>(mCore->mDefaultBufferDataSpace); break; break; case NATIVE_WINDOW_BUFFER_AGE: if (mCore->mBufferAge > INT32_MAX) { value = 0; } else { value = static_cast<int32_t>(mCore->mBufferAge); } break; default: default: return BAD_VALUE; return BAD_VALUE; } } Loading Loading
include/gui/BufferQueueCore.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -270,6 +270,10 @@ private: // mAllowAllocation determines whether dequeueBuffer is allowed to allocate // mAllowAllocation determines whether dequeueBuffer is allowed to allocate // new buffers // new buffers bool mAllowAllocation; bool mAllowAllocation; // mBufferAge tracks the age of the contents of the most recently dequeued // buffer as the number of frames that have elapsed since it was last queued uint64_t mBufferAge; }; // class BufferQueueCore }; // class BufferQueueCore } // namespace android } // namespace android Loading
libs/gui/BufferQueueCore.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -70,7 +70,8 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) : mTransformHint(0), mTransformHint(0), mIsAllocating(false), mIsAllocating(false), mIsAllocatingCondition(), mIsAllocatingCondition(), mAllowAllocation(true) mAllowAllocation(true), mBufferAge(0) { { if (allocator == NULL) { if (allocator == NULL) { sp<ISurfaceComposer> composer(ComposerService::getComposerService()); sp<ISurfaceComposer> composer(ComposerService::getComposerService()); Loading
libs/gui/BufferQueueProducer.cpp +16 −0 Original line number Original line Diff line number Diff line Loading @@ -337,10 +337,19 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot, mSlots[found].mEglDisplay = EGL_NO_DISPLAY; mSlots[found].mEglDisplay = EGL_NO_DISPLAY; mSlots[found].mEglFence = EGL_NO_SYNC_KHR; mSlots[found].mEglFence = EGL_NO_SYNC_KHR; mSlots[found].mFence = Fence::NO_FENCE; mSlots[found].mFence = Fence::NO_FENCE; mCore->mBufferAge = 0; returnFlags |= BUFFER_NEEDS_REALLOCATION; 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)) { if (CC_UNLIKELY(mSlots[found].mFence == NULL)) { BQ_LOGE("dequeueBuffer: about to return a NULL fence - " BQ_LOGE("dequeueBuffer: about to return a NULL fence - " "slot=%d w=%d h=%d format=%u", "slot=%d w=%d h=%d format=%u", Loading Loading @@ -784,6 +793,13 @@ int BufferQueueProducer::query(int what, int *outValue) { case NATIVE_WINDOW_DEFAULT_DATASPACE: case NATIVE_WINDOW_DEFAULT_DATASPACE: value = static_cast<int32_t>(mCore->mDefaultBufferDataSpace); value = static_cast<int32_t>(mCore->mDefaultBufferDataSpace); break; break; case NATIVE_WINDOW_BUFFER_AGE: if (mCore->mBufferAge > INT32_MAX) { value = 0; } else { value = static_cast<int32_t>(mCore->mBufferAge); } break; default: default: return BAD_VALUE; return BAD_VALUE; } } Loading