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

Commit 16596ab1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "SurfaceFlinger: use queueTime as well when calculating refresh rate" into rvc-dev

parents a511811b 49e65e42
Loading
Loading
Loading
Loading
+10 −6
Original line number Original line Diff line number Diff line
@@ -130,12 +130,16 @@ std::optional<float> LayerInfoV2::calculateRefreshRateIfPossible() {
    // Now once we calculated the refresh rate we need to make sure that all the frames we captured
    // Now once we calculated the refresh rate we need to make sure that all the frames we captured
    // are evenly distributed and we don't calculate the average across some burst of frames.
    // are evenly distributed and we don't calculate the average across some burst of frames.
    for (auto it = mFrameTimes.begin(); it != mFrameTimes.end() - 1; ++it) {
    for (auto it = mFrameTimes.begin(); it != mFrameTimes.end() - 1; ++it) {
        const nsecs_t frameTimeDeltas = [&] {
            nsecs_t delta;
            if (it->presetTime == 0 || (it + 1)->presetTime == 0) {
            if (it->presetTime == 0 || (it + 1)->presetTime == 0) {
            continue;
                delta = (it + 1)->queueTime - it->queueTime;
            } else {
                delta = (it + 1)->presetTime - it->presetTime;
            }
            }
        const nsecs_t presentTimeDeltas =
            return std::max(delta, mHighRefreshRatePeriod);
                std::max(((it + 1)->presetTime - it->presetTime), mHighRefreshRatePeriod);
        }();
        if (std::abs(presentTimeDeltas - averageFrameTime) > 2 * averageFrameTime) {
        if (std::abs(frameTimeDeltas - averageFrameTime) > 2 * averageFrameTime) {
            return std::nullopt;
            return std::nullopt;
        }
        }
    }
    }