Loading services/surfaceflinger/Scheduler/LayerHistoryV2.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -174,8 +174,10 @@ void LayerHistoryV2::partitionLayers(nsecs_t now) { return LayerVoteType::NoVote; } }(); if (layer->isVisible() && (frameRate.rate > 0 || voteType == LayerVoteType::NoVote)) { info->setLayerVote(voteType, frameRate.rate); if (frameRate.rate > 0 || voteType == LayerVoteType::NoVote) { const auto type = layer->isVisible() ? voteType : LayerVoteType::NoVote; info->setLayerVote(type, frameRate.rate); } else { info->resetLayerVote(); } Loading services/surfaceflinger/tests/unittests/LayerHistoryTestV2.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -512,5 +512,34 @@ TEST_F(LayerHistoryTestV2, inactiveLayers) { EXPECT_EQ(1, frequentLayerCount(time)); } TEST_F(LayerHistoryTestV2, invisibleExplicitLayer) { auto explicitVisiblelayer = createLayer(); auto explicitInvisiblelayer = createLayer(); EXPECT_CALL(*explicitVisiblelayer, isVisible()).WillRepeatedly(Return(true)); EXPECT_CALL(*explicitVisiblelayer, getFrameRateForLayerTree()) .WillRepeatedly(Return( Layer::FrameRate(60.0f, Layer::FrameRateCompatibility::ExactOrMultiple))); EXPECT_CALL(*explicitInvisiblelayer, isVisible()).WillRepeatedly(Return(false)); EXPECT_CALL(*explicitInvisiblelayer, getFrameRateForLayerTree()) .WillRepeatedly(Return( Layer::FrameRate(90.0f, Layer::FrameRateCompatibility::ExactOrMultiple))); nsecs_t time = systemTime(); // Post a buffer to the layers to make them active history().record(explicitVisiblelayer.get(), time, time); history().record(explicitInvisiblelayer.get(), time, time); EXPECT_EQ(2, layerCount()); ASSERT_EQ(1, history().summarize(time).size()); EXPECT_EQ(LayerHistory::LayerVoteType::ExplicitExactOrMultiple, history().summarize(time)[0].vote); EXPECT_FLOAT_EQ(60.0f, history().summarize(time)[0].desiredRefreshRate); EXPECT_EQ(2, activeLayerCount()); EXPECT_EQ(2, frequentLayerCount(time)); } } // namespace } // namespace android::scheduler Loading
services/surfaceflinger/Scheduler/LayerHistoryV2.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -174,8 +174,10 @@ void LayerHistoryV2::partitionLayers(nsecs_t now) { return LayerVoteType::NoVote; } }(); if (layer->isVisible() && (frameRate.rate > 0 || voteType == LayerVoteType::NoVote)) { info->setLayerVote(voteType, frameRate.rate); if (frameRate.rate > 0 || voteType == LayerVoteType::NoVote) { const auto type = layer->isVisible() ? voteType : LayerVoteType::NoVote; info->setLayerVote(type, frameRate.rate); } else { info->resetLayerVote(); } Loading
services/surfaceflinger/tests/unittests/LayerHistoryTestV2.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -512,5 +512,34 @@ TEST_F(LayerHistoryTestV2, inactiveLayers) { EXPECT_EQ(1, frequentLayerCount(time)); } TEST_F(LayerHistoryTestV2, invisibleExplicitLayer) { auto explicitVisiblelayer = createLayer(); auto explicitInvisiblelayer = createLayer(); EXPECT_CALL(*explicitVisiblelayer, isVisible()).WillRepeatedly(Return(true)); EXPECT_CALL(*explicitVisiblelayer, getFrameRateForLayerTree()) .WillRepeatedly(Return( Layer::FrameRate(60.0f, Layer::FrameRateCompatibility::ExactOrMultiple))); EXPECT_CALL(*explicitInvisiblelayer, isVisible()).WillRepeatedly(Return(false)); EXPECT_CALL(*explicitInvisiblelayer, getFrameRateForLayerTree()) .WillRepeatedly(Return( Layer::FrameRate(90.0f, Layer::FrameRateCompatibility::ExactOrMultiple))); nsecs_t time = systemTime(); // Post a buffer to the layers to make them active history().record(explicitVisiblelayer.get(), time, time); history().record(explicitInvisiblelayer.get(), time, time); EXPECT_EQ(2, layerCount()); ASSERT_EQ(1, history().summarize(time).size()); EXPECT_EQ(LayerHistory::LayerVoteType::ExplicitExactOrMultiple, history().summarize(time)[0].vote); EXPECT_FLOAT_EQ(60.0f, history().summarize(time)[0].desiredRefreshRate); EXPECT_EQ(2, activeLayerCount()); EXPECT_EQ(2, frequentLayerCount(time)); } } // namespace } // namespace android::scheduler