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

Commit 30515cb7 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Propagate frame rate correctly to child layers

If a child layer has a valid frame rate, and its parent does not
have a valid frame rate, we need to override the parent's frame
rate to no vote.

If the parent has a valid vote, including no vote, children would
inherit this vote if it has no valid vote.

When we were updating the hierarchy, we incorrectly propagated
novote due to a child having a novote to all its siblings in the tree.
Fix this by tracking inherited frame rate separately.

Bug: 304208511
Test: presubmit

Change-Id: I873e75d678fba8c8217a1887f48726d1e4828049
parent a387c08f
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -84,6 +84,7 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState {
    bool isTrustedOverlay;
    bool isTrustedOverlay;
    gui::GameMode gameMode;
    gui::GameMode gameMode;
    scheduler::LayerInfo::FrameRate frameRate;
    scheduler::LayerInfo::FrameRate frameRate;
    scheduler::LayerInfo::FrameRate inheritedFrameRate;
    scheduler::LayerInfo::FrameRateSelectionStrategy frameRateSelectionStrategy;
    scheduler::LayerInfo::FrameRateSelectionStrategy frameRateSelectionStrategy;
    scheduler::FrameRateCompatibility defaultFrameRateCompatibility =
    scheduler::FrameRateCompatibility defaultFrameRateCompatibility =
            scheduler::FrameRateCompatibility::Default;
            scheduler::FrameRateCompatibility::Default;
+8 −3
Original line number Original line Diff line number Diff line
@@ -815,9 +815,14 @@ void LayerSnapshotBuilder::updateSnapshot(LayerSnapshot& snapshot, const Args& a
                             RequestedLayerState::Changes::Hierarchy)) {
                             RequestedLayerState::Changes::Hierarchy)) {
        bool shouldOverrideChildren = parentSnapshot.frameRateSelectionStrategy ==
        bool shouldOverrideChildren = parentSnapshot.frameRateSelectionStrategy ==
                scheduler::LayerInfo::FrameRateSelectionStrategy::OverrideChildren;
                scheduler::LayerInfo::FrameRateSelectionStrategy::OverrideChildren;
        snapshot.frameRate = !requested.requestedFrameRate.isValid() || shouldOverrideChildren
        if (!requested.requestedFrameRate.isValid() || shouldOverrideChildren) {
                ? parentSnapshot.frameRate
            snapshot.inheritedFrameRate = parentSnapshot.inheritedFrameRate;
                : requested.requestedFrameRate;
        } else {
            snapshot.inheritedFrameRate = requested.requestedFrameRate;
        }
        // Set the framerate as the inherited frame rate and allow children to override it if
        // needed.
        snapshot.frameRate = snapshot.inheritedFrameRate;
        snapshot.changes |= RequestedLayerState::Changes::FrameRate;
        snapshot.changes |= RequestedLayerState::Changes::FrameRate;
    }
    }


+37 −11
Original line number Original line Diff line number Diff line
@@ -282,25 +282,51 @@ TEST_F(LayerSnapshotTest, NoLayerVoteForParentWithChildVotes) {
    // │   └── 13
    // │   └── 13
    // └── 2
    // └── 2


    std::vector<TransactionState> transactions;
    setFrameRate(11, 90.0, ANATIVEWINDOW_FRAME_RATE_EXACT, ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS);
    transactions.emplace_back();
    UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
    transactions.back().states.push_back({});

    transactions.back().states.front().state.what = layer_state_t::eFrameRateChanged;
    EXPECT_EQ(getSnapshot(11)->frameRate.vote.rate.getIntValue(), 90);
    transactions.back().states.front().state.frameRate = 90.0;
    EXPECT_EQ(getSnapshot(11)->frameRate.vote.type, scheduler::FrameRateCompatibility::Exact);
    transactions.back().states.front().state.frameRateCompatibility =
    EXPECT_EQ(getSnapshot(111)->frameRate.vote.rate.getIntValue(), 90);
            ANATIVEWINDOW_FRAME_RATE_EXACT;
    EXPECT_EQ(getSnapshot(111)->frameRate.vote.type, scheduler::FrameRateCompatibility::Exact);
    transactions.back().states.front().state.changeFrameRateStrategy =
    EXPECT_EQ(getSnapshot(1)->frameRate.vote.rate.getIntValue(), 0);
            ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS;
    EXPECT_EQ(getSnapshot(1)->frameRate.vote.type, scheduler::FrameRateCompatibility::NoVote);
    transactions.back().states.front().layerId = 11;
}
    mLifecycleManager.applyTransactions(transactions);

