Loading libs/gui/BufferQueueProducer.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -347,9 +347,9 @@ status_t BufferQueueProducer::waitForFreeSlotThenRelock(FreeSlotCaller caller, return NO_ERROR; } status_t BufferQueueProducer::dequeueBuffer(int *outSlot, sp<android::Fence> *outFence, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, status_t BufferQueueProducer::dequeueBuffer(int* outSlot, sp<android::Fence>* outFence, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, uint64_t* outBufferAge, FrameEventHistoryDelta* outTimestamps) { ATRACE_CALL(); { // Autolock scope Loading Loading @@ -558,6 +558,9 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot, mSlots[*outSlot].mFrameNumber, mSlots[*outSlot].mGraphicBuffer->handle, returnFlags); if (outBufferAge) { *outBufferAge = mCore->mBufferAge; } addAndGetFrameTimestamps(nullptr, outTimestamps); return returnFlags; Loading libs/gui/IGraphicBufferProducer.cpp +22 −10 Original line number Diff line number Diff line Loading @@ -124,8 +124,8 @@ public: return result; } virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, virtual status_t dequeueBuffer(int* buf, sp<Fence>* fence, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, uint64_t* outBufferAge, FrameEventHistoryDelta* outTimestamps) { Parcel data, reply; bool getFrameTimestamps = (outTimestamps != nullptr); Loading @@ -149,6 +149,17 @@ public: fence->clear(); return result; } if (outBufferAge) { result = reply.readUint64(outBufferAge); } else { // Read the value even if outBufferAge is nullptr: uint64_t bufferAge; result = reply.readUint64(&bufferAge); } if (result != NO_ERROR) { ALOGE("IGBP::dequeueBuffer failed to read buffer age: %d", result); return result; } if (getFrameTimestamps) { result = reply.read(*outTimestamps); if (result != NO_ERROR) { Loading Loading @@ -516,11 +527,10 @@ public: return mBase->setAsyncMode(async); } status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, PixelFormat format, uint64_t usage, status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, PixelFormat format, uint64_t usage, uint64_t* outBufferAge, FrameEventHistoryDelta* outTimestamps) override { return mBase->dequeueBuffer( slot, fence, w, h, format, usage, outTimestamps); return mBase->dequeueBuffer(slot, fence, w, h, format, usage, outBufferAge, outTimestamps); } status_t detachBuffer(int slot) override { Loading Loading @@ -655,16 +665,18 @@ status_t BnGraphicBufferProducer::onTransact( uint32_t height = data.readUint32(); PixelFormat format = static_cast<PixelFormat>(data.readInt32()); uint64_t usage = data.readUint64(); uint64_t bufferAge = 0; bool getTimestamps = data.readBool(); int buf = 0; sp<Fence> fence = Fence::NO_FENCE; FrameEventHistoryDelta frameTimestamps; int result = dequeueBuffer(&buf, &fence, width, height, format, usage, getTimestamps ? &frameTimestamps : nullptr); int result = dequeueBuffer(&buf, &fence, width, height, format, usage, &bufferAge, getTimestamps ? &frameTimestamps : nullptr); reply->writeInt32(buf); reply->write(*fence); reply->writeUint64(bufferAge); if (getTimestamps) { reply->write(frameTimestamps); } Loading libs/gui/Surface.cpp +25 −18 Original line number Diff line number Diff line Loading @@ -44,11 +44,10 @@ namespace android { Surface::Surface( const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp) Surface::Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp) : mGraphicBufferProducer(bufferProducer), mCrop(Rect::EMPTY_RECT), mBufferAge(0), mGenerationNumber(0), mSharedBufferMode(false), mAutoRefresh(false), Loading @@ -57,8 +56,7 @@ Surface::Surface( mQueriedSupportedTimestamps(false), mFrameTimestampsSupportsPresent(false), mEnableFrameTimestamps(false), mFrameEventHistory(std::make_unique<ProducerFrameEventHistory>()) { mFrameEventHistory(std::make_unique<ProducerFrameEventHistory>()) { // Initialize the ANativeWindow function pointers. ANativeWindow::setSwapInterval = hook_setSwapInterval; ANativeWindow::dequeueBuffer = hook_dequeueBuffer; Loading Loading @@ -506,9 +504,10 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) { nsecs_t startTime = systemTime(); FrameEventHistoryDelta frameTimestamps; status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence, reqWidth, reqHeight, reqFormat, reqUsage, enableFrameTimestamps ? &frameTimestamps : nullptr); status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence, reqWidth, reqHeight, reqFormat, reqUsage, &mBufferAge, enableFrameTimestamps ? &frameTimestamps : nullptr); mLastDequeueDuration = systemTime() - startTime; if (result < 0) { Loading Loading @@ -845,6 +844,14 @@ int Surface::query(int what, int* value) const { } return err; } case NATIVE_WINDOW_BUFFER_AGE: { if (mBufferAge > INT32_MAX) { *value = 0; } else { *value = static_cast<int32_t>(mBufferAge); } return NO_ERROR; } case NATIVE_WINDOW_LAST_DEQUEUE_DURATION: { int64_t durationUs = mLastDequeueDuration / 1000; *value = durationUs > std::numeric_limits<int>::max() ? Loading libs/gui/bufferqueue/1.0/H2BGraphicBufferProducer.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -989,10 +989,10 @@ status_t H2BGraphicBufferProducer::setAsyncMode(bool async) { } // FIXME: usage bits truncated -- needs a 64-bits usage version status_t H2BGraphicBufferProducer::dequeueBuffer( int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, ::android::PixelFormat format, uint64_t usage, FrameEventHistoryDelta* outTimestamps) { status_t H2BGraphicBufferProducer::dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, ::android::PixelFormat format, uint64_t usage, uint64_t* outBufferAge, FrameEventHistoryDelta* outTimestamps) { *fence = new Fence(); status_t fnStatus; status_t transStatus = toStatusT(mBase->dequeueBuffer( Loading @@ -1016,6 +1016,10 @@ status_t H2BGraphicBufferProducer::dequeueBuffer( fnStatus = fnStatus == NO_ERROR ? BAD_VALUE : fnStatus; } })); if (outBufferAge) { // Since the HAL version doesn't return the buffer age, set it to 0: *outBufferAge = 0; } return transStatus == NO_ERROR ? fnStatus : transStatus; } Loading libs/gui/include/gui/BufferQueueProducer.h +4 −3 Original line number Diff line number Diff line Loading @@ -80,9 +80,10 @@ public: // // 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, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, FrameEventHistoryDelta* outTimestamps) override; virtual status_t dequeueBuffer(int* outSlot, sp<Fence>* outFence, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, uint64_t* outBufferAge, FrameEventHistoryDelta* outTimestamps) override; // See IGraphicBufferProducer::detachBuffer virtual status_t detachBuffer(int slot); Loading Loading
libs/gui/BufferQueueProducer.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -347,9 +347,9 @@ status_t BufferQueueProducer::waitForFreeSlotThenRelock(FreeSlotCaller caller, return NO_ERROR; } status_t BufferQueueProducer::dequeueBuffer(int *outSlot, sp<android::Fence> *outFence, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, status_t BufferQueueProducer::dequeueBuffer(int* outSlot, sp<android::Fence>* outFence, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, uint64_t* outBufferAge, FrameEventHistoryDelta* outTimestamps) { ATRACE_CALL(); { // Autolock scope Loading Loading @@ -558,6 +558,9 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot, mSlots[*outSlot].mFrameNumber, mSlots[*outSlot].mGraphicBuffer->handle, returnFlags); if (outBufferAge) { *outBufferAge = mCore->mBufferAge; } addAndGetFrameTimestamps(nullptr, outTimestamps); return returnFlags; Loading
libs/gui/IGraphicBufferProducer.cpp +22 −10 Original line number Diff line number Diff line Loading @@ -124,8 +124,8 @@ public: return result; } virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, virtual status_t dequeueBuffer(int* buf, sp<Fence>* fence, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, uint64_t* outBufferAge, FrameEventHistoryDelta* outTimestamps) { Parcel data, reply; bool getFrameTimestamps = (outTimestamps != nullptr); Loading @@ -149,6 +149,17 @@ public: fence->clear(); return result; } if (outBufferAge) { result = reply.readUint64(outBufferAge); } else { // Read the value even if outBufferAge is nullptr: uint64_t bufferAge; result = reply.readUint64(&bufferAge); } if (result != NO_ERROR) { ALOGE("IGBP::dequeueBuffer failed to read buffer age: %d", result); return result; } if (getFrameTimestamps) { result = reply.read(*outTimestamps); if (result != NO_ERROR) { Loading Loading @@ -516,11 +527,10 @@ public: return mBase->setAsyncMode(async); } status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, PixelFormat format, uint64_t usage, status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, PixelFormat format, uint64_t usage, uint64_t* outBufferAge, FrameEventHistoryDelta* outTimestamps) override { return mBase->dequeueBuffer( slot, fence, w, h, format, usage, outTimestamps); return mBase->dequeueBuffer(slot, fence, w, h, format, usage, outBufferAge, outTimestamps); } status_t detachBuffer(int slot) override { Loading Loading @@ -655,16 +665,18 @@ status_t BnGraphicBufferProducer::onTransact( uint32_t height = data.readUint32(); PixelFormat format = static_cast<PixelFormat>(data.readInt32()); uint64_t usage = data.readUint64(); uint64_t bufferAge = 0; bool getTimestamps = data.readBool(); int buf = 0; sp<Fence> fence = Fence::NO_FENCE; FrameEventHistoryDelta frameTimestamps; int result = dequeueBuffer(&buf, &fence, width, height, format, usage, getTimestamps ? &frameTimestamps : nullptr); int result = dequeueBuffer(&buf, &fence, width, height, format, usage, &bufferAge, getTimestamps ? &frameTimestamps : nullptr); reply->writeInt32(buf); reply->write(*fence); reply->writeUint64(bufferAge); if (getTimestamps) { reply->write(frameTimestamps); } Loading
libs/gui/Surface.cpp +25 −18 Original line number Diff line number Diff line Loading @@ -44,11 +44,10 @@ namespace android { Surface::Surface( const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp) Surface::Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp) : mGraphicBufferProducer(bufferProducer), mCrop(Rect::EMPTY_RECT), mBufferAge(0), mGenerationNumber(0), mSharedBufferMode(false), mAutoRefresh(false), Loading @@ -57,8 +56,7 @@ Surface::Surface( mQueriedSupportedTimestamps(false), mFrameTimestampsSupportsPresent(false), mEnableFrameTimestamps(false), mFrameEventHistory(std::make_unique<ProducerFrameEventHistory>()) { mFrameEventHistory(std::make_unique<ProducerFrameEventHistory>()) { // Initialize the ANativeWindow function pointers. ANativeWindow::setSwapInterval = hook_setSwapInterval; ANativeWindow::dequeueBuffer = hook_dequeueBuffer; Loading Loading @@ -506,9 +504,10 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) { nsecs_t startTime = systemTime(); FrameEventHistoryDelta frameTimestamps; status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence, reqWidth, reqHeight, reqFormat, reqUsage, enableFrameTimestamps ? &frameTimestamps : nullptr); status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence, reqWidth, reqHeight, reqFormat, reqUsage, &mBufferAge, enableFrameTimestamps ? &frameTimestamps : nullptr); mLastDequeueDuration = systemTime() - startTime; if (result < 0) { Loading Loading @@ -845,6 +844,14 @@ int Surface::query(int what, int* value) const { } return err; } case NATIVE_WINDOW_BUFFER_AGE: { if (mBufferAge > INT32_MAX) { *value = 0; } else { *value = static_cast<int32_t>(mBufferAge); } return NO_ERROR; } case NATIVE_WINDOW_LAST_DEQUEUE_DURATION: { int64_t durationUs = mLastDequeueDuration / 1000; *value = durationUs > std::numeric_limits<int>::max() ? Loading
libs/gui/bufferqueue/1.0/H2BGraphicBufferProducer.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -989,10 +989,10 @@ status_t H2BGraphicBufferProducer::setAsyncMode(bool async) { } // FIXME: usage bits truncated -- needs a 64-bits usage version status_t H2BGraphicBufferProducer::dequeueBuffer( int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, ::android::PixelFormat format, uint64_t usage, FrameEventHistoryDelta* outTimestamps) { status_t H2BGraphicBufferProducer::dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, ::android::PixelFormat format, uint64_t usage, uint64_t* outBufferAge, FrameEventHistoryDelta* outTimestamps) { *fence = new Fence(); status_t fnStatus; status_t transStatus = toStatusT(mBase->dequeueBuffer( Loading @@ -1016,6 +1016,10 @@ status_t H2BGraphicBufferProducer::dequeueBuffer( fnStatus = fnStatus == NO_ERROR ? BAD_VALUE : fnStatus; } })); if (outBufferAge) { // Since the HAL version doesn't return the buffer age, set it to 0: *outBufferAge = 0; } return transStatus == NO_ERROR ? fnStatus : transStatus; } Loading
libs/gui/include/gui/BufferQueueProducer.h +4 −3 Original line number Diff line number Diff line Loading @@ -80,9 +80,10 @@ public: // // 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, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, FrameEventHistoryDelta* outTimestamps) override; virtual status_t dequeueBuffer(int* outSlot, sp<Fence>* outFence, uint32_t width, uint32_t height, PixelFormat format, uint64_t usage, uint64_t* outBufferAge, FrameEventHistoryDelta* outTimestamps) override; // See IGraphicBufferProducer::detachBuffer virtual status_t detachBuffer(int slot); Loading