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

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

Merge "SF: add tracing for LayerHistory"

parents fc7e6e19 73c3df5a
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -22,9 +22,9 @@


#include <android-base/stringprintf.h>
#include <android-base/stringprintf.h>
#include <cutils/properties.h>
#include <cutils/properties.h>
#include <gui/TraceUtils.h>
#include <utils/Log.h>
#include <utils/Log.h>
#include <utils/Timers.h>
#include <utils/Timers.h>
#include <utils/Trace.h>


#include <algorithm>
#include <algorithm>
#include <cmath>
#include <cmath>
@@ -165,6 +165,7 @@ void LayerHistory::setDefaultFrameRateCompatibility(Layer* layer, bool contentDe
}
}


auto LayerHistory::summarize(const RefreshRateSelector& selector, nsecs_t now) -> Summary {
auto LayerHistory::summarize(const RefreshRateSelector& selector, nsecs_t now) -> Summary {
    ATRACE_CALL();
    Summary summary;
    Summary summary;


    std::lock_guard lock(mLock);
    std::lock_guard lock(mLock);
@@ -178,6 +179,7 @@ auto LayerHistory::summarize(const RefreshRateSelector& selector, nsecs_t now) -
        ALOGV("%s has priority: %d %s focused", info->getName().c_str(), frameRateSelectionPriority,
        ALOGV("%s has priority: %d %s focused", info->getName().c_str(), frameRateSelectionPriority,
              layerFocused ? "" : "not");
              layerFocused ? "" : "not");


        ATRACE_FORMAT("%s", info->getName().c_str());
        const auto vote = info->getRefreshRateVote(selector, now);
        const auto vote = info->getRefreshRateVote(selector, now);
        // Skip NoVote layer as those don't have any requirements
        // Skip NoVote layer as those don't have any requirements
        if (vote.type == LayerVoteType::NoVote) {
        if (vote.type == LayerVoteType::NoVote) {
@@ -192,6 +194,8 @@ auto LayerHistory::summarize(const RefreshRateSelector& selector, nsecs_t now) -


        const float layerArea = transformed.getWidth() * transformed.getHeight();
        const float layerArea = transformed.getWidth() * transformed.getHeight();
        float weight = mDisplayArea ? layerArea / mDisplayArea : 0.0f;
        float weight = mDisplayArea ? layerArea / mDisplayArea : 0.0f;
        ATRACE_FORMAT_INSTANT("%s %s (%d%)", ftl::enum_string(vote.type).c_str(),
                              to_string(vote.fps).c_str(), weight * 100);
        summary.push_back({info->getName(), info->getOwnerUid(), vote.type, vote.fps,
        summary.push_back({info->getName(), info->getOwnerUid(), vote.type, vote.fps,
                           vote.seamlessness, weight, layerFocused});
                           vote.seamlessness, weight, layerFocused});


@@ -204,6 +208,7 @@ auto LayerHistory::summarize(const RefreshRateSelector& selector, nsecs_t now) -
}
}


void LayerHistory::partitionLayers(nsecs_t now) {
void LayerHistory::partitionLayers(nsecs_t now) {
    ATRACE_CALL();
    const nsecs_t threshold = getActiveLayerThreshold(now);
    const nsecs_t threshold = getActiveLayerThreshold(now);


    // iterate over inactive map
    // iterate over inactive map
+5 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@
#include <cutils/compiler.h>
#include <cutils/compiler.h>
#include <cutils/trace.h>
#include <cutils/trace.h>
#include <ftl/enum.h>
#include <ftl/enum.h>
#include <gui/TraceUtils.h>


#undef LOG_TAG
#undef LOG_TAG
#define LOG_TAG "LayerInfo"
#define LOG_TAG "LayerInfo"
@@ -189,6 +190,7 @@ std::optional<nsecs_t> LayerInfo::calculateAverageFrameTime() const {


std::optional<Fps> LayerInfo::calculateRefreshRateIfPossible(const RefreshRateSelector& selector,
std::optional<Fps> LayerInfo::calculateRefreshRateIfPossible(const RefreshRateSelector& selector,
                                                             nsecs_t now) {
                                                             nsecs_t now) {
    ATRACE_CALL();
    static constexpr float MARGIN = 1.0f; // 1Hz
    static constexpr float MARGIN = 1.0f; // 1Hz
    if (!hasEnoughDataForHeuristic()) {
    if (!hasEnoughDataForHeuristic()) {
        ALOGV("Not enough data");
        ALOGV("Not enough data");
@@ -224,18 +226,21 @@ std::optional<Fps> LayerInfo::calculateRefreshRateIfPossible(const RefreshRateSe


LayerInfo::LayerVote LayerInfo::getRefreshRateVote(const RefreshRateSelector& selector,
LayerInfo::LayerVote LayerInfo::getRefreshRateVote(const RefreshRateSelector& selector,
                                                   nsecs_t now) {
                                                   nsecs_t now) {
    ATRACE_CALL();
    if (mLayerVote.type != LayerHistory::LayerVoteType::Heuristic) {
    if (mLayerVote.type != LayerHistory::LayerVoteType::Heuristic) {
        ALOGV("%s voted %d ", mName.c_str(), static_cast<int>(mLayerVote.type));
        ALOGV("%s voted %d ", mName.c_str(), static_cast<int>(mLayerVote.type));
        return mLayerVote;
        return mLayerVote;
    }
    }


    if (isAnimating(now)) {
    if (isAnimating(now)) {
        ATRACE_FORMAT_INSTANT("animating");
        ALOGV("%s is animating", mName.c_str());
        ALOGV("%s is animating", mName.c_str());
        mLastRefreshRate.animatingOrInfrequent = true;
        mLastRefreshRate.animatingOrInfrequent = true;
        return {LayerHistory::LayerVoteType::Max, Fps()};
        return {LayerHistory::LayerVoteType::Max, Fps()};
    }
    }


    if (!isFrequent(now)) {
    if (!isFrequent(now)) {
        ATRACE_FORMAT_INSTANT("infrequent");
        ALOGV("%s is infrequent", mName.c_str());
        ALOGV("%s is infrequent", mName.c_str());
        mLastRefreshRate.animatingOrInfrequent = true;
        mLastRefreshRate.animatingOrInfrequent = true;
        // Infrequent layers vote for mininal refresh rate for
        // Infrequent layers vote for mininal refresh rate for
+1 −0
Original line number Original line Diff line number Diff line
@@ -354,6 +354,7 @@ float RefreshRateSelector::calculateDistanceScoreFromMax(Fps refreshRate) const


float RefreshRateSelector::calculateLayerScoreLocked(const LayerRequirement& layer, Fps refreshRate,
float RefreshRateSelector::calculateLayerScoreLocked(const LayerRequirement& layer, Fps refreshRate,
                                                     bool isSeamlessSwitch) const {
                                                     bool isSeamlessSwitch) const {
    ATRACE_CALL();
    // Slightly prefer seamless switches.
    // Slightly prefer seamless switches.
    constexpr float kSeamedSwitchPenalty = 0.95f;
    constexpr float kSeamedSwitchPenalty = 0.95f;
    const float seamlessness = isSeamlessSwitch ? 1.0f : kSeamedSwitchPenalty;
    const float seamlessness = isSeamlessSwitch ? 1.0f : kSeamedSwitchPenalty;
+1 −0
Original line number Original line Diff line number Diff line
@@ -661,6 +661,7 @@ void Scheduler::demoteLeaderDisplay() {


template <typename S, typename T>
template <typename S, typename T>
auto Scheduler::applyPolicy(S Policy::*statePtr, T&& newState) -> GlobalSignals {
auto Scheduler::applyPolicy(S Policy::*statePtr, T&& newState) -> GlobalSignals {
    ATRACE_CALL();
    std::vector<display::DisplayModeRequest> modeRequests;
    std::vector<display::DisplayModeRequest> modeRequests;
    GlobalSignals consideredSignals;
    GlobalSignals consideredSignals;