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

Commit 20dcde8e authored by Ady Abraham's avatar Ady Abraham
Browse files

SF: use parent layer frame rate

If an ancestor of a layer set a frame rate, and that layer doesn't
have a frame rate configured, use the one of the ancestor. The reason
for this is to support the high refresh rate deny list where WM will
set the frame rate on a container layer which is not visible. With this
change we will treat all child layers of that container as if they voted
themselves.

Test: test app that sets preferredDisplayModeId
Bug: 163079696
Change-Id: I3c55d393af72e19cd7b4f107d8cc0b2e85289d96
parent 97a4f38d
Loading
Loading
Loading
Loading
+21 −13
Original line number Diff line number Diff line
@@ -1432,9 +1432,10 @@ void Layer::updateTreeHasFrameRateVote() {
    };

    // update parents and children about the vote
    // First traverse the tree and count how many layers has votes
    // First traverse the tree and count how many layers has votes. In addition
    // activate the layers in Scheduler's LayerHistory for it to check for changes
    int layersWithVote = 0;
    traverseTree([&layersWithVote](Layer* layer) {
    traverseTree([&layersWithVote, this](Layer* layer) {
        const auto layerVotedWithDefaultCompatibility =
                layer->mCurrentState.frameRate.rate.isValid() &&
                layer->mCurrentState.frameRate.type == FrameRateCompatibility::Default;
@@ -1447,6 +1448,9 @@ void Layer::updateTreeHasFrameRateVote() {
        if (layerVotedWithDefaultCompatibility || layerVotedWithNoVote) {
            layersWithVote++;
        }

        mFlinger->mScheduler->recordLayerHistory(layer, systemTime(),
                                                 LayerHistory::LayerUpdateType::SetFrameRate);
    });

    // Now update the other layers
@@ -1474,10 +1478,6 @@ bool Layer::setFrameRate(FrameRate frameRate) {
        return false;
    }

    // Activate the layer in Scheduler's LayerHistory
    mFlinger->mScheduler->recordLayerHistory(this, systemTime(),
                                             LayerHistory::LayerUpdateType::SetFrameRate);

    mCurrentState.sequence++;
    mCurrentState.frameRate = frameRate;
    mCurrentState.modified = true;
@@ -1501,8 +1501,16 @@ Layer::FrameRate Layer::getFrameRateForLayerTree() const {
        return frameRate;
    }

    // This layer doesn't have a frame rate. If one of its ancestors or successors
    // have a vote, return a NoVote for ancestors/successors to set the vote
    // This layer doesn't have a frame rate. Check if its ancestors have a vote
    if (sp<Layer> parent = getParent(); parent) {
        if (const auto parentFrameRate = parent->getFrameRateForLayerTree();
            parentFrameRate.rate.isValid()) {
            return parentFrameRate;
        }
    }

    // This layer and its ancestors don't have a frame rate. If one of successors
    // has a vote, return a NoVote for successors to set the vote
    if (getDrawingState().treeHasFrameRateVote) {
        return {Fps(0.0f), FrameRateCompatibility::NoVote};
    }
@@ -1692,11 +1700,11 @@ void Layer::miniDump(std::string& result, const DisplayDevice& display) const {
    const FloatRect& crop = outputLayerState.sourceCrop;
    StringAppendF(&result, "%6.1f %6.1f %6.1f %6.1f | ", crop.left, crop.top, crop.right,
                  crop.bottom);
    if (layerState.frameRate.rate.isValid() ||
        layerState.frameRate.type != FrameRateCompatibility::Default) {
        StringAppendF(&result, "%s %15s %17s", to_string(layerState.frameRate.rate).c_str(),
                      frameRateCompatibilityString(layerState.frameRate.type).c_str(),
                      toString(layerState.frameRate.seamlessness).c_str());
    const auto frameRate = getFrameRateForLayerTree();
    if (frameRate.rate.isValid() || frameRate.type != FrameRateCompatibility::Default) {
        StringAppendF(&result, "%s %15s %17s", to_string(frameRate.rate).c_str(),
                      frameRateCompatibilityString(frameRate.type).c_str(),
                      toString(frameRate.seamlessness).c_str());
    } else {
        result.append(41, ' ');
    }
+11 −11
Original line number Diff line number Diff line
@@ -263,13 +263,13 @@ TEST_P(SetFrameRateTest, SetAndGetParentAllVote) {
    commitTransaction();
    EXPECT_EQ(FRAME_RATE_VOTE3, parent->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE2, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_TREE, child2->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE2, child2->getFrameRateForLayerTree());

    child1->setFrameRate(FRAME_RATE_NO_VOTE);
    commitTransaction();
    EXPECT_EQ(FRAME_RATE_VOTE3, parent->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_TREE, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_TREE, child2->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE3, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE3, child2->getFrameRateForLayerTree());

    parent->setFrameRate(FRAME_RATE_NO_VOTE);
    commitTransaction();
@@ -293,8 +293,8 @@ TEST_P(SetFrameRateTest, SetAndGetChild) {
    parent->setFrameRate(FRAME_RATE_VOTE1);
    commitTransaction();
    EXPECT_EQ(FRAME_RATE_VOTE1, parent->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_TREE, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_TREE, child2->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE1, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE1, child2->getFrameRateForLayerTree());

    parent->setFrameRate(FRAME_RATE_NO_VOTE);
    commitTransaction();
@@ -356,14 +356,14 @@ TEST_P(SetFrameRateTest, SetAndGetChildAddAfterVote) {
    parent->setFrameRate(FRAME_RATE_VOTE1);
    commitTransaction();
    EXPECT_EQ(FRAME_RATE_VOTE1, parent->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_TREE, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE1, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_NO_VOTE, child2->getFrameRateForLayerTree());

    addChild(child1, child2);
    commitTransaction();
    EXPECT_EQ(FRAME_RATE_VOTE1, parent->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_TREE, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_TREE, child2->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE1, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE1, child2->getFrameRateForLayerTree());

    parent->setFrameRate(FRAME_RATE_NO_VOTE);
    commitTransaction();
@@ -387,13 +387,13 @@ TEST_P(SetFrameRateTest, SetAndGetChildRemoveAfterVote) {
    parent->setFrameRate(FRAME_RATE_VOTE1);
    commitTransaction();
    EXPECT_EQ(FRAME_RATE_VOTE1, parent->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_TREE, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_TREE, child2->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE1, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE1, child2->getFrameRateForLayerTree());

    removeChild(child1, child2);
    commitTransaction();
    EXPECT_EQ(FRAME_RATE_VOTE1, parent->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_TREE, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_VOTE1, child1->getFrameRateForLayerTree());
    EXPECT_EQ(FRAME_RATE_NO_VOTE, child2->getFrameRateForLayerTree());

    parent->setFrameRate(FRAME_RATE_NO_VOTE);