Skip to content

Commit 4d87c4d

Browse files
Treehugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "Add GTE compatibility logic for NoVote" into main
2 parents 5604fd9 + 76eb78f commit 4d87c4d

3 files changed

Lines changed: 78 additions & 1 deletion

File tree

services/surfaceflinger/Scheduler/LayerHistory.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ void LayerHistory::partitionLayers(nsecs_t now, bool isVrrDevice) {
280280
case Layer::FrameRateCompatibility::Exact:
281281
return LayerVoteType::ExplicitExact;
282282
case Layer::FrameRateCompatibility::Gte:
283+
if (frameRate.isNoVote()) {
284+
return LayerVoteType::NoVote;
285+
}
283286
if (isVrrDevice) {
284287
return LayerVoteType::ExplicitGte;
285288
} else {

services/surfaceflinger/Scheduler/LayerInfo.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,10 @@ LayerInfo::FrameRateSelectionStrategy LayerInfo::convertFrameRateSelectionStrate
562562
}
563563

564564
bool LayerInfo::FrameRate::isNoVote() const {
565-
return vote.type == FrameRateCompatibility::NoVote;
565+
// A desired frame rate greater than or equal to 0 is treated as NoVote.
566+
bool isNoVoteGte = FlagManager::getInstance().arr_setframerate_gte_enum() &&
567+
vote.type == FrameRateCompatibility::Gte && !vote.rate.isValid();
568+
return vote.type == FrameRateCompatibility::NoVote || isNoVoteGte;
566569
}
567570

568571
bool LayerInfo::FrameRate::isValuelessType() const {
@@ -577,7 +580,12 @@ bool LayerInfo::FrameRate::isValuelessType() const {
577580
case FrameRateCompatibility::Default:
578581
case FrameRateCompatibility::ExactOrMultiple:
579582
case FrameRateCompatibility::Exact:
583+
return false;
580584
case FrameRateCompatibility::Gte:
585+
if (isNoVote()) {
586+
// Special case: GTE 0 is same as NoVote.
587+
return true;
588+
}
581589
return false;
582590
}
583591
}

services/surfaceflinger/tests/unittests/LayerHistoryIntegrationTest.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,72 @@ TEST_F(LayerHistoryIntegrationTest, oneLayerExplicitGte_nonVrr) {
654654
EXPECT_EQ(FrameRateCategory::Default, summarizeLayerHistory(time)[0].frameRateCategory);
655655
}
656656

657+
TEST_F(LayerHistoryIntegrationTest, oneLayerGteNoVote_arr) {
658+
SET_FLAG_FOR_TEST(flags::arr_setframerate_gte_enum, true);
659+
// Set the test to be on a vrr mode.
660+
SET_FLAG_FOR_TEST(flags::vrr_config, true);
661+
mSelector->setActiveMode(kVrrModeId, HI_FPS);
662+
663+
auto layer = createLegacyAndFrontedEndLayer(1);
664+
showLayer(1);
665+
setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_GTE,
666+
ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS);
667+
668+
EXPECT_EQ(1u, layerCount());
669+
EXPECT_EQ(0u, activeLayerCount());
670+
671+
nsecs_t time = systemTime();
672+
for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) {
673+
setBufferWithPresentTime(layer, time);
674+
time += HI_FPS_PERIOD;
675+
}
676+
677+
// Layer is active but GTE with 0 should be considered NoVote, thus nothing from summarize.
678+
ASSERT_EQ(0u, summarizeLayerHistory(time).size());
679+
EXPECT_EQ(1u, activeLayerCount());
680+
EXPECT_EQ(1, frequentLayerCount(time));
681+
682+
// layer became inactive.
683+
setDefaultLayerVote(layer.get(), LayerHistory::LayerVoteType::Heuristic);
684+
time += MAX_ACTIVE_LAYER_PERIOD_NS.count();
685+
ASSERT_EQ(0u, summarizeLayerHistory(time).size());
686+
EXPECT_EQ(0u, activeLayerCount());
687+
EXPECT_EQ(0, frequentLayerCount(time));
688+
}
689+
690+
TEST_F(LayerHistoryIntegrationTest, oneLayerGteNoVote_mrr) {
691+
SET_FLAG_FOR_TEST(flags::arr_setframerate_gte_enum, true);
692+
// True by default on MRR devices as well, but the device is not set to VRR mode.
693+
SET_FLAG_FOR_TEST(flags::vrr_config, true);
694+
695+
auto layer = createLegacyAndFrontedEndLayer(1);
696+
showLayer(1);
697+
setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_GTE,
698+
ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS);
699+
setFrameRateCategory(1, 0);
700+
701+
EXPECT_EQ(1u, layerCount());
702+
EXPECT_EQ(0u, activeLayerCount());
703+
704+
nsecs_t time = systemTime();
705+
for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) {
706+
setBufferWithPresentTime(layer, time);
707+
time += HI_FPS_PERIOD;
708+
}
709+
710+
// Layer is active but GTE with 0 should be considered NoVote, thus nothing from summarize.
711+
ASSERT_EQ(0u, summarizeLayerHistory(time).size());
712+
EXPECT_EQ(1u, activeLayerCount());
713+
EXPECT_EQ(1, frequentLayerCount(time));
714+
715+
// layer became inactive.
716+
setDefaultLayerVote(layer.get(), LayerHistory::LayerVoteType::Heuristic);
717+
time += MAX_ACTIVE_LAYER_PERIOD_NS.count();
718+
ASSERT_EQ(0u, summarizeLayerHistory(time).size());
719+
EXPECT_EQ(0u, activeLayerCount());
720+
EXPECT_EQ(0, frequentLayerCount(time));
721+
}
722+
657723
TEST_F(LayerHistoryIntegrationTest, oneLayerExplicitVoteWithCategory_vrrFeatureOff) {
658724
SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false);
659725

0 commit comments

Comments
 (0)