diff options
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 34 | ||||
-rw-r--r-- | services/surfaceflinger/tests/unittests/SetFrameRateTest.cpp | 22 |
2 files changed, 32 insertions, 24 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index a545d186dd..24d1b52a49 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -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, ' '); } diff --git a/services/surfaceflinger/tests/unittests/SetFrameRateTest.cpp b/services/surfaceflinger/tests/unittests/SetFrameRateTest.cpp index 1bbe8e2485..c8f4cb4c19 100644 --- a/services/surfaceflinger/tests/unittests/SetFrameRateTest.cpp +++ b/services/surfaceflinger/tests/unittests/SetFrameRateTest.cpp @@ -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); |