Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78d9b6d4 authored by Jen-Chih Chang's avatar Jen-Chih Chang Committed by Automerger Merge Worker
Browse files

DO NOT MERGE Extend mPreviousPresentFences for high refresh rate am: 1febfb87

parents e51d301c 1febfb87
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -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) {
@@ -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 =
+2 −1
Original line number Diff line number Diff line
@@ -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.