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

Commit 8a65ff9c authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10017950 from 9895dfe4 to udc-release

Change-Id: I7eca7250dc197726f1a6bf0503b020a5bdd74286
parents 833e60fd 9895dfe4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -127,6 +127,8 @@ struct __attribute__ ((__packed__, aligned(alignof(uint32_t)))) ColorAspects {
        PrimariesBT601_6_525,   // Rec.ITU-R BT.601-6 525 or equivalent
        PrimariesGenericFilm,   // Generic Film
        PrimariesBT2020,        // Rec.ITU-R BT.2020 or equivalent
        PrimariesRP431,         // SMPTE RP 431-2 (DCI P3)
        PrimariesEG432,         // SMPTE EG 432-1 (Display P3)
        PrimariesOther = 0xff,
    };

@@ -173,6 +175,8 @@ struct __attribute__ ((__packed__, aligned(alignof(uint32_t)))) ColorAspects {
        StandardBT2020Constant,         // PrimariesBT2020 and MatrixBT2020Constant
        StandardBT470M,                 // PrimariesBT470_6M and MatrixBT470_6M
        StandardFilm,                   // PrimariesGenericFilm and KR=0.253, KB=0.068
        StandardDisplayP3,              // PrimariesEG432 and MatrixBT601_6
        // StandardAdobeRGB,  // for placeholder only (not used by media)
        StandardOther = 0xff,
    };

@@ -282,6 +286,8 @@ inline static const char *asString(ColorAspects::Primaries i, const char *def =
        case ColorAspects::PrimariesBT601_6_525: return "BT601_6_525";
        case ColorAspects::PrimariesGenericFilm: return "GenericFilm";
        case ColorAspects::PrimariesBT2020:      return "BT2020";
        case ColorAspects::PrimariesRP431:       return "RP431";
        case ColorAspects::PrimariesEG432:       return "EG432";
        case ColorAspects::PrimariesOther:       return "Other";
        default:                                 return def;
    }
@@ -332,6 +338,8 @@ inline static const char *asString(ColorAspects::Standard i, const char *def = "
        case ColorAspects::StandardBT2020Constant:       return "BT2020Constant";
        case ColorAspects::StandardBT470M:               return "BT470M";
        case ColorAspects::StandardFilm:                 return "Film";
        case ColorAspects::StandardDisplayP3:            return "DisplayP3";
        // case ColorAspects::StandardAdobeRGB:             return "AdobeRGB";
        case ColorAspects::StandardOther:                return "Other";
        default:                                         return def;
    }
