Loading services/surfaceflinger/SurfaceFlinger.cpp +14 −3 Original line number Diff line number Diff line Loading @@ -1955,8 +1955,16 @@ SurfaceFlinger::FenceWithFenceTime SurfaceFlinger::previousFrameFence() { const auto now = systemTime(); const auto vsyncPeriod = mScheduler->getDisplayStatInfo(now).vsyncPeriod; const bool expectedPresentTimeIsTheNextVsync = mExpectedPresentTime - now <= vsyncPeriod; return expectedPresentTimeIsTheNextVsync ? mPreviousPresentFences[0] : mPreviousPresentFences[1]; size_t shift = 0; if (!expectedPresentTimeIsTheNextVsync) { shift = static_cast<size_t>((mExpectedPresentTime - now) / vsyncPeriod); if (shift >= mPreviousPresentFences.size()) { shift = mPreviousPresentFences.size() - 1; } } ATRACE_FORMAT("previousFrameFence shift=%zu", shift); return mPreviousPresentFences[shift]; } bool SurfaceFlinger::previousFramePending(int graceTimeMs) { Loading Loading @@ -2425,7 +2433,10 @@ void SurfaceFlinger::postComposition() { glCompositionDoneFenceTime = FenceTime::NO_FENCE; } mPreviousPresentFences[1] = mPreviousPresentFences[0]; for (size_t i = mPreviousPresentFences.size()-1; i >= 1; i--) { mPreviousPresentFences[i] = mPreviousPresentFences[i-1]; } mPreviousPresentFences[0].fence = display ? getHwComposer().getPresentFence(display->getPhysicalId()) : Fence::NO_FENCE; mPreviousPresentFences[0].fenceTime = Loading services/surfaceflinger/SurfaceFlinger.h +2 −1 Original line number Diff line number Diff line Loading @@ -1224,7 +1224,8 @@ private: std::unordered_set<sp<Layer>, SpHash<Layer>> mLayersWithQueuedFrames; // Tracks layers that need to update a display's dirty region. std::vector<sp<Layer>> mLayersPendingRefresh; std::array<FenceWithFenceTime, 2> mPreviousPresentFences; // size should be longest sf-duration / shortest vsync period and round up std::array<FenceWithFenceTime, 5> mPreviousPresentFences; // currently consider 166hz. // True if in the previous frame at least one layer was composed via the GPU. bool mHadClientComposition = false; // True if in the previous frame at least one layer was composed via HW Composer. Loading Loading
services/surfaceflinger/SurfaceFlinger.cpp +14 −3 Original line number Diff line number Diff line Loading @@ -1955,8 +1955,16 @@ SurfaceFlinger::FenceWithFenceTime SurfaceFlinger::previousFrameFence() { const auto now = systemTime(); const auto vsyncPeriod = mScheduler->getDisplayStatInfo(now).vsyncPeriod; const bool expectedPresentTimeIsTheNextVsync = mExpectedPresentTime - now <= vsyncPeriod; return expectedPresentTimeIsTheNextVsync ? mPreviousPresentFences[0] : mPreviousPresentFences[1]; size_t shift = 0; if (!expectedPresentTimeIsTheNextVsync) { shift = static_cast<size_t>((mExpectedPresentTime - now) / vsyncPeriod); if (shift >= mPreviousPresentFences.size()) { shift = mPreviousPresentFences.size() - 1; } } ATRACE_FORMAT("previousFrameFence shift=%zu", shift); return mPreviousPresentFences[shift]; } bool SurfaceFlinger::previousFramePending(int graceTimeMs) { Loading Loading @@ -2425,7 +2433,10 @@ void SurfaceFlinger::postComposition() { glCompositionDoneFenceTime = FenceTime::NO_FENCE; } mPreviousPresentFences[1] = mPreviousPresentFences[0]; for (size_t i = mPreviousPresentFences.size()-1; i >= 1; i--) { mPreviousPresentFences[i] = mPreviousPresentFences[i-1]; } mPreviousPresentFences[0].fence = display ? getHwComposer().getPresentFence(display->getPhysicalId()) : Fence::NO_FENCE; mPreviousPresentFences[0].fenceTime = Loading
services/surfaceflinger/SurfaceFlinger.h +2 −1 Original line number Diff line number Diff line Loading @@ -1224,7 +1224,8 @@ private: std::unordered_set<sp<Layer>, SpHash<Layer>> mLayersWithQueuedFrames; // Tracks layers that need to update a display's dirty region. std::vector<sp<Layer>> mLayersPendingRefresh; std::array<FenceWithFenceTime, 2> mPreviousPresentFences; // size should be longest sf-duration / shortest vsync period and round up std::array<FenceWithFenceTime, 5> mPreviousPresentFences; // currently consider 166hz. // True if in the previous frame at least one layer was composed via the GPU. bool mHadClientComposition = false; // True if in the previous frame at least one layer was composed via HW Composer. Loading