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

Commit 53fc11d9 authored by Marin Shalamanov's avatar Marin Shalamanov
Browse files

Make shouldBeSeamless an enum

We change theboolean shouldBeSemaless to an enum with
three values. This introduces a third value "Default" which
indicates that the layer doesn't have a preference for
seamlessness. This is the default value for Surfaces which
haven't called setFrameRate, or have called setFrameRate(0).

Bug: 161776961
Test: presubmit
Change-Id: I157e332e82e95badc928d6a8135e657cd6984db4
parent b98a1bfb
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -1687,9 +1687,9 @@ void Layer::miniDump(std::string& result, const DisplayDevice& display) const {
                  crop.bottom);
                  crop.bottom);
    if (layerState.frameRate.rate != 0 ||
    if (layerState.frameRate.rate != 0 ||
        layerState.frameRate.type != FrameRateCompatibility::Default) {
        layerState.frameRate.type != FrameRateCompatibility::Default) {
        StringAppendF(&result, "% 6.2ffps %15s seamless=%d", layerState.frameRate.rate,
        StringAppendF(&result, "% 6.2ffps %15s seamless=%s", layerState.frameRate.rate,
                      frameRateCompatibilityString(layerState.frameRate.type).c_str(),
                      frameRateCompatibilityString(layerState.frameRate.type).c_str(),
                      layerState.frameRate.shouldBeSeamless);
                      toString(layerState.frameRate.seamlessness).c_str());
    } else {
    } else {
        StringAppendF(&result, "                         ");
        StringAppendF(&result, "                         ");
    }
    }
@@ -2754,7 +2754,7 @@ bool Layer::getPrimaryDisplayOnly() const {
std::ostream& operator<<(std::ostream& stream, const Layer::FrameRate& rate) {
std::ostream& operator<<(std::ostream& stream, const Layer::FrameRate& rate) {
    return stream << "{rate=" << rate.rate
    return stream << "{rate=" << rate.rate
                  << " type=" << Layer::frameRateCompatibilityString(rate.type)
                  << " type=" << Layer::frameRateCompatibilityString(rate.type)
                  << " shouldBeSeamless=" << rate.shouldBeSeamless << "}";
                  << " seamlessness=" << toString(rate.seamlessness) << "}";
}
}


}; // namespace android
}; // namespace android
+24 −5
Original line number Original line Diff line number Diff line
@@ -49,7 +49,9 @@
#include "LayerVector.h"
#include "LayerVector.h"
#include "MonitoredProducer.h"
#include "MonitoredProducer.h"
#include "RenderArea.h"
#include "RenderArea.h"
#include "Scheduler/Seamlessness.h"
#include "SurfaceFlinger.h"
#include "SurfaceFlinger.h"
#include "SurfaceTracing.h"
#include "TransactionCompletedThread.h"
#include "TransactionCompletedThread.h"


using namespace android::surfaceflinger;
using namespace android::surfaceflinger;
@@ -151,17 +153,21 @@ public:
    // Encapsulates the frame rate and compatibility of the layer. This information will be used
    // Encapsulates the frame rate and compatibility of the layer. This information will be used
    // when the display refresh rate is determined.
    // when the display refresh rate is determined.
    struct FrameRate {
    struct FrameRate {
        using Seamlessness = scheduler::Seamlessness;

        float rate;
        float rate;
        FrameRateCompatibility type;
        FrameRateCompatibility type;
        bool shouldBeSeamless;
        Seamlessness seamlessness;


        FrameRate() : rate(0), type(FrameRateCompatibility::Default), shouldBeSeamless(true) {}
        FrameRate()
              : rate(0),
                type(FrameRateCompatibility::Default),
                seamlessness(Seamlessness::Default) {}
        FrameRate(float rate, FrameRateCompatibility type, bool shouldBeSeamless = true)
        FrameRate(float rate, FrameRateCompatibility type, bool shouldBeSeamless = true)
              : rate(rate), type(type), shouldBeSeamless(shouldBeSeamless) {}
              : rate(rate), type(type), seamlessness(getSeamlessness(rate, shouldBeSeamless)) {}


        bool operator==(const FrameRate& other) const {
        bool operator==(const FrameRate& other) const {
            return rate == other.rate && type == other.type &&
            return rate == other.rate && type == other.type && seamlessness == other.seamlessness;
                    shouldBeSeamless == other.shouldBeSeamless;
        }
        }


        bool operator!=(const FrameRate& other) const { return !(*this == other); }
        bool operator!=(const FrameRate& other) const { return !(*this == other); }
@@ -169,6 +175,19 @@ public:
        // Convert an ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* value to a
        // Convert an ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* value to a
        // Layer::FrameRateCompatibility. Logs fatal if the compatibility value is invalid.
        // Layer::FrameRateCompatibility. Logs fatal if the compatibility value is invalid.
        static FrameRateCompatibility convertCompatibility(int8_t compatibility);
        static FrameRateCompatibility convertCompatibility(int8_t compatibility);

    private:
        static Seamlessness getSeamlessness(float rate, bool shouldBeSeamless) {
            if (rate == 0.0f) {
                // Refresh rate of 0 is a special value which should reset the vote to
                // its default value.
                return Seamlessness::Default;
            } else if (shouldBeSeamless) {
                return Seamlessness::OnlySeamless;
            } else {
                return Seamlessness::SeamedAndSeamless;
            }
        }
    };
    };


    struct State {
    struct State {
+3 −3
Original line number Original line Diff line number Diff line
@@ -129,8 +129,7 @@ LayerHistory::Summary LayerHistory::summarize(nsecs_t now) {
                        RefreshRateConfigs::LayerRequirement{.name = layer->getName(),
                        RefreshRateConfigs::LayerRequirement{.name = layer->getName(),
                                                             .vote = voteType,
                                                             .vote = voteType,
                                                             .desiredRefreshRate = frameRate.rate,
                                                             .desiredRefreshRate = frameRate.rate,
                                                             .shouldBeSeamless =
                                                             .seamlessness = frameRate.seamlessness,
                                                                     frameRate.shouldBeSeamless,
                                                             .weight = 1.0f,
                                                             .weight = 1.0f,
                                                             .focused = layerFocused});
                                                             .focused = layerFocused});
            } else if (recent) {
            } else if (recent) {
@@ -139,7 +138,8 @@ LayerHistory::Summary LayerHistory::summarize(nsecs_t now) {
                                                             .vote = LayerVoteType::Heuristic,
                                                             .vote = LayerVoteType::Heuristic,
                                                             .desiredRefreshRate =
                                                             .desiredRefreshRate =
                                                                     info->getRefreshRate(now),
                                                                     info->getRefreshRate(now),
                                                             .shouldBeSeamless = true,
                                                             .seamlessness =
                                                                     Seamlessness::OnlySeamless,
                                                             .weight = 1.0f,
                                                             .weight = 1.0f,
                                                             .focused = layerFocused});
                                                             .focused = layerFocused});
            }
            }
