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

Commit 8e95fe85 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "SF: Flag guard VSyncPredictor duplicate timestamp check" into main

parents a98fc3a2 349b2902
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -111,16 +111,20 @@ bool VSyncPredictor::validate(nsecs_t timestamp) const {
        return false;
    }

    const auto isThresholdEnabled =
            FlagManager::getInstance().vsync_predictor_predicts_within_threshold() &&
            mDisplayModePtr->getVrrConfig();
    const auto iter = std::min_element(mTimestamps.begin(), mTimestamps.end(),
                                       [timestamp, this](nsecs_t a, nsecs_t b) {
                                       [=, this](nsecs_t a, nsecs_t b) {
                                           nsecs_t diffA = std::abs(timestamp - a);
                                           nsecs_t diffB = std::abs(timestamp - b);
                                           if (isThresholdEnabled) {
                                               bool withinThresholdA = diffA <= kPredictorThreshold;
                                               bool withinThresholdB = diffB <= kPredictorThreshold;

                                               if (withinThresholdA != withinThresholdB) {
                                                   return withinThresholdA;
                                               }
                                           }
                                           return diffA < diffB;
                                       });
    const auto distancePercent = std::abs(*iter - timestamp) * kMaxPercent / idealPeriod();