+2 −5
Original line number Diff line number Diff line
@@ -176,11 +176,8 @@ status_t SensorManager::assertStateLocked() {

        mSensors = mSensorServer->getSensorList(mOpPackageName);
        size_t count = mSensors.size();
        if (count == 0) {
            ALOGE("Failed to get Sensor list");
            mSensorServer.clear();
            return UNKNOWN_ERROR;
        }
        // If count is 0, mSensorList will be non-null. This is old
        // existing behavior and callers expect this.
        mSensorList =
                static_cast<Sensor const**>(malloc(count * sizeof(Sensor*)));
        LOG_ALWAYS_FATAL_IF(mSensorList == nullptr, "mSensorList NULL");
+16 −62
Original line number Diff line number Diff line
@@ -830,81 +830,35 @@ auto Scheduler::chooseDisplayModes() const -> DisplayModeChoiceMap {

    using RankedRefreshRates = RefreshRateSelector::RankedFrameRates;
    display::PhysicalDisplayVector<RankedRefreshRates> perDisplayRanking;

    // Tallies the score of a refresh rate across `displayCount` displays.
    struct RefreshRateTally {
        explicit RefreshRateTally(float score) : score(score) {}

        float score;
        size_t displayCount = 1;
    };

    // Chosen to exceed a typical number of refresh rates across displays.
    constexpr size_t kStaticCapacity = 8;
    ftl::SmallMap<Fps, RefreshRateTally, kStaticCapacity, FpsApproxEqual> refreshRateTallies;

    const auto globalSignals = makeGlobalSignals();
    Fps pacesetterFps;

    for (const auto& [id, display] : mDisplays) {
        auto rankedFrameRates =
                display.selectorPtr->getRankedFrameRates(mPolicy.contentRequirements,
                                                         globalSignals);

        for (const auto& [frameRateMode, score] : rankedFrameRates.ranking) {
            const auto [it, inserted] = refreshRateTallies.try_emplace(frameRateMode.fps, score);

            if (!inserted) {
                auto& tally = it->second;
                tally.score += score;
                tally.displayCount++;
        if (id == *mPacesetterDisplayId) {
            pacesetterFps = rankedFrameRates.ranking.front().frameRateMode.fps;
        }
        }

        perDisplayRanking.push_back(std::move(rankedFrameRates));
    }

    auto maxScoreIt = refreshRateTallies.cbegin();

    // Find the first refresh rate common to all displays.
    while (maxScoreIt != refreshRateTallies.cend() &&
           maxScoreIt->second.displayCount != mDisplays.size()) {
        ++maxScoreIt;
    }

    if (maxScoreIt != refreshRateTallies.cend()) {
        // Choose the highest refresh rate common to all displays, if any.
        for (auto it = maxScoreIt + 1; it != refreshRateTallies.cend(); ++it) {
            const auto [fps, tally] = *it;

            if (tally.displayCount == mDisplays.size() && tally.score > maxScoreIt->second.score) {
                maxScoreIt = it;
            }
        }
    }

    const std::optional<Fps> chosenFps = maxScoreIt != refreshRateTallies.cend()
            ? std::make_optional(maxScoreIt->first)
            : std::nullopt;

    DisplayModeChoiceMap modeChoices;

    using fps_approx_ops::operator==;

    for (auto& [ranking, signals] : perDisplayRanking) {
        if (!chosenFps) {
            const auto& [frameRateMode, _] = ranking.front();
            modeChoices.try_emplace(frameRateMode.modePtr->getPhysicalDisplayId(),
                                    DisplayModeChoice{frameRateMode, signals});
            continue;
        }
    for (auto& [rankings, signals] : perDisplayRanking) {
        const auto chosenFrameRateMode =
                ftl::find_if(rankings,
                             [&](const auto& ranking) {
                                 return ranking.frameRateMode.fps == pacesetterFps;
                             })
                        .transform([](const auto& scoredFrameRate) {
                            return scoredFrameRate.get().frameRateMode;
                        })
                        .value_or(rankings.front().frameRateMode);

        for (auto& [frameRateMode, _] : ranking) {
            if (frameRateMode.fps == *chosenFps) {
                modeChoices.try_emplace(frameRateMode.modePtr->getPhysicalDisplayId(),
                                        DisplayModeChoice{frameRateMode, signals});
                break;
            }
        }
        modeChoices.try_emplace(chosenFrameRateMode.modePtr->getPhysicalDisplayId(),
                                DisplayModeChoice{chosenFrameRateMode, signals});
    }
    return modeChoices;
}
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ cc_test {
    ],
    test_suites: ["device-tests"],
    sanitize: {
        address: false,
        address: true,
    },
    srcs: [
        ":libsurfaceflinger_sources",
+22 −1
Original line number Diff line number Diff line
@@ -359,7 +359,8 @@ TEST_F(SchedulerTest, chooseDisplayModesMultipleDisplays) {
        EXPECT_EQ(expectedChoices, actualChoices);
    }
    {
        // This display does not support 120 Hz, so we should choose 60 Hz despite the touch signal.
        // The kDisplayId3 does not support 120Hz, The pacesetter display rate is chosen to be 120
        // Hz. In this case only the display kDisplayId3 choose 60Hz as it does not support 120Hz.
        mScheduler
                ->registerDisplay(kDisplayId3,
                                  std::make_shared<RefreshRateSelector>(kDisplay3Modes,
@@ -369,6 +370,26 @@ TEST_F(SchedulerTest, chooseDisplayModesMultipleDisplays) {
        mScheduler->replaceTouchTimer(10);
        mScheduler->setTouchStateAndIdleTimerPolicy(globalSignals);

        expectedChoices = ftl::init::map<
                const PhysicalDisplayId&,
                DisplayModeChoice>(kDisplayId1, FrameRateMode{120_Hz, kDisplay1Mode120},
                                   globalSignals)(kDisplayId2,
                                                  FrameRateMode{120_Hz, kDisplay2Mode120},
                                                  globalSignals)(kDisplayId3,
                                                                 FrameRateMode{60_Hz,
                                                                               kDisplay3Mode60},
                                                                 globalSignals);

        const auto actualChoices = mScheduler->chooseDisplayModes();
        EXPECT_EQ(expectedChoices, actualChoices);
    }
    {
        // We should choose 60Hz despite the touch signal as pacesetter only supports 60Hz
        mScheduler->setPacesetterDisplay(kDisplayId3);
        const GlobalSignals globalSignals = {.touch = true};
        mScheduler->replaceTouchTimer(10);
        mScheduler->setTouchStateAndIdleTimerPolicy(globalSignals);

        expectedChoices = ftl::init::map<
                const PhysicalDisplayId&,
                DisplayModeChoice>(kDisplayId1, FrameRateMode{60_Hz, kDisplay1Mode60},