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

Commit 6d28182b authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13908396 from f0b60c5d to 25Q4-release

Change-Id: I56685c8f22562b89cb2b0ff0c50d7870b8a29683
parents 1933e8af f0b60c5d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1554,7 +1554,7 @@ static void DumpVintf() {

    const std::string sku = android::base::GetProperty("ro.boot.product.hardware.sku", "");
    const auto vintfFiles = android::vintf::details::dumpFileList(sku);
    for (const auto vintfFile : vintfFiles) {
    for (const auto& vintfFile : vintfFiles) {
        struct stat st;
        if (stat(vintfFile.c_str(), &st) == 0) {
            if (S_ISDIR(st.st_mode)) {
+1 −0
Original line number Diff line number Diff line
@@ -900,6 +900,7 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
    }

    // Parsing was successful. Update the object.
    mLogCallPoints = logCallPoints;
    mState = std::move(state);
    mListenerCallbacks = listenerCallbacks;
    mApplyToken = applyToken;
+1 −1
Original line number Diff line number Diff line
@@ -318,7 +318,7 @@ std::vector<tonemap::ShaderUniform> buildLinearEffectUniforms(
                               .buffer = buffer,
                               .renderIntent = renderIntent};

    for (const auto uniform : tonemap::getToneMapper()->generateShaderSkSLUniforms(metadata)) {
    for (const auto& uniform : tonemap::getToneMapper()->generateShaderSkSLUniforms(metadata)) {
        uniforms.push_back(uniform);
    }

+1 −0
Original line number Diff line number Diff line
@@ -197,6 +197,7 @@ public:
                    isApproxEqual(desiredRefreshRate, other.desiredRefreshRate) &&
                    seamlessness == other.seamlessness && weight == other.weight &&
                    focused == other.focused && frameRateCategory == other.frameRateCategory &&
                    frameRateCategorySmoothSwitchOnly == other.frameRateCategorySmoothSwitchOnly &&
                    layerFilter == other.layerFilter;
        }

+84 −21
Original line number Diff line number Diff line
@@ -294,6 +294,12 @@ void Scheduler::unregisterDisplay(PhysicalDisplayId displayId,
                promotePacesetterDisplayLocked(defaultPacesetterId, kPromotionParams);
    }
    applyNewVsyncSchedule(std::move(pacesetterVsyncSchedule));

    {
        std::scoped_lock lock(mPolicyLock);
        mPolicy.modeOpt.erase(displayId);
        mPolicy.emittedModeOpt.erase(displayId);
    }
}

void Scheduler::run() {
@@ -559,9 +565,11 @@ bool Scheduler::updatePolicyContentRequirements(PhysicalDisplayId displayId,
            FTL_FAKE_GUARD(kMainThreadContext,
                           (std::scoped_lock(mDisplayLock), displayId == mPacesetterDisplayId));

    if (isPacesetter) {
    const bool followerArbitraryRefreshRate =
            FlagManager::getInstance().follower_arbitrary_refresh_rate_selection();
    if (isPacesetter || followerArbitraryRefreshRate) {
        std::lock_guard<std::mutex> lock(mPolicyLock);
        mPolicy.emittedModeOpt = mode;
        mPolicy.emittedModeOpt[displayId] = mode;

        if (clearContentRequirements) {
            // Invalidate content based refresh rate selection so it could be calculated
@@ -612,25 +620,26 @@ void Scheduler::onDisplayModeRejected(PhysicalDisplayId displayId, DisplayModeId
    }
}

void Scheduler::emitModeChangeIfNeeded() {
    if (!mPolicy.modeOpt || !mPolicy.emittedModeOpt) {
void Scheduler::emitPacesetterModeChangeIfNeeded() {
    const PhysicalDisplayId pacesetterId = getPacesetterDisplayId();
    if (!mPolicy.modeOpt[pacesetterId] || !mPolicy.emittedModeOpt[pacesetterId]) {
        ALOGW("No mode change to emit");
        return;
    }

    const auto& mode = *mPolicy.modeOpt;
    const auto& mode = *mPolicy.modeOpt[pacesetterId];

    if (mode != pacesetterSelectorPtr()->getActiveMode()) {
        // A mode change is pending. The event will be emitted when the mode becomes active.
        return;
    }

    if (mode == *mPolicy.emittedModeOpt) {
    if (mode == *mPolicy.emittedModeOpt[pacesetterId]) {
        // The event was already emitted.
        return;
    }

    mPolicy.emittedModeOpt = mode;
    mPolicy.emittedModeOpt[pacesetterId] = mode;

    if (hasEventThreads()) {
        const auto vsyncConfigSet = getVsyncConfigsForRefreshRate(mode.fps);
@@ -921,11 +930,30 @@ void Scheduler::setLayerProperties(int32_t id, const android::scheduler::LayerPr
    mLayerHistory.setLayerProperties(id, properties);
}

bool Scheduler::canAnySelectorSwitch() const {
    std::scoped_lock lock(mDisplayLock);
    ftl::FakeGuard guard(kMainThreadContext);

    bool canAnySelectorSwitch = false;
    for (const auto& [_, display] : mDisplays) {
        if (display.powerMode != hal::PowerMode::ON) {
            continue;
        }
        if (display.selectorPtr->canSwitch()) {
            return true;
        }
    }
    return false;
}

void Scheduler::chooseRefreshRateForContent(
        const surfaceflinger::frontend::LayerHierarchy* hierarchy,
        bool updateAttachedChoreographer) {
    const auto selectorPtr = pacesetterSelectorPtr();
    if (!selectorPtr->canSwitch()) return;
    const bool canSwitch = FlagManager::getInstance().follower_arbitrary_refresh_rate_selection()
            ? canAnySelectorSwitch()
            : pacesetterSelectorPtr()->canSwitch();

    if (!canSwitch) return;

    SFTRACE_CALL();

@@ -938,7 +966,8 @@ void Scheduler::chooseRefreshRateForContent(
        // update the attached choreographers after we selected the render rate.
        const ftl::Optional<FrameRateMode> modeOpt = [&] {
            std::scoped_lock lock(mPolicyLock);
            return mPolicy.modeOpt;
            ftl::FakeGuard guard(mDisplayLock);
            return mPolicy.modeOpt[*mPacesetterDisplayId];
        }();

        if (modeOpt) {
@@ -1412,9 +1441,6 @@ auto Scheduler::applyPolicy(S Policy::*statePtr, T&& newState) -> GlobalSignals

            modeChoices = chooseDisplayModes();

            // TODO(b/240743786): The pacesetter display's mode must change for any
            // DisplayModeRequest to go through. Fix this by tracking per-display Scheduler::Policy
            // and timers.
            std::tie(modeOpt, consideredSignals) =
                    modeChoices.get(*mPacesetterDisplayId)
                            .transform([](const DisplayModeChoice& choice) {
@@ -1429,24 +1455,60 @@ auto Scheduler::applyPolicy(S Policy::*statePtr, T&& newState) -> GlobalSignals
            if (FlagManager::getInstance().unify_refresh_rate_callbacks()) {
                modeRequests.emplace_back(display::DisplayModeRequest{.mode = choice.mode});
                emitModeChangedEvents.emplace_back(
                        display::DisplayModeRequest{.mode = std::move(choice.mode),
                        display::DisplayModeRequest{.mode = choice.mode,
                                                    .emitEvent = choice.consideredSignals
                                                                         .shouldEmitEvent()});
            } else {
                modeRequests.emplace_back(
                        display::DisplayModeRequest{.mode = std::move(choice.mode),
                        display::DisplayModeRequest{.mode = choice.mode,
                                                    .emitEvent = choice.consideredSignals
                                                                         .shouldEmitEvent()});
            }
        }

        if (mPolicy.modeOpt != modeOpt) {
            mPolicy.modeOpt = modeOpt;
        const bool followerRefreshRateSelection =
                FlagManager::getInstance().follower_arbitrary_refresh_rate_selection();
        bool anyChosenModeDiffers = false;
        bool chosenModeDiffersForPacesetter = false;
        {
            std::scoped_lock lock(mDisplayLock);
            ftl::FakeGuard guard(kMainThreadContext);
            for (const auto& [id, display] : mDisplays) {
                const auto choiceOpt = modeChoices.get(id);
                if (id != *mPacesetterDisplayId && !followerRefreshRateSelection) {
                    continue;
                }
                if (!choiceOpt) {
                    continue;
                }

                const bool chosenModeDiffers = (mPolicy.modeOpt[id] != choiceOpt->get().mode);
                anyChosenModeDiffers |= chosenModeDiffers;
                if (id == *mPacesetterDisplayId) {
                    chosenModeDiffersForPacesetter = chosenModeDiffers;
                }
            }
        }

        if (anyChosenModeDiffers) {
            refreshRateChanged = true;
        } else if (consideredSignals.shouldEmitEvent()) {

            std::scoped_lock lock(mDisplayLock);
            ftl::FakeGuard guard(kMainThreadContext);
            for (const auto& [id, display] : mDisplays) {
                if (id != *mPacesetterDisplayId && !followerRefreshRateSelection) {
                    continue;
                }
                if (const auto choiceOpt = modeChoices.get(id)) {
                    mPolicy.modeOpt[id] = choiceOpt->get().mode;
                }
            }
        }

        if (!chosenModeDiffersForPacesetter && consideredSignals.shouldEmitEvent()) {
            // The mode did not change, but we may need to emit if DisplayModeRequest::emitEvent was
            // previously false.
            emitModeChangeIfNeeded();
            emitPacesetterModeChangeIfNeeded();
        }
    }
    if (refreshRateChanged) {
@@ -1457,7 +1519,8 @@ auto Scheduler::applyPolicy(S Policy::*statePtr, T&& newState) -> GlobalSignals
    {
        std::scoped_lock lock(mPolicyLock);
        frameRateOverridesChanged =
                updateFrameRateOverridesLocked(consideredSignals, mPolicy.modeOpt->fps);
                updateFrameRateOverridesLocked(consideredSignals,
                                               mPolicy.modeOpt[getPacesetterDisplayId()]->fps);
    }
    if (frameRateOverridesChanged && !FlagManager::getInstance().unify_refresh_rate_callbacks()) {
        onFrameRateOverridesChanged();
@@ -1528,7 +1591,7 @@ FrameRateMode Scheduler::getPreferredDisplayMode() {
                    .frameRateMode;

    // Make sure the stored mode is up to date.
    mPolicy.modeOpt = frameRateMode;
    mPolicy.modeOpt[getPacesetterDisplayId()] = frameRateMode;

    return frameRateMode;
}
Loading