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