Loading libs/gui/BLASTBufferQueue.cpp +25 −7 Original line number Diff line number Diff line Loading @@ -584,9 +584,23 @@ status_t BLASTBufferQueue::acquireNextBufferLocked( t->setDesiredPresentTime(bufferItem.mTimestamp); } if (!mNextFrameTimelineInfoQueue.empty()) { t->setFrameTimelineInfo(mNextFrameTimelineInfoQueue.front()); mNextFrameTimelineInfoQueue.pop(); // Drop stale frame timeline infos while (!mPendingFrameTimelines.empty() && mPendingFrameTimelines.front().first < bufferItem.mFrameNumber) { ATRACE_FORMAT_INSTANT("dropping stale frameNumber: %" PRIu64 " vsyncId: %" PRId64, mPendingFrameTimelines.front().first, mPendingFrameTimelines.front().second.vsyncId); mPendingFrameTimelines.pop(); } if (!mPendingFrameTimelines.empty() && mPendingFrameTimelines.front().first == bufferItem.mFrameNumber) { ATRACE_FORMAT_INSTANT("Transaction::setFrameTimelineInfo frameNumber: %" PRIu64 " vsyncId: %" PRId64, bufferItem.mFrameNumber, mPendingFrameTimelines.front().second.vsyncId); t->setFrameTimelineInfo(mPendingFrameTimelines.front().second); mPendingFrameTimelines.pop(); } { Loading Loading @@ -843,12 +857,13 @@ public: return mBbq->setFrameRate(frameRate, compatibility, changeFrameRateStrategy); } status_t setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInfo) override { status_t setFrameTimelineInfo(uint64_t frameNumber, const FrameTimelineInfo& frameTimelineInfo) override { std::unique_lock _lock{mMutex}; if (mDestroyed) { return DEAD_OBJECT; } return mBbq->setFrameTimelineInfo(frameTimelineInfo); return mBbq->setFrameTimelineInfo(frameNumber, frameTimelineInfo); } void destroy() override { Loading @@ -870,9 +885,12 @@ status_t BLASTBufferQueue::setFrameRate(float frameRate, int8_t compatibility, return t.setFrameRate(mSurfaceControl, frameRate, compatibility, shouldBeSeamless).apply(); } status_t BLASTBufferQueue::setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInfo) { status_t BLASTBufferQueue::setFrameTimelineInfo(uint64_t frameNumber, const FrameTimelineInfo& frameTimelineInfo) { ATRACE_FORMAT("%s(%s) frameNumber: %" PRIu64 " vsyncId: %" PRId64, __func__, mName.c_str(), frameNumber, frameTimelineInfo.vsyncId); std::unique_lock _lock{mMutex}; mNextFrameTimelineInfoQueue.push(frameTimelineInfo); mPendingFrameTimelines.push({frameNumber, frameTimelineInfo}); return OK; } Loading libs/gui/Surface.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -1862,12 +1862,13 @@ int Surface::dispatchGetLastQueuedBuffer2(va_list args) { int Surface::dispatchSetFrameTimelineInfo(va_list args) { ATRACE_CALL(); auto frameNumber = static_cast<uint64_t>(va_arg(args, uint64_t)); auto frameTimelineVsyncId = static_cast<int64_t>(va_arg(args, int64_t)); auto inputEventId = static_cast<int32_t>(va_arg(args, int32_t)); auto startTimeNanos = static_cast<int64_t>(va_arg(args, int64_t)); ALOGV("Surface::%s", __func__); return setFrameTimelineInfo({frameTimelineVsyncId, inputEventId, startTimeNanos}); return setFrameTimelineInfo(frameNumber, {frameTimelineVsyncId, inputEventId, startTimeNanos}); } bool Surface::transformToDisplayInverse() const { Loading Loading @@ -2637,7 +2638,8 @@ status_t Surface::setFrameRate(float frameRate, int8_t compatibility, changeFrameRateStrategy); } status_t Surface::setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInfo) { status_t Surface::setFrameTimelineInfo(uint64_t /*frameNumber*/, const FrameTimelineInfo& frameTimelineInfo) { return composerService()->setFrameTimelineInfo(mGraphicBufferProducer, frameTimelineInfo); } Loading libs/gui/include/gui/BLASTBufferQueue.h +2 −2 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ public: void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height, int32_t format); status_t setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless); status_t setFrameTimelineInfo(const FrameTimelineInfo& info); status_t setFrameTimelineInfo(uint64_t frameNumber, const FrameTimelineInfo& info); void setSidebandStream(const sp<NativeHandle>& stream); Loading Loading @@ -237,7 +237,7 @@ private: std::vector<std::tuple<uint64_t /* framenumber */, SurfaceComposerClient::Transaction>> mPendingTransactions GUARDED_BY(mMutex); std::queue<FrameTimelineInfo> mNextFrameTimelineInfoQueue GUARDED_BY(mMutex); std::queue<std::pair<uint64_t, FrameTimelineInfo>> mPendingFrameTimelines GUARDED_BY(mMutex); // Tracks the last acquired frame number uint64_t mLastAcquiredFrameNumber GUARDED_BY(mMutex) = 0; Loading libs/gui/include/gui/Surface.h +1 −1 Original line number Diff line number Diff line Loading @@ -193,7 +193,7 @@ public: virtual status_t setFrameRate(float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy); virtual status_t setFrameTimelineInfo(const FrameTimelineInfo& info); virtual status_t setFrameTimelineInfo(uint64_t frameNumber, const FrameTimelineInfo& info); protected: virtual ~Surface(); Loading libs/gui/include/gui/TraceUtils.h +16 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ #define ATRACE_FORMAT_BEGIN(fmt, ...) TraceUtils::atraceFormatBegin(fmt, ##__VA_ARGS__) #define ATRACE_FORMAT_INSTANT(fmt, ...) TraceUtils::intantFormat(fmt, ##__VA_ARGS__) namespace android { class TraceUtils { Loading @@ -50,6 +52,20 @@ public: ATRACE_BEGIN(buf); } static void intantFormat(const char* fmt, ...) { if (CC_LIKELY(!ATRACE_ENABLED())) return; const int BUFFER_SIZE = 256; va_list ap; char buf[BUFFER_SIZE]; va_start(ap, fmt); vsnprintf(buf, BUFFER_SIZE, fmt, ap); va_end(ap); ATRACE_INSTANT(buf); } }; // class TraceUtils } /* namespace android */ Loading
libs/gui/BLASTBufferQueue.cpp +25 −7 Original line number Diff line number Diff line Loading @@ -584,9 +584,23 @@ status_t BLASTBufferQueue::acquireNextBufferLocked( t->setDesiredPresentTime(bufferItem.mTimestamp); } if (!mNextFrameTimelineInfoQueue.empty()) { t->setFrameTimelineInfo(mNextFrameTimelineInfoQueue.front()); mNextFrameTimelineInfoQueue.pop(); // Drop stale frame timeline infos while (!mPendingFrameTimelines.empty() && mPendingFrameTimelines.front().first < bufferItem.mFrameNumber) { ATRACE_FORMAT_INSTANT("dropping stale frameNumber: %" PRIu64 " vsyncId: %" PRId64, mPendingFrameTimelines.front().first, mPendingFrameTimelines.front().second.vsyncId); mPendingFrameTimelines.pop(); } if (!mPendingFrameTimelines.empty() && mPendingFrameTimelines.front().first == bufferItem.mFrameNumber) { ATRACE_FORMAT_INSTANT("Transaction::setFrameTimelineInfo frameNumber: %" PRIu64 " vsyncId: %" PRId64, bufferItem.mFrameNumber, mPendingFrameTimelines.front().second.vsyncId); t->setFrameTimelineInfo(mPendingFrameTimelines.front().second); mPendingFrameTimelines.pop(); } { Loading Loading @@ -843,12 +857,13 @@ public: return mBbq->setFrameRate(frameRate, compatibility, changeFrameRateStrategy); } status_t setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInfo) override { status_t setFrameTimelineInfo(uint64_t frameNumber, const FrameTimelineInfo& frameTimelineInfo) override { std::unique_lock _lock{mMutex}; if (mDestroyed) { return DEAD_OBJECT; } return mBbq->setFrameTimelineInfo(frameTimelineInfo); return mBbq->setFrameTimelineInfo(frameNumber, frameTimelineInfo); } void destroy() override { Loading @@ -870,9 +885,12 @@ status_t BLASTBufferQueue::setFrameRate(float frameRate, int8_t compatibility, return t.setFrameRate(mSurfaceControl, frameRate, compatibility, shouldBeSeamless).apply(); } status_t BLASTBufferQueue::setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInfo) { status_t BLASTBufferQueue::setFrameTimelineInfo(uint64_t frameNumber, const FrameTimelineInfo& frameTimelineInfo) { ATRACE_FORMAT("%s(%s) frameNumber: %" PRIu64 " vsyncId: %" PRId64, __func__, mName.c_str(), frameNumber, frameTimelineInfo.vsyncId); std::unique_lock _lock{mMutex}; mNextFrameTimelineInfoQueue.push(frameTimelineInfo); mPendingFrameTimelines.push({frameNumber, frameTimelineInfo}); return OK; } Loading
libs/gui/Surface.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -1862,12 +1862,13 @@ int Surface::dispatchGetLastQueuedBuffer2(va_list args) { int Surface::dispatchSetFrameTimelineInfo(va_list args) { ATRACE_CALL(); auto frameNumber = static_cast<uint64_t>(va_arg(args, uint64_t)); auto frameTimelineVsyncId = static_cast<int64_t>(va_arg(args, int64_t)); auto inputEventId = static_cast<int32_t>(va_arg(args, int32_t)); auto startTimeNanos = static_cast<int64_t>(va_arg(args, int64_t)); ALOGV("Surface::%s", __func__); return setFrameTimelineInfo({frameTimelineVsyncId, inputEventId, startTimeNanos}); return setFrameTimelineInfo(frameNumber, {frameTimelineVsyncId, inputEventId, startTimeNanos}); } bool Surface::transformToDisplayInverse() const { Loading Loading @@ -2637,7 +2638,8 @@ status_t Surface::setFrameRate(float frameRate, int8_t compatibility, changeFrameRateStrategy); } status_t Surface::setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInfo) { status_t Surface::setFrameTimelineInfo(uint64_t /*frameNumber*/, const FrameTimelineInfo& frameTimelineInfo) { return composerService()->setFrameTimelineInfo(mGraphicBufferProducer, frameTimelineInfo); } Loading
libs/gui/include/gui/BLASTBufferQueue.h +2 −2 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ public: void update(const sp<SurfaceControl>& surface, uint32_t width, uint32_t height, int32_t format); status_t setFrameRate(float frameRate, int8_t compatibility, bool shouldBeSeamless); status_t setFrameTimelineInfo(const FrameTimelineInfo& info); status_t setFrameTimelineInfo(uint64_t frameNumber, const FrameTimelineInfo& info); void setSidebandStream(const sp<NativeHandle>& stream); Loading Loading @@ -237,7 +237,7 @@ private: std::vector<std::tuple<uint64_t /* framenumber */, SurfaceComposerClient::Transaction>> mPendingTransactions GUARDED_BY(mMutex); std::queue<FrameTimelineInfo> mNextFrameTimelineInfoQueue GUARDED_BY(mMutex); std::queue<std::pair<uint64_t, FrameTimelineInfo>> mPendingFrameTimelines GUARDED_BY(mMutex); // Tracks the last acquired frame number uint64_t mLastAcquiredFrameNumber GUARDED_BY(mMutex) = 0; Loading
libs/gui/include/gui/Surface.h +1 −1 Original line number Diff line number Diff line Loading @@ -193,7 +193,7 @@ public: virtual status_t setFrameRate(float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy); virtual status_t setFrameTimelineInfo(const FrameTimelineInfo& info); virtual status_t setFrameTimelineInfo(uint64_t frameNumber, const FrameTimelineInfo& info); protected: virtual ~Surface(); Loading
libs/gui/include/gui/TraceUtils.h +16 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ #define ATRACE_FORMAT_BEGIN(fmt, ...) TraceUtils::atraceFormatBegin(fmt, ##__VA_ARGS__) #define ATRACE_FORMAT_INSTANT(fmt, ...) TraceUtils::intantFormat(fmt, ##__VA_ARGS__) namespace android { class TraceUtils { Loading @@ -50,6 +52,20 @@ public: ATRACE_BEGIN(buf); } static void intantFormat(const char* fmt, ...) { if (CC_LIKELY(!ATRACE_ENABLED())) return; const int BUFFER_SIZE = 256; va_list ap; char buf[BUFFER_SIZE]; va_start(ap, fmt); vsnprintf(buf, BUFFER_SIZE, fmt, ap); va_end(ap); ATRACE_INSTANT(buf); } }; // class TraceUtils } /* namespace android */