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

Commit f7ff43f0 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "Update LayerHistory layer properties when they change" into main

parents b6660dd4 41376b6f
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -167,6 +167,27 @@ void LayerHistory::setDefaultFrameRateCompatibility(int32_t id,
    info->setDefaultLayerVote(getVoteType(frameRateCompatibility, contentDetectionEnabled));
}

void LayerHistory::setLayerProperties(int32_t id, const LayerProps& properties) {
    std::lock_guard lock(mLock);

    auto [found, layerPair] = findLayer(id);
    if (found == LayerStatus::NotFound) {
        // Offscreen layer
        ALOGV("%s: %d not registered", __func__, id);
        return;
    }

    const auto& info = layerPair->second;
    info->setProperties(properties);

    // Activate layer if inactive and visible.
    if (found == LayerStatus::LayerInInactiveMap && info->isVisible()) {
        mActiveLayerInfos.insert(
                {id, std::make_pair(layerPair->first, std::move(layerPair->second))});
        mInactiveLayerInfos.erase(id);
    }
}

auto LayerHistory::summarize(const RefreshRateSelector& selector, nsecs_t now) -> Summary {
    ATRACE_CALL();
    Summary summary;
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ public:
    // does not set a preference for refresh rate.
    void setDefaultFrameRateCompatibility(int32_t id, FrameRateCompatibility frameRateCompatibility,
                                          bool contentDetectionEnabled);

    void setLayerProperties(int32_t id, const LayerProps&);
    using Summary = std::vector<RefreshRateSelector::LayerRequirement>;

    // Rebuilds sets of active/inactive layers, and accumulates stats for active layers.
+4 −0
Original line number Diff line number Diff line
@@ -75,6 +75,10 @@ void LayerInfo::setLastPresentTime(nsecs_t lastPresentTime, nsecs_t now, LayerUp
    }
}

void LayerInfo::setProperties(const android::scheduler::LayerProps& properties) {
    *mLayerProps = properties;
}

bool LayerInfo::isFrameTimeValid(const FrameTimeData& frameTime) const {
    return frameTime.queueTime >= std::chrono::duration_cast<std::chrono::nanoseconds>(
                                          mFrameTimeValidSince.time_since_epoch())
+2 −0
Original line number Diff line number Diff line
@@ -182,6 +182,8 @@ public:
    // layer can go back to whatever vote it had before the app voted for it.
    void setDefaultLayerVote(LayerHistory::LayerVoteType type) { mDefaultVote = type; }

    void setProperties(const LayerProps&);

    // Resets the layer vote to its default.
    void resetLayerVote() {
        mLayerVote = {mDefaultVote, Fps(), Seamlessness::Default, FrameRateCategory::Default};
+4 −0
Original line number Diff line number Diff line
@@ -654,6 +654,10 @@ void Scheduler::setDefaultFrameRateCompatibility(
                                                   mFeatures.test(Feature::kContentDetection));
}

void Scheduler::setLayerProperties(int32_t id, const android::scheduler::LayerProps& properties) {
    mLayerHistory.setLayerProperties(id, properties);
}

void Scheduler::chooseRefreshRateForContent(
        const surfaceflinger::frontend::LayerHierarchy* hierarchy,
        bool updateAttachedChoreographer) {
Loading