TEST_F(LayerSnapshotTest, NoLayerVoteForParentWithChildVotesDoesNotAffectSiblings) {
    // ROOT
    // ├── 1 (verify layer has no vote)
    // │   ├── 11 (frame rate set)
    // │   │   └── 111
    // │   ├── 12 (frame rate set)
    // │   │   ├── 121
    // │   │   └── 122
    // │   │       └── 1221
    // │   └── 13 (verify layer has default vote)
    // └── 2

    setFrameRate(11, 90.0, ANATIVEWINDOW_FRAME_RATE_EXACT, ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS);
    setFrameRate(12, 45.0, ANATIVEWINDOW_FRAME_RATE_EXACT, ANATIVEWINDOW_CHANGE_FRAME_RATE_ALWAYS);

    UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
    UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);


    EXPECT_EQ(getSnapshot(11)->frameRate.vote.rate.getIntValue(), 90);
    EXPECT_EQ(getSnapshot(11)->frameRate.vote.rate.getIntValue(), 90);
    EXPECT_EQ(getSnapshot(11)->frameRate.vote.type, scheduler::FrameRateCompatibility::Exact);
    EXPECT_EQ(getSnapshot(11)->frameRate.vote.type, scheduler::FrameRateCompatibility::Exact);
    EXPECT_EQ(getSnapshot(111)->frameRate.vote.rate.getIntValue(), 90);
    EXPECT_EQ(getSnapshot(111)->frameRate.vote.rate.getIntValue(), 90);
    EXPECT_EQ(getSnapshot(111)->frameRate.vote.type, scheduler::FrameRateCompatibility::Exact);
    EXPECT_EQ(getSnapshot(111)->frameRate.vote.type, scheduler::FrameRateCompatibility::Exact);
    EXPECT_EQ(getSnapshot(12)->frameRate.vote.rate.getIntValue(), 45);
    EXPECT_EQ(getSnapshot(12)->frameRate.vote.type, scheduler::FrameRateCompatibility::Exact);
    EXPECT_EQ(getSnapshot(121)->frameRate.vote.rate.getIntValue(), 45);
    EXPECT_EQ(getSnapshot(121)->frameRate.vote.type, scheduler::FrameRateCompatibility::Exact);
    EXPECT_EQ(getSnapshot(1221)->frameRate.vote.rate.getIntValue(), 45);
    EXPECT_EQ(getSnapshot(1221)->frameRate.vote.type, scheduler::FrameRateCompatibility::Exact);

    EXPECT_EQ(getSnapshot(1)->frameRate.vote.rate.getIntValue(), 0);
    EXPECT_EQ(getSnapshot(1)->frameRate.vote.rate.getIntValue(), 0);
    EXPECT_EQ(getSnapshot(1)->frameRate.vote.type, scheduler::FrameRateCompatibility::NoVote);
    EXPECT_EQ(getSnapshot(1)->frameRate.vote.type, scheduler::FrameRateCompatibility::NoVote);
    EXPECT_EQ(getSnapshot(13)->frameRate.vote.rate.getIntValue(), 0);
    EXPECT_EQ(getSnapshot(13)->frameRate.vote.type, scheduler::FrameRateCompatibility::Default);
    EXPECT_EQ(getSnapshot(2)->frameRate.vote.rate.getIntValue(), 0);
    EXPECT_EQ(getSnapshot(2)->frameRate.vote.type, scheduler::FrameRateCompatibility::Default);
}
}


TEST_F(LayerSnapshotTest, CanCropTouchableRegion) {
TEST_F(LayerSnapshotTest, CanCropTouchableRegion) {