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

Commit 9275c965 authored by Thierry Strudel's avatar Thierry Strudel Committed by Android (Google) Code Review
Browse files

Merge "Surfaceflinger: adjust content detection fps selection" into qt-r1-dev

parents 93265850 09be73f6
Loading
Loading
Loading
Loading
+9 −12
Original line number Original line Diff line number Diff line
@@ -523,22 +523,19 @@ Scheduler::RefreshRateType Scheduler::calculateRefreshRateType() {
        return RefreshRateType::PERFORMANCE;
        return RefreshRateType::PERFORMANCE;
    }
    }


    // Content detection is on, find the appropriate refresh rate
    // Content detection is on, find the appropriate refresh rate with minimal error
    // Start with the smallest refresh rate which is within a margin of the content
    auto iter = min_element(mRefreshRateConfigs.getRefreshRates().cbegin(),
    RefreshRateType currRefreshRateType = RefreshRateType::PERFORMANCE;
                            mRefreshRateConfigs.getRefreshRates().cend(),
    constexpr float MARGIN = 0.05f;
                            [rate = mContentRefreshRate](const auto& l, const auto& r) -> bool {
    auto iter = mRefreshRateConfigs.getRefreshRates().cbegin();
                                return std::abs(l.second->fps - static_cast<float>(rate)) <
    while (iter != mRefreshRateConfigs.getRefreshRates().cend()) {
                                        std::abs(r.second->fps - static_cast<float>(rate));
        if (iter->second->fps >= mContentRefreshRate * (1 - MARGIN)) {
                            });
            currRefreshRateType = iter->first;
    RefreshRateType currRefreshRateType = iter->first;
            break;
        }
        ++iter;
    }


    // Some content aligns better on higher refresh rate. For example for 45fps we should choose
    // Some content aligns better on higher refresh rate. For example for 45fps we should choose
    // 90Hz config. However we should still prefer a lower refresh rate if the content doesn't
    // 90Hz config. However we should still prefer a lower refresh rate if the content doesn't
    // align well with both
    // align well with both
    constexpr float MARGIN = 0.05f;
    float ratio = mRefreshRateConfigs.getRefreshRate(currRefreshRateType)->fps /
    float ratio = mRefreshRateConfigs.getRefreshRate(currRefreshRateType)->fps /
            float(mContentRefreshRate);
            float(mContentRefreshRate);
    if (std::abs(std::round(ratio) - ratio) > MARGIN) {
    if (std::abs(std::round(ratio) - ratio) > MARGIN) {