+3 −3
Original line number Original line Diff line number Diff line
@@ -144,8 +144,8 @@ LayerHistoryV2::Summary LayerHistoryV2::summarize(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;
        summary.push_back({strong->getName(), vote.type, vote.fps, vote.shouldBeSeamless, weight,
        summary.push_back(
                           layerFocused});
                {strong->getName(), vote.type, vote.fps, vote.seamlessness, weight, layerFocused});


        if (CC_UNLIKELY(mTraceEnabled)) {
        if (CC_UNLIKELY(mTraceEnabled)) {
            trace(layer, *info, vote.type, static_cast<int>(std::round(vote.fps)));
            trace(layer, *info, vote.type, static_cast<int>(std::round(vote.fps)));
@@ -179,7 +179,7 @@ void LayerHistoryV2::partitionLayers(nsecs_t now) {


            if (frameRate.rate > 0 || voteType == LayerVoteType::NoVote) {
            if (frameRate.rate > 0 || voteType == LayerVoteType::NoVote) {
                const auto type = layer->isVisible() ? voteType : LayerVoteType::NoVote;
                const auto type = layer->isVisible() ? voteType : LayerVoteType::NoVote;
                info->setLayerVote({type, frameRate.rate, frameRate.shouldBeSeamless});
                info->setLayerVote({type, frameRate.rate, frameRate.seamlessness});
            } else {
            } else {
                info->resetLayerVote();
                info->resetLayerVote();
            }
            }
+3 −2
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@


#include "LayerHistory.h"
#include "LayerHistory.h"
#include "RefreshRateConfigs.h"
#include "RefreshRateConfigs.h"
#include "Scheduler/Seamlessness.h"
#include "SchedulerUtils.h"
#include "SchedulerUtils.h"


namespace android {
namespace android {
@@ -60,7 +61,7 @@ public:
    struct LayerVote {
    struct LayerVote {
        LayerHistory::LayerVoteType type = LayerHistory::LayerVoteType::Heuristic;
        LayerHistory::LayerVoteType type = LayerHistory::LayerVoteType::Heuristic;
        float fps = 0.0f;
        float fps = 0.0f;
        bool shouldBeSeamless = true;
        Seamlessness seamlessness = Seamlessness::Default;
    };
    };


    static void setTraceEnabled(bool enabled) { sTraceEnabled = enabled; }
    static void setTraceEnabled(bool enabled) { sTraceEnabled = enabled; }
@@ -91,7 +92,7 @@ public:
    void setDefaultLayerVote(LayerHistory::LayerVoteType type) { mDefaultVote = type; }
    void setDefaultLayerVote(LayerHistory::LayerVoteType type) { mDefaultVote = type; }


    // Resets the layer vote to its default.
    // Resets the layer vote to its default.
    void resetLayerVote() { mLayerVote = {mDefaultVote, 0.0f, true}; }
    void resetLayerVote() { mLayerVote = {mDefaultVote, 0.0f, Seamlessness::Default}; }


    LayerVote getRefreshRateVote(nsecs_t now);
    LayerVote getRefreshRateVote(nsecs_t now);


Loading