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

Commit 0dd0518f authored by Rachel Lee's avatar Rachel Lee
Browse files

Fixed source vote + no preference category for MRR

This allows the explicit setFrameRate fixed source votes to pass through
in MRR devices when an explicit frame rate category (No Preference)
is sent.

This allows new View logic to set video frame rate when there
is only one View.

Bug: 352206100
Test: atest libsurfaceflinger_unittest
Flag: com.android.graphics.surfaceflinger.flags.view_set_requested_frame_rate_mrr

Change-Id: I1d19318815f323852eab95b9d7c4b4a6e78518ab
parent ba38f872
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -595,6 +595,12 @@ bool LayerInfo::FrameRate::isVoteValidForMrr(bool isVrrDevice) const {
        return true;
    }

    if (FlagManager::getInstance().view_set_requested_frame_rate_mrr() &&
        category == FrameRateCategory::NoPreference && vote.rate.isValid() &&
        vote.type == FrameRateCompatibility::ExactOrMultiple) {
        return true;
    }

    return false;
}

+3 −0
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ void FlagManager::dump(std::string& result) const {
    DUMP_READ_ONLY_FLAG(connected_display);
    DUMP_READ_ONLY_FLAG(enable_small_area_detection);
    DUMP_READ_ONLY_FLAG(frame_rate_category_mrr);
    DUMP_READ_ONLY_FLAG(view_set_requested_frame_rate_mrr);
    DUMP_READ_ONLY_FLAG(misc1);
    DUMP_READ_ONLY_FLAG(vrr_config);
    DUMP_READ_ONLY_FLAG(hotplug2);
@@ -222,6 +223,8 @@ FLAG_MANAGER_LEGACY_SERVER_FLAG(use_skia_tracing, PROPERTY_SKIA_ATRACE_ENABLED,
FLAG_MANAGER_READ_ONLY_FLAG(connected_display, "")
FLAG_MANAGER_READ_ONLY_FLAG(enable_small_area_detection, "")
FLAG_MANAGER_READ_ONLY_FLAG(frame_rate_category_mrr, "debug.sf.frame_rate_category_mrr")
FLAG_MANAGER_READ_ONLY_FLAG(view_set_requested_frame_rate_mrr,
                            "debug.sf.view_set_requested_frame_rate_mrr")
FLAG_MANAGER_READ_ONLY_FLAG(misc1, "")
FLAG_MANAGER_READ_ONLY_FLAG(vrr_config, "debug.sf.enable_vrr_config")
FLAG_MANAGER_READ_ONLY_FLAG(hotplug2, "")
+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ public:
    /// Trunk stable readonly flags ///
    bool connected_display() const;
    bool frame_rate_category_mrr() const;
    bool view_set_requested_frame_rate_mrr() const;
    bool enable_small_area_detection() const;
    bool misc1() const;
    bool vrr_config() const;
+8 −0
Original line number Diff line number Diff line
@@ -125,6 +125,14 @@ flag {
  }
} # override_trusted_overlay

flag {
    name: "view_set_requested_frame_rate_mrr"
    namespace: "core_graphics"
    description: "Enable to use frame rate category NoPreference with fixed frame rate vote on MRR devices"
    bug: "352206100"
    is_fixed_read_only: true
} # view_set_requested_frame_rate_mrr

flag {
  name: "vrr_bugfix_24q4"
  namespace: "core_graphics"
+44 −0
Original line number Diff line number Diff line
@@ -892,6 +892,50 @@ TEST_F(LayerHistoryIntegrationTest, oneLayerExplicitCategory) {
    EXPECT_EQ(FrameRateCategory::High, summarizeLayerHistory(time)[0].frameRateCategory);
}

TEST_F(LayerHistoryIntegrationTest, oneLayerExplicitVoteWithFixedSourceAndNoPreferenceCategory) {
    SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false);
    SET_FLAG_FOR_TEST(flags::view_set_requested_frame_rate_mrr, true);

    auto layer = createLegacyAndFrontedEndLayer(1);
    setFrameRate(1, (45.6_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
                 ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS);
    setFrameRateCategory(1, ANATIVEWINDOW_FRAME_RATE_CATEGORY_NO_PREFERENCE);

    EXPECT_EQ(1u, layerCount());
    EXPECT_EQ(0u, activeLayerCount());

    nsecs_t time = systemTime();
    updateLayerSnapshotsAndLayerHistory(time);
    for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) {
        setBufferWithPresentTime(layer, time);
        time += HI_FPS_PERIOD;
    }

    // There are 2 LayerRequirement's due to the frame rate category.
    ASSERT_EQ(2u, summarizeLayerHistory(time).size());
    EXPECT_EQ(1u, activeLayerCount());
    EXPECT_EQ(1, frequentLayerCount(time));
    // First LayerRequirement is the layer's category specification
    EXPECT_EQ(LayerHistory::LayerVoteType::ExplicitCategory, summarizeLayerHistory(time)[0].vote);
    EXPECT_EQ(0_Hz, summarizeLayerHistory(time)[0].desiredRefreshRate);
    EXPECT_EQ(FrameRateCategory::NoPreference, summarizeLayerHistory(time)[0].frameRateCategory);

    // Second LayerRequirement is the frame rate specification
    EXPECT_EQ(LayerHistory::LayerVoteType::ExplicitExactOrMultiple,
              summarizeLayerHistory(time)[1].vote);
    EXPECT_EQ(45.6_Hz, summarizeLayerHistory(time)[1].desiredRefreshRate);
    EXPECT_EQ(FrameRateCategory::Default, summarizeLayerHistory(time)[1].frameRateCategory);

    // layer became infrequent, but the vote stays
    time += MAX_ACTIVE_LAYER_PERIOD_NS.count();
    ASSERT_EQ(2u, summarizeLayerHistory(time).size());
    EXPECT_EQ(1u, activeLayerCount());
    EXPECT_EQ(0, frequentLayerCount(time));
    EXPECT_EQ(LayerHistory::LayerVoteType::ExplicitCategory, summarizeLayerHistory(time)[0].vote);
    EXPECT_EQ(0_Hz, summarizeLayerHistory(time)[0].desiredRefreshRate);
    EXPECT_EQ(FrameRateCategory::NoPreference, summarizeLayerHistory(time)[0].frameRateCategory);
}

TEST_F(LayerHistoryIntegrationTest, multipleLayers) {
    auto layer1 = createLegacyAndFrontedEndLayer(1);
    auto layer2 = createLegacyAndFrontedEndLayer(2);